htesp.oqmd_extract¶
Module to extract data from OQMD database
Module Attributes
seconds a single OQMD socket operation may block before it is abandoned. |
|
how many times search() retries an OQMD query with a smaller limit |
|
base delay, in seconds, between those retries (multiplied by the attempt) |
Functions
|
Assemble the OQMD query dictionary and the property list. |
|
Function to create input files. |
|
Entry point for |
|
Function to convert POSCAR into ground-state input files. |
|
Function to search compounds. |
|
Apply a default socket timeout for the duration of the block. |
- htesp.oqmd_extract.OQMD_SOCKET_TIMEOUT = 30.0¶
seconds a single OQMD socket operation may block before it is abandoned.
FIX:
qmpy_resterbuilds a barerequests.Session()and passes no timeout to it, so a connection that stalls blocks for ever. It did:mainprogram oqmd-downloadwas found nineteen minutes in, alive, with two open sockets and not a line of output, and nothing short of a kill would have ended it. A socket timeout is the right instrument here because it distinguishes the two cases a wall-clock budget cannot – a stalled connection is abandoned, while a query that is merely slow (OQMD searches have taken anywhere from 35 to 100 seconds) keeps going as long as data is still arriving.
- htesp.oqmd_extract.socket_timeout(seconds: float = 30.0)[source]¶
Apply a default socket timeout for the duration of the block.
Scoped rather than set at import, deliberately.
socket.setdefaulttimeoutis process-global andhtesp/aflow_extract.pyimports this module, so setting it on import would quietly put a timeout on AFLOW’s queries too – and on everythingmainprogram data-combinedoes, which runs all three front ends in one process. Only sockets opened inside the block are affected, and the previous value is restored even when the query raises.
- htesp.oqmd_extract.MAX_SEARCH_RETRIES = 8¶
how many times search() retries an OQMD query with a smaller limit
- htesp.oqmd_extract.RETRY_BACKOFF_SECONDS = 2.0¶
base delay, in seconds, between those retries (multiplied by the attempt)
- htesp.oqmd_extract.poscar_to_input(calc_type, mpid, compound, keven)[source]¶
Function to convert POSCAR into ground-state input files.
- Parameters:
calc_type (str) – Calculation type. “QE” or “VASP”.
mpid (str) – Material id.
compound (str) – Compound name.
keven (bool) – If even k-mesh to use.
- Returns:
Compound name.
- Return type:
str
Notes
This function reads a POSCAR file and generates input files required for ground-state calculations using either Quantum Espresso (QE) or VASP software.
It checks if ‘config.json’ exists, and if so, it retrieves settings such as k-point density and download configurations.
Based on the calculation type, it creates input files and directories accordingly. For VASP, it prepares INCAR, POSCAR, and POTCAR files and potentially runs VASP processing scripts if available. For QE, it creates input files with appropriate settings.
Finally, it moves input files to the designated directories.
- htesp.oqmd_extract.search(kwargs, properties)[source]¶
Function to search compounds.
- Parameters:
kwargs (dict) – Dictionary object for query to the OQMD website.
properties (list) – Properties to extract.
Notes
This function uses QMPYRester to retrieve data from the OQMD (Open Quantum Materials Database) website. It attempts to get data with the provided query parameters. If the limit is reached, it decreases the limit and retries until successful.
It then writes the retrieved data to ‘download.csv’ file, including IDs and properties specified in the list ‘properties’. It also creates ‘mpid-list.in’ file containing IDs, names, and compounds for each entry.
Example
>>> kwargs = {'element_set': '(Fe-Mn),B', 'stability': '<-0.1', 'natom': '<10', 'limit': 100} >>> properties = ['entry_id', 'name', 'enthalpy', 'composition'] >>> search(kwargs, properties)
- htesp.oqmd_extract.download(calc_type, start, end)[source]¶
Function to create input files.
- Parameters:
calc_type (str) – Type of calculations, QE or VASP.
start (int) – Start index of the compounds to download.
end (int) – End index of the compounds to download.
Notes
This function utilizes QMPYRester to retrieve data from the Open Quantum Materials Database (OQMD). It reads material IDs and compounds from ‘mpid-list.in’ file and downloads the corresponding data. For each compound, it creates a POSCAR file containing the compound structure. Then, it invokes the ‘poscar_to_input’ function to generate input files for QE or VASP calculations. Finally, it updates ‘mpid.in’ file with downloaded compounds.
- htesp.oqmd_extract.build_kwargs(input_data=None)[source]¶
Assemble the OQMD query dictionary and the property list.
Returns
(kwargs, properties, calc_type). This used to live insideif __name__ == "__main__":, which is why none of it could be tested or reused – see FIX(9).
- htesp.oqmd_extract.main(argv=None)[source]¶
Entry point for
oqmd_extract searchandoqmd_extract download.FIX(9): the whole driver – reading
input.in, readingconfig.jsonand building KWARGS – used to sit in theif __name__ == "__main__":block, so importing this module gave no way to run it and the names it defined (LIMIT, CALC_TYPE, …) were module globals.__main__now only calls this function; thesearch/downloadargument contract is unchanged.