# Nickel twist boundary
units           metal
atom_style      atomic

#processors     12 1 1 

boundary        p f p
#read_restart   Cu1200strestart.file.10000
read_data       run1200.data
#Divides the simulation box into 3 regions, top fixed region, bottom fixed region and region 1 (just like cfgsolver by Dick Hoagland)
region          middle block -45.060772  45.060772 -30.4 30.46  -6.53673 6.53673 units box
region          bot block -45.060772  45.060772 -46.609 -30.4 -6.53673 6.53673 units box
region          top block -45.060772  45.060772 30.46 47.6212 -6.53673 6.53673 units box
#Divides region 1 into 4 different regions in order to calculate stresses in the bulk
region          ls block -45.060772  45.060772 -30.5196 -20 -6.53673 6.53673 units box
region          us  block -45.060772  45.060772 20 30.4795 -6.53673 6.53673 units box
region          lss block -45.060772  45.060772 -20 -15 -6.53673 6.53673 units box
region          uss  block -45.060772  45.060772 15 20 -6.53673 6.53673 units box

#creates groups from regions
#combines the fixed regions into one group by using union
group           l region bot
group           r region top
group           lr union l r
#group for region 1
group           mid region middle
#groups the four regions for stress
group           upstr region us
group           lostr region ls
group           upstrs region uss
group           lostrs region lss

#reading in potential file in dynamo setfl format
pair_style      eam/alloy
pair_coeff      * * MishinCu.setfl Cu

#defining velocity and temperature for the middle region
velocity        mid create 1200.0 85675 dist gaussian
fix             1 mid nvt 1200.0 1200.0 0.1

#Applying strain to the file by applying velocity to top region
fix             bg r rigid group 1 r torque 1 off off off
fix             zfr r aveforce 0.000379651 0.0 0.0

#calculating stress tensor for each atom in region us and ls
compute         ust upstr stress/atom
compute         lst lostr stress/atom
compute         usts upstrs stress/atom
compute         lsts lostrs stress/atom

#summing up stress, need to divide output by the volume of the region (stress_xy)
compute         sut upstr reduce sum c_ust[4]
compute         slt lostr reduce sum c_lst[4]
compute         suts upstrs reduce sum c_usts[4]
compute         slts lostrs reduce sum c_lsts[4]
#Divide the stress above by Volume of the region
variable        s22u equal c_sut/(12394.19693)
variable        s22l equal c_slt/(12346.9511)
variable        s22us equal c_suts/(5891.002003)
variable        s22ls equal c_slts/(5891.002003)

#computes temperature,ke,pe for region 1
compute         tmp mid temp
compute         kem mid ke/atom
compute         pem mid pe/atom
#adding the per atom values for pe and ke
compute         kema mid reduce sum c_kem
compute         pema mid reduce sum c_pem
#getting total energy per atom in the middle region
variable        tema equal (c_kema+c_pema)

#compute pressure fore region 1, need to divide output for 3*volume of region1
compute         prm mid stress/atom #calculate stress per atom for region 1
compute         press mid reduce sum c_prm[1] c_prm[2] c_prm[3] #summing up the diagnol components for each atom
compute         pom mid reduce sum c_prm[2]
compute         pof mid reduce sum c_prm[1]
compute         pol mid reduce sum c_prm[3]
variable        tp equal (c_press[1]+c_press[2]+c_press[3])/(3*71634.58436)
variable        ft equal (c_pom)/(3*71634.58436)
variable        ot equal (c_pof)/(3*71634.58436)
variable        bt equal (c_pol)/(3*71634.58436)
#dumping files
                                
fix             chg all ave/atom 1 1000 1000 xu yu zu
dump            2 all custom 1000  Cu1200st_run1.* id f_chg[1] f_chg[2] f_chg[3] vx vy vz
#dumping forces in fixed regions
thermo          100
thermo_style    custom step c_tmp v_tp v_ot v_ft v_bt c_kema c_pema v_tema v_s22u v_s22l v_s22us v_s22ls

#thermo_modify  line multi flush yes
restart         10000 Cu1200strestart.file

timestep        0.001
run             10000
                                                                                                                                                                                                         1,1