mp_api.client.routes.materials.thermo.ThermoRester¶
- class mp_api.client.routes.materials.thermo.ThermoRester(api_key: str | None = None, endpoint: str = 'https://api.materialsproject.org/', include_user_agent: bool = True, session: requests.Session | None = None, s3_resource: Any | None = None, debug: bool = False, monty_decode: bool = True, use_document_model: bool = True, timeout: int = 20, headers: dict = None, mute_progress_bars: bool = False)[source]¶
Bases:
BaseRester
[ThermoDoc
]Args: api_key (str): A String API key for accessing the MaterialsProject REST interface. Please obtain your API key at https://www.materialsproject.org/dashboard. If this is None, the code will check if there is a “PMG_MAPI_KEY” setting. If so, it will use that environment variable. This makes easier for heavy users to simply add this environment variable to their setups and MPRester can then be called without any arguments. endpoint (str): Url of endpoint to access the MaterialsProject REST interface. Defaults to the standard Materials Project REST address at “https://api.materialsproject.org”, but can be changed to other urls implementing a similar interface. include_user_agent (bool): If True, will include a user agent with the HTTP request including information on pymatgen and system version making the API request. This helps MP support pymatgen users, and is similar to what most web browsers send with each page request. Set to False to disable the user agent. session: requests Session object with which to connect to the API, for advanced usage only. debug: if True, print the URL for every request monty_decode: Decode the data using monty into python objects use_document_model: If False, skip the creating the document model and return data as a dictionary. This can be simpler to work with but bypasses data validation and will not give auto-complete for available fields. timeout: Time in seconds to wait until a request timeout error is thrown headers (dict): Custom headers for localhost connections.
- __init__(api_key: str | None = None, endpoint: str = 'https://api.materialsproject.org/', include_user_agent: bool = True, session: requests.Session | None = None, s3_resource: Any | None = None, debug: bool = False, monty_decode: bool = True, use_document_model: bool = True, timeout: int = 20, headers: dict = None, mute_progress_bars: bool = False)¶
Args: api_key (str): A String API key for accessing the MaterialsProject REST interface. Please obtain your API key at https://www.materialsproject.org/dashboard. If this is None, the code will check if there is a “PMG_MAPI_KEY” setting. If so, it will use that environment variable. This makes easier for heavy users to simply add this environment variable to their setups and MPRester can then be called without any arguments. endpoint (str): Url of endpoint to access the MaterialsProject REST interface. Defaults to the standard Materials Project REST address at “https://api.materialsproject.org”, but can be changed to other urls implementing a similar interface. include_user_agent (bool): If True, will include a user agent with the HTTP request including information on pymatgen and system version making the API request. This helps MP support pymatgen users, and is similar to what most web browsers send with each page request. Set to False to disable the user agent. session: requests Session object with which to connect to the API, for advanced usage only. debug: if True, print the URL for every request monty_decode: Decode the data using monty into python objects use_document_model: If False, skip the creating the document model and return data as a dictionary. This can be simpler to work with but bypasses data validation and will not give auto-complete for available fields. timeout: Time in seconds to wait until a request timeout error is thrown headers (dict): Custom headers for localhost connections.
Methods
__init__
([api_key, endpoint, ...])Args: api_key (str): A String API key for accessing the MaterialsProject REST interface.
count
([criteria])Return a count of total documents.
get_data_by_id
(document_id[, fields])Query the endpoint for a single document.
get_phase_diagram_from_chemsys
(chemsys, ...)Get a pre-computed phase diagram for a given chemsys.
search
([chemsys, energy_above_hull, ...])Query core material docs using a variety of search criteria.
search_thermo_docs
(*args, **kwargs)Deprecated.
Attributes
available_fields
primary_key
s3_resource
session
suffix
supports_versions
- document_model¶
alias of
ThermoDoc
- search(chemsys: str | list[str] | None = None, energy_above_hull: tuple[float, float] | None = None, equilibrium_reaction_energy: tuple[float, float] | None = None, formation_energy: tuple[float, float] | None = None, formula: str | list[str] | None = None, is_stable: bool | None = None, material_ids: list[str] | None = None, num_elements: tuple[int, int] | None = None, thermo_ids: list[str] | None = None, thermo_types: list[ThermoType | str] | None = None, total_energy: tuple[float, float] | None = None, uncorrected_energy: tuple[float, float] | None = None, num_chunks: int | None = None, chunk_size: int = 1000, all_fields: bool = True, fields: list[str] | None = None)[source]¶
Query core material docs using a variety of search criteria.
- Parameters:
chemsys (str, List[str]) – A chemical system or list of chemical systems (e.g., Li-Fe-O, Si-*, [Si-O, Li-Fe-P]).
energy_above_hull (Tuple[float,float]) – Minimum and maximum energy above the hull in eV/atom to consider.
equilibrium_reaction_energy (Tuple[float,float]) – Minimum and maximum equilibrium reaction energy in eV/atom to consider.
formation_energy (Tuple[float,float]) – Minimum and maximum formation energy in eV/atom to consider.
formula (str, List[str]) – A formula including anonymized formula or wild cards (e.g., Fe2O3, ABO3, Si*). A list of chemical formulas can also be passed (e.g., [Fe2O3, ABO3]).
is_stable (bool) – Whether the material is stable.
material_ids (List[str]) – List of Materials Project IDs to return data for.
thermo_ids (List[str]) – List of thermo IDs to return data for. This is a combination of the Materials Project ID and thermo type (e.g. mp-149_GGA_GGA+U).
thermo_types (List[ThermoType]) – List of thermo types to return data for (e.g. ThermoType.GGA_GGA_U).
num_elements (Tuple[int,int]) – Minimum and maximum number of elements in the material to consider.
total_energy (Tuple[float,float]) – Minimum and maximum corrected total energy in eV/atom to consider.
uncorrected_energy (Tuple[float,float]) – Minimum and maximum uncorrected total energy in eV/atom to consider.
num_chunks (int) – Maximum number of chunks of data to yield. None will yield all possible.
chunk_size (int) – Number of data entries per chunk.
all_fields (bool) – Whether to return all fields in the document. Defaults to True.
fields (List[str]) – List of fields in ThermoDoc to return data for. Default is material_id and last_updated if all_fields is False.
- Returns:
([ThermoDoc]) List of thermo documents
- get_phase_diagram_from_chemsys(chemsys: str, thermo_type: ThermoType | str) PhaseDiagram [source]¶
Get a pre-computed phase diagram for a given chemsys.
- Parameters:
chemsys (str) – A chemical system (e.g. Li-Fe-O)
thermo_type (ThermoType) – The thermo type for the phase diagram. Defaults to ThermoType.GGA_GGA_U.
- Returns:
Pymatgen phase diagram object.
- Return type:
phase_diagram (PhaseDiagram)