htesp.aflow_extract¶
Module to search and download input files from AFLOW database.
Module Attributes
AFLUX endpoint |
|
seconds before an AFLUX request is abandoned -- FIX(10) |
|
how many times a failed AFLUX request is retried -- FIX(10) |
|
base delay between those retries, multiplied by the attempt number |
Functions
|
Function to create input files. |
|
GET |
|
Main program. |
|
Function to create a POSCAR file from data obtained from a query. |
|
Function to create a string for URL search from the dictionary provided in config.json. |
|
Function to search data via AFLOW database. |
- htesp.aflow_extract.AFLOW_URL = 'http://www.aflowlib.org/API/aflux/'¶
AFLUX endpoint
- htesp.aflow_extract.REQUEST_TIMEOUT = 60.0¶
seconds before an AFLUX request is abandoned – FIX(10)
- htesp.aflow_extract.MAX_REQUEST_RETRIES = 5¶
how many times a failed AFLUX request is retried – FIX(10)
- htesp.aflow_extract.RETRY_BACKOFF_SECONDS = 3.0¶
base delay between those retries, multiplied by the attempt number
- htesp.aflow_extract.fetch_aflux(url)[source]¶
GET
urland decode the AFLUX JSON reply.FIX(10): the two call sites used to be
while not success: try: urlopen() except: continue– an unbounded busy loop with no timeout, which spins forever on a typo in the query or on a network outage and never says why. This helper gives every request a timeout, retries a bounded number of times with linear backoff and raises a message naming the URL.FIX(11): the reply is JSON, and it was parsed with
ast.literal_eval, which does not knownull,trueorfalseand raises ValueError on any record that contains one.json.loadsis used instead.
- htesp.aflow_extract.properties_string(dict_param)[source]¶
Function to create a string for URL search from the dictionary provided in config.json.
Parameters: dict_param (dict): A dictionary from the config.json file containing search criteria.
Returns: str: A string representing the search criteria for URL.
Example
>>> criteria_dict = { ... "aflow": { ... "filter": True, ... "elm": ["Cu", "Zn"], ... "nsites": 4, ... "metal": True, ... "FE": False, ... "spacegroup": None, ... "limit": 10, ... "prop": ["energy", "bandgap"] ... } ... } >>> criteria_string = properties_string(criteria_dict) >>> print(criteria_string) 'species(Cu,Zn),natoms(1*,*4),Egap(0),enthalpy_formation_atom(*),spacegroup_relax(*), $paging(1,10),energy,bandgap'
- htesp.aflow_extract.search_data(dict_param)[source]¶
Function to search data via AFLOW database.
Parameters: dict_param (dict): A dictionary containing search criteria.
Returns: None
This function constructs a URL based on the search criteria provided in dict_param and retrieves data from the AFLOW database. It saves the retrieved data as a CSV file in the ‘download’ directory and also generates an ‘mpid-list.in’ file containing relevant data.
Example
>>> search_criteria = { ... "aflow": { ... "elm": ["Cu", "Zn"], ... "nsites": 4, ... "metal": True, ... "FE": False, ... "spacegroup": None, ... "limit": 10, ... "prop": ["energy", "bandgap"] ... } ... } >>> search_data(search_criteria)
- htesp.aflow_extract.poscar_create(data)[source]¶
Function to create a POSCAR file from data obtained from a query.
Parameters: data (dict): A dictionary containing information necessary for creating the POSCAR file.
Returns: Structure: A pymatgen Structure object representing the structure.
This function takes data including lattice parameters, compound information, fractional positions, and creates a pymatgen Structure object. It then returns the Structure object representing the structure. This function currently does not write the POSCAR file to disk but can be extended to do so.
Example
>>> data = { ... "geometry": [3.84, 3.84, 3.84, 90, 90, 90], ... "compound": "Si", ... "auid": "aflow:12345", ... "positions_fractional": [[0.000000, 0.000000, 0.000000], [0.250000, 0.250000, 0.250000]] ... } >>> structure = poscar_create(data) >>> print(structure) Full Formula (Si2) Reduced Formula: Si abc : 3.840198 3.840198 3.840198 angles: 90.000000 90.000000 90.000000 Sites (2) # SP auid --- ---- ------------- 0 Si aflow:12345 1 Si aflow:12345
- htesp.aflow_extract.download(calc_type, start, end)[source]¶
Function to create input files.
Parameters: calc_type (str): Type of calculations, either ‘QE’ or ‘VASP’. start (int): Starting index. end (int): Ending index.
Returns: None
This function retrieves data from the AFLOW database based on the specified range of indices, constructs input files for quantum mechanical calculations, and saves them. It also creates a file named ‘mpid.in’ containing information about the downloaded structures.
Example
>>> download("QE", 1, 10)