git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@12095 f3b2605a-c512-4ea7-a41b-209d697bcdaa
This commit is contained in:
@ -9,6 +9,8 @@ These scripts are provided for illustration purposes. No guarantee is
|
|||||||
made that the systems are fully equilibrated or that the runs are long
|
made that the systems are fully equilibrated or that the runs are long
|
||||||
enough to generate good statistics and highly accurate results.
|
enough to generate good statistics and highly accurate results.
|
||||||
|
|
||||||
|
These scripts could easily be adapted to work with solids as well.
|
||||||
|
|
||||||
-------------
|
-------------
|
||||||
|
|
||||||
These are the 4 methods for computing thermal conductivity. The first
|
These are the 4 methods for computing thermal conductivity. The first
|
||||||
|
|||||||
33
examples/MC/README
Normal file
33
examples/MC/README
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
This directory has an input script that illustrates how to use LAMMPS
|
||||||
|
as an energy-evaluation engine in a Monte Carlo (MC) relaxation loop.
|
||||||
|
It is just an illustration of how to do this for a toy 2d problem, but
|
||||||
|
the script is fairly sophisticated in its use of variables, looping,
|
||||||
|
and an if-the-else statement which applies the Boltzmann factor to
|
||||||
|
accept or reject a trial atomic-displacement move.
|
||||||
|
|
||||||
|
The script sets up a perfect 2d hex lattice, then perturbs all
|
||||||
|
the atom positions to "disorder" the system. It then
|
||||||
|
loops in the following manner:
|
||||||
|
|
||||||
|
pick a random atom and displace it to a random new position
|
||||||
|
evaluate the change in energy of the system due to
|
||||||
|
the single-atom displacement
|
||||||
|
accept or reject the trial move
|
||||||
|
if accepted, continue to the next iteration
|
||||||
|
if rejected, restore the atom to its original position
|
||||||
|
before continuing to the next iteration
|
||||||
|
|
||||||
|
The 6 variables at the top of the input script can be adjusted
|
||||||
|
to play with various MC parameters.
|
||||||
|
|
||||||
|
When the script is finished, statistics about the MC procedure
|
||||||
|
are printed.
|
||||||
|
|
||||||
|
Dump file snapshots or images or a movie of the MC relaxation can be
|
||||||
|
produced by uncommenting the appropriate dump lines in the script.
|
||||||
|
|
||||||
|
At some point, we will add a Python script to the python/examples
|
||||||
|
directory that performs the same operation as this script. It will
|
||||||
|
invoke LAMMPS as a library and use Python to implement the MC
|
||||||
|
accept/reject logic more cleanly than the LAMMPS input script can do
|
||||||
|
it.
|
||||||
118
examples/MC/in.mc
Normal file
118
examples/MC/in.mc
Normal file
@ -0,0 +1,118 @@
|
|||||||
|
# Monte Carlo relaxation of perturbed 2d hex lattice
|
||||||
|
|
||||||
|
# set these parameters
|
||||||
|
# make sure neigh skin > 2*deltamove
|
||||||
|
|
||||||
|
variable iter loop 3000 # number of Monte Carlo moves
|
||||||
|
variable deltaperturb equal 0.2 # max size of initial perturbation per dim
|
||||||
|
variable deltamove equal 0.1 # max size of MC move in one dimension
|
||||||
|
variable density equal 1.0 # reduced LJ density of atoms on lattice
|
||||||
|
variable kT equal 0.05 # effective T in Boltzmann factor
|
||||||
|
variable seed equal 582783 # RNG seed
|
||||||
|
|
||||||
|
# problem setup
|
||||||
|
|
||||||
|
units lj
|
||||||
|
atom_style atomic
|
||||||
|
atom_modify map array sort 0 0.0
|
||||||
|
|
||||||
|
dimension 2
|
||||||
|
|
||||||
|
lattice hex ${density}
|
||||||
|
region box block 0 10 0 5 -0.5 0.5
|
||||||
|
|
||||||
|
create_box 1 box
|
||||||
|
create_atoms 1 box
|
||||||
|
mass 1 1.0
|
||||||
|
|
||||||
|
pair_style lj/cut 2.5
|
||||||
|
pair_coeff 1 1 1.0 1.0 2.5
|
||||||
|
pair_modify shift yes
|
||||||
|
|
||||||
|
neighbor 0.3 bin
|
||||||
|
neigh_modify delay 0 every 1 check yes
|
||||||
|
|
||||||
|
variable e equal pe
|
||||||
|
|
||||||
|
# run 0 to get minimum energy of system
|
||||||
|
|
||||||
|
run 0
|
||||||
|
variable emin equal $e
|
||||||
|
|
||||||
|
# disorder the system
|
||||||
|
# estart = initial energy
|
||||||
|
|
||||||
|
variable x atom x+v_deltaperturb*random(-1.0,1.0,${seed})
|
||||||
|
variable y atom y+v_deltaperturb*random(-1.0,1.0,${seed})
|
||||||
|
|
||||||
|
set group all x v_x
|
||||||
|
set group all y v_y
|
||||||
|
|
||||||
|
#dump 1 all atom 25 dump.mc
|
||||||
|
|
||||||
|
#dump 2 all image 25 image.*.jpg type type &
|
||||||
|
# zoom 1.6 adiam 1.0
|
||||||
|
#dump_modify 2 pad 5
|
||||||
|
|
||||||
|
#dump 3 all movie 25 movie.mpg type type &
|
||||||
|
# zoom 1.6 adiam 1.0
|
||||||
|
#dump_modify 3 pad 5
|
||||||
|
|
||||||
|
variable elast equal $e
|
||||||
|
thermo_style custom step v_emin v_elast pe
|
||||||
|
|
||||||
|
run 0
|
||||||
|
|
||||||
|
variable estart equal $e
|
||||||
|
variable elast equal $e
|
||||||
|
|
||||||
|
# loop over Monte Carlo moves
|
||||||
|
|
||||||
|
variable naccept equal 0
|
||||||
|
variable increment equal v_naccept+1
|
||||||
|
variable irandom equal floor(atoms*random(0.0,1.0,${seed})+1)
|
||||||
|
variable rn equal random(0.0,1.0,${seed})
|
||||||
|
variable boltzfactor equal "exp(atoms*(v_elast - v_e) / v_kT)"
|
||||||
|
variable xnew equal x[v_i]+v_deltamove*random(-1.0,1.0,${seed})
|
||||||
|
variable ynew equal y[v_i]+v_deltamove*random(-1.0,1.0,${seed})
|
||||||
|
variable xi equal x[v_i]
|
||||||
|
variable yi equal y[v_i]
|
||||||
|
|
||||||
|
label loop
|
||||||
|
|
||||||
|
variable i equal ${irandom}
|
||||||
|
|
||||||
|
variable x0 equal ${xi}
|
||||||
|
variable y0 equal ${yi}
|
||||||
|
|
||||||
|
set atom $i x ${xnew}
|
||||||
|
set atom $i y ${ynew}
|
||||||
|
|
||||||
|
run 1 pre no post no
|
||||||
|
|
||||||
|
if "$e <= ${elast}" then &
|
||||||
|
"variable elast equal $e" &
|
||||||
|
"variable naccept equal ${increment}" &
|
||||||
|
elif "${rn} <= ${boltzfactor}" &
|
||||||
|
"variable elast equal $e" &
|
||||||
|
"variable naccept equal ${increment}" &
|
||||||
|
else &
|
||||||
|
"set atom $i x ${x0}" &
|
||||||
|
"set atom $i y ${y0}"
|
||||||
|
|
||||||
|
next iter
|
||||||
|
jump SELF loop
|
||||||
|
|
||||||
|
# final energy and stats
|
||||||
|
|
||||||
|
variable nb equal nbuild
|
||||||
|
variable nbuild equal ${nb}
|
||||||
|
|
||||||
|
run 0
|
||||||
|
|
||||||
|
print "MC stats:"
|
||||||
|
print " starting energy = ${estart}"
|
||||||
|
print " final energy = $e"
|
||||||
|
print " minimum energy of perfect lattice = ${emin}"
|
||||||
|
print " accepted MC moves = ${naccept}"
|
||||||
|
print " neighbor list rebuilds = ${nbuild}"
|
||||||
106235
examples/MC/log.mc.6Jun14
Normal file
106235
examples/MC/log.mc.6Jun14
Normal file
File diff suppressed because it is too large
Load Diff
@ -132,12 +132,19 @@ The ELASTIC directory has an example script for computing elastic
|
|||||||
constants, using a zero temperature Si example. See the
|
constants, using a zero temperature Si example. See the
|
||||||
ELASTIC/in.elastic file for more info.
|
ELASTIC/in.elastic file for more info.
|
||||||
|
|
||||||
The KAPPA directory has an example scripts for computing the thermal
|
The KAPPA directory has example scripts for computing the thermal
|
||||||
conductivity (kappa) of a LJ liquid using 4 different methods. See
|
conductivity (kappa) of a LJ liquid using 4 different methods. See
|
||||||
the KAPPA/README file for more info.
|
the KAPPA/README file for more info.
|
||||||
|
|
||||||
|
The MC directory has an example script for using LAMMPS as an
|
||||||
|
energy-evaluation engine in a iterative Monte Carlo energy-relaxation
|
||||||
|
loop.
|
||||||
|
|
||||||
The USER directory contains subdirectories of user-provided example
|
The USER directory contains subdirectories of user-provided example
|
||||||
scripts for ser packages. See the README files in those directories
|
scripts for ser packages. See the README files in those directories
|
||||||
for more info. See the doc/Section_start.html file for more info
|
for more info. See the doc/Section_start.html file for more info
|
||||||
about installing and building user packages.
|
about installing and building user packages.
|
||||||
|
|
||||||
|
The VISCOSITY directory has example scripts for computing the
|
||||||
|
viscosity of a LJ liquid using 4 different methods. See the
|
||||||
|
VISCOSITY/README file for more info.
|
||||||
|
|||||||
Reference in New Issue
Block a user