Dear fellow R users, I am currently interested in simulating a nonlinear ODE system which has an input function that is described by a finite state machine (FSM). Conversely, the state transitions of the FSM are depending on the state of the dynamical system. This is hence a hybrid, discrete-continuous problem. I have the impression that for a linear ODE system this should be possible using e.g. the 'radau' solver from the 'deSolve' package and using the solver's root-finding capability to detect discrete state change events. However, none of the solvers that support root-finding (see deSolve manual, page 34) appears to be capable of solving nonlinear ODEs. Am I missing something here, or is this currently not possible? If the latter is true, how hard would it be to implement root-finding capability for e.g. the 'daspk' solver? We might be willing to spend some effort on this problem. I am also open to suggestions for completely different approaches to this problem. Apologies in advance if this has been asked before; I could not find any previous questions on this matter but am unsure whether I searched in the right corners. Kind regards, Eike
[R-sig-dyn-mod] Hybrid simulation of nonlinear ode and discrete state machine
7 messages · Eike Petersen, Daniel Kaschek, John Harrold +1 more
Dear Eike, all solvers of deSolve are able to solve nonlinear ODE systems. Regards, Thomas
Dear Thomas, My apologies; I wasn't being clear here - what I meant was nonlinearity in the derivatives, i.e., something like y'^2 + y' = f(y, t). I guess what I should have asked for is capability to solve fully implicit ODEs. Kind regards, Eike -----Original Message----- From: R-sig-dynamic-models [mailto:r-sig-dynamic-models-bounces at r-project.org] On Behalf Of Thomas Petzoldt Sent: Freitag, 9. Dezember 2016 17:39 To: Special Interest Group for Dynamic Simulation Models in R <r-sig-dynamic-models at r-project.org> Cc: Jan Grasshoff <j.grasshoff at uni-luebeck.de> Subject: Re: [R-sig-dyn-mod] Hybrid simulation of nonlinear ode and discrete state machine Dear Eike, all solvers of deSolve are able to solve nonlinear ODE systems. Regards, Thomas _______________________________________________ R-sig-dynamic-models mailing list R-sig-dynamic-models at r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-dynamic-models
Hi Eike, you might have a look at the deSolve vignette,? https://cran.r-project.org/web/packages/deSolve/vignettes/deSolve.pdf Section 4 on Differential algebraic equations. The "daspk" solver seems to be the only solver implemented in deSolve which could perhaps handle such problems. I don't know much about DAEs and therefore don't know about the "index" of a DAE. Just give it a try. Best, Daniel
On Fri, 2016-12-09 at 20:44 +0000, Eike Petersen wrote:
Dear Thomas, My apologies; I wasn't being clear here - what I meant was nonlinearity in the derivatives, i.e., something like y'^2 + y' = f(y, t). I guess what I should have asked for is capability to solve fully implicit ODEs. Kind regards, Eike
You can try using Laplace transforms to convert your second order differential equation into two coupled first order ODEs: http://www.me.utexas.edu/~bryant/courses/me344/DownloadFiles/LectureNotes/Laplace+TransferFunctions.pdf https://www.youtube.com/watch?v=AC5o436J_0o On Fri, Dec 9, 2016 at 12:44 PM, Eike Petersen <eike.petersen at uni-luebeck.de
wrote:
Dear Thomas, My apologies; I wasn't being clear here - what I meant was nonlinearity in the derivatives, i.e., something like y'^2 + y' = f(y, t). I guess what I should have asked for is capability to solve fully implicit ODEs. Kind regards, Eike -----Original Message----- From: R-sig-dynamic-models [mailto:r-sig-dynamic-models- bounces at r-project.org] On Behalf Of Thomas Petzoldt Sent: Freitag, 9. Dezember 2016 17:39 To: Special Interest Group for Dynamic Simulation Models in R < r-sig-dynamic-models at r-project.org> Cc: Jan Grasshoff <j.grasshoff at uni-luebeck.de> Subject: Re: [R-sig-dyn-mod] Hybrid simulation of nonlinear ode and discrete state machine Dear Eike, all solvers of deSolve are able to solve nonlinear ODE systems. Regards, Thomas
_______________________________________________ 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
------------------------------------- John M. Harrold john.m.harrold _at_gmail ------------------------------------- [[alternative HTML version deleted]]
Thanks for clarification. The transformation of a second order derivative is briefly shown here: https://journal.r-project.org/archive/2010-2/RJournal_2010-2_Soetaert~et~al.pdf#3 and some more may be found in the book of Soetaert, Cash and Mazzia: http://www.springer.com/cn/book/9783642280696 Thomas
2 days later
Maybe I'm mistaken, but I think you misunderstood me: I'm really dealing with a nonlinear function of the first derivative of the state on my left-hand side. By y'^2 + y' I really mean the squared of the first derivative, plus the same derivative itself. I am *not* talking about a second derivative here. I stand to be corrected, but as far as I know, there are no general techniques to transform (fully implicit?) ODEs of this type into a system of linear first-order ODEs. Hence I am currently using the daspk solver for my problem, since it can deal with fully implicit ODEs. However, returning to my initial question, I'd like to use the output of a finite state machine (FSM) as the input function to my problem. This requires the efficient and reliable detection of state transitions, for which I wanted to use the 'root function' solver option. According to the deSolve documentation however, this option is currently not implemented for the daspk solver, which is why I wrote to this list, asking for my options. Hopefully this clarifies things a bit. Kind regards and thanks for your time, Eike
On 12/09/2016 11:59 PM, Thomas Petzoldt wrote:
Thanks for clarification. The transformation of a second order derivative is briefly shown here: https://journal.r-project.org/archive/2010-2/RJournal_2010-2_Soetaert~et~al.pdf#3 and some more may be found in the book of Soetaert, Cash and Mazzia: http://www.springer.com/cn/book/9783642280696 Thomas
_______________________________________________ R-sig-dynamic-models mailing list R-sig-dynamic-models at r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-dynamic-models