---
  output:
  pdf_document: default
  html_document: default
---

library(BacArena)

diet = read.csv("S1_Table.csv", header = T)
load("S1_Data.Rdata")

arena <- Arena(n=100, m = 100, tstep = 1)

for(i in 1:length(sihumi)){
  model <- sihumi[[i]]
  bac <- Bac(model=model, growtype = "exponential", speed = 10)
  arena <- addOrg(arena, bac, amount = 10)
}

diet <- diet[which(diet$Exchange %in% arena@mediac),]
arena <- addSubs(arena, smax = diet$concentration.im.mM,
                 + diffspeed = diet$diffconstant, unit = "mM,
                 + mediac = as.character(diet$Exchange))
                 
sim <- simEnv(arena, time = 100, with_shadow = TRUE)
save(sim, file = "sim.rda")

arena2 <- getArena(sim, 34)
arena2 <- addSubs(arena, smax = diet$concentration.im.mM,
                 + diffspeed = diet$diffconstant, unit = "mM,
                 + mediac = as.character(diet$Exchange))
                 
sim <- simEnv(arena, time = 100, with_shadow = TRUE)
save(sim, file = "sim2.rda")                 
                 
arena3 <- getArena(sim, 61)
arena3 <- addSubs(arena3, smax = diet$concentration.im.mM,
                 + diffspeed = diet$diffconstant, unit = "mM,
                 + mediac = as.character(diet$Exchange))
                 
sim <- simEnv(arena3, time = 100, with_shadow = TRUE)
save(sim, file = "sim3.rda")                  
                 
arena4 <- getArena(sim, 120)
arena4 <- addSubs(arena4, smax = diet$concentration.im.mM,
                 + diffspeed = diet$diffconstant, unit = "mM,
                 + mediac = as.character(diet$Exchange))
                 
sim <- simEnv(arena4, time = 100, with_shadow = TRUE)
save(sim, file = "sim4.rda")                  
                 
                 