I have created a SavingCallback
which prints out and saves the du
, here is my code:
prob = DDEProblem(model,u0,h,(0.0,120.0),p)
alg = MethodOfSteps(Tsit5())
saved_values = SavedValues(Float64,Array{Float64})
saving = SavingCallback((u,t,integrator)->begin
du = get_du(integrator)
println(du)
du
end,saved_values,saveat=0.0:1.0:120.0)
positive_domain = PositiveDomain(zeros(6))
sol = solve(prob,alg,reltol=1e-5,abstol=1e-5,verbose=false,
callback=CallbackSet(positive_domain,saving))
saved_values.saveval
However, I get only copies of the same array in saved_values.saveval
:
121-element Array{Array{Float64,N} where N,1}:
[-0.10130122735023514, -0.12747378214637814, -0.9356362119311361, -0.14477642620179343, -3.214542262837749e-9, 0.0]
[-0.10130122735023514, -0.12747378214637814, -0.9356362119311361, -0.14477642620179343, -3.214542262837749e-9, 0.0]
[-0.10130122735023514, -0.12747378214637814, -0.9356362119311361, -0.14477642620179343, -3.214542262837749e-9, 0.0]
[-0.10130122735023514, -0.12747378214637814, -0.9356362119311361, -0.14477642620179343, -3.214542262837749e-9, 0.0]
â‹®
whereas the values that are printed out are:
[-9.758880078641988, 9.73926587110036, 0.0, 0.0010190401331306772, 1.731440765537098e-11, 0.0]
[-9.2710620972309, 8.437221518401948, 0.0, 0.02908298475881324, 7.167640978098638e-10, 0.0]
[-9.001511975595097, 7.750094269936375, 0.0, 0.03564680683011713, 1.0608697222391056e-9, 0.0]
[-8.68452543732975, 6.971780891579974, 0.0, 0.03913534215472937, 1.4286156914998178e-9, 0.0]
[-8.313055858601432, 6.100969249011655, 0.0, 0.039895854945804096, 1.8100876888516305e-9, 0.0]
[-7.890979385401242, 5.166178043953941, 0.0, 0.038391043227802596, 2.180181419839846e-9, 0.0]
[-7.419848644971299, 4.192318009030844, 0.0, 0.03509693089910976, 2.5152511392120506e-9, 0.0]
Many thanks in advance for any input!