# in this example the electron temperature on the left is ramped up in time 
# and held fixed on the right. the phonon temperature is free on the left 
# and fixed and consistent with the electron temperature on the right. 
# ATC restarting is used to eliminate the need to redo the equilibration phase.
# This benchmark tests restarting and the fractional step method with the TTM.
#echo both
# units
units		real
atom_style	atomic
variable restart equal 0 # NOTE add support for ifs when we update to new lammps
# create domain
#lattice	type reduced density rho* = 4*(sigma/a)^3, 
#   where N = 4 for fcc, 
#         s = 3.405 A (Wagner) 
#         a = 5.25 A (Ashcroft & Mermin, p. 70)
boundary        f p p
pair_style      lj/cut 13.5
#if "${restart}"
#read_data       atom_restart.data # NOTE reading in text atom data results in minor differences due to truncation
#else
read_data	temp.init
#endif
lattice         fcc 5.405 origin 0.25 0.25 0.25
region feRegion   block -14 14 -3 3 -3 3
region mdRegion   block -12 12 -3 3 -3 3
region mdInternal block -10 10 -3 3 -3 3
# NOTE: don't define ghosts if they are outside the feRegion
group		internal region mdInternal
group		ghost subtract all internal
# create atoms
#boundary	f p p
#create_box	1 mdRegion
#create_atoms	1 region mdRegion
#mass		1 39.95
#pair_style	lj/cut 13.5
#pair_coeff  	1 1 .238 3.405 13.5
#velocity  internal create 40 87287 mom yes loop geom
# timestep & neighboring
timestep	5.0
thermo		10
neighbor	5. bin
neigh_modify	every 10 delay 0 check no
#               ID  group atc PhysicsType ParameterFile
fix             AtC internal atc two_temperature  Ar_ttm.mat
fix_modify      AtC boundary ghost
#               ID  part keywords    nx ny nz region
fix_modify      AtC mesh create 14 1  1  feRegion f p p
fix_modify      AtC time_integration fractional_step
fix_modify      AtC internal_quadrature off
# fix initial temperatures
fix_modify 	AtC initial temperature      all 20
fix_modify 	AtC fix temperature          all 20
fix_modify 	AtC initial electron_temperature all 20
fix_modify 	AtC fix electron_temperature     all 20
# equilibrate MD field with rescale
fix_modify AtC extrinsic exchange off
fix_modify	AtC  control thermal rescale 10
thermo		100
run 		1000

# change thermostat 
fix_modify 	AtC extrinsic exchange on
fix_modify	AtC unfix          temperature all
fix_modify	AtC unfix electron_temperature all
fix_modify  	AtC mesh create_faceset bndy box -10 10 -10 10 -10 10
fix_modify  	AtC control thermal flux faceset bndy 
# add nodesets & boundary temperature controls
#               ID  mesh create_nodeset tag xmin xmax ymin ymax zmin zmax
# NOTE create_nodeset doesn't handle "inf"
fix_modify      AtC mesh create_nodeset lbc -14.1 -13.9  -INF INF -INF INF
fix_modify      AtC mesh create_nodeset rbc  13.9  14.1  -INF INF -INF INF
fix_modify      AtC  fix electron_temperature lbc 40.
fix_modify      AtC  fix electron_temperature rbc 20.
fix_modify      AtC  fix          temperature rbc 20. 
fix_modify      AtC  source electron_temperature all 9.50445e-11
# run transient
thermo          100
reset_timestep  0
run             2000
write_restart   atom_restart.bin
fix_modify      AtC write_restart atc_restart.bin

unfix		AtC
fix             AtC internal atc two_temperature  Ar_ttm.mat
fix_modify      AtC boundary ghost
#               ID  part keywords    nx ny nz region
fix_modify      AtC mesh create 14 1  1  feRegion f p p
fix_modify      AtC time_integration fractional_step
fix_modify      AtC internal_quadrature off
# fix initial temperatures
fix_modify      AtC initial temperature      all 20
fix_modify      AtC initial electron_temperature all 20
# change thermostat
fix_modify      AtC mesh create_faceset bndy box -10 10 -10 10 -10 10
fix_modify      AtC control thermal flux faceset bndy
# add nodesets & boundary temperature controls
#               ID  mesh create_nodeset tag xmin xmax ymin ymax zmin zmax
# NOTE create_nodeset doesn't handle "inf"
fix_modify      AtC mesh create_nodeset lbc -14.1 -13.9  -INF INF -INF INF
fix_modify      AtC mesh create_nodeset rbc  13.9  14.1  -INF INF -INF INF
fix_modify      AtC  fix electron_temperature lbc 40.
fix_modify      AtC  fix electron_temperature rbc 20.
fix_modify      AtC  fix          temperature rbc 20.
fix_modify      AtC  source electron_temperature all 9.50445e-11
# read in reference positions
fix_modify      AtC reset_atomic_reference_positions temp.init
fix_modify      AtC consistent_fe_initialization on
# output                   filename    frequency [text output]
fix_modify      AtC output restartFE 100       text
# ATC restart command
fix_modify     AtC read_restart atc_restart.bin

# run to steady state
thermo		100
reset_timestep  0
fix_modify	AtC reset_time
run 		2000
