def calc(self, phi=None): """Calculate torsion angle and energy Args: phi (float, optional): define the angle instead of calculating it from the structure Returns tuple (E [kcal/mol], phi [degrees]) """ if phi == None: ac1, ac2, ac3, ac4 = [a.struct.coordinates for a in self.atoms] phi = qpotential.torsion_angle(ac1, ac2, ac3, ac4) energy = 0 for fc, multiplicity, phase, npaths in self.prm.get_prms(): energy += qpotential.torsion_energy(phi, fc, multiplicity, npaths, phase) return (energy, phi)
nprm[bati_name] = 0 data[bati_name] = [] for bati in getattr(qtop, bati_name): if bati_name == "bonds": e0 = 0 v0 = bati.prm.r0 elif bati_name == "angles": e0 = 0 v0 = bati.prm.theta0 elif bati_name == "torsions": # get the torsion minimum energy_profile = [] for phi in range(0, 181, 30): energy = 0 for fc, multiplicity, phase, npaths in bati.prm.get_prms(): energy += torsion_energy(phi, fc, multiplicity, npaths, phase) energy_profile.append((energy, phi)) energy_profile.sort() e0, v0 = min(energy_profile) elif bati_name == "improper": e0 = 0 v0 = bati.prm.phi0 e, v = bati.calc() de = e - e0 data[bati_name].append((bati, de, v, v0)) total_e[bati_name] += de if de > max_e[bati_name]: max_e[bati_name] = de nprm[bati_name] += 1