PHYS 3061 Introduction to Computer Simulation of Physical Systems Lab 2: Initialization with Boltzmann distribution
Molecular Dynamic System (Ideal gas) At temperature T, f(v) Although the KE satisfies the statistical quantity, the system is not at equilibrium! v
Molecular Dynamic System (Ideal gas) At temperature T, After many collisions f(v) f(v) Must satisfies Maxwell Boltzmann distribution v v
Task for today Initialize the system at equilibrium (Maxwell Boltzmann distribution)
Initializing the system at equilibrium Reasons Reduce computational time for reaching equilibrium Reduce accumulated computational error (you will meet this problem when Euler algorithm is implemented after lab 3)
Initialization with Maxwell Boltzmann distribution The speed Maxwell Boltzmann distribution, But before we continue, we first take some time do decide what unit should be used So that the system is suitable for molecular dynamic simulation
Appropriate units Choose the most convenient unit for MD simulation and visualization by VMD 1. Length : (10 ) 2. Time : ps (10 ) 3. Energy : ev All the constants should be written in unit of, ps and ev. Speed of light : c 3.0 10 3.010 Boltzmann constant : 8.617 10 / Declare them at the beginning of the program is helpful (with high precision) #define Kb 8.6173324e-5 //Boltzmann constant (in ev/k) #define PI 3.14159265 #define light_speed 2997924.58 // in angstrom/ps
Define useful constants Be careful and denote the units of the constants Boltzmann constants: 8.62 10-5 ev/k vs 1.38 10-23 J/K Always write units of your constants in the comment
How to handle mass of particle? In MD simulation, particles are often atoms. It is easy and straightforward to use atomic mass as the unit. Convert atomic mass to standard unit by 1 931.49 9.314910
Initialization with Maxwell Boltzmann distribution The speed with Maxwell Boltzmann distribution, Equivalently, the one-dimensional velocity satisfies Gaussian distribution, (For detail explanations, please take PHYS4031 Statistical Mechanics)
Convert uniform distribution to other distributions For Gaussian distribution, direct conversion (Box-Muller method) may be used, 1 2π 1 2 2 For general distribution, Monte Carlo method should be used (If you are interested in Monte Carlo method, please take PHYS4061 Computational Physics)
Convert uniform distribution to Gaussian distribution Box-Muller transform, Where ϑ1, ϑ2 are independent random numbers, 0 < ϑ1, ϑ2 < 1 x1, x2 are independent random numbers with standard normal distribution https://en.wikipedia.org/wiki/box Muller_transform#/media/File:Box- Muller_transform_visualisation.svg
Sample C/C++ Code for the Box Muller transform #include <math.h> #define PI 3.14159265359 using namespace std; double Box_Muller_Transform(double y1, double y2){ //y1 and y2 are independent random numbers, where 0 < y1,y2 <1 // Remember to exclude 0!!! Since log(0) will cause bugs double x1 = sqrt(-2*log(y1))*cos(2*pi*y2); return x1; } //For those who use java: Just use Random.nextGaussian()
Maxwell Boltzmann distribution After getting the one-dimensional velocity, which satisfies What is the deviation now? Obviously not 1! Simply, get the velocity by Hint: linear transformation to the correct scale
After initialization of the atoms Check your result! Use Excel to plot a histogram for the distribution in speed Print the mean and Max speed Implement a free expansion simulation to see - Is the initial position and the expansion spherically symmetric?
Excel Histogram Scatter plot Output the speeds & Put them in Frequency Column of data (in this case, E) Velocity (Å/fs) Column of interval (in this case, G)
Compare the result with analytic solution Check the peak value of speed Does it match with the analytic solution Probably, you need to check again the temperature of your MD system By checking mean KE
Free expansion Simulation Write a function to update the position of the particles by Δ Δ Out put your result in.xyz file
Appropriate system size Appropriate system size is critical to meet approximation and reach convergence 1. Too large far from reaching equilibrium 2. Too small violate ideal gas law 3. Too many particles heavy computational process 4. Too few particles statistical properties hidden Probably, you will only meet problem 4 in this LAB but all of them in the next LAB
Summary of today tasks
Checklist 1. Set proper units and constants for the physical properties of the particle 2. Set appropriate system size 3. All your particles should be Argon (Ar) atoms with atomic mass 39.948u. 4. Initialise the position of particles with randomly uniform distribution 5. Initialise the velocity of particles according to Maxwell-Boltzmann distribution for a given temperature of the system 6. Check the temperature (mean KE), centre of mass and max particle speed of the system 7. Compare the distribution and the peak value of speed, v p, with analytic solution in Excel 8. Create a free expansion simulation and output results in.xyz file
Submission Flow chart Code - Initialisation (check if it fulfills point 1-6) - Free expansion Excel file Table Chart Analysis (check if it fulfills point 6 7)