Beispiel #1
0
class MDSim:
    def __init__(self, numpyart, rho, temp, force, stepsize=0.001):
        """Initializes the various parts of an MD simulation.

        Parameters:
        numpyart: Number of particles
        rho  : Density
        temp : Temperature
        force: A force model
        stepsize: Time step
        """ 
        self.geometry = CubicLattice( numpyart, rho )               # Initialize a geometry,
                                                                 # in this case a cubic lattice.
        self.system = Ensemble( self.geometry, temp )            # Create an ensemble to
                                                                 # store information about
                                                                 # the simulation.
        self.solver = VeloVerlet( self.system, force, stepsize ) # Create the sampler class.
        self.sampler = Sampler()
    
    def run( self, nsteps, tSet):
        """Simulates N steps of the simulation.""" 
        # Equilibration Run.
        print "equilibrating %i steps" % (nsteps/2)
        for n in range(0,nsteps/2,2):
            self.solver.step()
            if( n % 1000 == 0 ):
                #self.system.setT(tSet)
                print "step = %05i, temp = %12.7f" % (n, self.system.getT()) 
        print "Equilibration done." 
        # Production Run.  
        for n in range(nsteps/2, nsteps+1): 
            # sample every 100 steps but only after nsteps / 2 equilibration steps
            if( n % fil == 0 and n > nsteps / 2 ):
                U = copy.deepcopy(self.system.getPos()) 
                #Sampling
                self.sampler.sampleData( U[0], U[1], U[2],
                                         self.system.getEpot(),
                                         self.system.getEkin(),
                                         self.system.getT(),
                                         self.system.getP(),
                                         copy.deepcopy(self.system.getVel()) ) 
            # print every 500 steps
            if( n % 1000 == 0 ):
                print "step = %05i, temp = %12.7f" % (n, self.system.getT()) 
            self.solver.step()  # take a simulation step
Beispiel #2
0
    def __init__(self, numpyart, rho, temp, force, stepsize=0.001):
        """Initializes the various parts of an MD simulation.

        Parameters:
        numpyart: Number of particles
        rho  : Density
        temp : Temperature
        force: A force model
        stepsize: Time step
        """ 
        self.geometry = CubicLattice( numpyart, rho )               # Initialize a geometry,
                                                                 # in this case a cubic lattice.
        self.system = Ensemble( self.geometry, temp )            # Create an ensemble to
                                                                 # store information about
                                                                 # the simulation.
        self.solver = VeloVerlet( self.system, force, stepsize ) # Create the sampler class.
        self.sampler = Sampler()