LAMMPS Nanowire Deformation

From EVOCD
Revision as of 22:13, 2 December 2013 by Mtschopp (Talk | contribs)

Jump to: navigation, search

Contents

Questions / Comments

Please contact me if you have any questions or comments about this tutorial. I'll try to add questions and answers to the bottom of the tutorial pages as they arise.

Email: Mark Tschopp, mark.tschopp@gatech.edu

Abstract

Figure 1. The Magnesium Single Crystal Nanowire; HCP atoms.

This is a tutorial to deform a nanowire. For this tutorial, We have a Magnesium single crystal nanowire which is deformed after Symmetry Calculation, Energy and Pressure Equilibration.

Author(s): Suman Kandel, Mark A. Tschopp

Corresponding Author: Mark Tschopp

Methodology

The following input script shows how to generate a periodic nanowire and then deform it at a prescribed strain rate. Files are dumped during the simulation in two different folder; equilibration dump files and deformed dump files. The dump files can then be easily viewed and post-processed for results.

Please go through first few LAMMPS tutorials before you do this tutorial.

LAMMPS Input file


# Deforming a Nanowire.
# Suman Kandel, Dr. Mark A. Tschopp, 2011.

# ------------------------ INITIALIZATION ----------------------------
units        metal
boundary     p p p

atom_style   atomic


# ----------------------- ATOM DEFINITION ----------------------------
lattice hcp 3.20
region whole block 0  100 0 100 0 100 units box
create_box 1 whole
region LLF cylinder z  50 50 20  INF INF  units box
lattice hcp 3.20 orient x 1 0 0 orient y 0 1 0 orient z 0 0 1
create_atoms 1 region LLF
#delete_atoms overlap 0.5 all all

# ------------------------ FORCE FIELDS ------------------------------
pair_style   eam/fs
pair_coeff   * * Al-Mg.eam.fs Mg

# ------------------------- SETTINGS ---------------------------------
#### Computes Required
compute csym all centro/atom 12
compute 2 all stress/atom
compute mytemp all temp
compute 11 all reduce sum c_2[1]
compute 12 all reduce sum c_2[2]
compute 13 all reduce sum c_2[3]
compute 14 all reduce sum c_2[4]
compute 15 all reduce sum c_2[5]
compute 16 all reduce sum c_2[6]

neighbor     0.3 bin
neigh_modify delay 10
thermo 100
velocity all create 100.0 16723
thermo_style custom step temp etotal press pxx pyy pzz lx ly lz
shell mkdir dump
shell cd dump

#---------------Energy Equilibriation--------------------------
reset_timestep 0
fix 1 all nve
fix 2 all temp/rescale 10 100.0 100.0 1.0 0.5
dump 1 all custom 10000 dump.equilibrate.* id type x y z 

run 10000
unfix 1
unfix 2

#-----------------Pressure Equilibriation-----------------------
fix 1 all npt 100.0 100.0 10.0 aniso NULL NULL NULL NULL 0.0 0.0 10 drag 0.3
run 10000
unfix 1
undump 1
shell cd ..
shell mkdir deform
shell cd deform

#--------------------Storing Initial length---------------------
variable tmp equal "lz"
variable L0 equal ${tmp}
print "Initial Length, L0: ${L0}"
variable strain equal "v_srate/1e12"

#------------Deform------------------------------
reset_timestep 0
fix 1 all deform 1 z erate 0.0001 units box
fix 2 all nvt 100.0 100.0 10.0

variable strain equal "(lz - v_L0)/v_L0"
variable p1 equal "v_strain"
variable p2 equal "-pxx/10000"
variable p3 equal "-pyy/10000"
variable p4 equal "-pzz/10000"
variable p5 equal "lx"
variable p6 equal "ly"
variable p7 equal "lz"
variable p8 equal "temp"
variable p9 equal "pe"
variable p10 equal "ke"
variable p11 equal "-pxy/10000"
variable p13 equal "-pyz/10000"
variable p12 equal "-pxz/10000"
variable fm equal "(v_p2+v_p3+v_p4)/3" ##### Hydrostatic stress

