Exploring LAMMPS Examples

Mino
September 04, 2024
software_and_toolslammps

A Deep Dive into Molecular Dynamics Simulations

LAMMPS Examples
LAMMPS Examples

LAMMPS (Large-scale Atomic/Molecular Massively Parallel Simulator) is an open-source molecular dynamics (MD) software that has become a staple in computational research across various scientific disciplines. Whether you're simulating the behavior of polymers, metals, biological molecules, or even granular media, LAMMPS provides a versatile platform with extensive documentation and community support.

This blog post reviews some of the most illustrative examples provided by LAMMPS, demonstrating the power of MD simulations and offering insights into their practical application. Additionally, we'll explore how you can leverage DiPhyx's computational platform to run LAMMPS simulations more efficiently.

LAMMPS Example 1: Molecular Dynamics of Water

One of the classic examples in LAMMPS is the simulation of water molecules using the TIP3P model.

This example illustrates the fundamentals of setting up a system with a realistic force field, where the interactions between atoms are modeled using a combination of Lennard-Jones potentials and Coulombic interactions.

Simulation Setup

  • Molecule Definition: Define the water molecule using the TIP3P model, which includes two hydrogen atoms and one oxygen atom.
  • Initial Configuration: Create a box of water molecules.
  • Potential: Use a combination of Lennard-Jones and Coulombic interactions to model the interactions between water molecules.

Input Script

bash
# Initialize simulation
units real
atom_style full
boundary p p p

# Create simulation box
region box block 0 20 0 20 0 20
create_box 2 box
create_atoms 1 random 512 12345 box

# Define molecule structure for water (TIP3P model)
molecule water H2O.molecule

# Pair and bond potentials for TIP3P water model
pair_style lj/cut/coul/long 10.0
pair_coeff 1 1 0.1521 3.1507
pair_coeff 2 2 0.0000 0.0000
pair_coeff 1 2 0.0000 0.0000

bond_style harmonic
bond_coeff 1 450 0.9572
angle_style harmonic
angle_coeff 1 55 104.52

# Setup kspace for long-range Coulombic interactions
kspace_style pppm 1e-4

# Define the group for water molecules
group water type 1 2

# Initial velocity distribution
velocity all create 300.0 12345

# Thermostat
fix 1 all nvt temp 300.0 300.0 100.0

# Run the simulation
timestep 1.0
thermo 100
run 5000

Explanation:

  • units real: The real units are used because they are appropriate for molecular dynamics with biomolecules or liquids.
  • pair_style lj/cut/coul/long 10.0: This command sets up the Lennard-Jones potential with a cutoff of 10 Å for short-range interactions and long-range Coulombic interactions handled by the PPPM method.
  • fix 1 all nvt temp 300.0 300.0 100.0: This thermostat maintains the temperature at 300 K using the NVT ensemble.

Post-Processing:

  • You can use visualization tools like VMD or OVITO to visualize the trajectory and observe the behavior of water molecules during the simulation.
  • Analyze the thermodynamic data outputted during the simulation to check for equilibrium.

This example is a great starting point for anyone new to LAMMPS, as it covers the basic principles of molecular dynamics and provides a template for more complex simulations.

LAMMPS Example 2: Polymer Chain Dynamics

The following LAMMPS example focuses on simulating a single polymer chain in a solvent, which is useful for understanding the properties of polymers such as radius of gyration and end-to-end distance.

Simulation Setup

  • Polymer Initialization: Create a linear polymer chain using LAMMPS's molecule command.
  • Potential: Use the FENE (Finitely Extensible Nonlinear Elastic) potential for bonded interactions and Lennard-Jones potentials for non-bonded interactions.

Input Script

bash
# Initialize simulation
units lj
atom_style bond
boundary p p p

# Create simulation box
region box block 0 50 0 50 0 50
create_box 1 box
create_atoms 1 random 100 12345 box

# Define polymer chain
molecule polymer chain.molecule

# Set interaction potentials
pair_style lj/cut 1.12
pair_coeff 1 1 1.0 1.0 2.5

bond_style fene
bond_coeff 1 30.0 1.5 1.0 1.0

