Skip to content
Prev 509 / 696 Next

[R-sig-dyn-mod] Skinny square waves (John Harrold)

Can you arrange to code this using deSolve's "events"? You would have to code the model so that it is state variables that change abruptly.

Woody

-----Original Message-----
From: R-sig-dynamic-models [mailto:r-sig-dynamic-models-bounces at r-project.org] On Behalf Of Karline Soetaert
Sent: Thursday, March 09, 2017 2:22 AM
To: Special Interest Group for Dynamic Simulation Models in R <r-sig-dynamic-models at r-project.org>
Subject: Re: [R-sig-dyn-mod] Skinny square waves (John Harrold)

Hi John,

Usually in such cases, the problem is that the default solver is too efficient and thus takes too large timesteps. You could either try a less efficient solver that by default takes smaller time steps or restrict the maximal time step (argument hmax).  

Karline

-----Original Message-----
From: R-sig-dynamic-models [mailto:r-sig-dynamic-models-bounces at r-project.org] On Behalf Of John Harrold
Sent: donderdag 9 maart 2017 2:56
To: Special Interest Group for Dynamic Simulation Models in R <r-sig-dynamic-models at r-project.org>
Subject: Re: [R-sig-dyn-mod] Skinny square waves (John Harrold)

Howdy Steve,

I've run into this problem in the past in Matlab. I tested it in R at the time and I didn't seem to have the same problem. But it seems to be somewhat situational :).

I had a similar solution in Matlab to what you did. The R-equivalent of adding events at each of the switching times. So as a test I added events at each of the switching times. Basically I told ode to add 0 to the first state at each of those times, and that seemed to do it. These events should force the ode solver to stop and restart at each time point. Now I just need to automate this in my simulation routines.

I think it would be good if we could just provide the ode function a list of times and have it do this automatically. This way it would make it easier for me :). And it would also allow this to be optimized better than my poor coding skills will probably allow. Is this the appropriate list to make these suggestions?

John

On Wed, Mar 8, 2017 at 8:33 PM, Stephen Paul Ellner <spe2 at cornell.edu>
wrote:
--
-------------------------------------
John M. Harrold
john.m.harrold _at_gmail
-------------------------------------


_______________________________________________
R-sig-dynamic-models mailing list
R-sig-dynamic-models at r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-dynamic-models

_______________________________________________
R-sig-dynamic-models mailing list
R-sig-dynamic-models at r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-dynamic-models