variable fv equal "sqrt((v_p2-v_p3)^2+(v_p3-v_p4)^2+(v_p4-v_p2)^2+6*(v_p11^2+v_p12^2+v_p13^2)/2)" ######Von Mises Stress

variable t equal "v_fm/v_fv"
variable fd equal (((v_p2-v_fm)*(v_p3-v_fm)*(v_p4-v_fm))-v_p11^2*(v_p4-v_fm)-v_p12^2*(v_p3-v_fm)-v_p13^2*(v_p2-v_fm)+2*v_p11*v_p12*v_p13)####Deviatoric Von Mises stress

dump 2 all custom 10000 dump.defo.* id type x y z c_csym c_2[1] c_2[2] c_2[3] c_2[4] c_2[5] c_2[6]

fix def_print all print 100 "${p1} ${p2} ${p3} ${p4} ${p5} ${p6} ${p7} ${p8} ${p9} ${p10} ${p11} ${p12} ${p13} ${fm} ${fv} ${t} ${fd}" file mg001.defo.txt screen no
run 100000 

Understanding the Script

Here is the breakdown of the input script. Go here to get help with commands used in the script.

# Deforming a Nanowire.
# Suman Kandel, Mark A. Tschopp, 2011.

The "INITIALIZATION" section defines the style of units, the dimension (3-D here) and style of atoms.

# ------------------------ INITIALIZATION ----------------------------
units        metal
boundary     p p p

atom_style   atomic

We use 'lattice' command to produce an array of HCP atoms, typically of Magnesium. With some commands, we cut out a block and then nanowire from that array. If we have overlapping atoms, we can delete them.

# ----------------------- ATOM DEFINITION ----------------------------
lattice hcp 3.20
region whole block 0  100 0 100 0 100 units box
create_box 1 whole
region LLF cylinder z  50 50 20  INF INF  units box
lattice hcp 3.20 orient x 1 0 0 orient y 0 1 0 orient z 0 0 1
create_atoms 1 region LLF
#delete_atoms overlap 0.5 all all

We need to define the pair potentials for pairwise interactions. Simulation is run with the defined potential. Results vary according to potentials used. Here, we have finnis-sinclair potential used for Magnesium.

# ------------------------ FORCE FIELDS ------------------------------
pair_style   eam/fs
pair_coeff   * * Al-Mg.eam.fs Mg

After Creating a nanowire and defining the pair interactions, we have to set up the the way our simulation is going to run. This section computes various properties, then defines the variables such as thermo, velocity etc. which prescribes how a simulation runs and dumps results.

# ------------------------- SETTINGS ---------------------------------
#### Computes Required
compute csym all centro/atom 12
compute 2 all stress/atom
compute mytemp all temp
compute 11 all reduce sum c_2[1]
compute 12 all reduce sum c_2[2]
compute 13 all reduce sum c_2[3]
compute 14 all reduce sum c_2[4]
compute 15 all reduce sum c_2[5]
compute 16 all reduce sum c_2[6]

neighbor     0.3 bin
neigh_modify delay 10
thermo 100
velocity all create 100.0 16723
thermo_style custom step temp etotal press pxx pyy pzz lx ly lz
shell mkdir dump
shell cd dump

It's now time for simulation to actually run, which begins with the energy equilibration. The nanowire has to be equilibrated to constant energy before the deformation.

#---------------Energy Equilibriation--------------------------
reset_timestep 0
fix 1 all nve
fix 2 all temp/rescale 10 100.0 100.0 1.0 0.5
dump 1 all custom 5000 dump.equilibrate.* id type x y z 

run 10000
unfix 1
unfix 2

Nanowire also has to be equilibrated to constant pressure. Files are dumped after every 5000 timesteps.

#-----------------Pressure Equilibriation-----------------------
fix 1 all npt 100.0 100.0 10.0 aniso NULL NULL NULL NULL 0.0 0.0 10 drag 0.3
run 10000
unfix 1
undump 1
shell cd ..
shell mkdir deform
shell cd deform

