def add_rotational_velocity(atoms, rot_vel, axis, anchor): """ Adds the rot_vel to the vel vector of atoms with respect to the rotation around axis and attached to anchor. """ for atom in atoms: r_perp = v3.perpendicular(atom.pos - anchor, axis) v_tang_dir = v3.cross(axis, r_perp) v_tang_dir_len = v3.mag(v_tang_dir) if v3.is_similar_mag(v_tang_dir_len, 0): v_tang = v3.vector() else: v_new_len = rot_vel * v3.mag(r_perp) v_tang = v3.scale(v_tang_dir, v_new_len/v_tang_dir_len) atom.vel += v_tang
def add_rotational_velocity(atoms, rot_vel, axis, anchor): """ Adds the rot_vel to the vel vector of atoms with respect to the rotation around axis and attached to anchor. """ for atom in atoms: r_perp = v3.perpendicular(atom.pos - anchor, axis) v_tang_dir = v3.cross(axis, r_perp) v_tang_dir_len = v3.mag(v_tang_dir) if v3.is_similar_mag(v_tang_dir_len, 0): v_tang = v3.vector() else: v_new_len = rot_vel * v3.mag(r_perp) v_tang = v3.scale(v_tang_dir, v_new_len / v_tang_dir_len) atom.vel += v_tang
def moment_of_inertia(atom, axis, anchor): """ Returns the moment (DaAng^^2) of atom around axis at anchor. """ r = atom.pos - anchor r_perp = v3.perpendicular(r, axis) r_len = v3.mag(r_perp) return atom.mass * r_len * r_len
def kinetic_energy(atoms): """ Returns the kinetic energy (Da*angs/ps^2) of the atoms. """ en = 0.0 for a in atoms: vel = v3.mag(a.vel) en += 0.5 * a.mass * vel * vel return en
def rotational_velocity(atom, axis, anchor): """ Returns the rotational velocity (rad/ps) of the atom connected to anchor around axis. """ r = atom.pos - anchor r_perp = v3.perpendicular(r, axis) vel_perp = v3.perpendicular(atom.vel, axis) vel_tang = v3.perpendicular(vel_perp, r_perp) pos_ref = v3.cross(axis, r_perp) if v3.dot(vel_tang, pos_ref) < 0.0: sign = -1.0 else: sign = 1.0 if v3.is_similar_mag(v3.mag(r_perp), 0): result = 0.0 else: result = sign * v3.mag(vel_tang) / v3.mag(r_perp) return result
def calculate_output(self): work_applied = self.kinetic_energy - self.old_kinetic_energy work_applied *= work_DaAngSqPerPsSq_to_pNAng work_applied *= work_pNAng_to_kcalPerMol self.output_dict = { 'separation': v3.mag(self.disp2to1), 'mass': sum(a.mass for a in self.move_atoms), 'target_vel': self.target_val, 'vel': self.vel, 'work_applied': work_applied }