units lj	

atom_style full 

boundary p p f

timestep 0.001

#read_data initpos.dat
#read_restart liquido.460000

region 1 block -10. 10. -10. 10. -3.0 3.0
region 2 block -10. 10. -10. 10. -5.5 -3.5
region 3 block -10. 10. -10. 10. 3.5 5.5
region 4 block -10. 10. -10. 10. -4.5 4.5

region 5 block -10. 10. -10. 10. -10.0 10.0
create_box 7 5

lattice fcc 0.3
create_atoms 1 region 1

lattice fcc 0.3 origin 0 0 0.5
create_atoms 2 region 1

lattice fcc 0.4
create_atoms 4 region 2

lattice fcc 0.4
create_atoms 3 region 3

mass      1    1.0
mass      2    1.0
mass      3    1.0
mass      4    1.0
mass      5    1.0
mass      6    0.0001
mass      7    1.0

group anions  type 1 
group cations type 2 
group bottom  type 5 6 
group top     type 3
#group top     type 3 1
group topplate type 3
group gancio type 7
group coda     type 8
group lube subtract all bottom top gancio 
group mobile type 1 2 5 6

velocity        all set 0.0 0.0 0.0 units box 
velocity        mobile create 0.05 87467
velocity        gancio set 0. 0. 0. units box

#pair_style hybrid lj/cut/coul/long 2.5 8.0 lj/cut/coul/longrep 2.5 8.0
pair_style coul/debye 1.4 3.0
pair_coeff * * 0.5
#pair_coeff 1 1 3.5
#pair_coeff 1 2 -3.5
#pair_coeff 2 2 3.5
pair_modify table 0

#bond_style harmonic
#bond_coeff 1 100.0 0.5

dielectric 2.0 

#kspace_style ewald 1.0e-7
#kspace_modify slab 3.0

neighbor	0.3 bin
neigh_modify	every 1 delay 0 check no one 15000 page 150000 

# here we define some useful variables 
variable viscosity equal 20.0
variable vload equal LOAD
variable svel  equal 0.02  # spring velocity
variable kd    equal 0.#20.0   # driving spring
variable yt0   equal 2.39   # initial position of gancio

set type 1 charge -1.0
set type 2 charge +1.0
# fix the charge on substrates
set type 3 charge -1.919573643
set type 5 charge -1.919573643

# top evolution
fix sopra top rigid group 1 top torque * off off off force * off on on 
variable ftx equal -mass(lube)*0.5/v_viscosity*(vcm(top,x)-vcm(lube,x))/count(top)
variable fty equal -mass(lube)*0.5/v_viscosity*(vcm(top,y)-vcm(lube,y))/count(top)
variable ftz equal -mass(lube)*0.5/v_viscosity*(vcm(top,z)-vcm(lube,z))/count(top)-v_vload/count(top)
fix load top addforce v_ftx v_fty v_ftz 
compute gancom gancio com 
variable yganc equal c_gancom[2]
variable dampx equal -(vcm(gancio,x)-vcm(top,x))*20./v_viscosity
variable dampy equal -(vcm(gancio,y)-vcm(top,y))*20./v_viscosity
variable dampz equal -(vcm(gancio,z)-vcm(top,z))*20./v_viscosity
fix dampa gancio addforce v_dampx v_dampy v_dampz
# force from spring
variable varspr equal v_kd*((v_yt0+v_svel*0.005*step)-v_yganc)/count(top)
fix fspring top addforce 0. v_varspr 0. 
# lubricant evolution
# balance dynamic xz 20 1.1 out tmp.balance
fix evoluzione mobile nve
compute corr mobile temp/com
fix termostato mobile langevin TEMPERATURE TEMPERATURE 0.02 699483
fix_modify termostato temp corr
fix ref gancio nve
variable fx equal 0.5/v_viscosity*1.0*f_sopra[1][4]
variable fy equal 0.5/v_viscosity*1.0*f_sopra[1][5]
variable fz equal 0.5/v_viscosity*1.0*f_sopra[1][6]
fix vcm mobile addforce v_fx v_fy v_fz


variable aggancio equal f_sopra[1][3]+5.0
fix muraglia mobile wall/reflect zlo -10.0 zhi v_aggancio units box
fix freeze bottom setforce 0.0 0.0 0.0

dump   05 all xyz    100 testLABEL.xyz
dump   10 all custom 500 velLABEL.dat id type x z vx vy 
thermo	 1
#thermo_style custom step c_corr press etotal v_fx v_fy v_fz 
#thermo_style custom step c_corr press etotal f_sopra[1][1] f_sopra[1][2] f_sopra[1][3] v_varspr v_yganc lx 
thermo_style multi
run 4000
