AU-BCE-EE / ABM

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

Data frame inputs through add_pars #33

Closed sashahafner closed 11 months ago

sashahafner commented 1 year ago

From @fdalby : passing a data.frame eg. variable conc fresh in the add_pars, is not working. Seems the problem is in line 147 "pe.pars <- as.numeric(pe.pars)" cannot convert object list.

sashahafner commented 1 year ago

@fdalby I don't think conc_fresh should go through that pe.pars bit. That's just for the "par.element" approach stuff, isn't it?

But I get an error trying to send conc_fresh data frame through add_pars:

Error in eval(substitute(expr), data, enclos = parent.frame()) :
  attempt to apply non-function

I get that with either approach though:

out <- abm(365, add_pars = list(conc_fresh = conc_fresh)) 

man_pars = list(conc_fresh = data.frame(time = c(0, 100, 101, 365), sulfide = c(0.01, 0.01, 0.1, 0.1), urea = 0, 
                                        sulfate = 0.2, TAN = c(0, 3, 5, 6), starch = 1, 
                                        VFA = c(2.83, 2.83, 10, 10), 
                                        xa_dead = 0, Cfat = 12, CP = 20, RFd = 29, iNDF = 10, VSd = 0, 
                                        VSd_A = 44.4, VSnd_A = 20, ash = 15), pH = 7, dens = 1000)

out <- abm(365, man_pars = man_pars)
fdalby commented 1 year ago

That is strange, how come it works in the Vignette (see some of the last examples) . I will check tomorrow.

sashahafner commented 1 year ago

Maybe I have an outdated package! Will check.

sashahafner commented 1 year ago

The error I saw was because I hadn't updated the package, oops. With latest version from master branch (v1.20.2, d61aadc78f3747df34ccddee18e9620350bf7e3b) both calls run without any errors. So I don't see any problems now. Let me know if you still see the pe.pars error and send the call that causes it if so. @fdalby

fdalby commented 1 year ago

That's good! I made some related changes earlier today that may have solved it then. I will check up on it tomorrow.

sashahafner commented 11 months ago

This is no longer a problem, right @fdalby ?

fdalby commented 11 months ago

@sashahafner I just checked and it works fine. Closing issue