# Create polymer chain
create_atoms 1 single 25 25 25 mol polymer 12345

# Set up velocity
velocity all create 1.0 12345

# Run the simulation
fix 1 all nve
dump 1 all xyz 100 polymer_chain.xyz
run 10000

Explanation:

  • units lj: This command sets up the simulation using Lennard-Jones reduced units, which are commonly used for polymer simulations.
  • bond_style fene: The FENE potential is used for modeling the bonds between monomers in the polymer chain.
  • fix 1 all nve: This command sets up the simulation in the NVE ensemble, conserving energy.

Post-Processing:

  • The dump command outputs the positions of atoms, which can be visualized using tools like OVITO.
  • You can analyze the end-to-end distance or radius of gyration of the polymer chain to study its conformational properties.

Polymer dynamics simulations are critical for material science research, helping predict the behavior of polymers in various environments.

LAMMPS Example 3: Nanoparticle Aggregation

In this LAMMPS example, LAMMPS is used to simulate the aggregation of nanoparticles in a solvent, an important process in nanotechnology and materials science.

Simulation Setup

  • Nanoparticle Initialization: Define the nanoparticles using a simple cubic lattice.
  • Potential: Use Lennard-Jones interactions to model the interactions between the particles.

Input Script

bash
# Initialize simulation
units lj
atom_style atomic
boundary p p p

# Create simulation box
region box block 0 20 0 20 0 20
create_box 2 box
lattice sc 1.0
create_atoms 1 box

# Define nanoparticle interactions
pair_style lj/cut 2.5
pair_coeff 1 1 1.0 1.0 2.5

# Group nanoparticles
group nanoparticles type 1

# Initial velocities
velocity all create 1.0 12345

# Run simulation
fix 1 all nve
fix 2 all langevin 1.0 1.0 100.0 12345
dump 1 all custom 100 nanoparticle_aggregation.xyz id type x y z
run 10000

Explanation:

  • lattice sc 1.0: This command sets up a simple cubic lattice for placing the nanoparticles.
  • pair_style lj/cut 2.5: The Lennard-Jones potential with a cutoff of 2.5 sigma is used for the interaction between particles.
  • fix 2 all langevin 1.0 1.0 100.0 12345: The Langevin thermostat is applied to maintain the temperature at 1.0 (LJ units).

Post-Processing:

  • The output nanoparticle_aggregation.xyz can be analyzed to observe how nanoparticles cluster over time.
  • Visualize the aggregation process using tools like VMD or OVITO to see the formation of clusters.

Note that for visualization, ParaView is also a good choice here if you want to visualize how nanoparticles come together to form clusters, especially when dealing with larger scales or complex geometries.

ParaView’s support for 3D visualization and ability to handle large datasets makes it a great choice for visualizing how nanoparticles aggregate over time. You can use techniques like glyphs or point cloud visualizations to represent each nanoparticle.

This example is particularly relevant for those working in nanotechnology, where understanding the assembly of nanoparticles is key to designing new materials.

LAMMPS Example 4: Dislocation Dynamics in Metals

This LAMMPS example focuses on simulating dislocation motion in a crystalline metal, which is crucial for understanding the mechanical properties of materials such as strength and ductility.

Simulation Setup

  • Initial Configuration: Create a simulation box containing a perfect crystalline lattice (e.g., FCC aluminum) and introduce a dislocation by modifying the atomic positions.
  • Potential: Use the Embedded Atom Method (EAM) potential, which is well-suited for simulating metallic systems. The following snippet shows how to define the potential in the input script:
bash
# Set up units and atom style
units metal
atom_style atomic

# Create box and atoms
lattice fcc 4.05
region box block 0 10 0 10 0 10
create_box 1 box
create_atoms 1 box

# Define EAM potential for aluminum
pair_style eam
pair_coeff * * Al_u3.eam

# Apply displacements to create dislocation
displace_atoms all move 0.1 0.0 0.0 units box

Boundary Conditions: Apply periodic boundary conditions in the directions perpendicular to the dislocation line and fixed boundaries along the dislocation line.

