Skip to content

Commit

Permalink
revert to legacy key
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielYang59 committed Dec 4, 2024
1 parent 8273459 commit d44eb71
Showing 1 changed file with 6 additions and 30 deletions.
36 changes: 6 additions & 30 deletions notebooks/2017-12-15-Plotting a Pourbaix Diagram.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@
"outputs": [],
"source": [
"# Uncomment the subsequent lines in this cell to install dependencies for Google Colab.\n",
"# !pip install pymatgen==2022.7.19\n",
"from __future__ import annotations"
"# !pip install pymatgen==2022.7.19"
]
},
{
Expand All @@ -72,13 +71,13 @@
"outputs": [],
"source": [
"# Import necessary tools from pymatgen\n",
"from mp_api.client import MPRester\n",
"from pymatgen.analysis.pourbaix_diagram import PourbaixDiagram, PourbaixPlotter\n",
"from pymatgen.ext.matproj import MPRester\n",
"\n",
"%matplotlib inline\n",
"\n",
"# Initialize the MP Rester\n",
"mpr = MPRester()"
"mpr = MPRester(MP_API_KEY)"
]
},
{
Expand All @@ -92,30 +91,7 @@
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/Users/shyue/miniconda3/envs/mavrl/lib/python3.11/site-packages/mp_api/client/mprester.py:368: UserWarning: mpcontribs-client not installed. Install the package to query MPContribs data, or construct pourbaix diagrams: 'pip install mpcontribs-client'\n",
" warnings.warn(\n"
]
},
{
"ename": "AttributeError",
"evalue": "'NoneType' object has no attribute 'query_contributions'",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mAttributeError\u001b[0m Traceback (most recent call last)",
"Cell \u001b[0;32mIn[4], line 2\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[38;5;66;03m# Get all pourbaix entries corresponding to the Cu-O-H chemical system.\u001b[39;00m\n\u001b[0;32m----> 2\u001b[0m entries \u001b[38;5;241m=\u001b[39m \u001b[43mmpr\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mget_pourbaix_entries\u001b[49m\u001b[43m(\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mCu\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m]\u001b[49m\u001b[43m)\u001b[49m\n",
"File \u001b[0;32m~/miniconda3/envs/mavrl/lib/python3.11/site-packages/mp_api/client/mprester.py:851\u001b[0m, in \u001b[0;36mMPRester.get_pourbaix_entries\u001b[0;34m(self, chemsys, solid_compat, use_gibbs)\u001b[0m\n\u001b[1;32m 845\u001b[0m chemsys \u001b[38;5;241m=\u001b[39m \u001b[38;5;28msorted\u001b[39m(e\u001b[38;5;241m.\u001b[39mcapitalize() \u001b[38;5;28;01mfor\u001b[39;00m e \u001b[38;5;129;01min\u001b[39;00m chemsys)\n\u001b[1;32m 847\u001b[0m \u001b[38;5;66;03m# Get ion entries first, because certain ions have reference\u001b[39;00m\n\u001b[1;32m 848\u001b[0m \u001b[38;5;66;03m# solids that aren't necessarily in the chemsys (Na2SO4)\u001b[39;00m\n\u001b[1;32m 849\u001b[0m \n\u001b[1;32m 850\u001b[0m \u001b[38;5;66;03m# download the ion reference data from MPContribs\u001b[39;00m\n\u001b[0;32m--> 851\u001b[0m ion_data \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mget_ion_reference_data_for_chemsys\u001b[49m\u001b[43m(\u001b[49m\u001b[43mchemsys\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 853\u001b[0m \u001b[38;5;66;03m# build the PhaseDiagram for get_ion_entries\u001b[39;00m\n\u001b[1;32m 854\u001b[0m ion_ref_comps \u001b[38;5;241m=\u001b[39m [\n\u001b[1;32m 855\u001b[0m Ion\u001b[38;5;241m.\u001b[39mfrom_formula(d[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mdata\u001b[39m\u001b[38;5;124m\"\u001b[39m][\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mRefSolid\u001b[39m\u001b[38;5;124m\"\u001b[39m])\u001b[38;5;241m.\u001b[39mcomposition \u001b[38;5;28;01mfor\u001b[39;00m d \u001b[38;5;129;01min\u001b[39;00m ion_data\n\u001b[1;32m 856\u001b[0m ]\n",
"File \u001b[0;32m~/miniconda3/envs/mavrl/lib/python3.11/site-packages/mp_api/client/mprester.py:989\u001b[0m, in \u001b[0;36mMPRester.get_ion_reference_data_for_chemsys\u001b[0;34m(self, chemsys)\u001b[0m\n\u001b[1;32m 956\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mget_ion_reference_data_for_chemsys\u001b[39m(\u001b[38;5;28mself\u001b[39m, chemsys: \u001b[38;5;28mstr\u001b[39m \u001b[38;5;241m|\u001b[39m \u001b[38;5;28mlist\u001b[39m) \u001b[38;5;241m-\u001b[39m\u001b[38;5;241m>\u001b[39m \u001b[38;5;28mlist\u001b[39m[\u001b[38;5;28mdict\u001b[39m]:\n\u001b[1;32m 957\u001b[0m \u001b[38;5;250m \u001b[39m\u001b[38;5;124;03m\"\"\"Download aqueous ion reference data used in the construction of Pourbaix diagrams.\u001b[39;00m\n\u001b[1;32m 958\u001b[0m \n\u001b[1;32m 959\u001b[0m \u001b[38;5;124;03m Use this method to examine the ion reference data and to add additional\u001b[39;00m\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 987\u001b[0m \u001b[38;5;124;03m compounds and aqueous species, Wiley, New York (1978)'}}\u001b[39;00m\n\u001b[1;32m 988\u001b[0m \u001b[38;5;124;03m \"\"\"\u001b[39;00m\n\u001b[0;32m--> 989\u001b[0m ion_data \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mget_ion_reference_data\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 991\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(chemsys, \u001b[38;5;28mstr\u001b[39m):\n\u001b[1;32m 992\u001b[0m chemsys \u001b[38;5;241m=\u001b[39m chemsys\u001b[38;5;241m.\u001b[39msplit(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m-\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n",
"File \u001b[0;32m~/miniconda3/envs/mavrl/lib/python3.11/site-packages/mp_api/client/mprester.py:948\u001b[0m, in \u001b[0;36mMPRester.get_ion_reference_data\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 919\u001b[0m \u001b[38;5;129m@lru_cache\u001b[39m\n\u001b[1;32m 920\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mget_ion_reference_data\u001b[39m(\u001b[38;5;28mself\u001b[39m) \u001b[38;5;241m-\u001b[39m\u001b[38;5;241m>\u001b[39m \u001b[38;5;28mlist\u001b[39m[\u001b[38;5;28mdict\u001b[39m]:\n\u001b[1;32m 921\u001b[0m \u001b[38;5;250m \u001b[39m\u001b[38;5;124;03m\"\"\"Download aqueous ion reference data used in the construction of Pourbaix diagrams.\u001b[39;00m\n\u001b[1;32m 922\u001b[0m \n\u001b[1;32m 923\u001b[0m \u001b[38;5;124;03m Use this method to examine the ion reference data and to add additional\u001b[39;00m\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 946\u001b[0m \u001b[38;5;124;03m compounds and aqueous species, Wiley, New York (1978)'}}\u001b[39;00m\n\u001b[1;32m 947\u001b[0m \u001b[38;5;124;03m \"\"\"\u001b[39;00m\n\u001b[0;32m--> 948\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mcontribs\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mquery_contributions\u001b[49m( \u001b[38;5;66;03m# type: ignore\u001b[39;00m\n\u001b[1;32m 949\u001b[0m query\u001b[38;5;241m=\u001b[39m{\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mproject\u001b[39m\u001b[38;5;124m\"\u001b[39m: \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mion_ref_data\u001b[39m\u001b[38;5;124m\"\u001b[39m},\n\u001b[1;32m 950\u001b[0m fields\u001b[38;5;241m=\u001b[39m[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124midentifier\u001b[39m\u001b[38;5;124m\"\u001b[39m, \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mformula\u001b[39m\u001b[38;5;124m\"\u001b[39m, \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mdata\u001b[39m\u001b[38;5;124m\"\u001b[39m],\n\u001b[1;32m 951\u001b[0m paginate\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mTrue\u001b[39;00m,\n\u001b[1;32m 952\u001b[0m )\u001b[38;5;241m.\u001b[39mget(\n\u001b[1;32m 953\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mdata\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[1;32m 954\u001b[0m )\n",
"\u001b[0;31mAttributeError\u001b[0m: 'NoneType' object has no attribute 'query_contributions'"
]
}
],
"outputs": [],
"source": [
"# Get all pourbaix entries corresponding to the Cu-O-H chemical system.\n",
"entries = mpr.get_pourbaix_entries([\"Cu\"])"
Expand Down Expand Up @@ -317,7 +293,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"display_name": "pmg",
"language": "python",
"name": "python3"
},
Expand All @@ -331,7 +307,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.5"
"version": "3.12.0"
}
},
"nbformat": 4,
Expand Down

0 comments on commit d44eb71

Please sign in to comment.