# dae.solve: Solve Differential-Algebraic Equations (DAE) In JuliaDiffEq/diffeqr: Solving Differential Equations (ODEs, SDEs, DDEs, DAEs)

## Description

Solves a DAE with f(du,u,p,t)=0 for u(0)=u0 over the tspan

## Usage

 ```1 2 3``` ```dae.solve(f, du0, u0, tspan, p = NULL, alg = "nothing", reltol = 0.001, abstol = 1e-06, maxiters = 1e+06, saveat = NULL, differential_vars = NULL) ```

## Arguments

 `f` the implicit ODE function. `du0` the initial derivative. Can be a number or (arbitrary dimension) array. `u0` the initial condition. Can be a number or (arbitrary dimension) array. `tspan` the timespan to solve over. Should be a list of two values: (initial time, end time). `p` the parameters. Defaults to no parameters. Can be a number or an array. `alg` the algorithm used to solve the differential equation. Defaults to an adaptive choice. Algorithm choices are done through a string which matches the DifferentialEquations.jl form. `reltol` the relative tolerance of the ODE solver. Defaults to 1e-3. `abstol` the absolute tolerance of the ODE solver. Defaults to 1e-6. `maxiters` the maximum number of iterations the adaptive solver is allowed to try before exiting. Defualt value is 1000000. `saveat` the time points to save values at. Should be an array of times. Defaults to automatic. `differential_vars` boolean array declaring which variables are differential. All falses correspond to purely algebraic variables.

## Value

sol. Has the sol\$t for the time points and sol\$u for the values.

## Examples

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26``` ``` ## diffeq_setup() is time-consuming and requires Julia+DifferentialEquations.jl diffeqr::diffeq_setup() f <- function (du,u,p,t) { resid1 = - 0.04*u + 1e4*u*u - du resid2 = + 0.04*u - 3e7*u^2 - 1e4*u*u - du resid3 = u + u + u - 1.0 c(resid1,resid2,resid3) } u0 = c(1.0, 0, 0) du0 = c(-0.04, 0.04, 0.0) tspan = list(0.0,100000.0) differential_vars = c(TRUE,TRUE,FALSE) sol = diffeqr::dae.solve(f,du0,u0,tspan,differential_vars=differential_vars) udf = as.data.frame(sol\$u) #plotly::plot_ly(udf, x = sol\$t, y = ~V1, type = 'scatter', mode = 'lines') %>% #plotly::add_trace(y = ~V2) %>% #plotly::add_trace(y = ~V3) f = JuliaCall::julia_eval("function f(out,du,u,p,t) out = - 0.04u + 1e4*u*u - du out = + 0.04u - 3e7*u^2 - 1e4*u*u - du out = u + u + u - 1.0 end") sol = diffeqr::dae.solve('f',du0,u0,tspan,differential_vars=differential_vars) ```

JuliaDiffEq/diffeqr documentation built on Nov. 24, 2019, 7:53 p.m.