Skip to content

Commit

Permalink
migrate mprester to new mp_api.client
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielYang59 committed Dec 4, 2024
1 parent 5f51fe8 commit ae0d664
Show file tree
Hide file tree
Showing 14 changed files with 41 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,18 @@
}
],
"source": [
"from mp_api.client import MPRester\n",
"from pymatgen.analysis.reaction_calculator import ComputedReaction\n",
"from pymatgen.core import Composition\n",
"from pymatgen.core.units import FloatWithUnit\n",
"from pymatgen.entries.computed_entries import ComputedEntry\n",
"from pymatgen.ext.matproj import MPRester\n",
"\n",
"# This initializes the REST adaptor. Put your own API key in if necessary.\n",
"mpr = MPRester()\n",
"\n",
"# This gets all entries belonging to the Ca-C-O system.\n",
"all_entries = mpr.get_entries_in_chemsys([\"Ca\", \"C\", \"O\"])\n",
"\n",
"\n",
"# This method simply gets the lowest energy entry for all entry with the same composition.\n",
"def get_most_stable_entry(formula):\n",
" relevant_entries = [\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"metadata": {},
"outputs": [],
"source": [
"from pymatgen.ext.matproj import MPRester\n",
"from mp_api.client import MPRester\n",
"\n",
"# Note that you will need to add your Materials API key in your .pmgrc.yaml file as \"PMG_MAPI_KEY\".\n",
"# Alternatively, you will need to supply the API key as an arg to MPRester.\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
"metadata": {},
"outputs": [],
"source": [
"from mp_api.client import MPRester\n",
"from pymatgen.analysis.phase_diagram import PDPlotter, PhaseDiagram\n",
"from pymatgen.ext.matproj import MPRester\n",
"\n",
"%matplotlib inline"
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"\n",
"import matplotlib as mpl\n",
"import palettable\n",
"from mp_api.client import MPRester\n",
"from pymatgen.analysis.phase_diagram import (\n",
" CompoundPhaseDiagram,\n",
" PDPlotter,\n",
Expand All @@ -48,7 +49,6 @@
"from pymatgen.core import Composition, Element\n",
"from pymatgen.entries.compatibility import MaterialsProjectCompatibility\n",
"from pymatgen.entries.computed_entries import ComputedEntry\n",
"from pymatgen.ext.matproj import MPRester\n",
"from pymatgen.io.vasp import Vasprun\n",
"from pymatgen.util.plotting import pretty_plot"
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,9 @@
"outputs": [],
"source": [
"import pprint\n",
"import re\n",
"\n",
"from mp_api.client import MPRester\n",
"from pymatgen.core import Composition\n",
"from pymatgen.ext.matproj import MPRester\n",
"\n",
"# Make sure that you have the Materials API key. Put the key in the call to\n",
"# MPRester if needed, e.g, MPRester(\"MY_API_KEY\")\n",
Expand Down
2 changes: 1 addition & 1 deletion notebooks/2017-12-15-Plotting a Pourbaix Diagram.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@
"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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
"source": [
"import logging\n",
"\n",
"from mp_api.client import MPRester\n",
"from pymatgen.analysis.chemenv.coordination_environments.chemenv_strategies import (\n",
" SimplestChemenvStrategy,\n",
")\n",
Expand All @@ -94,8 +95,7 @@
")\n",
"from pymatgen.analysis.chemenv.coordination_environments.structure_environments import (\n",
" LightStructureEnvironments,\n",
")\n",
"from pymatgen.ext.matproj import MPRester"
")"
]
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
"metadata": {},
"outputs": [],
"source": [
"from mp_api.client import MPRester\n",
"from pymatgen.analysis.phase_diagram import PhaseDiagram, ReactionDiagram\n",
"from pymatgen.entries.compatibility import MaterialsProjectCompatibility, ComputedEntry\n",
"from pymatgen.ext.matproj import MPRester"
"from pymatgen.entries.compatibility import ComputedEntry, MaterialsProjectCompatibility"
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion notebooks/2018-07-24-Adsorption on solid surfaces.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@
"from __future__ import annotations\n",
"\n",
"from matplotlib import pyplot as plt\n",
"from mp_api.client import MPRester\n",
"from pymatgen.analysis.adsorption import *\n",
"from pymatgen.core import Lattice, Molecule, Structure\n",
"from pymatgen.core.surface import generate_all_slabs\n",
"from pymatgen.ext.matproj import MPRester\n",
"from pymatgen.symmetry.analyzer import SpacegroupAnalyzer\n",
"\n",
"%matplotlib inline\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@
"\n",
"from pprint import pprint\n",
"\n",
"from mp_api.client import MPRester\n",
"from pymatgen.analysis.structure_matcher import ElementComparator, StructureMatcher\n",
"from pymatgen.analysis.structure_prediction.substitution_probability import (\n",
" SubstitutionPredictor,\n",
")\n",
"from pymatgen.analysis.structure_prediction.substitutor import Substitutor\n",
"from pymatgen.core.periodic_table import Specie\n",
"from pymatgen.ext.matproj import MPRester\n",
"from pymatgen.transformations.standard_transformations import (\n",
" AutoOxiStateDecorationTransformation,\n",
")"
Expand Down
4 changes: 2 additions & 2 deletions notebooks/2018-11-6-Dopant suggestions using Pymatgen.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@
"\n",
"from pprint import pprint\n",
"\n",
"from mp_api.client import MPRester\n",
"from pymatgen.analysis.local_env import CrystalNN\n",
"from pymatgen.analysis.structure_prediction.dopant_predictor import (\n",
" get_dopants_from_shannon_radii,\n",
" get_dopants_from_substitution_probabilities,\n",
")\n",
"from pymatgen.ext.matproj import MPRester"
")"
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion notebooks/2019-03-11-Interface Reactions.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@
"metadata": {},
"outputs": [],
"source": [
"from mp_api.client import MPRester\n",
"from pymatgen.analysis.interface_reactions import InterfacialReactivity\n",
"from pymatgen.analysis.phase_diagram import GrandPotentialPhaseDiagram, PhaseDiagram\n",
"from pymatgen.core import Composition, Element\n",
"from pymatgen.ext.matproj import MPRester\n",
"\n",
"%matplotlib inline\n",
"\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "markdown",
"id": "2feb87ef",
"id": "0",
"metadata": {},
"source": [
"# Magnetic Structure Generation as Input for Initial DFT Calculations\n",
Expand All @@ -14,7 +14,7 @@
},
{
"cell_type": "markdown",
"id": "f8548d15",
"id": "1",
"metadata": {},
"source": [
"## Introduction\n",
Expand All @@ -25,7 +25,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "e167481e",
"id": "2",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -37,20 +37,20 @@
{
"cell_type": "code",
"execution_count": null,
"id": "4622d496",
"id": "3",
"metadata": {},
"outputs": [],
"source": [
"from mp_api.client import MPRester\n",
"from pymatgen.analysis.magnetism.analyzer import CollinearMagneticStructureAnalyzer\n",
"from pymatgen.ext.matproj import MPRester\n",
"from pymatgen.symmetry.analyzer import SpacegroupAnalyzer\n",
"from pymatgen.util.testing import PymatgenTest"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "299fd4df",
"id": "4",
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -104,7 +104,7 @@
},
{
"cell_type": "markdown",
"id": "e5fc1f62",
"id": "5",
"metadata": {},
"source": [
"## Add magmoms to initial structure\n",
Expand All @@ -117,7 +117,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "7c7b6ea0",
"id": "6",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -129,7 +129,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "94b18ea1",
"id": "7",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -140,7 +140,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "64729507",
"id": "8",
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -193,7 +193,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "56698524",
"id": "9",
"metadata": {},
"outputs": [
{
Expand All @@ -211,7 +211,7 @@
},
{
"cell_type": "markdown",
"id": "cb607211",
"id": "10",
"metadata": {},
"source": [
"## Get space group information"
Expand All @@ -220,7 +220,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "c3e09dbc",
"id": "11",
"metadata": {},
"outputs": [
{
Expand All @@ -242,7 +242,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "10867b71",
"id": "12",
"metadata": {},
"outputs": [
{
Expand All @@ -263,7 +263,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "4a8ec0de",
"id": "13",
"metadata": {},
"outputs": [
{
Expand All @@ -284,7 +284,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "8703b5d7",
"id": "14",
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -339,7 +339,7 @@
},
{
"cell_type": "markdown",
"id": "9dc72f40",
"id": "15",
"metadata": {},
"source": [
"The above structure is saved as a magCIF with .mcif extension. This can be converted back to a CIF with relevant magnetic information associated with each site. OpenBabel does this easily, on command line write-\n",
Expand All @@ -350,7 +350,7 @@
},
{
"cell_type": "markdown",
"id": "130df9f1",
"id": "16",
"metadata": {},
"source": [
"## Analyze magnetic moment present in a calculated structure using MAPI\n",
Expand All @@ -361,7 +361,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "e90dcfb8",
"id": "17",
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -432,7 +432,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "eb53cc57",
"id": "18",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -444,7 +444,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "ccedc00c",
"id": "19",
"metadata": {},
"outputs": [
{
Expand All @@ -465,7 +465,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "d400c9af",
"id": "20",
"metadata": {},
"outputs": [
{
Expand All @@ -486,7 +486,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "1436c1aa",
"id": "21",
"metadata": {},
"outputs": [
{
Expand Down
4 changes: 2 additions & 2 deletions notebooks/2021-5-12-Explanation of Corrections.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@
"metadata": {},
"outputs": [],
"source": [
"from pymatgen.entries.compatibility import MaterialsProjectCompatibility\n",
"from pymatgen.ext.matproj import MPRester"
"from mp_api.client import MPRester\n",
"from pymatgen.entries.compatibility import MaterialsProjectCompatibility"
]
},
{
Expand Down

0 comments on commit ae0d664

Please sign in to comment.