qc2.ase ======= .. py:module:: qc2.ase .. autoapi-nested-parse:: qc2 ASE package. Submodules ---------- .. toctree:: :maxdepth: 1 /autoapi/qc2/ase/dirac/index /autoapi/qc2/ase/dirac_io/index /autoapi/qc2/ase/psi4/index /autoapi/qc2/ase/pyscf/index /autoapi/qc2/ase/qc2_ase_base_class/index /autoapi/qc2/ase/rose/index Classes ------- .. autoapisummary:: qc2.ase.DIRAC Package Contents ---------------- .. py:class:: DIRAC(restart: Optional[bool] = None, ignore_bad_restart_file: Optional[bool] = FileIOCalculator._deprecated, label: Optional[str] = None, atoms: Optional[ase.Atoms] = None, command: Optional[str] = None, **kwargs) Bases: :py:obj:`ase.calculators.calculator.FileIOCalculator`, :py:obj:`qc2.ase.qc2_ase_base_class.BaseQc2ASECalculator` A general ASE calculator for the relativistic qchem DIRAC code. :param FileIOCalculator: Base class for calculators that write/read input/output files. :type FileIOCalculator: FileIOCalculator :param BaseQc2ASECalculator: Base class for ase calculartors in qc2. :type BaseQc2ASECalculator: BaseQc2ASECalculator .. py:attribute:: implemented_properties :type: List[str] :value: ['energy'] .. py:attribute:: label :type: str :value: 'dirac' .. py:attribute:: command :type: str :value: 'pam --inp=PREFIX.inp --mol=PREFIX.xyz --silent --get="AOMOMAT MRCONEE MDCINT"' .. py:attribute:: prefix :value: 'dirac' .. py:method:: check_dirac_attributes() -> None Checks for any missing and/or mispelling DIRAC input attribute. .. rubric:: Notes it can also be used to eventually set specific options in the near future. .. py:method:: calculate(*args, **kwargs) -> None Execute DIRAC workflow. .. py:method:: write_input(atoms: Optional[ase.Atoms] = None, properties: Optional[List[str]] = None, system_changes: Optional[List[str]] = None) -> None Generate all necessary inputs for DIRAC. .. py:method:: read_results() Read energy from DIRAC output file. .. py:method:: save(datafile: h5py.File) -> None Dumps qchem data to a datafile using QCSchema or FCIDump formats. :param datafile: file to save the data to. :type datafile: Union[h5py.File, str] :returns: None .. rubric:: 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') .. py:method:: load(datafile: Union[h5py.File, str]) -> Union[qiskit_nature.second_q.formats.qcschema.QCSchema, qiskit_nature.second_q.formats.fcidump.FCIDump] Loads electronic structure data from a datafile. :param datafile: file to read the data from. :type datafile: Union[h5py.File, str] :returns: Instances of :class:`QCSchema` or :class:`FCIDump` dataclasses containing qchem data. .. rubric:: 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') .. py:method:: get_integrals_mo_basis() -> Tuple[Union[float, complex], Dict[int, Union[float, complex]], Dict[Tuple[int, int], Union[float, complex]], Dict[Tuple[int, int, int, int], Union[float, complex]]] 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. :rtype: A tuple containing `np.ndarray` types .. rubric:: Notes Adapted from Openfermion-Dirac: see: https://github.com/bsenjean/Openfermion-Dirac. .. py:method:: get_integrals_ao_basis() -> Tuple[Any, Ellipsis] :abstractmethod: Calculates one- and two-electron integrals in AO basis. TODO: after Luuks's python interface .. py:method:: get_molecular_orbitals_coefficients() -> Tuple[Any, Ellipsis] :abstractmethod: Reads alpha and beta molecular orbital coefficients. TODO: after Luuks's python interface .. py:method:: get_molecular_orbitals_energies() -> Tuple[Any, Ellipsis] :abstractmethod: Reads alpha and beta orbital energies. TODO: after Luuks's python interface .. py:method:: get_overlap_matrix() -> Tuple[Any, Ellipsis] :abstractmethod: Reads overlap matrix. TODO: after Luuks's python interface .. py:method:: _get_from_dirac_hdf5_file(property_name) -> Any Helper routine to open dirac HDF5 output and extract property. .. py:method:: _get_dirac_fcidump() -> None Helper routine to generate DIRAC FCIDUMP file. :raises EnvironmentError: If the command execution fails. :raises CalculationFailed: If the calculator fails with a non-zero error code. .. rubric:: Notes Requires ``MRCONEE`` and ``MDCINT`` files obtained using ``**DIRAC .4INDEX``, ``**MOLTRA .ACTIVE all`` and ``pam ... --get="MRCONEE MDCINT"`` options. .. py:method:: _format_fcidump_mo_integrals(one_body_integrals: Dict[Tuple[int, int], Union[float, complex]], two_body_integrals: Dict[Tuple[int, int, int, int], Union[float, complex]], nmo: int) -> Tuple[numpy.ndarray, numpy.ndarray, numpy.ndarray, numpy.ndarray, numpy.ndarray, numpy.ndarray] 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. :rtype: A tuple containing `np.ndarray` types .. rubric:: Notes Adapted from Openfermion-Dirac: see: https://github.com/bsenjean/Openfermion-Dirac.