Hi,
I’m currently using DifferentialEquations.jl to solve some ODEs arising in Chemical Reaction Networks, in particular the Linear Noise Approximation to the Chemical Langevin Equation.
In my example, the ODE involves a pair of 2-dimensional vectors (z, m), and a 2x2 matrix V, as follows
# dz/dt = \alpha(z)
# dm/dt = F(z) m
# dV/dt = V F(z)' + F(z) V + \beta(z) \beta(z)'
where (\alpha, \beta, F)
are defined below, and ’ denotes taking the transpose.
I wanted to ask about the syntax for ODEs which have ‘mixed form’ in this sense of containing both matrix and vector components, in case there are any relevant worked examples which I can look at, or if there are any extra details of which I should be wary.
To be concrete: given expressions for (\alpha, \beta, F)
as below, how should I best go about aggregating them, in order to represent and solve the above ODE jointly for (z, m , F)
My current code is as follows:
using DifferentialEquations
function parameterised_α_LNA!(dx, x, c, t)
dx[1] = c[1] * x[1] - c[2] * x[1] * x[2]
dx[2] = c[2] * x[1] * x[2] - c[3] * x[2]
end
function parameterised_β_LNA!(σx, x, c, t)
σx[1, 1] = c[1] * x[1] + c[2] * x[1] * x[2]
σx[1, 2] = -c[2] * x[1] * x[2]
σx[2, 1] = -c[2] * x[1] * x[2]
σx[2, 2] = c[2] * x[1] * x[2] + c[3] * x[2]
end
function parameterised_F_LNA!(jx, x, c, t)
jx[1, 1] = c[1] - c[2] * x[2]
jx[1, 2] = -c[2] * x[1]
jx[2, 1] = c[2] * x[2]
jx[2, 2] = c[2] * x[1] - c[3]
end
x0 = [70.0; 80,0]
m0 = [0.0; 0.0]
V0 = [0.0 0.0; 0.0 0.0]
tspan = (0.0, 50.0)
c = [ 1.0, 0.005, 0.6 ]