energy_all  = np.zeros((nsteps,3))  # store energy
    pos_par_0   = np.zeros((nsteps,3))  # the postions of particle 0
    veloc_t0    = np.zeros((num_atoms,3))  #init velocity for all the particles
    veloc_t     = np.zeros((num_atoms,3))  # store vel. for particles at t
    vv_a        = np.zeros(nsteps)      # store velocity products at tj steps
    Inst_T_all  = np.zeros(nsteps)      # store instananeous time
    seed        = 3   # change seed to initial velocity
    r_num       = 50 # the pieces of g(r) is cut into
    maxk        = 5   #max value of k vector component
    firstcutoff = 50  # the start of equillibrium
    g_r_ave     = np.zeros(r_num)
    s_r_ave     = np.zeros(num_k_mag(maxk,3))
    vv_0        = np.zeros(num_atoms)

    # create and initialize a set of particles
    pset = ParticleSet(num_atoms,mass)
    #pset._alloc_pos_vel_accel()
    pset.init_pos_cubic(box_length)
    pset.init_vel(temperature,seed)

    # molecular dynamics simulation loop

    for istep in range(nsteps):

        # calculate properties of the particles
        Ene_all = compute_energy(pset,box_length)
        print(istep, Ene_all[0],Ene_all[1],Ene_all[2])

        #record the initial velocity and vv_0 for all the particles
        if istep == 0:
            veloc_t0 = pset.all_vel()
    return (tot_kinetic, tot_potential, tot_energy)


# end def compute_energy

if __name__ == '__main__':

    num_atoms = 64
    mass = 48.0
    temperature = 0.728
    box_length = 4.2323167
    nsteps = 10
    dt = 0.01

    # create and initialize a set of particles
    pset = ParticleSet(num_atoms, mass)
    pset.init_pos_cubic(box_length)
    pset.init_vel(temperature)

    # molecular dynamics simulation loop
    for istep in range(nsteps):

        # calculate properties of the particles
        print(istep, compute_energy(pset, box_length))

        # update positions
        for iat in range(num_atoms):
            my_next_pos = verlet_next_pos(pset.pos(iat), pset.vel(iat),
                                          pset.accel(iat), dt)
            new_pos = pos_in_box(my_next_pos, box_length)
            pset.change_pos(iat, new_pos)
Beispiel #3
0
    veloc_t0    = np.zeros((num_atoms,3))  #init velocity for all the particles
    veloc_t     = np.zeros((num_atoms,3))  # store vel. for particles at t
    #vv_a        = np.zeros(nsteps)      # store velocity products at tj steps
    #Inst_T_all  = np.zeros(nsteps)      # store instananeous time
    seed        = 3   # change seed to initial velocity
    r_num       = 50 # the pieces of g(r) is cut into
    maxk        = 5   #max value of k vector component
    firstcutoff = 1000  # the start of equillibrium
    g_r_sum     = np.zeros(r_num)
    s_r_sum     = np.zeros(num_k_mag(maxk,3))
    sigma       = 0.04   # the std dev for position update
    beta        = 1.0/temperature
    poten       = []  #store pot. after equillibrium

    # create and initialize a set of particles
    pset = ParticleSet(num_atoms,mass)
    #pset._alloc_pos_vel_accel()
    pset.init_pos_cubic(box_length)
    pset.init_vel(temperature,seed)

    # Monte Carlo simulation main loop

    for istep in range(nsteps):

        old_pot = compute_potential(pset,box_length)
        pot_all[istep] = old_pot
        print('*'*60)
        print(istep,pot_all[istep])
        # update positions

        for iat in range(num_atoms):
    return (tot_kinetic, tot_potential, tot_energy)


# end def compute_energy

if __name__ == '__main__':

    num_atoms = 64
    mass = 48.0
    temperature = 0.728
    box_length = 4.2323167
    nsteps = 1000
    dt = 0.01

    # create and initialize a set of particles
    pset = ParticleSet(num_atoms, mass)
    pset.init_pos_cubic(box_length)
    pset.init_vel(temperature)

    # molecular dynamics simulation loop
    for istep in range(nsteps):

        # update accelerations/forces
        for iat in range(num_atoms):
            iaccel = internal_force(iat, pset, box_length)
            for idim in range(pset.ndim()):
                iaccel[idim] /= mass
            pset.change_accel(iat, iaccel)
        # end for iat

        # calculate properties of the particles
Beispiel #5
0
if __name__ == '__main__':

    num_atoms = 64
    mass = 48.0
    temperature = 0.728
    box_length = 4.2323167
    nsteps = 1000  # total step for simulation
    energy_all = np.zeros((nsteps, 3))  # used to store energy
    pos_par_0 = np.zeros(
        (nsteps, 3))  # used to store the postions of particle 0
    dt = 0.01  #time step
    seed = 20  # change seed to initial velocity

    # create and initialize a set of particles
    pset = ParticleSet(num_atoms, mass)
    pset._alloc_pos_vel_accel()
    pset.init_pos_cubic(box_length)
    pset.init_vel(temperature, seed)
    # molecular dynamics simulation loop
    for istep in range(nsteps):

        # calculate properties of the particles
        Ene_all = compute_energy(pset, box_length)
        print(istep, Ene_all[0], Ene_all[1], Ene_all[2])
        energy_all[istep][0] = Ene_all[0]
        energy_all[istep][1] = Ene_all[1]
        energy_all[istep][2] = Ene_all[2]

        # update positions
        for iat in range(num_atoms):