13
$\begingroup$

I am writing a simple Lennard-Jones fluid simulation in LAMMPS.

So far, I have outputted the temperature, volume, density, total energy, enthalpy, pressure, and all of it seems to be believable every 500 steps. This leads me to believe that my simulation is doing the right physics.

thermo_style    custom step temp vol density etotal pe ke enthalpy press
thermo_modify   format float %14.6f #format in log file
thermo 500 

However, I wanted to evaluate the autocorrelation function for my simulation. Looking up the LAMMPS documentation I see the following command:

compute velacf all vacf

From my understanding, the deal with a vacf is that I need the entire simulation to be complete before I start computing it, since $$\psi(t_d) = \frac{1}{N_{part}}\sum_{i=1}^{N_{part}} \sum_{j=0}^{f-d} \mathbf{v}_i(t_j)\cdot\mathbf{v}_i(t_j+t_d)$$ where $N_{part}$ is the number of particles, and $t_f$ is the final time, and $t_i+t_j = t_{i+j}$ (equal time steps taken throughout simulation).

How do I make LAMMPS get me an output of VACF at each time, so I can use it for analysis and visualization?

$\endgroup$
1

2 Answers 2

8
$\begingroup$

You don't need to wait for the completed simulation to evaluate VACF. VACF is usually calculated by subdividing the entire trajectory into $N$ fragments, where $N=T/\tau$. $T$ is the total(current) length of the simulation and $\tau$ is the autocorrelation length which depends on the molecular features of the system under study. You can also choose an appropriate $\tau$ by comparing the convergence of the VACF via changing $\tau$.

The simplified relation is:

$$\text{VACF}=\frac{1}{N}\cdot\frac{\tau}{T}\sum_{i=1}^{N_{atom}}\sum_{n=1}^{T/\tau}\sum_{t=0}^{t=\tau}\langle \textbf{v}(t_0)\cdot \textbf{v}(t_0+t)\rangle$$

where $\tau$ is the autocorrelation length and $T$ denotes the total length of the trajectory.

That being said, there are a few utilities you can use to extract VACF for your simulation. MDAnaylsis is a swiss-army knife for molecular dynamics and can be easily used for extracting and analysing many features for MD, including VACF.

$\endgroup$
1
  • 1
    $\begingroup$ @mykd, i am still unsure as to how to get outputs from the vacf command in LAMMPS though... $\endgroup$
    – megamence
    Aug 5, 2020 at 16:37
4
$\begingroup$

The command for calculating vacf is:

compute velacf all vacf

You can use fix ave/time command to export compute results into a file. From lammps doc, by compute vacf command "A vector of four quantities is calculated". So you can specify which columns you'd want to export by using c_velacf[x] x: 1,2,3,4, c: compute ID.

The syntax for fix ave/time is as follows:

fix ID group-ID ave/time Nevery Nrepeat Nfreq value1 value2 ... keyword args ...

More can be found in the doc pages but simply divide your Simulation timesteps (i.e. 10,000) by Nfreq (i.e. 100), and you'll have the results printed for 100 times. So using this should do it:

fix myvacf all ave/time 1 1 100 c_vac[1] c_vac[2] c_vac[3] c_vac[4] file vacf.dat

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .