qc2.ase
qc2 ASE package.
Submodules
Classes
A general ASE calculator for the relativistic qchem DIRAC code. |
Package Contents
- class qc2.ase.DIRAC(restart: bool | None = None, ignore_bad_restart_file: bool | None = FileIOCalculator._deprecated, label: str | None = None, atoms: ase.Atoms | None = None, command: str | None = None, **kwargs)[source]
Bases:
ase.calculators.calculator.FileIOCalculator,qc2.ase.qc2_ase_base_class.BaseQc2ASECalculatorA general ASE calculator for the relativistic qchem DIRAC code.
- Parameters:
FileIOCalculator (FileIOCalculator) – Base class for calculators that write/read input/output files.
BaseQc2ASECalculator (BaseQc2ASECalculator) – Base class for ase calculartors in qc2.
- prefix = 'dirac'
- check_dirac_attributes() None[source]
Checks for any missing and/or mispelling DIRAC input attribute.
Notes
it can also be used to eventually set specific options in the near future.
- write_input(atoms: ase.Atoms | None = None, properties: List[str] | None = None, system_changes: List[str] | None = None) None[source]
Generate all necessary inputs for DIRAC.
- save(datafile: h5py.File) None[source]
Dumps qchem data to a datafile using QCSchema or FCIDump formats.
- Parameters:
datafile (Union[h5py.File, str]) – file to save the data to.
- Returns:
None
Notes
files are written following the QCSchema or FCIDump formats.
Example
>>> from ase.build import molecule >>> from qc2.ase import DIRAC >>> >>> molecule = molecule('H2') >>> molecule.calc = DIRAC() # => RHF/STO-3G >>> molecule.calc.schema_format = "qcschema" >>> molecule.calc.get_potential_energy() >>> molecule.calc.save('h2.h5') >>> >>> molecule = molecule('H2') >>> molecule.calc = DIRAC() # => RHF/STO-3G >>> molecule.calc.schema_format = "fcidump" >>> molecule.calc.get_potential_energy() >>> molecule.calc.save('h2.fcidump')
- load(datafile: h5py.File | str) qiskit_nature.second_q.formats.qcschema.QCSchema | qiskit_nature.second_q.formats.fcidump.FCIDump[source]
Loads electronic structure data from a datafile.
- Parameters:
datafile (Union[h5py.File, str]) – file to read the data from.
- Returns:
Instances of
QCSchemaorFCIDumpdataclasses containing qchem data.
Notes
files are read following the qcschema or fcidump formats.
Example
>>> from ase.build import molecule >>> from qc2.ase import DIRAC >>> >>> molecule = molecule('H2') >>> molecule.calc = DIRAC() # => RHF/STO-3G >>> molecule.calc.schema_format = "qcschema" >>> qcschema = molecule.calc.load('h2.h5') >>> >>> molecule = molecule('H2') >>> molecule.calc = DIRAC() # => RHF/STO-3G >>> molecule.calc.schema_format = "fcidump" >>> fcidump = molecule.calc.load('h2.fcidump')
- get_integrals_mo_basis() Tuple[float | complex, Dict[int, float | complex], Dict[Tuple[int, int], float | complex], Dict[Tuple[int, int, int, int], float | complex]][source]
Retrieves 1- and 2-body integrals in MO basis from
FCIDUMP.- Returns:
e_core (Union[float, complex]): Nuclear repulsion energy.
spinor (Dict[int, Union[float, complex]]): Dictionary of spinor values with their corresponding indices.
one_body_int (Dict[Tuple[int, int], Union[float, complex]]): Dictionary of one-body integrals with their corresponding indices as tuples.
two_body_int (Dict[Tuple[int, int, int, int], Union[float, complex]]): Dictionary of two-body integrals with their corresponding indices as tuples.
- Return type:
A tuple containing np.ndarray types
Notes
Adapted from Openfermion-Dirac: see: https://github.com/bsenjean/Openfermion-Dirac.
- abstract get_integrals_ao_basis() Tuple[Any, Ellipsis][source]
Calculates one- and two-electron integrals in AO basis.
TODO: after Luuks’s python interface
- abstract get_molecular_orbitals_coefficients() Tuple[Any, Ellipsis][source]
Reads alpha and beta molecular orbital coefficients.
TODO: after Luuks’s python interface
- abstract get_molecular_orbitals_energies() Tuple[Any, Ellipsis][source]
Reads alpha and beta orbital energies.
TODO: after Luuks’s python interface
- abstract get_overlap_matrix() Tuple[Any, Ellipsis][source]
Reads overlap matrix.
TODO: after Luuks’s python interface
- _get_from_dirac_hdf5_file(property_name) Any[source]
Helper routine to open dirac HDF5 output and extract property.
- _get_dirac_fcidump() None[source]
Helper routine to generate DIRAC FCIDUMP file.
- Raises:
EnvironmentError – If the command execution fails.
CalculationFailed – If the calculator fails with a non-zero error code.
Notes
Requires
MRCONEEandMDCINTfiles obtained using**DIRAC .4INDEX,**MOLTRA .ACTIVE allandpam ... --get="MRCONEE MDCINT"options.
- _format_fcidump_mo_integrals(one_body_integrals: Dict[Tuple[int, int], float | complex], two_body_integrals: Dict[Tuple[int, int, int, int], float | complex], nmo: int) Tuple[numpy.ndarray, numpy.ndarray, numpy.ndarray, numpy.ndarray, numpy.ndarray, numpy.ndarray][source]
Helper routine to format DIRAC FCIDUMP integrals.
- Returns:
one_body_coefficients_a & one_body_coefficients_b: Numpy arrays containing alpha and beta components of the one-body integrals.
two_body_coefficients_aa, two_body_coefficients_bb, two_body_coefficients_ab & two_body_coefficients_ba: Numpy arrays containing alpha-alpha, beta-beta, alpha-beta & beta-alpha components of the two-body integrals.
- Return type:
A tuple containing np.ndarray types
Notes
Adapted from Openfermion-Dirac: see: https://github.com/bsenjean/Openfermion-Dirac.