def write_equilibrium_trajectory(trajectory: md.Trajectory, trajectory_filename: str) -> float: """ Write the results of an equilibrium simulation to disk. This task will append the results to the given filename. Arguments ---------- trajectory : md.Trajectory the trajectory resulting from an equilibrium simulation trajectory_filename : str the name of the trajectory file to which we should append Returns ------- True """ if not os.path.exists(trajectory_filename): trajectory.save_hdf5(trajectory_filename) _logger.debug( f"{trajectory_filename} does not exist; instantiating and writing to." ) else: _logger.debug(f"{trajectory_filename} exists; appending.") written_traj = md.load_hdf5(trajectory_filename) concatenated_traj = written_traj.join(trajectory) concatenated_traj.save_hdf5(trajectory_filename) return True
def write_equilibrium_trajectory(equilibrium_result: EquilibriumResult, trajectory: md.Trajectory, trajectory_filename: str) -> float: """ Write the results of an equilibrium simulation to disk. This task will append the results to the given filename. Parameters ---------- equilibrium_result : EquilibriumResult namedtuple the result of an equilibrium calculation trajectory : md.Trajectory the trajectory resulting from an equilibrium simulation trajectory_filename : str the name of the trajectory file to which we should append Returns ------- reduced_potential_final_frame : float the reduced potential of the final frame """ if not os.path.exists(trajectory_filename): trajectory.save_hdf5(trajectory_filename) else: written_traj = md.load_hdf5(trajectory_filename) concatenated_traj = written_traj.join(trajectory) concatenated_traj.save_hdf5(trajectory_filename) return equilibrium_result.reduced_potential
def write_equilibrium_trajectory(equilibrium_result: EquilibriumResult, trajectory: md.Trajectory, trajectory_filename: str) -> float: """ Write the results of an equilibrium simulation to disk. This task will append the results to the given filename. Parameters ---------- equilibrium_result : EquilibriumResult namedtuple the result of an equilibrium calculation trajectory : md.Trajectory the trajectory resulting from an equilibrium simulation trajectory_filename : str the name of the trajectory file to which we should append Returns ------- reduced_potential_final_frame : float the reduced potential of the final frame """ if not os.path.exists(trajectory_filename): trajectory.save_hdf5(trajectory_filename) else: written_traj = md.load_hdf5(trajectory_filename) concatenated_traj = written_traj.join(trajectory) concatenated_traj.save_hdf5(trajectory_filename) return equilibrium_result.reduced_potential
def write_nonequilibrium_trajectory( nonequilibrium_result: NonequilibriumResult, nonequilibrium_trajectory: md.Trajectory, trajectory_filename: str) -> float: """ Write the results of a nonequilibrium switching trajectory to a file. The trajectory is written to an mdtraj hdf5 file, whereas the cumulative work is written to a numpy file. Parameters ---------- nonequilibrium_result : NonequilibriumResult namedtuple The result of a nonequilibrium switching calculation nonequilibrium_trajectory : md.Trajectory The trajectory resulting from a nonequilibrium simulation trajectory_filename : str The full filepath for where to store the trajectory Returns ------- final_work : float The final value of the work trajectory """ if nonequilibrium_trajectory is not None: nonequilibrium_trajectory.save_hdf5(trajectory_filename) return nonequilibrium_result.cumulative_work[-1]
def write_nonequilibrium_trajectory(nonequilibrium_result: NonequilibriumResult, nonequilibrium_trajectory: md.Trajectory, trajectory_filename: str) -> float: """ Write the results of a nonequilibrium switching trajectory to a file. The trajectory is written to an mdtraj hdf5 file, whereas the cumulative work is written to a numpy file. Parameters ---------- nonequilibrium_result : NonequilibriumResult namedtuple The result of a nonequilibrium switching calculation nonequilibrium_trajectory : md.Trajectory The trajectory resulting from a nonequilibrium simulation trajectory_filename : str The full filepath for where to store the trajectory Returns ------- final_work : float The final value of the work trajectory """ if nonequilibrium_trajectory is not None: nonequilibrium_trajectory.save_hdf5(trajectory_filename) return nonequilibrium_result.cumulative_work[-1]