# NUFEB simulation with Cyanobacteria and E.Coli-Wild

units si                                   # using si units
atom_style      bacillus                      # using coccus atom style
atom_modify     map array sort 1000 1e-6  # map array: find atoms using indices
		                           # sort 1000 5.0e-6: sort every 1000
					   #   steps with 5.0e-6 binsize
boundary        pp pp ff                   # fixed boundaries in x and y
                                           #   fixed boundary in z
newton          on                        # forces between local and ghost
                                           #   atoms are computed in each
					   #   processor without communication
processors  * * *                     # processor grid

comm_modify     vel yes                    # communicate velocities for ghost
                                           # atoms
comm_modify     cutoff 1e-5                # guarantee that enough atoms are
                                           # communicated to correctly compute
					   # grid values

 variable reps loop ${Replicates}
 read_data atom_${n_cyanos}_${n_ecw}_${SucPct}_${Replicates}.in
 shell mkdir Run_${n_cyanos}_${n_ecw}_${SucPct}_${Replicates}
 shell cd Run_${n_cyanos}_${n_ecw}_${SucPct}_${Replicates}


 ${CYANOGroup}
 ${ECWGroup}

neighbor        1e-5 bin                # setting neighbour skin distance and
                                        #   style
neigh_modify    check yes               # rebuild neighbour list if any atom
                                        #   had moved more than half the skin
					#   distance

# select grid style
grid_style      nufeb/monod 5 light o2 suc co2 gco2 2e-6

# set substrates initial concentration
grid_modify     set light  ${light}
grid_modify     set o2     ${o2}
grid_modify     set suc    ${sucrose}
grid_modify     set co2    ${co2}
grid_modify     set gco2   ${gco2}

# define pair style
variable cutoff  equal 0
variable k_n        equal 1e-12
variable k_na       equal 0
variable c_n        equal 0
variable c_t        equal 0
variable mu         equal 1

pair_style bacillus ${c_n} ${c_t} ${mu} ${cutoff}
pair_coeff * * ${k_n} ${k_na}


# NVE integration with maximum distance limit
fix nve all nve/bacillus/limit 1e-9

# monod reaction fixes
# should consider using read_data's fix keyword
${CYANOMonod}
${ECWMonod}

# diffusion reaction fixes
fix diff_o2  all nufeb/diffusion_reaction o2  2.3e-09 nn nn nn
fix diff_suc all nufeb/diffusion_reaction suc 5.2e-10 nn nn nn
fix diff_co2 all nufeb/diffusion_reaction co2 1.9e-09 nn nn nn

# biological model fixes
${CYANODiv}
${ECWDiv}

# mechanical model fixes
fix vis all viscous 1e-12

variable mass equal "mass(all)"
${CYANOcount}
${ECWcount}

compute mycon all nufeb/ave_conc

##############Simulation exit condition##############
variable co2 equal c_mycon[4]
fix f_myhalt all halt 1 v_co2 <= 1e-19

# file output
${vtk_dump}


${image_dump}


${movie_dump}


${hdf_dump}


# thermo output
thermo_style custom step atoms v_mass ${v_ncyano} ${v_necw} c_mycon[*]
thermo 1
thermo_modify lost ignore

# issue run command
run_style nufeb diffdt 1e-4 difftol 1e-11 pairdt 1e-3 pairtol 1e-8 pairmax 1000 diffmax 1000000
timestep $ts
run $Timesteps
shell cd ..
clear
next reps
jump SELF
