AU-BCE-EE / ABM

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

Simplify element extraction #29

Open sashahafner opened 1 year ago

sashahafner commented 1 year ago

Things like this:

         xa_dead = pars$conc_init[['xa_dead']] * slurry_mass_init, 
         RFd = pars$conc_init[['RFd']] * slurry_mass_init,
         iNDF = pars$conc_init[['iNDF']] * slurry_mass_init,
         ash = pars$conc_init[['ash']] * slurry_mass_init,
         VSd = pars$conc_init[['VSd']] * slurry_mass_init,
         starch = pars$conc_init[['starch']] * slurry_mass_init,
         CP = pars$conc_init[['CP']] * slurry_mass_init,
         CF = pars$conc_init[['CF']] * slurry_mass_init,
         VFA = pars$conc_init[['VFA']] * slurry_mass_init, 
         urea = pars$conc_init[['urea']] * slurry_mass_init, 
         TAN = pars$conc_init[['TAN']] * slurry_mass_init, 
         sulfate = pars$conc_init[['sulfate']] * slurry_mass_init, 
         sulfide = pars$conc_init[['sulfide']] * slurry_mass_init, 
         VSd_A = pars$conc_init[['VSd_A']] * slurry_mass_init,
         VSnd_A = pars$conc_init[['VSnd_A']] * slurry_mass_init,

Can't we do it by using the whole pars$... list at once?

fdalby commented 2 months ago

hmm.. something like this?

results <- sapply(variables, function(var) pars$conc_init[[var]] * slurry_mass_init) list2env(as.list(results), envir = .GlobalEnv)

but this will give a problem in some of the carbon accounting code, will check how to solve..