def get_forces(self, atoms, coords): xyz = make_xyz_str(atoms, coords.reshape(-1, 3) * BOHR2ANG) mol = psi4.geometry(xyz) energy, wfn = psi4.energy(self.meth_bas, return_wfn=True) gradient = psi4.gradient(self.meth_bas, molecule=mol, ref_wfn=wfn) results = { "energy": energy, "forces": -np.asarray(gradient).flatten(), } return results
def write_trj(self, path, prefix, coords=None): path = pathlib.Path(path) atoms = self.geometry.atoms if coords is None: coords = self.all_mw_coords coords = coords.copy() coords /= self.m_sqrt coords = coords.reshape(-1, len(atoms), 3) * BOHR2ANG # all_mw_coords = self.all_mw_coords.flatten() trj_string = make_trj_str(atoms, coords, comments=self.all_energies) trj_fn = f"{prefix}_irc.trj" with open(path / trj_fn, "w") as handle: handle.write(trj_string) first_coords = coords[0] first_fn = f"{prefix}_first.xyz" with open(path / first_fn, "w") as handle: handle.write(make_xyz_str(atoms, first_coords)) last_coords = coords[-1] first_fn = f"{prefix}_last.xyz" with open(path / first_fn, "w") as handle: handle.write(make_xyz_str(atoms, last_coords))
def as_xyz(self, comment=""): """Current geometry as a string in XYZ-format. Parameters ---------- comment : str, optional Will be written in the second line (comment line) of the XYZ-string. Returns ------- xyz_str : str Current geometry as string in XYZ-format. """ coords = self._coords * BOHR2ANG if comment == "": comment = self.comment return make_xyz_str(self.atoms, coords.reshape((-1, 3)), comment)
def prepare_coords(self, atoms, coords): coords = coords * BOHR2ANG return make_xyz_str(atoms, coords.reshape((-1, 3)))