AU-BCE-EE / ABM

R model for anaerobic microbial degradation of organic matter with multiple microbial groups
0 stars 2 forks source link

Silent problem with startup because of added time 0 #50

Closed sashahafner closed 1 month ago

sashahafner commented 1 month ago

I have been trying to figure out why methanogen concentrations at the start and end of a simulation did not match when using startup = 2. They should! This was with v2.0.8 (but looks the same in latest commit 0fcc737e5594b54d46abe38bba3f9eb1c39eb4ab).

I think the problem is here in abm.R, where a time 0 with 0 slurry mass is added:

https://github.com/AU-BCE-EE/ABM/blob/0fcc737e5594b54d46abe38bba3f9eb1c39eb4ab/R/abm.R#L245

That was kind of stupid of us! The abm_variable() will go from 0 slurry up to the quantity given at time = 1 or whatever the first value is. And any concentrations from the end of the last startup simulation are swamped by fresh concentrations.

sashahafner commented 1 month ago

Trying this instead, extrapolating with constant slurry mass:

      pars$slurry_mass <- rbind(c(0, pars$slurry_mass[1]), pars$slurry_mass)
sashahafner commented 1 month ago

Oh, this actually:

https://github.com/AU-BCE-EE/ABM/blob/f0832450074a5e1be170d2b66a3852a6354e9fb7/R/abm.R#L245

sashahafner commented 1 month ago

That fixes it. Did it in dev but will now merge with master.