# needs description
echo both

units		metal
atom_style	atomic

# create domain
#lattice	type reduced density rho* = 4*(sigma/a)^3, where N=4 for fcc, s = 3.405 A (Wagner) and a = 5.25 A (Ashcroft & Mermin, p. 70)
lattice         fcc 5.405 origin 0.25 0.25 0.25

# create atoms
region		simRegion block -12 12 -3 3 -3 3
region		atomRegion block -9 9 -3 3 -3 3
region		mdRegion block -8 8 -3 3 -3 3
boundary	f p p
create_box	2 simRegion 
create_atoms	1 region mdRegion
mass		* 39.95

# specify interal/ghost atoms
region		mdInternal block -6 6 -3 3 -3 3
region		leftghost block -8 -6 -3 3 -3 3
region		rightghost block 6 8 -3 3 -3 3
group		internal region mdInternal
group		Lghost region leftghost
group		Rghost region rightghost
group		ghosts union Lghost Rghost

# velocities have Vcm = 0
#velocity	internal create 40. 87287 mom yes loop geom

pair_style	lj/cut 13.5
#pair_coeff  	* * .238 3.405 13.5
pair_coeff      * * 0.010323166 3.405 13.5

neighbor	5. bin
neigh_modify	every 10 delay 0 check no

# define  layer
#               ID  group atc PhysicsType ParameterFile
fix             AtC internal   atc elastic     Ar_damped.mat

#               ID  part keywords    nx ny nz region
fix_modify      AtC mesh create 12  1  1  simRegion f p p

# initial conditions 
fix_modify  AtC  initial displacement x all 0.0
fix_modify  AtC  initial displacement y all 0.0
fix_modify  AtC  initial displacement z all 0.0
fix_modify  AtC  initial velocity x all 0.0
fix_modify  AtC  initial velocity y all 0.0
fix_modify  AtC  initial velocity z all 0.0


variable v equal 0.00000004e3
variable n equal 1000
variable dt equal 0.005
variable u equal $v*$n*${dt}

# set node sets and bcs
#           ID  mesh create_nodeset tag xmin xmax ymin ymax zmin zmax
fix_modify  AtC mesh create_nodeset lbc -12.1  -11.9   -INF INF  -INF INF
fix_modify  AtC mesh create_nodeset rbc  11.9   12.1   -INF INF  -INF INF
fix_modify  AtC fix velocity     x rbc $v
fix_modify  AtC fix displacement x lbc 0.
fix_modify  AtC fix velocity     x lbc 0.

# specify atom types
fix_modify  AtC boundary ghosts

#fix_modify      AtC  output follow_ex.fe 50
fix_modify  AtC internal_quadrature off
fix_modify  AtC control localized_lambda on
fix_modify  AtC control  momentum glc_velocity
#fix_modify  AtC filter type exponential
#fix_modify  AtC filter scale 1.0
#fix_modify  AtC filter on

# run to extension
timestep	0.005
thermo		100
thermo_style custom step cpu ke pe 
run 		0
variable pe0 equal pe
variable pe equal pe-${pe0}
thermo_style custom step cpu ke pe v_pe f_AtC[1] f_AtC[2] f_AtC[4] f_AtC[5]

run 		$n

fix_modify      AtC  output bar1d_dampedFE 500 text 
dump CONFIG all custom 500 bar1d_damped.dmp id type x y z vx vy vz

# change nodes to fixed
fix_modify      AtC  fix velocity x rbc 0.
fix_modify	AtC  fix displacement x rbc $u

# run to equilibrium
thermo		100
log  bar1d_damped.log
run 		2000 
fix_modify AtC material all cubic  # M damping
run 		2000
fix_modify AtC material all damped # K damping
run 		2000
#  ATC: CB stiffness: 7.56717 Einstein freq: 0.355649 from Ar_CauchyBorn.mat 
#  real to metal 1 kcal/mol = 0.04336 eV
variable kCal2eV equal 0.04336
variable fconv equal 1./0.000103643 # NOTE old routine was doing calculations in lammps units, not atc units, so this conversion is necessary for bmark to pass
#variable k equal 1.e-3 # 7.56717*${kCal2eV}  NOTE <<<
#variable k equal 0.75*0.355649e3*${kCal2eV}
variable k equal 0.5*39.95*${fconv} # NOTE it was set to above, should have been 2 above, but there was a bug so this value is here for bmark
#variable g equal 0.75*0.355649e3*${kCal2eV}
variable g equal 1.e-3*${fconv} # NOTE it should be above, but there was a bug so this value is here for bmark
variable m equal 2. #0.5*39.95
fix_modify AtC boundary_dynamics damped_harmonic $k $g $m
run 		2000
