Team:BCCS-Bristol/BSim/Features/ODE solvers

From 2009.igem.org

(Difference between revisions)
(New page: {{:Team:BCCS-Bristol/Header}} =Notes on ODE Interfaces= Currently we can specify custom ODEs by creating a class that implements BSimOdeSingle or BSimOdeSystem. The custom classes can be...)
(Notes on ODE Interfaces)
Line 2: Line 2:
=Notes on ODE Interfaces=
=Notes on ODE Interfaces=
 +
 +
== GRNs ==
 +
 +
BSim 2008: "Each of the modelling approaches [GRNs and agent-based modelling] have been considered in separate contexts, mainly due to the differing aspects of the system they are concerned with. Now, having working models for each, it would be possible to bring these together with the aim of improving simulation accuracy and allowing for the internal cellular dynamics to be studied in an ever changing physical environment. Such a hybrid model may also help shed light on the critical aspects of project as a whole."
 +
 +
BSim 2009 provides a robust implementation of the second and fourth order Runge-Kutta methods for systems of ordinary differential equations. It is possible to easily specify systems of ODEs as objects within the simulation. These ODE systems can be "attached" to objects in the simulation if necessary and can be used to simulate any aspect of the environment to which they are coupled, depending on the user's requirements. An example would be attaching an ODE system to each bacterium and coupling these systems via an external chemical field. See the overview of our ongoing quorum-coupled repressilators simulation for an example application of this.
 +
 +
As a result of the modular nature of the solver implementation it would also be possible to implement stochastic ODEs, and delay differential equations in a similar manner. These features are likely to be implemented soon to assist with the modelling of more complex GRN systems across a population.
 +
 +
== Solvers ==
 +
 +
 +
Currently we can specify custom ODEs by creating a class that implements BSimOdeSingle or BSimOdeSystem.
Currently we can specify custom ODEs by creating a class that implements BSimOdeSingle or BSimOdeSystem.

Revision as of 00:17, 21 October 2009

BCCS-Bristol
iGEM 2009

Contents

Notes on ODE Interfaces

GRNs

BSim 2008: "Each of the modelling approaches [GRNs and agent-based modelling] have been considered in separate contexts, mainly due to the differing aspects of the system they are concerned with. Now, having working models for each, it would be possible to bring these together with the aim of improving simulation accuracy and allowing for the internal cellular dynamics to be studied in an ever changing physical environment. Such a hybrid model may also help shed light on the critical aspects of project as a whole."

BSim 2009 provides a robust implementation of the second and fourth order Runge-Kutta methods for systems of ordinary differential equations. It is possible to easily specify systems of ODEs as objects within the simulation. These ODE systems can be "attached" to objects in the simulation if necessary and can be used to simulate any aspect of the environment to which they are coupled, depending on the user's requirements. An example would be attaching an ODE system to each bacterium and coupling these systems via an external chemical field. See the overview of our ongoing quorum-coupled repressilators simulation for an example application of this.

As a result of the modular nature of the solver implementation it would also be possible to implement stochastic ODEs, and delay differential equations in a similar manner. These features are likely to be implemented soon to assist with the modelling of more complex GRN systems across a population.

Solvers

Currently we can specify custom ODEs by creating a class that implements BSimOdeSingle or BSimOdeSystem.

The custom classes can be passed directly to any solver, however the solvers are only single-step to make them more adaptable (and easier to integrate into BSim :) ) therefore implementing actual iteration along a time series is left up to the programmer.

BSimOdeSingle

This interface allows you to specify a single ODE. The interface requires two methods, one to define the derivatives and one to return the initial conditions for the initial value problem.

An Example ODE

To define the problem

(mathsy bits - eqn, ICs)

<math>\diff{y}{t} = t</math>

why doesn't this work :(

One would create a new class defining the ODE with the following code:

//Package, Imports etc here

// An example ODE
public class Linear implements BSimOdeSingle {
	public double derivative(double x, double y){
		dy = x;
		return dy;
	}

	public double getIC(){ return 0.0; }
}

The class Linear would then be passed to a solver along with current x (in this case x is in fact t) and y values.

BSimOdeSystem

With this interface it is possible to define a system of multiple (possibly coupled) ODEs. In a similar manner to BSimOdeSingle, it is necessary to specify the derivatives and the initial conditions, however they must now be in the form of arrays as there are multiple values to consider. There is also a third method which must be specified which returns the numebr of equations present in the system. The implementation of these methods is left up to the user.

An Example ODE System

As an example, we show here how one would define a simple (damped) harmonic oscillator. The original equation is as follows:

(maths - SHM 2nd order ODE)

This is a second order ODE and so must be simplified to a system of first order equations with the substitution

(maths - y1'=y2 , and the full system)

One can then specify the initial conditions

(maths - ICs)

The Java implementation of this system is illustrated in the following segment of code:

//Package, Imports etc here

// An example ODE system - Damped Simple Harmonic Motion
public class SHM implements BSimOdeSytem{
	private int numEq = 2;

        public int getNumEq(){return numEq ;}

	public double[] derivativeSystem(double x, double[] y){
		double[] dy = new double[numEq];
		dy[0] = y[1];
		dy[1] = -2*y[0] - 0.1*y[1];
		return dy;
	}
		
	public double[] getICs(){
		double[] y0 = new double[numEq];
		y0[0] = 0;
		y0[1] = 1;
		return y0;
	}
}

The class SHM can then be passed to the solver of choice.