Running the Simulation: Perform energy minimization to relax the system and then run the dynamics to observe the motion of the dislocation under an applied shear stress. The following code snippet demonstrates applying a shear deformation:

bash
# Apply shear deformation
fix 1 all deform 1 xy erate 0.001 units box

# Run the dynamics
run 10000

Analysis

  • Dislocation Motion: Track the positions of atoms to observe the motion of the dislocation through the crystal.
  • Stress-Strain Relationship: Compute the stress as a function of strain to study how the material yields and deforms under the applied load.

ParaView would be an ideal choice for visualizing dislocation motion in a crystal lattice, as it can handle the large-scale deformation and atomic displacements seen in these simulations.

This example is highly relevant for materials scientists and engineers working on the mechanical properties of metals.

LAMMPS Example 5: Thermal Conductivity of a Solid Using the Green-Kubo Method

This example calculates the thermal conductivity of a solid, such as silicon, using the Green-Kubo method, which is based on the fluctuation-dissipation theorem.

Simulation Details

Setup: Define a crystal structure, such as diamond cubic for silicon, and use a potential like Tersoff, which is suitable for covalent systems.

bash
# Set up units and atom style
units metal
atom_style atomic

# Create diamond cubic lattice
lattice diamond 5.43
region box block 0 10 0 10 0 10
create_box 1 box
create_atoms 1 box

# Define Tersoff potential for silicon
pair_style tersoff
pair_coeff * * Si.tersoff Si

Thermostat: Equilibrate the system at the desired temperature using a Nosé-Hoover thermostat:

bash
# Equilibrate system
fix 1 all nvt temp 300.0 300.0 0.1
run 10000
unfix 1

Green-Kubo Calculation: Use the compute command to calculate the heat flux and the fix ave/correlate command to compute the autocorrelation of the heat flux. The integral of this correlation function gives the thermal conductivity.

bash
# Compute heat flux
compute myFlux all heat/flux ke/atom pe/atom stress/atom

# Autocorrelation of heat flux
fix 2 all ave/correlate 100 10 1000 c_myFlux[1] c_myFlux[2] c_myFlux[3] type auto file Kubo.dat ave running

# Integrate to find thermal conductivity
variable scale equal ${kcal2J}/${T}/${T}/${V}/1.60219e-19/3.0
variable k11 equal trap(f_2[3]) * ${scale}

Post-Processing: After running the simulation, post-process the output file Kubo.dat to compute the thermal conductivity from the integral of the autocorrelation function.

Analysis

Thermal Conductivity Value: Compare the computed thermal conductivity with experimental values or other simulations to validate the accuracy of your model.

This example is particularly useful for researchers in materials science, nanotechnology, and thermal management, where understanding the heat conduction properties of materials is critical.

Leveraging DiPhyx for Advanced Simulations

Running these examples on DiPhyx can significantly enhance your computational efficiency and data management:

  1. Automated Workflow Management: Use DiPhyx’s workflow management tools to automate the setup, execution, and post-processing of these LAMMPS simulations. You can create a pipeline that automatically scales resources based on the computational demand of each example.
  2. Containerized Environments: Deploy LAMMPS in a containerized environment using DiPhyx, ensuring consistency across different simulations and avoiding issues related to software dependencies.
  3. Real-Time Collaboration and Monitoring: DiPhyx’s collaboration tools allow multiple users to monitor and analyze the simulation results in real time, making it easier to iterate on simulation setups or troubleshoot issues as they arise.

By integrating LAMMPS with DiPhyx, you can run large-scale simulations more effectively, optimize resource usage, and ensure that your simulation data is well-documented and reproducible​​.

Conclusion

LAMMPS provides an extensive toolkit for molecular dynamics simulations, suitable for a broad range of scientific inquiries. By exploring these examples, users can gain a better understanding of how to model different physical systems.

When paired with the capabilities of DiPhyx, running LAMMPS simulations becomes even more powerful, allowing for efficient, scalable, and reproducible research. Whether you're a beginner or an experienced user, DiPhyx can help take your LAMMPS simulations to the next level.