User:Chria a/Sandbox

Assimulo is a Python / Cython based simulation package for simulation of explicit ordinary differential equations (ODEs) and implicit ordinary differential equations (DAEs). Assimulo provides solvers written in Python, but its main goal is to provide a common high-level interface to state-of-the-art codes, such as IDA and CVODE from the SUNDIALS suite and more experimental codes, such as GLIMDA.

Introduction
The aim of Assimulo is to provide a common high-level interface in Python for the large code base that exists for solving ordinary differential equations. In part the wide array of research codes available which explores new methods and also the well-known established codes.

Assimulo consists of mainly two parts, problem formulations and solvers. The idea is to separate information related to a problem, such as the right-hand-side of the problem, the jacobian of the problem but also for instance in the DAE case, which variables are the algebraic and which are the states. In the solver case, there are the tolerances which are parameters to control the solver and thus, should not be in the problem description.

Assimulo also supports solving of discontinuous systems by providing constructs in the problem formulations for specifying methods for handling or detection of different types of events, such as state-, step- and time events. For the state events to be supported to solver has to support detection of events functions (or root functions).

Problem formulations
Assimulo support problems stated on the following forms:


 * Implicit hybrid ODE:


 * $$F(t,y,\dot{y},sw)=0, \quad y(t_0)=y_0, \quad \dot{y}(t_0)=\dot{y}_0, \quad sw(t_0)=sw_0$$


 * here, $$F$$ is the residual, $$y$$ are the states and $$\dot{y}$$ are the state derivatives. The parameter $$sw$$ are optionally (depending on if the solver supports discontinuous system) a set of switches that determines which branch of the discontinuous system that are active and this parameter is not altered by the solver.


 * Explicit hybrid ODE:


 * $$\dot{y}=f(t,y,sw), \quad y(t_0)=y_0, \quad sw(t_0)=sw_0$$


 * here, $$f$$ is the right-hand-side and $$y$$ are the states. The parameter $$sw$$ are optionally (depending on if the solver supports discontinuous system) a set of switches that determines which branch of the discontinuous system that are active and this parameter is not altered by the solver.


 * Second order explicit ODE:


 * $$\ddot{p}=M(p)^{-1}f(t,p,\dot{p})$$


 * here, $$p$$ are the positions of a mechanical problem which implies that $$\dot{p}$$ are the velocities and $$\ddot{p}$$ are the accelerations of the system. $$M(p)$$ is the mass matrix.


 * Overdetermined implicit ODE:


 * $$\begin{align}\dot{p}&=v \\ M(p)\dot{v}&=f(t,p,v)-G^T(p)\lambda \\ 0&=g(p) \\ 0&=G(p)v\end{align}$$


 * here, $$p$$ are the positions of a mechanical problem as in the second order explicit ODE formulation. The additional parameters in this formulations are the lagrange multipliers $$\lambda$$, the constraints $$g(p)$$ and the constraint derivatives $$\frac{dg(p)}{dp}=G(p)v$$.

Solvers
The solvers interfaced to Assimulo consists of a variety of different solvers written in both Fortran and C. The methods available consists of different multistep methods (BDF and Adams method), explicit and implicit Runge-Kutta methods and Rosenbrock-Wanner methods.

The state-of-the-art codes IDA and CVODE from the SUNDIALS suite developed at the Lawrence Livermore National Laboratory (LLNL) are interfaced. They are both multistep methods with variable order and variable step size where CVODE solves problem stated as an ODE while IDA solves the more general problem stated as an DAE. Also from LLNL, an interface to the solver LSODAR from ODEPACK is provided.

For Runge-Kutta type methods, the code RADAU5 by Hairer is included in Assimulo. Additionally by Hairer are the codes DOPRI5 and RODAS.

Additionally the experimental code GLIMDA is interfaced.

Example
Below is an example of simulating the problem, $$\dot{y}=-y$$ with the initial conditions, $$t_0=0$$ and $$y(t_0)=4$$ with the solver CVODE. The final time is set to $$5$$.