Created
July 8, 2012 00:57
-
-
Save gufodotto/3068827 to your computer and use it in GitHub Desktop.
Lorentz_short
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(deSolve) # require this library | |
solveLorenz <- function(pars, times=seq(0,100,by=0.1)) { | |
derivs <- function(t, state, pars) { # returns rate of change | |
with(as.list(c(state, pars)), { | |
dX <- a*X + Y*Z | |
dY <- b * (Y-Z) | |
dZ <- -X*Y + c*Y - Z | |
return(list(c(dX, dY, dZ))) | |
} | |
) | |
} | |
state <- c(X = 1, Y = 1, Z = 1) | |
## ode solves the model by integration... | |
return(ode(y = state, times = times, func = derivs, parms = pars)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment