from ase.calculators.gaussian import Gaussian
from pharmaforge.interfaces import AbstractIO
from pharmaforge.interfaces import DPDataInterface
[docs]
class GaussianInterface(AbstractIO):
""" This class is used to interface with Gaussian for quantum chemistry calculations, and will
be used to calculate the energies and forces of the system.
.. code-block:: python
self.gauss_options = {
"basis": "6-31G",
"method": "B3LYP",
"nprocshared": 1,
"charge": 0,
"mult": 1,
"save": None,
"mem": "4GB",
}
.. warning::
You must have gaussian installed and set up in your environment for this interface to work.
.. note::
This interface uses the Gaussian calculator from ASE, and thus, options are passed to the calculator with the calculator's names for them.
Parameters
----------
default : bool
If True, use the default options for the Gaussian calculator. Default is False.
options : dict
A dictionary of options to pass to the Gaussian calculator. Default is an empty dictionary.
Attributes
----------
calculator : object
The Gaussian calculator object.
allow_parallel : bool
Whether to allow parallelization. Default is True.
level_of_theory : str
The level of theory used for the calculations. Default is "Gaussian".
options_dict : dict
A dictionary of options for the Gaussian calculator, that can include things not sent to the calculator.
gauss_options : dict
A dictionary of options for the Gaussian calculator, that are passed to the calculator.
See Also
--------
pharmaforge.interfaces.abstractio.AbstractIO : The abstract interface class for the Psi4Interface.
ase.calculators.gaussian.Gaussian : The Gaussian calculator object.
"""
def __init__(self, default=False, **options):
"""Initialize the GaussianIO class."""
self.calculator = Gaussian
self.allow_parallel = True
if default:
self.gauss_options = {
"basis": "6-31G",
"method": "B3LYP",
"nprocshared": 1,
"mult": 1,
"save": None,
"mem": "4GB",
}
else:
self.gauss_options= {}
for option, value in options.items():
self.gauss_options[option] = value
for key, value in options.items():
self.options_dict[key] = value
self.level_of_theory=f"{self.options_dict['method']}/{self.options_dict['basis']}"
return
def _calculate(self, structure, charge=0):
"""Calculate the system data.
Parameters
----------
structure : ase.Atoms
The ASE atoms object containing the system data.
Returns
-------
calc : Gaussian
The Gaussian calculator object.
"""
structure.calc = self.calculator(charge=charge,**self.gauss_options)
return structure