mp_api.client.routes.materials.electronic_structure.DosRester

class mp_api.client.routes.materials.electronic_structure.DosRester(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

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_dos_from_material_id(material_id)

Get the complete density of states pymatgen object associated with a Materials Project ID.

get_dos_from_task_id(task_id)

Get the density of states pymatgen object associated with a given calculation ID.

search([band_gap, efermi, element, ...])

Query density of states summary data in electronic structure docs using a variety of search criteria.

search_dos_summary(*args, **kwargs)

Deprecated.

Attributes

available_fields

primary_key

s3_resource

session

suffix

supports_versions

document_model

alias of ElectronicStructureDoc

search_dos_summary(*args, **kwargs)[source]

Deprecated.

search(band_gap: tuple[float, float] | None = None, efermi: tuple[float, float] | None = None, element: Element | None = None, magnetic_ordering: Ordering | None = None, orbital: OrbitalType | None = None, projection_type: DOSProjectionType = DOSProjectionType.total, spin: Spin = Spin.up, num_chunks: int | None = None, chunk_size: int = 1000, all_fields: bool = True, fields: list[str] | None = None)[source]

Query density of states summary data in electronic structure docs using a variety of search criteria.

Parameters:
  • band_gap (Tuple[float,float]) – Minimum and maximum band gap in eV to consider.

  • efermi (Tuple[float,float]) – Minimum and maximum fermi energy in eV to consider.

  • element (Element) – Element for element-projected dos data.

  • magnetic_ordering (Ordering) – Magnetic ordering of the material.

  • orbital (OrbitalType) – Orbital for orbital-projected dos data.

  • projection_type (DOSProjectionType) – Projection type of dos data. Default is the total dos.

  • spin (Spin) – Spin channel of dos data. If non spin-polarized data is stored in Spin.up

  • 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 EOSDoc to return data for. Default is material_id and last_updated if all_fields is False.

Returns:

([ElectronicStructureDoc]) List of electronic structure documents

get_dos_from_task_id(task_id: str)[source]

Get the density of states pymatgen object associated with a given calculation ID.

Parameters:

task_id (str) – Task ID for the density of states calculation

Returns:

CompleteDos object

Return type:

bandstructure (CompleteDos)

get_dos_from_material_id(material_id: str)[source]

Get the complete density of states pymatgen object associated with a Materials Project ID.

Parameters:

material_id (str) – Materials Project ID for a material

Returns:

CompleteDos object

Return type:

dos (CompleteDos)

count(criteria: dict | None = None) int | str

Return a count of total documents.

Parameters:

criteria (dict | None) – As in .query(). Defaults to None

Returns:

Count of total results, or string indicating error

Return type:

(int | str)

get_data_by_id(document_id: str, fields: list[str] | None = None) T

Query the endpoint for a single document.

Parameters:
  • document_id – the unique key for this kind of document, typically a task_id

  • fields – list of fields to return, by default will return all fields

Returns:

A single document.