# Correct way to declare and use vector parameters in ModelingToolkit and PDE

**URL:** https://discourse.julialang.org/t/correct-way-to-declare-and-use-vector-parameters-in-modelingtoolkit-and-pde/92714
**Category:** New to Julia
**Tags:** modelingtoolkit
**Created:** [January 9, 2023, 1:40pm UTC](https://discourse.julialang.org/t/correct-way-to-declare-and-use-vector-parameters-in-modelingtoolkit-and-pde/92714 "2023-01-09T13:40:50Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Philippe\_Peeters](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/philippe_peeters/32/45674_2.png) [@Philippe\_Peeters](https://discourse.julialang.org/u/Philippe_Peeters)
#### Post date: [January 9, 2023, 1:40pm UTC](https://discourse.julialang.org/t/correct-way-to-declare-and-use-vector-parameters-in-modelingtoolkit-and-pde/92714/1 "2023-01-09T13:40:50Z")

</div>

Hi,

I’m experimenting with PDE and the MethodOfLines.jl. I’m trying to figuring out how to correctly declare and use a parameter which is a float64 vector of variable size.

Here is very basic (and useless) code sample where the system is parametrised by a function fc which takes a vector as argument.

```julia
using DifferentialEquations, ModelingToolkit

@parameters α
@variables t X(t)

Dt = Differential(t)

function fc(t,α::Vector{Float64})
    y = 0.0
    for var in α
        y += var * sin(t)
    end
    return y
end
@register fc(t,α::Vector{Float64})

#α=[1.0,2.0]
eq = Dt(X) ~ fc(t,α) * X

@named sys= ODESystem(eq);

X0 = [X=>1.0]

p = [α => [1.0,2.0]];
tspan=(0.0,10.0)
prob=ODEProblem(sys,X0,tspan,p);

```

Howerver, it fails with the error

```julia
ERROR: MethodError: no method matching fc(::Num, ::Num)
Closest candidates are:
  fc(::Num, ::SymbolicUtils.Symbolic{<:Vector{Float64}}) at ~/.julia/packages/Symbolics/UrqtQ/src/register.jl:51
  fc(::Real, ::SymbolicUtils.Symbolic{<:Vector{Float64}}) at ~/.julia/packages/Symbolics/UrqtQ/src/register.jl:51
  fc(::Num, ::Vector{Float64}) at ~/.julia/packages/Symbolics/UrqtQ/src/register.jl:51
  
Stacktrace:
 [1] top-level scope
   @ ~/Documents/SISTest.jl:18

```

when defining eq.

I’m new to ModelingToolkit and Symbolics, I guess I’m not using the parameter \alpha correctly.  
Is there a correct and standard way to use vector parameters ?  
BTW, the example doesn’t make use of MethodOfLines.jl but it’s the final goal to solve PDE involving functions taking vectors as argument.

---

<div class="post-metadata">

### Author: ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)
#### Post date: [January 9, 2023, 2:07pm UTC](https://discourse.julialang.org/t/correct-way-to-declare-and-use-vector-parameters-in-modelingtoolkit-and-pde/92714/2 "2023-01-09T14:07:45Z")

</div>

you can’t right now.

---

<div class="post-metadata">

### Author: ![Qfl3x](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/qfl3x/32/16227_2.png) [@Qfl3x](https://discourse.julialang.org/u/Qfl3x)
#### Post date: [July 18, 2023, 11:00am UTC](https://discourse.julialang.org/t/correct-way-to-declare-and-use-vector-parameters-in-modelingtoolkit-and-pde/92714/3 "2023-07-18T11:00:26Z")

</div>

Sorry for pinging an old thread. Is there a still no way? Even if the Vector is of fixed length? Or do I need to cut into smaller parameters? I currently get the error:

```julia
ERROR: MethodError: no method matching hasmetadata(::Vector{Num}, ::Type{Symbolics.VariableDefaultValue})

```

---

<div class="post-metadata">

### Author: ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)
#### Post date: [July 21, 2023, 2:24pm UTC](https://discourse.julialang.org/t/correct-way-to-declare-and-use-vector-parameters-in-modelingtoolkit-and-pde/92714/4 "2023-07-21T14:24:52Z")

</div>

@xtalax this should be handled now right?
