def run(self, formula, system, filename): """Calculate energy of specified system and save to file.""" system.get_potential_energy() # Won't create .bak file: traj = PickleTrajectory(open(filename, 'w'), 'w') traj.write(system) traj.close()
def run(self, formula, system, filename): """Calculate bond length of a dimer. This will calculate total energies for varying atomic separations close to the g2 bond length, allowing determination of bond length by fitting. """ if len(system) != 2: raise ValueError('Not a dimer') traj = PickleTrajectory(open(filename, 'w'), 'w') pos = system.positions d = np.linalg.norm(pos[1] - pos[0]) for x in range(-2, 3): system.set_distance(0, 1, d * (1.0 + x * 0.02)) traj.write(system) traj.close()