During the equilibration process for Energy and Pressure, The original length of the nanowire changes by a small value, but we want our nanowire to have original measurements before we could run the deformation on it. So this section stores the initial length of the nanowire.Strain rate must be defined for the simulation to run.

#--------------------Storing Initial length---------------------
variable tmp equal "lz"
variable L0 equal ${tmp}
print "Initial Length, L0: ${L0}"
variable strain equal "v_srate/1e12"

This is last section of the simulation, but not the least. This is where deformation is actually carried out. Different variables such as strain rate, pressures, stress has been defined and then later printed in the log files. After each particular timestep of 10000, this section dumps files with the information about the nanowire at that timestep. These dumped files can be later visualized to see what happens to a nanowire during the deformation.

#------------Deform------------------------------
reset_timestep 0
fix 1 all deform 1 z erate 0.0001 units box
fix 2 all nvt 100.0 100.0 10.0

variable strain equal "(lz - v_L0)/v_L0"
variable p1 equal "v_strain"
variable p2 equal "-pxx/10000"
variable p3 equal "-pyy/10000"
variable p4 equal "-pzz/10000"
variable p5 equal "lx"
variable p6 equal "ly"
variable p7 equal "lz"
variable p8 equal "temp"
variable p9 equal "pe"
variable p10 equal "ke"
variable p11 equal "-pxy/10000"
variable p13 equal "-pyz/10000"
variable p12 equal "-pxz/10000"
variable fm equal "(v_p2+v_p3+v_p4)/3" ##### Hydrostatic stress

variable fv equal "sqrt((v_p2-v_p3)^2+(v_p3-v_p4)^2+(v_p4-v_p2)^2+6*(v_p11^2+v_p12^2+v_p13^2)/2)" ######Von Mises Stress

variable t equal "v_fm/v_fv"
variable fd equal (((v_p2-v_fm)*(v_p3-v_fm)*(v_p4-v_fm))-v_p11^2*(v_p4-v_fm)-v_p12^2*(v_p3-v_fm)-v_p13^2*(v_p2-v_fm)+2*v_p11*v_p12*v_p13)####Deviatoric Von Mises stress

dump 2 all custom 10000 dump.defo.* id type x y z c_csym c_2[1] c_2[2] c_2[3] c_2[4] c_2[5] c_2[6]

fix def_print all print 100 "${p1} ${p2} ${p3} ${p4} ${p5} ${p6} ${p7} ${p8} ${p9} ${p10} ${p11} ${p12} ${p13} ${fm} ${fv} ${t} ${fd}" file mg001.defo.txt screen no
run 100000

As the result of simulation, we end up getting dump, deform folders, log files and few other files which can be used for post-processing.

LAMMPS Logfile

Here is an example logfile that is obtained after running this script. The run time values has been cut short to few lines since it is a long simulation. The deleted lines are as similar to those you can see in this Log Script.


LAMMPS (25 Sep 2011)
#Deforming a Nanowire.

# ------------------------ INITIALIZATION ----------------------------
units        metal
boundary     p p p

atom_style   atomic


# ----------------------- ATOM DEFINITION ----------------------------
lattice hcp 3.20
Lattice spacing in x,y,z = 3.2 5.54256 5.22558
region whole block 0  100 0 100 0 100 units box
create_box 1 whole
Created orthogonal box = (0 0 0) to (100 100 100)
  1 by 1 by 1 processor grid
region LLF cylinder z  50 50 20  INF INF  units box
lattice hcp 3.20 orient x 1 0 0 orient y 0 1 0 orient z 0 0 1
Lattice spacing in x,y,z = 3.2 5.54256 5.22558
create_atoms 1 region LLF
Created 5538 atoms
#delete_atoms overlap 0.5 all all

# ------------------------ FORCE FIELDS ------------------------------
pair_style   eam/fs
pair_coeff   * * Al-Mg.eam.fs Mg

# ------------------------- SETTINGS ---------------------------------
#### Computes Required
compute csym all centro/atom 12
compute 2 all stress/atom
compute mytemp all temp
compute 11 all reduce sum c_2[1]
compute 12 all reduce sum c_2[2]
compute 13 all reduce sum c_2[3]
compute 14 all reduce sum c_2[4]
compute 15 all reduce sum c_2[5]
compute 16 all reduce sum c_2[6]

