Docsity

Homework 1 for Simple MD Code with Velocity Verlet Algorithm | MSE 627, Assignments of Materials science

Toggle sidebar
bg1
MSE 492/627: Introduction to Atomistic Simulations, Leonid Zhigilei
Homework #1 (page 1 of 2)
Simple MD code with Velocity Verlet algorithm
Write the simplest possible one-dimensional “molecular dynamics code” for two particles
connected by a spring (Force = k(x2-x1-x0)) where Δx=x2-x1is the distance between particles,
x0 is the equilibrium length of the spring.
Your code can have the following structure:
• Define the parameters of the system (k, x0, m1, m2), initial coordinates and velocities of the
particles in the system (x10, x20, v10, v20), initial time = 0, time of the simulation, and timestep
of integration, Δt.
• Calculate initial force Finit = k(x20-x
10-x
0)
•F
old = Finit, x1old= x10, x2old= x20, v1old= v10, v2old= v20
• Time loop:
1. Calculate position at the current time
x1new = x1old + Δt v1old + Δt2Fold/2m1
x2new = x2old + Δt v2old -Δt2Fold/2m2
2. Calculate new forces
Fnew = k(x2new -x
1new -x
0)
3. Calculate new velocities
v1new = v1old + Δt(Fold + Fnew)/2m1
v2new = v2old -Δt(Fold + Fnew)/2m2
4. Copy new variables to old ones (actually, you do not need to store the values
of x and v at two different times, you can use the same variables
and write new values over the old ones at steps 1 and 3). Write
coordinates and velocities to disc for further analysis.
5. Update time (New time = old time + Δt). If the current time is less than the
time of the simulation, go to the time loop and repeat.
• End of the time loop and end of code
pf2

Partial preview of the text

Download Homework 1 for Simple MD Code with Velocity Verlet Algorithm | MSE 627 and more Assignments Materials science in PDF only on Docsity!

MSE 492/627: Introduction to Atomistic Simulations, Leonid Zhigilei

Homework #1 (page 1 of 2)

Simple MD code with Velocity Verlet algorithm

Write the simplest possible one-dimensional “molecular dynamics code” for two particles connected by a spring (Force = k(x 2 -x 1 -x 0 )) where Δx=x 2 -x 1 is the distance between particles, x 0 is the equilibrium length of the spring.

Your code can have the following structure:

  • Define the parameters of the system (k, x 0 , m 1 , m 2 ), initial coordinates and velocities of the particles in the system (x 10 , x 20 , v 10 , v 20 ), initial time = 0, time of the simulation, and timestep of integration, Δt.
  • Calculate initial force Finit^ = k(x 20 - x 10 - x 0 )
  • F old^ = F init^ , x 1 old= x 10 , x 2 old= x 20 , v 1 old= v 10 , v 2 old= v 20
  • Time loop:
    1. Calculate position at the current time x 1 new^ = x 1 old^ + Δt v 1 old^ + Δt 2 F old/2m 1 x 2 new^ = x 2 old^ + Δt v 2 old^ - Δt 2 F old/2m 2
    2. Calculate new forces F new^ = k(x 2 new^ - x 1 new^ - x 0 )
    3. Calculate new velocities v 1 new^ = v 1 old^ + Δt(F old^ + F new)/2m 1 v 2 new^ = v 2 old^ - Δt(F old^ + F new)/2m 2
    4. Copy new variables to old ones (actually, you do not need to store the values of x and v at two different times, you can use the same variables and write new values over the old ones at steps 1 and 3). Write coordinates and velocities to disc for further analysis.
    5. Update time (New time = old time + Δt). If the current time is less than the time of the simulation, go to the time loop and repeat.
  • End of the time loop and end of code

MSE 492/627: Introduction to Atomistic Simulations, Leonid Zhigilei

Homework #1 (page 2 of 2)

  1. Attach listing of your code to your homework report.
  2. Perform “MD simulation” for two particles using the code you wrote for a few (3-4) different parameters of the system (k, m 1 , m 2 , x 0 ). You can choose any set of parameters (a two-atomic molecule, a macroscopic balls with mass of 1 kg each connected by a spring, etc.). If you set v 10 = v 20 = 0, then make sure that x 20 – x 10 ≠ x 0.
  3. Find timestep of integration, Δt, that allows you to correctly reproduce the dynamics of the system. Provide one plot of the total energy of the system for incorrect choice of timestep and compare it with plots (from #5) for the correct choice of timestep.
  4. Make plots of the particle coordinates and velocities versus time for the simulations.
  5. Make plots of the kinetic, potential, and total energies versus time for the simulations.
  6. How do the vibrational frequency of the pair of particles and the maximum timestep that you can use depend on masses of the particles? Stiffness of the spring?
  7. Calculate the vibrational frequency for one of the set of the parameters analytically and compare with the results of your simulations (optional for undergraduates).