# MTK bugging for spacing between variable and operation?

**URL:** <https://discourse.julialang.org/t/mtk-bugging-for-spacing-between-variable-and-operation/121278>\
**Category:** Modelling & Simulations\
**Created:** [October 14, 2024, 9:56am UTC](https://discourse.julialang.org/t/mtk-bugging-for-spacing-between-variable-and-operation/121278 "2024-10-14T09:56:59Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sushrut\_Deshpande](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sushrut_deshpande/32/52754_2.png) [@Sushrut\_Deshpande](https://discourse.julialang.org/u/Sushrut_Deshpande)\
**Post date:** [October 14, 2024, 9:56am UTC](https://discourse.julialang.org/t/mtk-bugging-for-spacing-between-variable-and-operation/121278/1 "2024-10-14T09:56:59Z")

</div>

Hello,  
I have a toy replication of a problem I have faced.

```julia
using ModelingToolkit, DifferentialEquations

@independent_variables t

@connector function myConnector(;name)
    vars = @variables begin 
        x(t), [input = true]
        y(t), [input = true]
    end
    ODESystem(Equation[], t, vars, [];name=name)
end

function Source(;name,x_start,y_start)
    @named port = myConnector()
    vars = @variables begin
        
    end
    para = @parameters begin
        
    end
    eqs = [
        port.x ~ x_start
        port.y ~ y_start
    ]
    compose(ODESystem(eqs, t, vars, para;name),port)
end

function MyFun(;name,Δx,Δy)
    @named inport = myConnector()
    @named outport = myConnector() 
    vars = @variables begin
        
    end
    para = @parameters begin
        
    end
    eqs = [
        outport.x ~ inport.x +Δx
        outport.y ~ inport.y +Δy
    ]
    compose(ODESystem(eqs, t, vars, para;name),inport,outport)
end

function Sink(;name)
    @named port = myConnector()
    vars = @variables begin
        x(t)
        y(t)
    end
    para = @parameters begin
        
    end
    eqs = [
        x ~ port.x
        y ~ port.y
    ]
    compose(ODESystem(eqs, t, vars, para;name),port)
end

@named src = Source(x_start = 4,y_start = 10)
@named fun = MyFun(Δx = 4,Δy = 1)
@named sink = Sink()

eqs = [
    connect(src.port,fun.inport)
    connect(fun.outport,sink.port)
]

@named sys = ODESystem(eqs, t, systems=[src,fun,sink])

```

The error I get is as follows:

```julia
ERROR: LoadError: MethodError: no method matching ODESystem(::Matrix{Any}, ::Num, ::Vector{Any}, ::Vector{Any}; name::Symbol)

```

The fix I found for this was having a space between the `+` and `Δx` and `Δy`. Meaning if I write the function as

```julia
function MyFun(;name,Δx,Δy)
    @named inport = myConnector()
    @named outport = myConnector() 
    vars = @variables begin
        
    end
    para = @parameters begin
        
    end
    eqs = [
        outport.x ~ inport.x + Δx
        outport.y ~ inport.y + Δy
    ]
    compose(ODESystem(eqs, t, vars, para;name),inport,outport)
end

```

Then the system works.  
I am not sure if this is a bug or not.

Thank you.

---

<div class="post-metadata">

**Author:** ![baggepinnen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/baggepinnen/32/693_2.png) [@baggepinnen](https://discourse.julialang.org/u/baggepinnen)\
**Post date:** [October 14, 2024, 10:01am UTC](https://discourse.julialang.org/t/mtk-bugging-for-spacing-between-variable-and-operation/121278/2 "2024-10-14T10:01:01Z")

</div>

This issue is not due to MTK, it’s due to how spaces work inside array-construction brackets:

```julia
julia> [1 +1]
1×2 Matrix{Int64}:
 1 1

julia> [1 + 1]
1-element Vector{Int64}:
 2

```

---

<div class="post-metadata">

**Author:** ![Sushrut\_Deshpande](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sushrut_deshpande/32/52754_2.png) [@Sushrut\_Deshpande](https://discourse.julialang.org/u/Sushrut_Deshpande)\
**Post date:** [October 14, 2024, 10:02am UTC](https://discourse.julialang.org/t/mtk-bugging-for-spacing-between-variable-and-operation/121278/3 "2024-10-14T10:02:31Z")

</div>

I see. This clarifies it.
