Simulations: Difference between revisions

From csml-wiki.northwestern.edu
Jump to navigation Jump to search
(Create: log file and screen output)
 
(14 intermediate revisions by 4 users not shown)
Line 5: Line 5:
== Molecular dynamics simulations ==
== Molecular dynamics simulations ==


For many projects, the CSML uses [http://lammps.sandia.gov/ LAMMPS] for molecular dynamics, although (depending on the application) we also employ [http://www.ks.uiuc.edu/Research/namd/ NAMD] and [http://www.gromacs.org/ GROMACS].
===Special Usage Notes===

By default LAMMPS normalizes the temperature by an amount <math>n_\text{dof} - d</math>, where <math>n_\text{dof}</math> is the system's total number of degrees of freedom and <math>d</math> is the system's dimensionality. Subtracting <math>d</math> accounts for the center-of-mass motion of the system. This is incorrect if the system has a proper frame of reference, e.g., when using a Langevin thermostat in which all particles interact with a stationary background solvent. In this case it is necessary to ensure <math>n_\text{dof}</math> is used instead of <math>n_\text{dof} - d</math>. To do this, use the command [http://lammps.sandia.gov/doc/compute_modify.html compute_modify] as follows
For educational purposes, Moldy is strongly recommended, not in the least because it offers an excellent [http://ariadne.ms.northwestern.edu/Moldy/moldy-manual.pdf manual]. For class purposes, we maintain a separate list of [http://ariadne.ms.northwestern.edu/Moldy/moldy_homework.html executables] for various operating systems.

Many questions regarding LAMMPS can be resolved by consulting the [http://lammps.sandia.gov/doc/Manual.html manual], but we address some common problems below.

===LAMMPS Special Usage Notes===

====Temperature Normalization====

By default LAMMPS normalizes the temperature by an amount ''n''<sub>dof</sub> - ''d'', where ''n''<sub>dof</sub>
is the system's total number of degrees of freedom and ''d'' its dimensionality. Subtracting ''d'' accounts for the center-of-mass motion of the system. This leads to an incorrect reported value if the system has a proper frame of reference, e.g., when using a [http://lammps.sandia.gov/doc/fix_langevin.html Langevin thermostat] in which all particles interact with a stationary background solvent. In this case it is necessary to ensure ''n''<sub>dof</sub> is used instead of ''n''<sub>dof</sub> - ''d''. To do this, use [http://lammps.sandia.gov/doc/compute_modify.html compute_modify] as follows


<pre>
<pre>
Line 12: Line 22:
compute_modify myTemp extra 0
compute_modify myTemp extra 0
thermo_modify temp myTemp
thermo_modify temp myTemp
</pre>

As a note, the above only affects the reported temperature. The dynamics are computed correctly regardless.

====Compute RDF using 'rerun' command====

The 'rerun' command in LAMMPS performs a post-processing simulation by reading the atom information line-by-line from the dump file(s) created from a previous simulation. The command syntax is as follows:
<pre> rerun file1 file2 ... keyword args ... </pre>
A detailed description of the syntax can be found on the [http://lammps.sandia.gov/doc/rerun.html LAMMPS website].

Besides the fact that the atoms' positions (and possibly velocities, etc.) are pre-determined from the dump file(s), we use the rerun command as if we are running a normal simulation (with some differences and limitations, explained below). When the rerun command is called, it invokes the [http://lammps.sandia.gov/doc/read_dump.html read_dump] command to read in lines from the dumpfile(s) line-by-line, each time invoking the [http://lammps.sandia.gov/doc/run.html run] command to output computed energy, forces, and any thermo output or diagnostic info the user has defined. Thus, in the input file for this pseudo simulation, we must define a system, units, dimensions, box, etc, and these will typically be identical to the original simulation.

Commands from the original simulation that will not be included are ones such as dump commands and time integration fixes (e.g. fix nve; rerun only looks at single moments in time and cannot perform time integration). Fixes that constrain forces on atoms (such as fix langevin) can be invoked in general, but it does not make sense to do this for computing the RDF (even though the langevin thermostat may be employed in the original simulation).

As an example, let us consider computing the RDF for a typical Lennard-Jones fluid past the interaction cutoff, and let us assume that we have already generated a dumpfile containing information on the atom positions over some set of timesteps. Then we will run a second simulation that reads in the particle positions from the dumpfile(s) over some subset of the original recorded timesteps ([http://lammps.sandia.gov/doc/rerun.html see arguments for the rerun command]), and will compute and output the RDF with the following commands:
<pre>
compute rdfID groupID rdf N #computes rdf with N bins
fix fixID groupID ave/time Nevery Nrepeat Nfreq c_[rdfID] file rdf.dat mode vector # see note below
rerun dump.dat dump x y z # 'dump.dat' is the dumpfile to be read
</pre>
<i>
Notes:
* Since the [http://lammps.sandia.gov/doc/compute_rdf.html compute rdf] command will only compute the RDF up to the interaction cutoff distance, we must change this parameter in the [http://lammps.sandia.gov/doc/pair_style.html pair_style] and [http://lammps.sandia.gov/doc/pair_coeff.html pair_coeff] commands so that we can obtain the RDF over the desired domain (i.e. if we want to compute the RDF up to a cutoff of 4.0, we would set the 'cutoff' arguments in those commands to 4.0).
* While the rerun command creates a set of atoms at every snapshot of the dumpfile that it reads, the compute rdf command expects a set of atoms to be present at the start of the rerun simulation (remember, the compute command comes before the rerun command) and will produce an error if no atoms are present. To avoid this, one can use the [http://lammps.sandia.gov/doc/create_atoms.html create atoms] command (or read in the data file via the [http://lammps.sandia.gov/doc/read_data.html read data] command) used for creating atoms in the original simulation at the beginning of the rerun.
* When using rerun for 2D simulations, set dimension to 2 in the input file. For the rerun command, only read in two coordinates from dump file, for example "rerun dump.dat dump x y".
</i>

====Log file and screen output====
By default, LAMMPS will output basic information about your simulation (such as thermo output, neighbor list statistics, system initialization details, etc.) to a logfile and to the screen. In certain circumstances (e.g., when a simulation is restarted or the run command issued multiple times) the excess information can create unnecessary bulk in log files and screen output. The following commands (used separately or together) may be supplied on the command line when starting LAMMPS to suspend all output to the log file and/or screen:

<pre>
-log none -screen none
</pre>
</pre>



Latest revision as of 17:26, 26 April 2016

Introduction

Assorted topics relevant to programming particle-based simulation codes and to using these codes for the modeling of a wide range of systems, notably complex fluids.

Molecular dynamics simulations

For many projects, the CSML uses LAMMPS for molecular dynamics, although (depending on the application) we also employ NAMD and GROMACS.

For educational purposes, Moldy is strongly recommended, not in the least because it offers an excellent manual. For class purposes, we maintain a separate list of executables for various operating systems.

Many questions regarding LAMMPS can be resolved by consulting the manual, but we address some common problems below.

LAMMPS Special Usage Notes

Temperature Normalization

By default LAMMPS normalizes the temperature by an amount ndof - d, where ndof is the system's total number of degrees of freedom and d its dimensionality. Subtracting d accounts for the center-of-mass motion of the system. This leads to an incorrect reported value if the system has a proper frame of reference, e.g., when using a Langevin thermostat in which all particles interact with a stationary background solvent. In this case it is necessary to ensure ndof is used instead of ndof - d. To do this, use compute_modify as follows

compute myTemp all temp
compute_modify myTemp extra 0
thermo_modify temp myTemp

As a note, the above only affects the reported temperature. The dynamics are computed correctly regardless.

Compute RDF using 'rerun' command

The 'rerun' command in LAMMPS performs a post-processing simulation by reading the atom information line-by-line from the dump file(s) created from a previous simulation. The command syntax is as follows:

 rerun file1 file2 ... keyword args ... 

A detailed description of the syntax can be found on the LAMMPS website.

Besides the fact that the atoms' positions (and possibly velocities, etc.) are pre-determined from the dump file(s), we use the rerun command as if we are running a normal simulation (with some differences and limitations, explained below). When the rerun command is called, it invokes the read_dump command to read in lines from the dumpfile(s) line-by-line, each time invoking the run command to output computed energy, forces, and any thermo output or diagnostic info the user has defined. Thus, in the input file for this pseudo simulation, we must define a system, units, dimensions, box, etc, and these will typically be identical to the original simulation.

Commands from the original simulation that will not be included are ones such as dump commands and time integration fixes (e.g. fix nve; rerun only looks at single moments in time and cannot perform time integration). Fixes that constrain forces on atoms (such as fix langevin) can be invoked in general, but it does not make sense to do this for computing the RDF (even though the langevin thermostat may be employed in the original simulation).

As an example, let us consider computing the RDF for a typical Lennard-Jones fluid past the interaction cutoff, and let us assume that we have already generated a dumpfile containing information on the atom positions over some set of timesteps. Then we will run a second simulation that reads in the particle positions from the dumpfile(s) over some subset of the original recorded timesteps (see arguments for the rerun command), and will compute and output the RDF with the following commands:

compute    rdfID groupID rdf N #computes rdf with N bins
fix        fixID groupID ave/time Nevery Nrepeat Nfreq c_[rdfID] file rdf.dat mode vector # see note below
rerun      dump.dat dump x y z # 'dump.dat' is the dumpfile to be read 

Notes:

  • Since the compute rdf command will only compute the RDF up to the interaction cutoff distance, we must change this parameter in the pair_style and pair_coeff commands so that we can obtain the RDF over the desired domain (i.e. if we want to compute the RDF up to a cutoff of 4.0, we would set the 'cutoff' arguments in those commands to 4.0).
  • While the rerun command creates a set of atoms at every snapshot of the dumpfile that it reads, the compute rdf command expects a set of atoms to be present at the start of the rerun simulation (remember, the compute command comes before the rerun command) and will produce an error if no atoms are present. To avoid this, one can use the create atoms command (or read in the data file via the read data command) used for creating atoms in the original simulation at the beginning of the rerun.
  • When using rerun for 2D simulations, set dimension to 2 in the input file. For the rerun command, only read in two coordinates from dump file, for example "rerun dump.dat dump x y".

Log file and screen output

By default, LAMMPS will output basic information about your simulation (such as thermo output, neighbor list statistics, system initialization details, etc.) to a logfile and to the screen. In certain circumstances (e.g., when a simulation is restarted or the run command issued multiple times) the excess information can create unnecessary bulk in log files and screen output. The following commands (used separately or together) may be supplied on the command line when starting LAMMPS to suspend all output to the log file and/or screen:

-log none -screen none

Monte Carlo simulations