I updated to Julia 1.10 and was checking my past codes. Everything works fine, except for the EnsembleSummary function. I get the following error:
ERROR: type NamedTuple has no field u
The previous Julia version was 1.9.1. Here is the code:
using DifferentialEquations
using OrderedCollection, ComponentArrays
using QuasiMonteCarlo, Random
# Add ODE function file
include("pk_model.jl");
# Add parameter file
include("parameters.jl");
# Set intiaal conditions/Parameters
# Extravascular compartment EV has an initial bolus dose of 100 mg
Dose_mg = 100.0;
u0 = [Dose_mg, 0.0, 0.0];
#Define the simulation timespan
T = 30;
tspan = (0.0, T); #days
prob = ODEProblem(pk_model!, u0, tspan, collect(param));
#Ensemble Simulations
Random.seed!(1235)
sampler = SobolSample();
#define parameters to be explored and their ranges
params = OrderedDict(:CL=>[0.1, 10.0], :KA=>[0.01, 10.0]);
param_names = collect(keys(params));
param_values = collect(values(params));
# lower and upper bound for model parameters
lb = reduce(hcat,param_values)[1,:];
ub = reduce(hcat,param_values)[2,:];
Num = 1000;
vals = QuasiMonteCarlo.sample(Num, lb, ub, sampler);
CL_vals = vals[1,:];
KA_vals = vals[2,:];
params = OrderedDict(:CL=>CL_vals,
:KA=>KA_vals);
param_names = collect(keys(params));
param_values = reduce(hcat,collect(values(params)));
# create problem function to pass different values
function prob_func(prob,i,repeat)
p_pop = deepcopy(param);
p_pop[param_names] = param_values[i,:];
remake(prob, u0=u0, tspan = tspan, p=collect(p_pop));
end
# create an output function for things that need to be summarized
function output_func(sol,i)
((ev = sol[1,:], cp=sol[2,:], t=sol.t), false)
end
# create an ensemble problem to perform the simulations
t = collect(range(0, stop=20.0, length=200));
ensemble_prob = EnsembleProblem(prob, prob_func=prob_func, output_func=output_func);
ensemble_sol = solve(ensemble_prob, saveat=t, EnsembleSerial(), trajectories=Num);
summ = EnsembleSummary(ensemble_sol;quantiles=[0.05,0.95]);
Thanks!