dara.structure_db module#

Interact with the (local) ICSD database.

class CODDatabase(path_to_cifs=None)[source]#

Bases: StructureDatabase

Class to interact with CIF files acquired from the COD database. This class uses a parsed/filtered list of COD numbers that are automatically selected from when doing phase searches (data/cod_filtered_info_2024.json.gz).

This class features a method to download CIFs from the online COD database, as well as a method to get CIFs from a local copy of the database. To download the COD database in a folder called COD_2024, run the following command (this may take a while):

rsync -av –delete rsync://www.crystallography.net/cif/ COD_2024/

property default_folder_path: Path#

Default path to the folder containing the CIFs for the COD database.

download_structures(ids=None, save=False, default_folder='downloaded_cod_cifs')[source]#

Download structures from the COD database. Note that this downloads directly from the COD website, so it may be slow. Please do not abuse this feature.

Parameters:

ids (list[str] | None) – List of COD IDs to download.

Return type:

list[Cif]

get_file_path(cif_id)[source]#

Get the path to a CIF file in the COD database.

property name: str#

Name of the database.

class ICSDDatabase(path_to_cifs=None)[source]#

Bases: StructureDatabase

Class to interact with CIF files acquired from the ICSD database. This class uses a parsed/filtered list of ICSD_IDs that are automatically selected from when doing phase searches (see data/icsd_filtered_info_2024_v2.json.gz). Here we assume you have a folder containing relevant downloaded ICSD CIFs located at the default path in DaraSettings. You can also configure the path in dara.yaml.

Each CIF file should be named “icsd_<id>.cif” where <id> is the ICSD code.

Legal notice: to use the ICSD database, you must purchase a paid license that allows you to download and keep CIFs as a local copy. We do not provide any CIFs from the ICSD and discourage any unpermitted use of the database that is inconsistent with your license. Please visit https://icsd.products.fiz-karlsruhe.de/ for more information. We are not liable for any misuse of the ICSD database.

property default_folder_path: Path#

Default path to the folder containing the CIFs for the ICSD database.

download_structures(ids=None, save=False, default_folder=None)[source]#

Download structures from the ICSD database.

Return type:

list[Cif]

get_file_path(cif_id)[source]#

Get the path to a CIF file in the ICSD database.

property name: str#

Name of the database.

class StructureDatabase(path_to_cifs=None)[source]#

Bases: MSONable

Base class to interact with CIF files from an experimental database of structures. This class is subclassed by ICSDDatabase, CODDatabase, etc.

abstract property default_folder_path: Path#

Default path to the folder containing the CIFs for the database.

abstract download_structures(ids=None, save=False, default_folder=None)[source]#

Download structures from the database.

Return type:

list[Cif]

get_cifs_by_chemsys(chemsys, e_hull_filter=0.1, copy_files=True, dest_dir='dara_cifs', exclude_gases=True)[source]#

Get a list of database CIF codes corresponding to structures in a chemical system. Option to copy CIF files into a destination folder.

Parameters:
  • chemsys (str | list[str] | set[str]) – Chemical system to search for (e.g., “Fe-O”).

  • e_hull_filter (float) – Filter out structures with e_hull above this value (compared via spacegroup).

  • copy_files – Whether to copy CIF files to a destination folder.

  • dest_dir (str) – Destination folder for copied CIF files.

  • exclude_gases (bool) – Whether to exclude common gases (e.g., O2) from the results.

get_cifs_by_formulas(formulas, e_hull_filter=0.1, copy_files=True, dest_dir='dara_cifs', exclude_gases=True)[source]#

Get a list of database CIF codes corresponding to formulas, and optionally copy CIF files into a destination folder.

Parameters:
  • formulas (list[str]) – List of formulas to search for.

  • e_hull_filter (float) – Filter out structures with e_hull above this value (compared via spacegroup).

  • copy_files – Whether to copy CIF files to a destination folder.

  • dest_dir (str) – Destination folder for copied CIF files.

  • exclude_gases (bool) – Whether to exclude common gases (e.g., O2) from the results.

abstract get_file_path(cif_id)[source]#

Get the path to a CIF file in the database from its database ID.

get_formula_data(formula)[source]#

Get a list of database codes + info corresponding to a formula.

Parameters:

formula (str) – Chemical formula to search for.

property local_copy_found: bool#

Check if a local copy of the database is found.

abstract property name: str#

Name of the database.

property path: Path#

Path to local copy of the structure database (i.e., the folder containing all the relevant CIFs). Automatically uses the default path if not provided.

property preparsed_info: dict#

Preparsed information about the database. This is used to quickly filter and find structures based on chemical system, formula, etc. This has already been generated via the code in the scripts folder.