Skip to content

Commit

Permalink
Added few more tests: two for IP- and EA-CRCC(2,3) and one for UHF-CC…
Browse files Browse the repository at this point in the history
…SDT on F2.
  • Loading branch information
kgururangan committed Dec 15, 2024
1 parent d9f1994 commit f0a2b83
Show file tree
Hide file tree
Showing 4 changed files with 104 additions and 9 deletions.
38 changes: 38 additions & 0 deletions tests/chplus/test_creacc23_chplus.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
"""EA-EOMCCSD(2h-1p) computation used to describe the spectrum of the
open-shell CH molecule by attaching an electron to closed-shell CH+."""

import pytest
from pathlib import Path
import numpy as np
from ccpy import Driver

TEST_DATA_DIR = str(Path(__file__).parents[1].absolute() / "data")

@pytest.mark.short
def test_eaeom2_chplus():
driver = Driver.from_gamess(
logfile=TEST_DATA_DIR + "/chplus/chplus.log",
fcidump=TEST_DATA_DIR + "/chplus/chplus.FCIDUMP",
nfrozen=0,
)
driver.system.print_info()

driver.run_cc(method="ccsd")
driver.run_hbar(method="ccsd")
driver.run_guess(method="eacisd", multiplicity=-1, nact_occupied=3, nact_unoccupied=8,
roots_per_irrep={"A1": 2, "B1": 2, "B2": 2, "A2": 2})
driver.run_eaeomcc(method="eaeom2", state_index=[0, 1, 2, 3, 4, 5, 6, 7])
driver.run_lefteaeomcc(method="left_eaeom2", state_index=[0, 1, 2, 3, 4, 5, 6, 7])
driver.run_eaccp3(method="creacc23", state_index=[0, 1, 2, 3, 4, 5, 6, 7])

#
# Check the results
#
expected_vee = [-0.19558721, -0.16826126, -0.37794266, -0.08109635, -0.37794266, -0.08109635, -0.29285023, -0.19558721]
expected_crcc23 = [-38.2862219438, -38.2467552810, -38.3950222424, -38.0988834026, -38.3950222424, -38.0988834026, -38.3741059608, -38.2881834536]
for i, (vee, veep3) in enumerate(zip(expected_vee, expected_crcc23)):
assert np.allclose(driver.vertical_excitation_energy[i], vee, atol=1.0e-07, rtol=1.0e-07)
assert np.allclose(driver.system.reference_energy + driver.correlation_energy + driver.vertical_excitation_energy[i] + driver.deltap3[i]["D"], veep3, atol=1.0e-07, rtol=1.0e-07)

if __name__ == "__main__":
test_eaeom2_chplus()
36 changes: 36 additions & 0 deletions tests/data/chplus/olsen.gbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
spherical

****
C 0
S 9 1.00
6.665000D+03 6.920000D-04
1.000000D+03 5.329000D-03
2.280000D+02 2.707700D-02
6.471000D+01 1.017180D-01
2.106000D+01 2.747400D-01
7.495000D+00 4.485640D-01
2.797000D+00 2.850740D-01
5.215000D-01 1.520400D-02
1.596000D-01 -3.191000D-03
S 9 1.00
6.665000D+03 -1.460000D-04
1.000000D+03 -1.154000D-03
2.280000D+02 -5.725000D-03
6.471000D+01 -2.331200D-02
2.106000D+01 -6.395500D-02
7.495000D+00 -1.499810D-01
2.797000D+00 -1.272620D-01
5.215000D-01 5.445290D-01
1.596000D-01 5.804960D-01
S 1 1.00
1.596000D-01 1.000000D+00
S 1 1.00
0.0469000 1.0000000
P 1 1.00
1.517000D-01 1.000000D+00
P 1 1.00
0.0404100 1.0000000
D 1 1.00
5.500000D-01 1.0000000
****

26 changes: 26 additions & 0 deletions tests/f2/test_ccsdt_f2_uhf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import numpy as np
from pyscf import scf, gto
from ccpy import Driver

def test_ccsdt_f2():
geometry = [["F", (0.0, 0.0, -2.66816)],
["F", (0.0, 0.0, 2.66816)]]
mol = gto.M(
atom=geometry,
basis="cc-pvdz",
charge=0,
spin=0,
symmetry="D2H",
cart=True,
unit="Bohr",
)
mf = scf.UHF(mol)
mf.kernel()
driver = Driver.from_pyscf(mf, nfrozen=2, uhf=True)
driver.system.print_info()
driver.run_cc(method="ccsdt")

assert np.allclose(driver.system.reference_energy + driver.correlation_energy, -199.058201, rtol=1.0e-07, atol=1.0e-07)

if __name__ == "__main__":
test_ccsdt_f2()
13 changes: 4 additions & 9 deletions tests/ohminus/test_cripcc23_ohminus.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,11 @@ def test_cripcc23_ohminus():
# Check the results
#
expected_vee = [-0.02049758, 0.56909275, 0.14122875, 0.60699750, 0.61645987, 0.70904961, 0.51783683, 0.58412700]
expected_crcc23 = [-75.5437471773, -75.1404066669, -75.3840902578, -75.1776050392, -75.0853359523, -74.8867671659, -75.2687622370, -75.2408992393]
for i, (vee, veep3) in enumerate(zip(expected_vee, expected_crcc23)):
assert np.allclose(driver.vertical_excitation_energy[i], vee, atol=1.0e-07, rtol=1.0e-07)
assert np.allclose(driver.system.reference_energy + driver.correlation_energy + driver.vertical_excitation_energy[i] + driver.deltap3[i]["D"], veep3, atol=1.0e-07, rtol=1.0e-07)

print("Excitation Spectrum of Target Species")
for i, vee in enumerate(expected_vee):
print(f"Root {i}")
assert np.allclose(driver.vertical_excitation_energy[i], vee)
en = driver.vertical_excitation_energy[i] - driver.vertical_excitation_energy[0]
print(f" IP-EOMCCSD = {en*27.2114} eV")
for denom in ['A', 'B', 'C', 'D']:
cren = en + driver.deltap3[i][denom] - driver.deltap3[0][denom]
print(f" CR-IP-EOMCCSD_{denom} = {cren*27.2114} eV")

if __name__ == "__main__":
test_cripcc23_ohminus()

0 comments on commit f0a2b83

Please sign in to comment.