Chemistry files (qcip_tools.chemistry_files
)
Read/write files commonly used in quantum chemistry.
Concepts
Human readable text files are widely used in the field of quantum chemistry, but there is large syntaxic differences from one to another (when there IS a syntax). This is especially true for input files, which follows rigorous syntax, while output files are more or less incoherent. This module implement access to different formats.
All classes derive from ChemistryFile.
You need to override the read()
method to read from a file.
Thanks to the dispatcher pattern, derivation from this class allow to define taylor-made accessors: use the @Class.define_property(property_name)
decorator to give the ability to use this callback function with property(property_name[, optional kwargs ...])
.
Callbacks should have the form callback_func(obj, **kwargs)
, where obj
is the current object. In the code, those callbacks have the form property__*(obj, **kwargs)
. One can check if a property is available with has_property()
(which does not mean that the file actually contains this property, but that it can be carry out).
There is some mixins and derived classes to add functionnalities:
WithMoleculeMixin adds
self.molecule
, which is accessible troughget_molecule()
. It also provides aClass.from_molecule(molecule, *args, **kwargs)
class method to ease creation of a file from scratch (if defined in subclass).- WithIdentificationMixin adds
Class.possible_file_extensions()
andClass.attempt_identification()
to allow file recognition by helpers. possible_file_extensions()
helps to avoid some possibilities if the extension is trusted. The helper expects a list of possible extentions (without the dot).attempt_identification()
actually make the recognition of the file: givenf
(the file open in read mode), the helper function expectsTrue
orFalse
if it is a file corresponding to a given objects. This recognition is usually based on patterns or words (like the name of the program) that frequently appears.
- WithIdentificationMixin adds
WithOutputMixin, which gives the ability to
write()
in a new file. Note that it is easier to overrideto_string()
in this case.ChemistryLogFile (derived class) keeps the whole file in memory (in
self.lines
) and allow to divide the file inchunks
to ease their manipulation. Thechunk_exists()
function check if a given chunk is present in the file. The mixins defines aapply_function()
method to apply a given function (withapply_over_list()
, see here) to the lines (to carry out information for example). Based on that, it also defines asearch()
function, which returns the line where the information was found.
Note
If one would like to construct the chemistry files from scratch (without using read()
on an existing file) or get additional information from it, the different class members are given in the documentation.
Also check if from_molecule()
is defined.
API documentation
- Base (
chemistry_files
) - Helpers (
chemistry_files.helpers
) - XYZ files (
chemistry_files.xyz
) - PDB files (
chemistry_files.pdb
) - Gaussian files (
chemistry_files.gaussian
)BasisSet
BasisSetFormatError
ChargeTransferInformation
Cube
CubeFormatError
FCHK
FCHKChunkInformation
FCHKFormatError
Input
InputFormatError
LinkCalled
Output
OutputFormatError
beta_EOP_from_fchk()
beta_SHG_from_fchk()
gamma_from_gaussian()
gaussian__fchk__property__computed_energies()
gaussian__fchk__property__electrical_derivatives()
gaussian__fchk__property__excitations()
gaussian__fchk__property__geometrical_derivatives()
gaussian__output__get_computed_energies()
gaussian__output__property__electrical_derivatives()
gaussian__output__property__excitations()
make_cartesian_hessian_from_fchk()
- Dalton files (
chemistry_files.dalton
)ALLOWED_LEVEL_0_MODULES
ArchiveOutput
Input
InputCard
InputFormatError
InputModule
InputModuleError
MoleculeInput
Output
OutputFormatError
OutputSection
WrongNumberOfData
check_module()
dalton__archive_output__property__computed_energies()
dalton__archive_output__property__electrical_derivatives()
dalton__archive_output__property__excitations()
dalton__archive_output__property__geometrical_derivatives()
dalton__output__computed_energies()
dalton__output__get_geometrical_derivatives()
- GAMESS files (
chemistry_files.gamess
) - CRYSTAL17 files (
chemistry_files.crystal
) - Chemistry data files (
chemistry_files.chemistry_datafile
) - Tensor in CSV format (
chemistry_files.csv_tensor
)
More precisely,
Class |
Description |
Identifier |
Input |
Ouput |
---|---|---|---|---|
XYZ file (.xyz) |
|
Yes |
Yes |
|
Gaussian basis set (.gbs ?) |
|
Yes |
Yes |
|
Gaussian Cube file (.cub) |
|
Yes |
Yes |
|
|
Yes |
No |
||
Gaussian input file (.com, .gau or .inp) |
|
Yes |
Yes |
|
Gaussian output (.log or .out) |
|
Yes |
No |
|
Dalton archive (.tar.gz) |
|
Yes |
No |
|
Dalton input file (.dal) |
|
Yes |
Yes |
|
Dalton molecule file (.mol) |
|
Yes |
Yes |
|
Dalton output file (.out) |
|
Yes |
No |
|
GAMESS input (.inp) |
|
Yes |
Yes |
|
GAMESS output (.log or .out) |
|
Yes |
No |
|
QCIP chemistry data file (.h5) |
|
Yes |
Yes |