euba / BacArena

agent based modelling
GNU General Public License v3.0
26 stars 11 forks source link

add substances after X hours #121

Closed fairquestion closed 6 years ago

fairquestion commented 6 years ago

Dear all,

I was wondering if it is possible to add substances to the arena during the simulation. For example after 10 hours in a simulation of 20 hours. Do you have any idea about this?

Thanks in advance, fair

euba commented 6 years ago

Hi,

Yes, this should be possible. You just need to start the simulation, interupt it and take the last simulation arena object, add the additional concentration, and then simulate the modified arena object again like here:

data("Ec_core")
bac <- Bac(Ec_core)
arena <- Arena(n=20, m=20)
arena <- addOrg(arena,bac,amount=1)
arena <- addSubs(arena, smax=0.01, unit="mM")
sim <- simEnv(arena,time=10)

arena2 <- getArena(sim,10) #take the last simulation step
arena2 <- addSubs(arena2, smax=0.01, unit="mM", add=T)
sim2 <- simEnv(arena2,time=10)
plotCurves(sim)
plotCurves(sim2)

Cheers, Eugen

jotech commented 6 years ago

I think the solution proposed by @euba is the easiest solution! Another would be to define a custom diffusion problem with influx for the boundaries conditions.

fairquestion commented 6 years ago

Hi all!

Yes, it works!

Thanks a lot, Fair