Skip to content

Commit

Permalink
misc changes
Browse files Browse the repository at this point in the history
  • Loading branch information
corinwagen committed Jan 20, 2022
1 parent 85cb8d0 commit 1bc9ded
Show file tree
Hide file tree
Showing 7 changed files with 138,345 additions and 17 deletions.
2 changes: 1 addition & 1 deletion cctk/ensemble.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ def eliminate_redundant(self, RMSD_cutoff=0.5, comparison_atoms="heavy", return_
assert 1 <= a <= n_atoms, f"atom number out of range: got {a}, but must be between 1 and {n_atoms}"
assert len(comparison_atoms) >= 3, f"need at least 3 atoms for alignment, but only got {len(comparison_atoms)}"

assert isinstance(RMSD_cutoff, float), f"RMSD cutoff must be a float but got {str(type(RMSD_cutoff))}"
assert isinstance(RMSD_cutoff, (float, int)), f"RMSD cutoff must be a float but got {str(type(RMSD_cutoff))}"
assert RMSD_cutoff > 0.0001, "must use a big enough RMSD cutoff"

# align all molecules
Expand Down
2 changes: 1 addition & 1 deletion cctk/optimize.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def csearch(use_tempdir=True, **kwargs):

return ensemble

def _do_csearch(molecule, nprocs, logfile, noncovalent, directory, constraints):
def _do_csearch(molecule, directory, nprocs=1, logfile=None, noncovalent=False, constraints=None):
assert isinstance(molecule, cctk.Molecule), "need a valid molecule!"
assert isinstance(nprocs, int)
assert isinstance(logfile, str)
Expand Down
28 changes: 16 additions & 12 deletions cctk/parse_gaussian.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,11 @@ def read_file_fast(file_text, filename, link1idx, max_len=20000, extended_opt_in
max_int = extract_parameter(word_matches[10], 3)
delta_e = extract_parameter(word_matches[11], 3, cast_to_float=False)

for idx, force in enumerate(rms_forces):
properties[idx]["rms_force"] = force
# ccw 10.8.2021 - ad hoc correction to Gaussian. unsure what's going on here. sometimes len(rms_forces) > len(g)
force_property_index = min(len(g), len(rms_forces))

for idx in range(force_property_index):
properties[idx]["rms_force"] = rms_forces[idx]
properties[idx]["rms_displacement"] = rms_disp[idx]

if extended_opt_info:
Expand All @@ -216,7 +219,7 @@ def read_file_fast(file_text, filename, link1idx, max_len=20000, extended_opt_in
change_in_energy = re.sub(r"Energy=", "", delta_e[idx])
properties[idx]["predicted_change_in_energy"] = float(change_in_energy.replace('D', 'E'))

if cctk.GaussianJobType.FREQ in job_types:
if cctk.GaussianJobType.FREQ in job_types and len(molecules):
enthalpies = extract_parameter(word_matches[12], 6)
if len(enthalpies) == 1:
properties[-1]["enthalpy"] = enthalpies[0]
Expand Down Expand Up @@ -267,27 +270,28 @@ def read_file_fast(file_text, filename, link1idx, max_len=20000, extended_opt_in
if couplings is not None:
properties[-1]["j_couplings"] = couplings

if cctk.GaussianJobType.FORCE in job_types:
if cctk.GaussianJobType.FORCE in job_types and len(molecules):
assert len(molecules) == 1, "force jobs should not be combined with optimizations!"
force_block = block_matches[7]
if len(force_block) == 0:
raise ValueError("no forces to parse!")
forces = parse_forces(force_block)
properties[0]["forces"] = forces

if cctk.GaussianJobType.POP in job_types:
if cctk.GaussianJobType.POP in job_types and len(molecules):
if re.search("hirshfeld", f.route_card) or re.search("cm5", f.route_card) and len(block_matches[8]) > 0:
charges, spins = parse_hirshfeld(block_matches[8])
properties[-1]["hirshfeld_charges"] = charges
properties[-1]["hirshfeld_spins"] = spins

try:
charges, dipole, dipole_v = parse_charges_dipole(block_matches[9], block_matches[10])
properties[-1]["mulliken_charges"] = charges
properties[-1]["dipole_moment"] = dipole
properties[-1]["dipole_vector"] = dipole_v
except Exception as e:
pass
if len(molecules):
try:
charges, dipole, dipole_v = parse_charges_dipole(block_matches[9], block_matches[10])
properties[-1]["mulliken_charges"] = charges
properties[-1]["dipole_moment"] = dipole
properties[-1]["dipole_vector"] = dipole_v
except Exception as e:
pass

for mol, prop in zip(molecules, properties):
f.ensemble.add_molecule(mol, properties=prop)
Expand Down
4 changes: 2 additions & 2 deletions cctk/si_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ def write_file(self, filename, append=False):
text += f"Cartesian Coordinates (Å):\n"
for index, Z in enumerate(molecule.atomic_numbers, start=1):
line = molecule.get_vector(index)
text += f"{get_symbol(Z):>2} {line[0]:>13.8f} {line[1]:>13.8f} {line[2]:>13.8f}\n"
text += f"{get_symbol(Z):>2} {line[0]:>13.6f} {line[1]:>13.6f} {line[2]:>13.8f}\n"

text += "\n"
if first:
super().write_file(filename, text)
first = False
else:
text += "\n"
super().append_to_file(filename, text)


Expand Down
Loading

0 comments on commit 1bc9ded

Please sign in to comment.