From 96efe81b906e9bc007d05f5767c89c6515e97b8d Mon Sep 17 00:00:00 2001 From: Johannes Steinmetzer Date: Tue, 9 Apr 2024 20:55:08 +0200 Subject: [PATCH] fix: orca_ctnums.py also looks for *.log now improved detection of singlet-triplet excitations for ORCA --- pysisyphus/calculators/ORCA.py | 2 +- scripts/orca_ctnums.py | 17 +++++++++++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/pysisyphus/calculators/ORCA.py b/pysisyphus/calculators/ORCA.py index f40f47d0f..64415bcf8 100644 --- a/pysisyphus/calculators/ORCA.py +++ b/pysisyphus/calculators/ORCA.py @@ -675,7 +675,7 @@ def __init__( ) except AttributeError: self.log("Doing TDA/TDDFT calculation without gradient.") - self.triplets = bool(re.search(r"triplets\s+true", self.blocks)) + self.triplets = bool(re.search(r"triplets\s+true|irootmult\s+triplet", self.blocks)) self.inp_fn = "orca.inp" self.out_fn = "orca.out" self.to_keep = ( diff --git a/scripts/orca_ctnums.py b/scripts/orca_ctnums.py index 7b7504942..36d663777 100755 --- a/scripts/orca_ctnums.py +++ b/scripts/orca_ctnums.py @@ -17,7 +17,9 @@ from pysisyphus.wavefunction.excited_states import norm_ci_coeffs, ct_numbers_for_states -def load_data(base_name: Path, triplets: bool = False, ignore_bonds: Optional[list[int]] = None): +def load_data( + base_name: Path, triplets: bool = False, ignore_bonds: Optional[list[int]] = None +): if ignore_bonds is None: ignore_bonds = list() @@ -31,6 +33,9 @@ def load_data(base_name: Path, triplets: bool = False, ignore_bonds: Optional[li log_fn = base_name.with_suffix(".log") wf_fn = base_name.with_suffix(".bson") + if not log_fn.exists(): + log_fn = base_name.with_suffix(".out") + # Drop GS, only keep excitation energies all_ens = parse_orca_all_energies(log_fn, triplets=triplets, do_tddft=True) exc_ens = all_ens[1:] - all_ens[0] @@ -41,7 +46,9 @@ def load_data(base_name: Path, triplets: bool = False, ignore_bonds: Optional[li wf = Wavefunction.from_file(wf_fn) print(f"Loaded wavefunction from '{wf_fn}'.") - frags = get_fragments(wf.atoms, wf.coords, ignore_bonds=ignore_bonds, with_unconnected_atoms=True) + frags = get_fragments( + wf.atoms, wf.coords, ignore_bonds=ignore_bonds, with_unconnected_atoms=True + ) # Convert from list of frozensets to list of lists frags = list(map(list, frags)) @@ -104,7 +111,7 @@ def run(): nbonds = len(bonds) // 2 ignore_bonds = list() for i in range(nbonds): - ignore_bonds.append(bonds[2*i:2*(i+1)]) + ignore_bonds.append(bonds[2 * i : 2 * (i + 1)]) data = load_data(base_name, triplets, ignore_bonds) @@ -116,7 +123,9 @@ def run(): homogenous_frags = data["frags"] frags = [] - for key, _frag in it.groupby(homogenous_frags, key=lambda frag_atom_ind: frag_atom_ind[0]): + for key, _frag in it.groupby( + homogenous_frags, key=lambda frag_atom_ind: frag_atom_ind[0] + ): cur_frag = [] for _, atom_ind in _frag: cur_frag.append(atom_ind)