Skip to content

Commit f6c0df9

Browse files
author
eahuang
committed
added function to write integrals that dsrg uses to an fcidump
1 parent a6fa5f0 commit f6c0df9

1 file changed

Lines changed: 35 additions & 2 deletions

File tree

forte/proc/dsrg.py

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import math
3232
import json
3333
import psi4
34+
import os.path
3435

3536
import forte
3637
from forte.proc.external_active_space_solver import write_external_active_space_file
@@ -49,7 +50,6 @@ def __init__(self, active_space_solver, state_weights_map, mo_space_info, ints,
4950
:param scf_info: the Forte SCFInfo object
5051
"""
5152

52-
# Read options
5353
self.solver_type = options.get_str("CORRELATION_SOLVER")
5454
if self.solver_type in ["SA-MRDSRG", "SA_MRDSRG", "DSRG_MRPT", "DSRG-MRPT"]:
5555
self.rdm_type = forte.RDMsType.spin_free
@@ -179,10 +179,43 @@ def __init__(self, active_space_solver, state_weights_map, mo_space_info, ints,
179179
self.mo_space_info, self.ints, self.scf_info, inactive_mix, active_mix, semi_threshold
180180
)
181181

182+
def write_to_fcidump(self):
183+
"Writes integrals to FCIDUMP in PYSCF format"
184+
185+
if not os.path.exists('INTDUMP'):
186+
187+
mos = self.mo_space_info.corr_absolute_mo("CORRELATED")
188+
nmo = len(mos)
189+
a = self.ints.oei_a_block(mos,mos)
190+
ab = self.ints.tei_ab_block(mos,mos,mos,mos)
191+
tol = 1.0e-15
192+
fcidump_string = f"""&FCI NORB={nmo},NELEC={12},UHF=.FALSE.,ORBSYM={"1,"*(nmo)}MS2={0},ISYM=1
193+
&END
194+
"""
195+
print("...writing integrals to INTDUMP")
196+
#transform to chemist notation
197+
for i in range(nmo):
198+
for j in range(0, i+1):
199+
for k in range(0, nmo):
200+
for l in range(0, k+1):
201+
if abs(ab[i][k][j][l]) > tol:
202+
fcidump_string += f"{ab[i][k][j][l]:.20e} {i+1:4d}{j+1:4d}{k+1:4d}{l+1:4d}\n"
203+
for i in range(0, nmo):
204+
for j in range(0, i+1):
205+
if abs(a[i][j]) > tol:
206+
fcidump_string += f"{a[i][j]:.20e} {i+1:4d}{j+1:4d}{0:4d}{0:4d}\n"
207+
fcidump_string += f"{self.ints.nuclear_repulsion_energy() + self.ints.frozen_core_energy()} {0:4d}{0:4d}{0:4d}{0:4d}"
208+
209+
with open("INTDUMP", "w") as f:
210+
f.write(fcidump_string)
211+
212+
raise psi4.p4util.PsiException("Written integrals to INTDUMP")
213+
182214
def make_dsrg_solver(self):
183-
"""Make a DSRG solver."""
184215
args = (self.rdms, self.scf_info, self.options, self.ints, self.mo_space_info)
185216

217+
self.write_to_fcidump()
218+
186219
if self.solver_type in ["MRDSRG", "DSRG-MRPT2", "DSRG-MRPT3", "THREE-DSRG-MRPT2"]:
187220
self.dsrg_solver = forte.make_dsrg_method(*args)
188221
self.dsrg_solver.set_state_weights_map(self.state_weights_map)

0 commit comments

Comments
 (0)