12.4. Examples
12.4.1. RCI calculations on top of RHF for the water molecule
This is a basic example of how to perform a CI calculation in PyBEST. This script performs an RCIS, RCID, RCISD calculation on the water molecule using the cc-pVDZ basis set.
from pybest.ci import RCID, RCIS, RCISD
from pybest.context import context
from pybest.gbasis import (
compute_eri,
compute_kinetic,
compute_nuclear,
compute_nuclear_repulsion,
compute_overlap,
get_gobasis,
)
from pybest.linalg import DenseLinalgFactory
from pybest.occ_model import AufbauOccModel
from pybest.wrappers import RHF
#
# Set up molecule, define basis set
#
# get the XYZ file from PyBEST's test data directory
fn_xyz = context.get_fn("test/water.xyz")
basis = get_gobasis("cc-pvdz", fn_xyz)
#
# Define Occupation model, orbitals, and overlap
#
lf = DenseLinalgFactory(basis.nbasis)
# If we do not specify the number of frozen core orbitals (ncore),
# then ncore will be calculated automatically
occ_model = AufbauOccModel(basis, ncore=0)
orb_a = lf.create_orbital(basis.nbasis)
olp = compute_overlap(basis)
#
# Construct Hamiltonian
#
kin = compute_kinetic(basis)
ne = compute_nuclear(basis)
eri = compute_eri(basis)
external = compute_nuclear_repulsion(basis)
#
# Do a Hartree-Fock calculation
#
hf = RHF(lf, occ_model)
hf_output = hf(kin, ne, eri, external, olp, orb_a)
#
# Do RHF-CIS calculation using Davidson diagonalization
#
rcis = RCIS(lf, occ_model)
rcis_output = rcis(kin, ne, eri, hf_output)
#
# Do RHF-CID calculation using Davidson diagonalization
#
rcid = RCID(lf, occ_model)
rcid_output = rcid(kin, ne, eri, hf_output)
#
# Do RHF-CISD calculation using Davidson diagonalization
#
rcisd = RCISD(lf, occ_model)
rcisd_output = rcisd(kin, ne, eri, hf_output)
#
# Do RHF-CISD calculation for the ground state and 4 excited states
#
rcisd = RCISD(lf, occ_model)
rcisd_output = rcisd(kin, ne, eri, hf_output, nroot=5)
#
# Do RHF-CIS calculation using SD representation
#
rcis = RCIS(lf, occ_model, csf=False)
rcis_output = rcis(kin, ne, eri, hf_output)
#
# Do RHF-CID calculation using SD representation
#
rcid = RCID(lf, occ_model, csf=False)
rcid_output = rcid(kin, ne, eri, hf_output)
#
# Do RHF-CISD calculation using SD representation
#
rcisd = RCISD(lf, occ_model, csf=False)
rcisd_output = rcisd(kin, ne, eri, hf_output)
12.4.2. RCI calculations on top of pCCD for the water molecule
This is a basic example of how to perform a pCCD-CI calculation in PyBEST. This script performs an OOpCCD-CID and an OO-pCCD-CISD calculation on the water molecule using the cc-pVDZ basis set.
from pybest.ci import RpCCDCID, RpCCDCISD
from pybest.context import context
from pybest.gbasis import (
compute_eri,
compute_kinetic,
compute_nuclear,
compute_nuclear_repulsion,
compute_overlap,
get_gobasis,
)
from pybest.geminals import ROOpCCD
from pybest.linalg import DenseLinalgFactory
from pybest.occ_model import AufbauOccModel
from pybest.wrappers import RHF
#
# Set up molecule, define basis set
#
# get the XYZ file from PyBEST's test data directory
fn_xyz = context.get_fn("test/water.xyz")
basis = get_gobasis("cc-pvdz", fn_xyz)
#
# Define the occupation model, orbitals, and overlap
#
lf = DenseLinalgFactory(basis.nbasis)
# If we do not specify the number of frozen core orbitals (ncore),
# then ncore will be calculated automatically
occ_model = AufbauOccModel(basis, ncore=0)
orb_a = lf.create_orbital(basis.nbasis)
olp = compute_overlap(basis)
#
# Construct Hamiltonian
#
kin = compute_kinetic(basis)
ne = compute_nuclear(basis)
eri = compute_eri(basis)
external = compute_nuclear_repulsion(basis)
#
# Do a Hartree-Fock calculation
#
hf = RHF(lf, occ_model)
hf_output = hf(kin, ne, eri, external, olp, orb_a)
#
# Do an OO-pCCD calculation
#
pccd = ROOpCCD(lf, occ_model)
pccd_output = pccd(kin, ne, eri, hf_output)
#
# Do RpCCD-CID calculation using Davidson diagonalization
#
rcid = RpCCDCID(lf, occ_model)
rcid_output = rcid(kin, ne, eri, pccd_output)
#
# Do RpCCD-CISD calculation using Davidson diagonalization
#
rcisd = RpCCDCISD(lf, occ_model)
rcisd_output = rcisd(kin, ne, eri, pccd_output)
12.4.3. Core-valence separation RCI calculations on top of RHF for the uracil molecule
This is a basic example of how to perform a CVS-CI calculation in PyBEST. This script performs an RCIS calculation of the C 1s X-ray absorption of the uracil molecule using the cc-pVDZ basis set.
from pybest.ci import RCIS
from pybest.context import context
from pybest.gbasis import (
compute_eri,
compute_kinetic,
compute_nuclear,
compute_nuclear_repulsion,
compute_overlap,
get_gobasis,
)
from pybest.linalg import DenseLinalgFactory
from pybest.occ_model import AufbauOccModel
from pybest.wrappers import RHF
#
# Set up molecule, define basis set
#
# get the XYZ file from PyBEST's test data directory
fn_xyz = context.get_fn("test/uracil.xyz")
basis = get_gobasis("cc-pvdz", fn_xyz)
#
# Define Occupation model, orbitals, and overlap
#
lf = DenseLinalgFactory(basis.nbasis)
# To calculate the C 1s XAS, we have to place the two N 1s and two O 1s
# in the frozen core orbitals space (ncore), and the four C 1s orbitals in the
# core active space (nactc).
occ_model = AufbauOccModel(basis, ncore=4, nactc=4)
orb_a = lf.create_orbital(basis.nbasis)
olp = compute_overlap(basis)
#
# Construct Hamiltonian
#
kin = compute_kinetic(basis)
ne = compute_nuclear(basis)
eri = compute_eri(basis)
external = compute_nuclear_repulsion(basis)
#
# Do a Hartree-Fock calculation
#
hf = RHF(lf, occ_model)
hf_output = hf(kin, ne, eri, external, olp, orb_a)
#
# Do RHF-CIS calculation using Davidson diagonalization and CSF representation
#
rcis = RCIS(lf, occ_model, cvs=True)
rcis_output = rcis(kin, ne, eri, hf_output)
#
# Do RHF-CIS calculation using Davidson diagonalization and SD representation
#
rcis = RCIS(lf, occ_model, csf=False, cvs=True)
rcis_output = rcis(kin, ne, eri, hf_output)