# Best type for passing parameters to an ODE

**URL:** <https://discourse.julialang.org/t/best-type-for-passing-parameters-to-an-ode/118968>\
**Category:** Modelling & Simulations\
**Created:** [September 2, 2024, 11:47pm UTC](https://discourse.julialang.org/t/best-type-for-passing-parameters-to-an-ode/118968 "2024-09-02T23:47:40Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![julien-arino](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/julien-arino/32/211710_2.png) [@julien-arino](https://discourse.julialang.org/u/julien-arino)\
**Post date:** [September 2, 2024, 11:47pm UTC](https://discourse.julialang.org/t/best-type-for-passing-parameters-to-an-ode/118968/1 "2024-09-02T23:47:40Z")

</div>

New to julia, apologies if this is trivial. I am struggling to work out how to pass parameters to an ODE.

In short, I have two systems: one 7N dimensional (with N in the hundreds or thousands) and a 7-D one. I am not even at the point of running the 7N-D version, but in planning to do this: parameters of that one are both vectors with N entries and N\times N-matrices.

Every run of the ODE, I choose different values of the parameters and need to run the 7-D version first, picking the relevant parameters. So I cannot manually prepare a vector of parameters (and I most definitely cannot do in the 7N-D version).

What I have this far is a Dict() with a load of different fields (“keys”/“values” pairs?). I do something like

```julia
p_tmp = Dict()
for curr_param in ["eta", "xi", "d", "epsilon", "gamma", "beta"]
    p_tmp[curr_param] = p[curr_param][p["idx_positive_IC"]]
end

```

to pick up the relevant parameters for the 7-D version. Then set up the solver and call.

```julia
prob = ODEProblem(SLLLDUU_rhs, IC, (tspan[1], tspan[end]), p_tmp)
sol = solve(prob)

```

I get the error

```julia
ERROR: ArgumentError: This problem does not support symbolic maps with `remake`, i.e. it does not have a symbolic origin. Please use `remake`with the `p` keyword argument as a vector of values (paying attention toparameter order) or pass `interpret_symbolicmap = false` as a keyword argument

```

It is my understanding that I should be using remake, but I don’t understand the purpose of that function and I don’t like using things I don’t understand. Or I could transform to a NamedTuple using something like

```julia
p_tmp = NamedTuple([pair for pair in p_tmp])

```

But that fails (`ERROR: TypeError: in typeassert, expected Symbol, got a value of type String`). Or I could use ComponentArrays, but I am not sure how that would scale up to entries that are matrices. (Actually, not sure about that for NamedTuples either.)

Anyway, any recommendations on what to do? Thanks!!

---

<div class="post-metadata">

**Author:** ![DanielePessina](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/danielepessina/32/215157_2.png) [@DanielePessina](https://discourse.julialang.org/u/DanielePessina)\
**Post date:** [September 3, 2024, 6:19am UTC](https://discourse.julialang.org/t/best-type-for-passing-parameters-to-an-ode/118968/2 "2024-09-03T06:19:07Z")

</div>

[ComponentArrays.jl](https://github.com/jonniedie/ComponentArrays.jl) might be what you’re looking for: they appear as AbstractVectors but have keys in the same way structs do to be accessed with the dot . notation.

---

<div class="post-metadata">

**Author:** ![julien-arino](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/julien-arino/32/211710_2.png) [@julien-arino](https://discourse.julialang.org/u/julien-arino)\
**Post date:** [September 5, 2024, 6:15am UTC](https://discourse.julialang.org/t/best-type-for-passing-parameters-to-an-ode/118968/3 "2024-09-05T06:15:15Z")

</div>

Looks good indeed, thanks… I was trying to convert my Dict to that and failing miserably, so instead I load all my parameters in a ComponentArray from the start and I seem to be on the right track.

But now that raises another issue, which I will ask about in the general usage category because it is not specific to modelling.

---

<div class="post-metadata">

**Author:** ![rveltz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rveltz/32/2707_2.png) [@rveltz](https://discourse.julialang.org/u/rveltz)\
**Post date:** [September 5, 2024, 7:30am UTC](https://discourse.julialang.org/t/best-type-for-passing-parameters-to-an-ode/118968/4 "2024-09-05T07:30:48Z")

</div>

NamedTuples are also good if all you need is to unpack some parameters
