def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('-n', '--n_trajs', help='number of trajectories. Default=10', type=int, default=10)
    parser.add_argument('-t', '--traj_length', help='trajectories length. Default=10000', type=int, default=10000)
    args = parser.parse_args()
    
    # these could be configured
    kT = 15.0
    dt = 0.1
    mGamma = 1000.0
    
    forcecalculator = muller.muller_force()
    

    #project = Project({'conf_filename': os.path.join(mullermsm.__path__[0], 'conf.pdb'),
    #          'num_trajs': args.n_trajs,
    #          'project_root_dir': '.',
    #          'traj_file_base_name': 'trj',
    #          'traj_file_path': 'Trajectories',
    #          'traj_file_type': '.lh5',
    #          'traj_lengths': [args.traj_length]*args.n_trajs})
     
    #if os.path.exists('ProjectInfo.h5'):
    #    print >> sys.stderr, "The file ./ProjectInfo.h5 already exists. I don't want to overwrite anything, so i'm backing off"
    #    sys.exit(1)
    
    
    try:
        os.mkdir('Trajectories')
    except OSError:
        print >> sys.stderr, "The directory ./Trajectores already exists. I don't want to overwrite anything, so i'm backing off"
        sys.exit(1)
        
    for i in range(args.n_trajs):
        print 'simulating traj %s' % i
        
        # select initial configs randomly from a 2D box
        initial_x = [0,0]
        initial_x = [random.uniform(-1.5, 1.2), random.uniform(-0.2, 2)]
        print 'starting conformation from randomly sampled points (%s, %s)' % (initial_x[0], initial_x[1])
        print 'propagating for %s steps on the Muller potential with a Langevin integrator...' % args.traj_length
        
        positions = muller.propagate(args.traj_length, initial_x, kT, dt, mGamma, forcecalculator)

        # positions is N x 2, but we want to make it N x 1 x 3 where the additional
        # column is just zeros. This way, being N x 1 x 3, it looks like a regular MD
        # trajectory that would be N_frames x N_atoms x 3
        positions3 = np.hstack((positions, np.zeros((len(positions),1)))).reshape((len(positions), 1, 3))
        t = Trajectory.LoadTrajectoryFile(project['ConfFilename'])
        t['XYZList'] = positions3
        
        t.SaveToLHDF(project.GetTrajFilename(i))
        print 'saving trajectory to %s' % project.GetTrajFilename(i)
        
    project.SaveToHDF('ProjectInfo.h5')
    print 'saved ProjectInfo.h5 file'

    
    pickle.dump(metric.EuclideanMetric(), open('metric.pickl', 'w'))
    print 'saved metric.pickl'
Exemple #2
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('-n', '--n_trajs', help='number of trajectories. Default=10', type=int, default=10)
    parser.add_argument('-t', '--traj_length', help='trajectories length. Default=10000', type=int, default=10000)
    args = parser.parse_args()
    
    # these could be configured
    kT = 15.0
    dt = 0.1
    mGamma = 1000.0
    
    forcecalculator = muller.muller_force()
    

    project = Project({'ConfFilename': os.path.join(mullermsm.__path__[0], 'conf.pdb'),
              'NumTrajs': args.n_trajs,
              'ProjectRootDir': '.',
              'TrajFileBaseName': 'trj',
              'TrajFilePath': 'Trajectories',
              'TrajFileType': '.lh5',
              'TrajLengths': [args.traj_length]*args.n_trajs})
              
              
    if os.path.exists('ProjectInfo.h5'):
        print >> sys.stderr, "The file ./ProjectInfo.h5 already exists. I don't want to overwrite anything, so i'm backing off"
        sys.exit(1)
    
    
    try:
        os.mkdir('Trajectories')
    except OSError:
        print >> sys.stderr, "The directory ./Trajectores already exists. I don't want to overwrite anything, so i'm backing off"
        sys.exit(1)
        
    for i in range(args.n_trajs):
        print 'simulating traj %s' % i
        
        # select initial configs randomly from a 2D box
        initial_x = [random.uniform(-1.5, 1.2), random.uniform(-0.2, 2)]
        print 'starting conformation from randomly sampled points (%s, %s)' % (initial_x[0], initial_x[1])
        print 'propagating for %s steps on the Muller potential with a Langevin integrator...' % args.traj_length
        
        positions = muller.propagate(args.traj_length, initial_x, kT, dt, mGamma, forcecalculator)

        # positions is N x 2, but we want to make it N x 1 x 3 where the additional
        # column is just zeros. This way, being N x 1 x 3, it looks like a regular MD
        # trajectory that would be N_frames x N_atoms x 3
        positions3 = np.hstack((positions, np.zeros((len(positions),1)))).reshape((len(positions), 1, 3))
        t = Trajectory.LoadTrajectoryFile(project['ConfFilename'])
        t['XYZList'] = positions3
        
        t.SaveToLHDF(project.GetTrajFilename(i))
        print 'saving trajectory to %s' % project.GetTrajFilename(i)
        
    project.SaveToHDF('ProjectInfo.h5')
    print 'saved ProjectInfo.h5 file'

    
    pickle.dump(metric.EuclideanMetric(), open('metric.pickl', 'w'))
    print 'saved metric.pickl'
Exemple #3
0
import random
from mullermsm import muller
mullerforce = muller.muller_force()
import scipy.linalg
from matplotlib.pyplot import *
from argparse import ArgumentParser

parser = ArgumentParser()
parser.add_argument('--dt', dest='dt', type=float, default=0.1)
parser.add_argument('-n', dest='num_frames', type=int, default=100000)
parser.add_argument('-o', dest='output', default='pos.npy')
parser.add_argument('-i', dest='init_x', default=None, nargs='+', help='initial positions')
args = parser.parse_args()

kT = 15.0
dt = args.dt
mGamma = 1000.0
traj_length = args.num_frames 
if args.init_x is None:
    initial_x = [random.uniform(-1.5, 1.2), random.uniform(-0.2, 2)]
else:
    initial_x = [np.float(args.init_x[0]), np.float(args.init_x[1])]

positions = muller.propagate(traj_length, initial_x, kT, dt, mGamma, mullerforce)

np.save(args.output, positions)

#muller.plot_v()
#plot(positions[:,0], positions[:,1], color='white', lw=3)
#show()