Skip to content

Commit 9d9240c

Browse files
committed
Added option to determine the number of electrons in Slater determinant definition to be consistent with the active space if the latter is provided. Added the nelec_act_space keyword to the Libra/MOPAC workflow to reduce the size of Slater determinants to accelerate calculations
1 parent 263450f commit 9d9240c

2 files changed

Lines changed: 27 additions & 5 deletions

File tree

src/libra_py/citools/ci.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,14 +125,24 @@ def overlap(st_mo, data1, data2, params):
125125
nstates, common_sd_basis, data2[1], data2[2]
126126
)
127127

128+
#-------------------------------------------------------------------
129+
# Get the effective number of electrons - only those that are in the
130+
# active space
131+
#-------------------------------------------------------------------
132+
nelec_eff = 0
133+
if active_space is None:
134+
nelec_eff = nelec
135+
else:
136+
nelec_eff = 2 * sum(i <= homo_indx for i in active_space)
137+
128138
# ------------------------------------------------------------------
129139
# SD and CSF overlap matrices (singlet)
130140
# ------------------------------------------------------------------
131141
csf_ovlp, sd_ovlp = interfaces.sd_and_csf_overlaps_singlet(
132142
st_mo,
133143
lowest_orbital,
134144
highest_orbital,
135-
nelec,
145+
nelec_eff,
136146
homo_indx,
137147
common_sd_basis,
138148
active_space

src/libra_py/packages/mopac/methods.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -534,13 +534,14 @@ def mopac_compute_adi(q, params, full_id):
534534
coords = q.col(itraj)
535535

536536
critical_params = ["labels", "timestep"]
537-
default_params = {"mopac_exe": "mopac", "is_first_time": True, "orbital_space": None, "active_space": None,
537+
default_params = {"mopac_exe": "mopac", "is_first_time": True, "orbital_space": None,
538538
"nstates":2,
539539
"mopac_run_params": "INDO C.I.=(6,3) CHARGE=0 RELSCF=0.000001 ALLVEC WRTCONF=0.00 WRTCI=2",
540540
"mopac_working_directory": "mopac_wd",
541541
"mopac_input_prefix": "input_", "mopac_output_prefix": "output_",
542542
"dt": 1.0 * units.fs2au, "do_Lowdin": 0,
543-
"CAS":[ [1,2], 2], "mult_S":0, "mult_Ms":0, "is_singlet_excitation":0
543+
"CAS":[ [1,2], 2], "mult_S":0, "mult_Ms":0, "is_singlet_excitation":0,
544+
"nelec_act_space":None
544545
}
545546
comn.check_input(params[itraj], default_params, critical_params)
546547

@@ -554,14 +555,14 @@ def mopac_compute_adi(q, params, full_id):
554555
mopac_input_prefix = params[itraj]["mopac_input_prefix"]
555556
mopac_output_prefix = params[itraj]["mopac_output_prefix"]
556557
orbital_space = params[itraj]["orbital_space"]
557-
active_space = params[itraj]["active_space"]
558558
nstates = params[itraj]["nstates"]
559559
dt = params[itraj]["dt"]
560560
do_Lowdin = params[itraj]["do_Lowdin"]
561561
CAS = params[itraj]["CAS"]
562562
mult_S = params[itraj]["mult_S"]
563563
mult_Ms = params[itraj]["mult_Ms"]
564564
is_singlet_excitation = params[itraj]["is_singlet_excitation"]
565+
nelec_act_space = params[itraj]["nelec_act_space"]
565566
natoms = len(labels)
566567
ndof = 3 * natoms
567568

@@ -575,6 +576,17 @@ def mopac_compute_adi(q, params, full_id):
575576
read_params = {"nstates":nstates, "filename":filename, "orbital_space":None}
576577
info, MO_curr, data_curr = read_mopac_orbital_info(read_params)
577578

579+
#================= Construct active space ==================
580+
active_space = None
581+
if nelec_act_space is None:
582+
active_space = info["actual_orbital_space"]
583+
else:
584+
min_indx = info["nocc"] - nelec_act_space//2 + 1
585+
if min_indx > info["min_occ"]:
586+
min_elec = ((info["nocc"] - info["min_occ"]) + 1 )*2
587+
raise ValueError(f"The `nelec_act_space` should be at least { min_elec }")
588+
active_space = list(range(min_indx, info["nmo"]+1))
589+
578590
# Get the properties at the previous time-steps
579591
MO_prev, data_prev = None, None
580592
if is_first_time:
@@ -602,7 +614,7 @@ def mopac_compute_adi(q, params, full_id):
602614
# Make it doubled - block-matrix
603615
st_mo = np.kron(np.eye(2), st_mo_orb)
604616

605-
#================= Compute CI time-overlaps =============
617+
#================= Compute CI time-overlaps =============
606618
ovlp_params = {"homo_indx":info["nocc"],
607619
"nocc":info["nocc"] - 1,
608620
"nvirt":info["nmo"] - info["nocc"],

0 commit comments

Comments
 (0)