import unittest import pytraj as pt from array import array import numpy as np from pytraj import Frame from pytraj.base import * from pytraj.math import Vec3 from pytraj.testing import aa_eq N_ATOMS = 10 FRAME = Frame(N_ATOMS) arr = np.arange(3 * N_ATOMS) FRAME.xyz[:] = arr.reshape(N_ATOMS, 3) FRAME_orig = FRAME.copy() class TestFrame(unittest.TestCase): def test_fit(self): traj = pt.iterload("./data/Tc5b.x", "./data/Tc5b.top") trajnew = pt.iterload("./data/md1_prod.fit_to_first.Tc5b.x", "./data/Tc5b.top") # make sure 0-th frame does not change frame0 = traj[0] frame0new = trajnew[0] frame1 = traj[1] frame1new = trajnew[1] # try do-fitting from Python
import unittest import pytraj as pt from utils import fn from array import array import numpy as np from pytraj import Frame from pytraj.testing import aa_eq from pytraj import * N_ATOMS = 10 FRAME = Frame(N_ATOMS) arr = np.arange(3 * N_ATOMS) FRAME.xyz[:] = arr.reshape(N_ATOMS, 3) FRAME_orig = FRAME.copy() class TestFrame(unittest.TestCase): def test_fit(self): traj = pt.iterload(fn('Tc5b.x'), fn('Tc5b.top')) trajnew = pt.iterload(fn('md1_prod.fit_to_first.Tc5b.x'), fn('Tc5b.top')) # make sure 0-th frame does not change frame0 = traj[0] trajnew[0] frame1 = traj[1] frame1new = trajnew[1] # try do-fitting from Python
if rank == 0: ref = traj[0] ref_xyz = np.asarray(ref.xyz, dtype=np.float64) else: ref = None ref_xyz = np.empty((n_atoms, 3), dtype=np.float64) # broadcast ref_xyz to other cores from master comm.Bcast([ref_xyz, MPI.DOUBLE]) if rank != 0: # need to reconstruct ref ref = Frame() ref.append_xyz(ref_xyz) _ref = ref.copy() def rmsd_mpi(traj, _ref): arr0 = pyca.calc_rmsd("@CA", traj, traj.top, _ref) return arr0 arr0 = rmsd_mpi(traj, _ref) if rank == 0: data = np.empty(size * traj.n_frames, dtype=np.float64) else: data = None data = comm.gather(arr0, root=0)