First off, this framework for multi-scale modeling is fantastic. A lot of the software I've tried does not have an adequate ODE solver suite for complex simulations.
I was writing a callback event that adds a cell to a population using the add_nodes! function and it added a cell with different values than what I gave it. My best guess for the cause is using the similar function in the diffeq.jl file. Here is a minimal working example of what I mean:
using DifferentialEquations, MultiScaleArrays
# Create Structures that define a Cell and Population
struct Cell{B} <: AbstractMultiScaleArrayLeaf{B}
values::Vector{B}
end
struct Population{T<:AbstractMultiScaleArray,B<:Number} <: AbstractMultiScaleArrayHead{B}
nodes::Vector{T}
values::Vector{B}
end_idxs::Vector{Int}
end
nCells=2
cellConstructor = [Cell([1.0, 2.0]) for i=1:nCells]
cellPop = construct(Population, deepcopy(cellConstructor))
function StateModel(dpop,pop,p,t) #This is arbitrary
for (cell,dcell) in LevelIter(1,pop,dpop)
dcell = 1.0
end
end
prob = ODEProblem(StateModel,cellPop,(0.0,1.0))
integrator = init(prob,Tsit5())
add_node!(integrator,Cell([5.0, 20.0]))
integrator.u.nodes[end].values .== [5.0, 20.0] #Both false
First off, this framework for multi-scale modeling is fantastic. A lot of the software I've tried does not have an adequate ODE solver suite for complex simulations.
I was writing a callback event that adds a cell to a population using the
add_nodes!
function and it added a cell with different values than what I gave it. My best guess for the cause is using thesimilar
function in the diffeq.jl file. Here is a minimal working example of what I mean: