# 2d Lennard-Jones melt and subsequent energy minimization,
# followed by box relaxation to a target stress state
#
units		lj
dimension	2
atom_style	atomic

lattice		sq2 0.8442
region		box block 0 20 0 20 -0.1 0.1
create_box	1 box
create_atoms	1 box
mass		1 1.0

velocity	all create 5.0 87287 loop geom

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

fix		1 all nve
fix		2 all enforce2d

#dump		1 all atom 500 dump.min

#dump		2 all image 500 image.*.jpg type type &
#		zoom 1.6 adiam 1.5
#dump_modify	2 pad 4

#dump		3 all movie 500 movie.mpg type type &
#		zoom 1.6 adiam 1.5
#dump_modify	3 pad 4

thermo		100

run		1000

# perform the box relaxation by progressively
# adding more degrees of freedom, for smoother
# convergence

neigh_modify	delay 0 every 1 check yes

velocity	all create 0.0 1
thermo		50

# atoms only

minimize	1.0e-6 0.001 1000 10000

# isotropic volume relaxation to hydrostatic target

fix             3 all box/relax iso 1.5 vmax 1.0e-3

variable        emin equal pe+f_3/atoms
thermo_style    custom step temp pe pxx pyy pxy f_3 v_emin

# anisotropic volume relaxation to hydrostatic target

minimize	0.0 10.0e0 10000 100000

fix             3 all box/relax aniso 1.5 vmax 1.0e-3

minimize	0.0 10.0 10000 100000

# anisotropic volume relaxation to non-hydrostatic target

fix             3 all box/relax x 1.0 y 2.0 vmax 1.0e-3

minimize	0.0 10.0 10000 100000

minimize	0.0 1.0 10000 100000

minimize	0.0 1.0e-2 10000 100000

# Final refinement uses nreset to eliminate stress offset

fix             3 all box/relax x 1.0 y 2.0 vmax 1.0e-3 nreset 100

minimize	0.0 1.0e-4 10000 100000

