Psi4 test calculation (experience note)
Last Update:2022/12/26
Introduction
Here, I write a review of test calculation of Psi4.
Official tutorials can be found the following sites.
https://psicode.org/psi4manual/master/index_tutorials.html
https://www.youtube.com/watch?v=sTkCL37A64E&list=PL0jgn5Q60aHuUc2vcErG31yDRLD0oGjls
Install and compile
I downloaded the latest version from the Psi4 download page (https://psicode.org/installs/latest). My PC environment was WSL2(ubuntu)+Intel oneAPI. I executed the downloaded shell script on the linux terminal, and answer a few questions. Then the installation started.
$ bash Psi4conda-1.6.1-py310-Linux-x86_64.sh
...
...
...
Do you accept the license terms? [yes|no]
[no] >>> yes
Psi4conda will now be installed into this location:
/home/fukuda/psi4conda
- Press ENTER to confirm the location
- Press CTRL-C to abort the installation
- Or specify a different location below
[/home/fukuda/psi4conda] >>> /home/fukuda/apps/psi4/psi4conda
Basically, you can answer “yes” or click “Enter” to the questions. After the installation, I checked my conda environment to confirm that psi4 is available or not by using “conda info –envs”
$ conda info --envs
# conda environments:
#
/home/fukuda/apps/anaconda3
base * /home/fukuda/apps/psi4/psi4conda
※If you want to go back to your original conda environment, you can execute “conda activate”
$ conda activate /home/fukuda/apps/anaconda3
Test SCF calculation
Let’s try to perform Hartree–Fock SCF calculations of H2O molecule according to the tutorial in Psi4 website. (https://psicode.org/psi4manual/master/tutorial.html#sec-tutorial)
Make a test directory, and write an input.dat as follows.
# input.dat
# Any line starting with the # character is a comment line
#! Sample HF/cc-pVDZ H2O computation
memory 600 mb
molecule h2o {
O
H 1 0.96
H 1 0.96 2 104.5
}
set basis cc-pVDZ
energy('scf')
In “molecule h2o”, the molecular structure is written by Z-matrix format. You can write the structure data by the other format too. (https://psicode.org/psi4manual/master/psithonmol.html#coordinates)
Psi4 calculations can be performed as below.
$ psi4 input.dat output.dat
Results
The result can be found in “output.dat”. Looking at the part of “Iterations” in “output.dat”, you can confirm that the scf calculation has been successfully converged at the 8th step.
==> Iterations <==
Total Energy Delta E RMS |[F,P]|
@DF-RHF iter SAD: -75.50772041125677 -7.55077e+01 0.00000e+00
@DF-RHF iter 1: -75.95376270516482 -4.46042e-01 3.03066e-02 DIIS/ADIIS
@DF-RHF iter 2: -76.00706363301680 -5.33009e-02 1.73566e-02 DIIS/ADIIS
@DF-RHF iter 3: -76.02603257829331 -1.89689e-02 2.30937e-03 DIIS/ADIIS
@DF-RHF iter 4: -76.02661197956334 -5.79401e-04 3.72696e-04 DIIS/ADIIS
@DF-RHF iter 5: -76.02663177626316 -1.97967e-05 6.75689e-05 DIIS
@DF-RHF iter 6: -76.02663270891111 -9.32648e-07 1.05815e-05 DIIS
@DF-RHF iter 7: -76.02663273457703 -2.56659e-08 1.47100e-06 DIIS
@DF-RHF iter 8: -76.02663273509029 -5.13253e-10 3.44832e-07 DIIS
Energy and wave function converged.
Converged final energy is also found in the Energetics part.
@DF-RHF Final Energy: -76.02663273509029
=> Energetics <=
Nuclear Repulsion Energy = 9.1681932964243487
One-Electron Energy = -123.1035077420448545
Two-Electron Energy = 37.9086817105302245
Total Energy = -76.0266327350902884
PsiAPI
PsiAPI makes Psi4 possible to perform as python module.
Here, I prepare python code “run_h2o_scf.py” as below.
# run_h2o_scf.py
# Ignore this block -- it's for the documentation build
try:
import os, sys
sys.path.insert(1, os.path.abspath('/home/runner/work/psi4/psi4/code/objdir/stage//usr/local/psi4/lib/'))
except ImportError:
pass
# This is the important part
import psi4
psi4.core.set_output_file('output.dat', False)
#! Sample HF/cc-pVDZ H2O Computation
psi4.set_memory('500 MB')
h2o = psi4.geometry("""
O
H 1 0.96
H 1 0.96 2 104.5
""")
psi4.energy('scf/cc-pvdz')
The python code can be executed as below.
$ python run_h2o_scf.py
The result is the same as the previous one.
Summary
In this review, I performed Psi4 test calculations by ordinary Psi4 and PsiAPI. The official Psi4 website has already provided abundant manuals, tutorials and also video tutorials. If you are familiar with python programming, this modern application Psi4 allows you to write and perform calculations very simply.