ODE

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

ODE

hudeyfa jama
Hello All,


I'm struggling to solve this ODE using R,


vdpol <- function (h, v, t) (
          list(c (
            -0.1*v/(pi*(2*10*h-h^2)),
              (v = (-0.1*v/(pi*(2*10*h-h^2))^2) + 2*9.81*h))

                  ))
          library(deSolve)
          yini <- (c(h = 20, v=0))
          nonstiff <- ode(y = yini, func = vdpol,
                          times= seq(0, 30, by = 0.01),
                                     parms = 1)

It says that


 The number of derivatives returned by func() (4) must equal the length of the initial conditions vector (2)


I'm not sure how when i only have two derivates in the equation. I have little to no knowledge of R and I'm following guidance of the internet so any help is appreciated.


Kind Regards,


H



        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: ODE

David Winsemius
You cross-posted this to StackOverflow (where there is already a response.) Cross-posting is viewed with scorn on both StackOverflow and Rhelp.


> On Apr 12, 2018, at 1:36 PM, hudeyfa jama <[hidden email]> wrote:
>
> Hello All,
>
>
> I'm struggling to solve this ODE using R,
>
>
> vdpol <- function (h, v, t) (
>          list(c (
>            -0.1*v/(pi*(2*10*h-h^2)),
>              (v = (-0.1*v/(pi*(2*10*h-h^2))^2) + 2*9.81*h))
>
>                  ))
>          library(deSolve)
>          yini <- (c(h = 20, v=0))
>          nonstiff <- ode(y = yini, func = vdpol,
>                          times= seq(0, 30, by = 0.01),
>                                     parms = 1)
>
> It says that
>
>
> The number of derivatives returned by func() (4) must equal the length of the initial conditions vector (2)
>

> [[alternative HTML version deleted]]

Rhelp is very "old-school". We use plain-text. Do read the information in the links:

>
> ______________________________________________
> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

David Winsemius
Alameda, CA, USA

'Any technology distinguishable from magic is insufficiently advanced.'   -Gehm's Corollary to Clarke's Third Law

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.