psi4
psi4 is an open source quatum chemistry code out of the Sherill Group at Georgia Tech.
- class ase.calculators.psi4.Psi4(restart=None, ignore_bad_restart=False, label='psi4-calc', atoms=None, command=None, **kwargs)[source]
An ase calculator for the popular open source Q-chem code psi4. method is the generic input for whatever method you wish to use, thus and quantum chemistry method implemented in psi4 can be input (i.e. ccsd(t))
also note that you can always use the in-built psi4 module through: calc.psi4
Basic calculator implementation.
- restart: str
Prefix for restart file. May contain a directory. Default is None: don’t restart.
- ignore_bad_restart_file: bool
Deprecated, please do not use. Passing more than one positional argument to Calculator() is deprecated and will stop working in the future. Ignore broken or missing restart file. By default, it is an error if the restart file is missing or broken.
- directory: str or PurePath
Working directory in which to read and write files and perform calculations.
- label: str
Name used for all files. Not supported by all calculators. May contain a directory, but please use the directory parameter for that instead.
- atoms: Atoms object
Optional Atoms object to which the calculator will be attached. When restarting, atoms will get its positions and unit-cell updated from file.
Setup
First we need to install psi4. There are instructions available on their website for compiling the best possible version of psi4. However, the easiest way to obtain psi4 by obtaining the binary package from conda:
conda install psi4 -c psi4; conda update psi4 -c psi4
The ase calculator operates using the psi4 python API, meaning that if psi4 is installed correctly you won’t need to do anything else to get psi4 working. It is, however, recommended that you set up a psi4 scratch directory by setting the PSI_SCRATCH
environment variable:
export PSI_SCRATCH=/path/to/existing/writable/local-not-network/directory/for/scratch/files
This directory is where temporary electronic structure files will be written. It is important that this directory be located on the same machine as the calculation is being done to avoid slow read/write operations. This is set to /tmp
by default. However, be aware that the /tmp
directory might not be large enough.
Examples
You can import psi4 and run it like any other calculator in ase:
from ase.calculators.psi4 import Psi4
from ase.build import molecule
import numpy as np
atoms = molecule('H2O')
calc = Psi4(atoms = atoms,
method = 'b3lyp',
memory = '500MB' # this is the default, be aware!
basis = '6-311g_d_p_')
atoms.calc = calc
print(atoms.get_potential_energy())
print(atoms.get_forces())
However, once you have instantiated the psi4 ase calculator with an atoms object you can interact with the psi4 python API as well. The psi4 API is just an attribute of the psi4 ase calculator:
calc.psi4.frequency('scf/cc-pvdz', molecule=calc.molecule,
return_wfn=True, dertype=1)
This is not required though, as psi4 will act like any other ase calculator.
It should be noted that the method
argument supports non-DFT methods (such as coupled cluster ccsd(t)
) as well. There is a great variety of quatum methods and basis sets to choose from.
Parallelization
Psi4 runs on a single thread by default. However, you may increase the number of threads by passing in the num_threads
argument, which can take either “max” or integer values.
Parameters
The list of possible parameters and their defaults is shown below. See the Psi4 documentation for full explanations of these different options.
keyword |
type |
default value |
description |
---|---|---|---|
|
|
|
Label for saved files. |
|
|
|
Quantum Method or Functional |
|
|
Charge |
|
|
|
|
Basis set. |
|
|
|
The amount of memory allocated to psi4 |
|
|
The number of threads to run psi4 on |
|
|
|
|
The symmetry of your system |
|
|
|
The scratch directory for psi4 |
|
|
|
The spin multiplicity of your system |
|
|
|
The reference wave function. If you wish to run spin unrestricted enter “uhf”, otherwise, leave this blank. |