dara.cif module#

Functions related to opening/reading CIF files.

class Cif(data, orig_string=None, comment=None, filename=None)[source]#

Bases: MSONable, CifFile

Thin wrapper around pymatgen’s CifFile to enable serialization.

classmethod from_file(path)[source]#

Read Cif from a path.

Parameters:

path (str | Path) – File path to read from.

Return type:

Cif

Returns:

CifFile object

classmethod from_str(string)[source]#

Read CifFile from a string. Method closely adapted from pymatgen.io.cif.CifFile.from_str.

Parameters:

string – String representation.

Return type:

CifFile

Returns:

CifFile

classmethod from_structure(structure, filename=None)[source]#

Convert to Cif from pymatgen Structure.

Return type:

Cif

get_disordered_cifs(max_num_structs=10, vol_scale=1.0, **kwargs)[source]#

Call get_disordered_structures, but return Cif objects instead.

Parameters:
  • max_num_structs (int) – Maximum number of structures to return.

  • vol_scale (float) – Isotropic volume scaling factor. Defaults to 1 (no effect).

  • **kwargs – Additional kwargs to pass to to_structure.

Return type:

list[Cif]

get_disordered_structures(max_num_structs=10, vol_scale=1.0, **kwargs)[source]#

Convert to disordered structures, ranked from predicted lowest to highest energy. This method is useful when starting from ordered computed structures.

Parameters:
  • max_num_structs (int) – Maximum number of structures to return.

  • vol_scale (float) – Isotropic volume scaling factor. Defaults to 1 (no effect).

  • **kwargs – Additional kwargs to pass to to_structure.

Return type:

list[Structure]

property name: str#

Name of CIF, acquired from analyzing the structure. IF the CIF structure can not be read by pymatgen, the filename will be returned.

to_file(path=None)[source]#

Save to .cif file.

Parameters:

path (str | Path | None) – Path to save to. If None, will use the filename attribute (if available) or default to the name attribute ([formula]_[spacegroup]).

Return type:

None

to_scaled_structure(vol_scale=1.03, **kwargs)[source]#

Scales the structure isotropically by volume. Useful for expanding DFT-computed structures.

Parameters:
  • vol_scale – Isotropic volume scaling factor for lattice. Defaults to 1.03 (3% volume scaling).

  • **kwargs – Additional kwargs to pass to to_structure.

Return type:

Structure

to_structure(**kwargs)[source]#

Convert to pymatgen Structure.

Return type:

Structure

class CifBlock(data, loops, header)[source]#

Bases: MSONable, CifBlock

Thin wrapper around CifBlock to enable serialization by subclassing MSONable.

get_formula_with_disorder(structure)[source]#

Get the formula of a structure with disorder included.

Parameters:

structure (Structure) – pymatgen Structure object. If this is an ordered structure, the formula will be returned as is. Otherwise, the formula will attempt to include the disordered sites and occupancies.