amd.io module
Contains I/O tools, including a .CIF reader and CSD reader
(csd-python-api
only) to extract periodic set representations
of crystals which can be passed to calculate.AMD()
and calculate.PDD()
.
These intermediate periodicset.PeriodicSet
representations can be written
to a .hdf5 file with SetWriter
, which can be read back with SetReader
.
This is much faster than rereading a .CIF and recomputing invariants.
- class amd.io.CifReader(path, reader='ase', folder=False, remove_hydrogens=False, disorder='skip', heaviest_component=False, show_warnings=True, extract_data=None, include_if=None)
Bases:
amd._reader._Reader
Read all structures in a .CIF with
ase
orccdc
(csd-python-api
only), yieldingperiodicset.PeriodicSet
objects which can be passed tocalculate.AMD()
orcalculate.PDD()
.Examples
# Put all crystals in a .CIF in a list structures = list(amd.CifReader('mycif.cif')) # Reads just one if the .CIF has just one crystal periodic_set = amd.CifReader('mycif.cif').read_one() # If a folder has several .CIFs each with one crystal, use structures = list(amd.CifReader('path/to/folder', folder=True)) # Make list of AMDs (with k=100) of crystals in a .CIF amds = [amd.AMD(periodic_set, 100) for periodic_set in amd.CifReader('mycif.cif')]
- class amd.io.CSDReader(refcodes=None, families=False, remove_hydrogens=False, disorder='skip', heaviest_component=False, show_warnings=True, extract_data=None, include_if=None)
Bases:
amd._reader._Reader
Read Entries from the CSD, yielding
periodicset.PeriodicSet
objects.The CSDReader returns
periodicset.PeriodicSet
objects which can be passed tocalculate.AMD()
orcalculate.PDD()
.Examples
Get crystals with refcodes in a list:
refcodes = ['DEBXIT01', 'DEBXIT05', 'HXACAN01'] structures = list(amd.CSDReader(refcodes))
Read refcode families (any whose refcode starts with strings in the list):
refcodes = ['ACSALA', 'HXACAN'] structures = list(amd.CSDReader(refcodes, families=True))
Create a generic reader, read crystals by name with
CSDReader.entry()
:reader = amd.CSDReader() debxit01 = reader.entry('DEBXIT01') # looping over this generic reader will yield all CSD entries for periodic_set in reader: ...
Make list of AMD (with k=100) for crystals in these families:
refcodes = ['ACSALA', 'HXACAN'] amds = [] for periodic_set in amd.CSDReader(refcodes, families=True): amds.append(amd.AMD(periodic_set, 100))
- entry(refcode: str) amd.periodicset.PeriodicSet
Read a PeriodicSet given any CSD refcode.
- amd.io.crystal_to_periodicset(crystal)
ccdc.crystal.Crystal –> amd.periodicset.PeriodicSet. Ignores disorder, missing sites/coords, checks & no options. Is a stripped-down version of the function used in CifReader.
- amd.io.cifblock_to_periodicset(block)
ase.io.cif.CIFBlock –> amd.periodicset.PeriodicSet. Ignores disorder, missing sites/coords, checks & no options. Is a stripped-down version of the function used in CifReader.