[R-sig-dyn-mod] deSolve::ode workaround for solutions with NaN
Setzer.Woodrow at epamail.epa.gov
Setzer.Woodrow at epamail.epa.gov
Mon Jun 28 20:51:06 CEST 2010
What would happen if you re-wrote the system in terms of d log(Q) / dt =
(1/Q) dQ / dt?
R. Woodrow Setzer, Ph. D.
National Center for Computational Toxicology
http://www.epa.gov/comptox
US Environmental Protection Agency
Mail Drop B205-01/US EPA/RTP, NC 27711
Ph: (919) 541-0128 Fax: (919) 541-1194
From: Maik Renner <maikrenner at googlemail.com>
To: r-sig-dynamic-models at r-project.org
Date: 06/28/2010 02:37 PM
Subject: [R-sig-dyn-mod] deSolve::ode workaround for solutions with NaN
Sent by: r-sig-dynamic-models-bounces at r-project.org
Dear List,
I have a question regarding unstable solutions using deSolve. Due to
my model equation I get NaN, when my state drops below zero.
Now, I wish to set the state to some default value, when this happens,
such that the simulation is continuing without NaNs.
However I could not figure out how to do that technically.
An if clause in the Model equation did not help. And I also tried the
event / root example in the vignette, but it did not run, having some
problems with my forcing inputs.
I have a model with one simple differential equation and one state and
a forcing vector. Here is the model implementation:
KirchSimeq19 <- function(t, state, parameters, input1, input2) {
with(as.list(c(state, parameters)),{
P <- input1(t)
E <- input2(t)
dQ <- exp(c1 + c2 * log(Q) + c3 * (log(Q))^2) * ( (P - k_E * E) / Q -
1)
list(c(dQ))
}) # end with(as.list...
}
Any help is appreciated,
Maik
--
Maik Renner, Dipl. Hydrologist
TU Dresden Germany
Tel.: +49 351 463-31341
http://tu-dresden.de/meteorologie
_______________________________________________
R-sig-dynamic-models mailing list
R-sig-dynamic-models at r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-dynamic-models
More information about the R-sig-dynamic-models
mailing list