neighbor     0.3 bin
neigh_modify delay 10
thermo 100
velocity all create 100.0 16723
thermo_style custom step temp etotal press pxx pyy pzz lx ly lz
shell mkdir dump
shell cd dump

#---------------Energy Equilibriation--------------------------
reset_timestep 0
fix 1 all nve
fix 2 all temp/rescale 10 100.0 100.0 1.0 0.5
dump 1 all custom 10000 dump.equilibrate.* id type x y z 

run 10000
Memory usage per processor = 3.75083 Mbytes
Step Temp TotEng Press Pxx Pyy Pzz Lx Ly Lz 
       0          100    11762.587    34252.827   -564.98021    -542.3081    103865.77          100          100          100 
     100    296.68608   -7362.9381     1190.744    80.974988    42.704342    3448.5527          100          100          100 
     200    143.26937   -7856.7089    733.12318   -358.47245   -345.92823    2903.7702          100          100          100 
     300    110.42105   -7949.5204    556.36477   -397.36502   -376.80405    2443.2634          100          100          100 
     400    105.05788   -7973.2384    686.19033   -157.18656   -147.35776    2363.1153          100          100          100 
     500    101.93437   -7990.8446    749.00004    70.107163     63.20829    2113.6847          100          100          100 
     600    96.418127   -7989.2193    833.60094    260.25192     290.3415    1950.2094          100          100          100 
     700    99.156757    -7992.619    878.98411    366.23693    384.40412    1886.3113          100          100          100 
     800    103.45223   -7995.9571    810.33924    343.50697    319.99358    1767.5172          100          100          100 
     900     98.93141   -7995.0492    681.89691    215.31441     116.7975    1713.5788          100          100          100 
    1000    102.25279   -8003.6359    437.12292   -41.026689   -120.50561    1472.9011          100          100          100 
    1100     100.8158   -8010.3386    252.35937   -207.78018   -280.22979    1245.0881          100          100          100 
    1200    101.95899   -8022.9763    125.62407   -284.36119   -344.49891    1005.7323          100          100          100 
    1300    100.87891   -8031.9585    118.68891   -205.66102   -270.83314     832.5609          100          100          100 
    1400    100.10274   -8031.7417    262.10292    -61.19085   -20.508565    868.00818          100          100          100 
    1500    97.466234    -8029.589    350.34194    113.55211    104.28686    833.18686          100          100          100 
    1600    98.956551   -8020.7912    510.28564    262.94376    311.80314    956.11002          100          100          100 
    1700    99.075467   -8012.1187     574.9002    339.66732    375.30924     1009.724          100          100          100 

Questions and Answers?

Q1: Hey, I just wanted to point out something that may be an error in your code. Under the "Pressure Equilibration" section, the line "fix 1 all npt 100.0 100.0 10.0 aniso NULL NULL NULL NULL 0.0 0.0 10 drag 0.3" gave me an error saying that this particular fix command was incorrect in the log.lammps file. So I changed it to "fix 1 all npt temp 100.0 100.0 10.0 aniso 0.0 0.0 10 drag 0.3" and it seemed to work. Can you explain why you left out 'temp' and why you added NULL four times after aniso?

  • A1: Welcome to your first lesson in debugging. LAMMPS is really great about telling you which line it has a problem with. Once it tells you which line it is, go directly to the "correct" manual and make sure that the syntax is correct for the command. Unfortunately, sometimes the syntax changes with different versions of LAMMPS and it is not always forward compatible. So, while I could change this line in the input script herein (and change it again, when that syntax fails one day), I figured that I would leave it to introduce you to debugging and input script errors in LAMMPS, which you probably frequently run in to should you become a user.

Acknowledgments

S. Kandel and M.A. Tschopp would like to acknowledge funding provided under DOE.

Go Back

Personal tools
Namespaces

Variants
Actions
home
Materials
Material Models
Design
Resources
Projects
Education
Toolbox