# \`mul\_float: types of a and b must match\` error in ModelingToolkit

**URL:** https://discourse.julialang.org/t/mul-float-types-of-a-and-b-must-match-error-in-modelingtoolkit/77485
**Category:** Modelling & Simulations
**Tags:** question
**Created:** [March 7, 2022, 1:41am UTC](https://discourse.julialang.org/t/mul-float-types-of-a-and-b-must-match-error-in-modelingtoolkit/77485 "2022-03-07T01:41:14Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![anandpathak31](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/anandpathak31/32/33527_2.png) [@anandpathak31](https://discourse.julialang.org/u/anandpathak31)
#### Post date: [March 7, 2022, 1:41am UTC](https://discourse.julialang.org/t/mul-float-types-of-a-and-b-must-match-error-in-modelingtoolkit/77485/1 "2022-03-07T01:41:15Z")

</div>

I am getting the `mul_float: types of a and b must match` error in my code that uses ModelingToolkit in which I am solving an ODAEProblem costructed from ODESystem in a loop. In each iteration I am modifying the ODESystem while defining the ODAEProblem and solving it. It runs for 5-6 iterations and absuptly breaks down and gives this error :

```julia-auto
mul_float: types of a and b must match

1. <mark> ***** </mark>@ *float.jl:332* [inlined]
2. <mark> **macro expansion** </mark>@ *code.jl:351* [inlined]
3. <mark> **macro expansion** </mark>@ *RuntimeGeneratedFunctions.jl:129* [inlined]
4. <mark> **macro expansion** </mark>@ *none:0* [inlined]
5. <mark> **generated_callfunc** </mark>@ *none:0* [inlined]
6. <mark>(::RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(Symbol("##out#7673"), Symbol("##arg#14895969777671410020"), Symbol("##arg#12397454687446245267"), :t), ModelingToolkit.StructuralTransformations.var"#_RGF_ModTag", ModelingToolkit.StructuralTransformations.var"#_RGF_ModTag", (0xc101f4de, 0x01f1b297, 0xa7adcaa8, 0x3608c6d6, 0x144371da)})(::Vector{Float64}, ::Vector{Float64}, ::Vector{Float64}, ::Float64)</mark>@ *RuntimeGeneratedFunctions.jl:117*
7. <mark> **ODEFunction** </mark>@ *scimlfunctions.jl:334* [inlined]
8. <mark> **initialize!** (::OrdinaryDiffEq.ODEIntegrator{OrdinaryDiffEq.Tsit5{typeof(OrdinaryDiffEq.trivial_limiter!), typeof(OrdinaryDiffEq.trivial_limiter!), Static.False}, true, Vector{Float64}, Nothing, Float64, Vector{Float64}, Float64, Float64, Float64, Float64, Vector{Vector{Float64}}, SciMLBase.ODESolution{Float64, 2, Vector{Vector{Float64}}, Nothing, Nothing, Vector{Float64}, Vector{Vector{Vector{Float64}}}, SciMLBase.ODEProblem{Vector{Float64}, Tuple{Float64, Float64}, true, Vector{Float64}, SciMLBase.ODEFunction{true, RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(Symbol("##out#7673"), Symbol("##arg#14895969777671410020"), Symbol("##arg#12397454687446245267"), :t), ModelingToolkit.StructuralTransformations.var"#_RGF_ModTag", ModelingToolkit.StructuralTransformations.var"#_RGF_ModTag", (0xc101f4de, 0x01f1b297, 0xa7adcaa8, 0x3608c6d6, 0x144371da)}, LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, SparseArrays.SparseMatrixCSC{Bool, Int64}, Nothing, Nothing, Nothing, Vector{Symbol}, Nothing, ModelingToolkit.StructuralTransformations.var"#generated_observed#186"{Bool, ModelingToolkit.BipartiteGraphs.Matching{ModelingToolkit.BipartiteGraphs.Unassigned, Vector{Union{ModelingToolkit.BipartiteGraphs.Unassigned, Int64}}}, ModelingToolkit.SystemStructures.TearingState{ModelingToolkit.ODESystem}, Dict{Any, Any}, Vector{SymbolicUtils.Code.Assignment}, Tuple{Vector{Vector{Int64}}, Vector{BitSet}}, SymbolicUtils.Code.NameState, Dict{Any, Int64}}, Nothing}, Base.Iterators.Pairs{Symbol, SciMLBase.VectorContinuousCallback{ModelingToolkit.var"#248#258"{RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:ˍ₋out, :ˍ₋arg1, :ˍ₋arg2, :t), Symbolics.var"#_RGF_ModTag", Symbolics.var"#_RGF_ModTag", (0xe789e85d, 0xe1bdd0de, 0xcf5e9c2d, 0xad52a705, 0xc6e37bad)}}, ModelingToolkit.var"#250#260"{Vector{Function}, Vector{Int64}}, ModelingToolkit.var"#250#260"{Vector{Function}, Vector{Int64}}, typeof(SciMLBase.INITIALIZE_DEFAULT), typeof(SciMLBase.FINALIZE_DEFAULT), Float64, Int64, Rational{Int64}, Nothing, Int64}, Tuple{Symbol}, NamedTuple{(:callback,), Tuple{SciMLBase.VectorContinuousCallback{ModelingToolkit.var"#248#258"{RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:ˍ₋out, :ˍ₋arg1, :ˍ₋arg2, :t), Symbolics.var"#_RGF_ModTag", Symbolics.var"#_RGF_ModTag", (0xe789e85d, 0xe1bdd0de, 0xcf5e9c2d, 0xad52a705, 0xc6e37bad)}}, ModelingToolkit.var"#250#260"{Vector{Function}, Vector{Int64}}, ModelingToolkit.var"#250#260"{Vector{Function}, Vector{Int64}}, typeof(SciMLBase.INITIALIZE_DEFAULT), typeof(SciMLBase.FINALIZE_DEFAULT), Float64, Int64, Rational{Int64}, Nothing, Int64}}}}, SciMLBase.StandardODEProblem}, OrdinaryDiffEq.Tsit5{typeof(OrdinaryDiffEq.trivial_limiter!), typeof(OrdinaryDiffEq.trivial_limiter!), Static.False}, OrdinaryDiffEq.InterpolationData{SciMLBase.ODEFunction{true, RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(Symbol("##out#7673"), Symbol("##arg#14895969777671410020"), Symbol("##arg#12397454687446245267"), :t), ModelingToolkit.StructuralTransformations.var"#_RGF_ModTag", ModelingToolkit.StructuralTransformations.var"#_RGF_ModTag", (0xc101f4de, 0x01f1b297, 0xa7adcaa8, 0x3608c6d6, 0x144371da)}, LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, SparseArrays.SparseMatrixCSC{Bool, Int64}, Nothing, Nothing, Nothing, Vector{Symbol}, Nothing, ModelingToolkit.StructuralTransformations.var"#generated_observed#186"{Bool, ModelingToolkit.BipartiteGraphs.Matching{ModelingToolkit.BipartiteGraphs.Unassigned, Vector{Union{ModelingToolkit.BipartiteGraphs.Unassigned, Int64}}}, ModelingToolkit.SystemStructures.TearingState{ModelingToolkit.ODESystem}, Dict{Any, Any}, Vector{SymbolicUtils.Code.Assignment}, Tuple{Vector{Vector{Int64}}, Vector{BitSet}}, SymbolicUtils.Code.NameState, Dict{Any, Int64}}, Nothing}, Vector{Vector{Float64}}, Vector{Float64}, Vector{Vector{Vector{Float64}}}, OrdinaryDiffEq.Tsit5Cache{Vector{Float64}, Vector{Float64}, Vector{Float64}, OrdinaryDiffEq.Tsit5ConstantCache{Float64, Float64}, typeof(OrdinaryDiffEq.trivial_limiter!), typeof(OrdinaryDiffEq.trivial_limiter!), Static.False}}, DiffEqBase.DEStats}, SciMLBase.ODEFunction{true, RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(Symbol("##out#7673"), Symbol("##arg#14895969777671410020"), Symbol("##arg#12397454687446245267"), :t), ModelingToolkit.StructuralTransformations.var"#_RGF_ModTag", ModelingToolkit.StructuralTransformations.var"#_RGF_ModTag", (0xc101f4de, 0x01f1b297, 0xa7adcaa8, 0x3608c6d6, 0x144371da)}, LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, SparseArrays.SparseMatrixCSC{Bool, Int64}, Nothing, Nothing, Nothing, Vector{Symbol}, Nothing, ModelingToolkit.StructuralTransformations.var"#generated_observed#186"{Bool, ModelingToolkit.BipartiteGraphs.Matching{ModelingToolkit.BipartiteGraphs.Unassigned, Vector{Union{ModelingToolkit.BipartiteGraphs.Unassigned, Int64}}}, ModelingToolkit.SystemStructures.TearingState{ModelingToolkit.ODESystem}, Dict{Any, Any}, Vector{SymbolicUtils.Code.Assignment}, Tuple{Vector{Vector{Int64}}, Vector{BitSet}}, SymbolicUtils.Code.NameState, Dict{Any, Int64}}, Nothing}, OrdinaryDiffEq.Tsit5Cache{Vector{Float64}, Vector{Float64}, Vector{Float64}, OrdinaryDiffEq.Tsit5ConstantCache{Float64, Float64}, typeof(OrdinaryDiffEq.trivial_limiter!), typeof(OrdinaryDiffEq.trivial_limiter!), Static.False}, OrdinaryDiffEq.DEOptions{Float64, Float64, Float64, Float64, OrdinaryDiffEq.PIController{Rational{Int64}}, typeof(DiffEqBase.ODE_DEFAULT_NORM), typeof(LinearAlgebra.opnorm), Nothing, SciMLBase.CallbackSet{Tuple{SciMLBase.VectorContinuousCallback{ModelingToolkit.var"#248#258"{RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:ˍ₋out, :ˍ₋arg1, :ˍ₋arg2, :t), Symbolics.var"#_RGF_ModTag", Symbolics.var"#_RGF_ModTag", (0xe789e85d, 0xe1bdd0de, 0xcf5e9c2d, 0xad52a705, 0xc6e37bad)}}, ModelingToolkit.var"#250#260"{Vector{Function}, Vector{Int64}}, ModelingToolkit.var"#250#260"{Vector{Function}, Vector{Int64}}, typeof(SciMLBase.INITIALIZE_DEFAULT), typeof(SciMLBase.FINALIZE_DEFAULT), Float64, Int64, Rational{Int64}, Nothing, Int64}}, Tuple{}}, typeof(DiffEqBase.ODE_DEFAULT_ISOUTOFDOMAIN), typeof(DiffEqBase.ODE_DEFAULT_PROG_MESSAGE), typeof(DiffEqBase.ODE_DEFAULT_UNSTABLE_CHECK), DataStructures.BinaryHeap{Float64, DataStructures.FasterForward}, DataStructures.BinaryHeap{Float64, DataStructures.FasterForward}, Nothing, Nothing, Int64, Tuple{}, Float64, Tuple{}}, Vector{Float64}, Float64, DiffEqBase.CallbackCache{Vector{Float64}, Vector{Float64}}, OrdinaryDiffEq.DefaultInit}, ::OrdinaryDiffEq.Tsit5Cache{Vector{Float64}, Vector{Float64}, Vector{Float64}, OrdinaryDiffEq.Tsit5ConstantCache{Float64, Float64}, typeof(OrdinaryDiffEq.trivial_limiter!), typeof(OrdinaryDiffEq.trivial_limiter!), Static.False})</mark>@ *low_order_rk_perform_step.jl:627*
9. <mark> **var"#__init#496"** (::Float64, ::Tuple{}, ::Tuple{}, ::Nothing, ::Bool, ::Bool, ::Bool, ::Nothing, ::SciMLBase.VectorContinuousCallback{ModelingToolkit.var"#248#258"{RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:ˍ₋out, :ˍ₋arg1, :ˍ₋arg2, :t), Symbolics.var"#_RGF_ModTag", Symbolics.var"#_RGF_ModTag", (0xe789e85d, 0xe1bdd0de, 0xcf5e9c2d, 0xad52a705, 0xc6e37bad)}}, ModelingToolkit.var"#250#260"{Vector{Function}, Vector{Int64}}, ModelingToolkit.var"#250#260"{Vector{Function}, Vector{Int64}}, typeof(SciMLBase.INITIALIZE_DEFAULT), typeof(SciMLBase.FINALIZE_DEFAULT), Float64, Int64, Rational{Int64}, Nothing, Int64}, ::Bool, ::Bool, ::Float64, ::Nothing, ::Float64, ::Bool, ::Bool, ::Rational{Int64}, ::Nothing, ::Nothing, ::Rational{Int64}, ::Int64, ::Int64, ::Int64, ::Nothing, ::Nothing, ::Rational{Int64}, ::Nothing, ::Bool, ::Int64, ::Int64, ::typeof(DiffEqBase.ODE_DEFAULT_NORM), ::typeof(LinearAlgebra.opnorm), ::typeof(DiffEqBase.ODE_DEFAULT_ISOUTOFDOMAIN), ::typeof(DiffEqBase.ODE_DEFAULT_UNSTABLE_CHECK), ::Bool, ::Bool, ::Bool, ::Bool, ::Bool, ::Bool, ::Bool, ::Int64, ::String, ::typeof(DiffEqBase.ODE_DEFAULT_PROG_MESSAGE), ::Nothing, ::Bool, ::Bool, ::Bool, ::Bool, ::OrdinaryDiffEq.DefaultInit, ::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, ::typeof(SciMLBase.__init), ::SciMLBase.ODEProblem{Vector{Float64}, Tuple{Float64, Float64}, true, Vector{Float64}, SciMLBase.ODEFunction{true, RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(Symbol("##out#7673"), Symbol("##arg#14895969777671410020"), Symbol("##arg#12397454687446245267"), :t), ModelingToolkit.StructuralTransformations.var"#_RGF_ModTag", ModelingToolkit.StructuralTransformations.var"#_RGF_ModTag", (0xc101f4de, 0x01f1b297, 0xa7adcaa8, 0x3608c6d6, 0x144371da)}, LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, SparseArrays.SparseMatrixCSC{Bool, Int64}, Nothing, Nothing, Nothing, Vector{Symbol}, Nothing, ModelingToolkit.StructuralTransformations.var"#generated_observed#186"{Bool, ModelingToolkit.BipartiteGraphs.Matching{ModelingToolkit.BipartiteGraphs.Unassigned, Vector{Union{ModelingToolkit.BipartiteGraphs.Unassigned, Int64}}}, ModelingToolkit.SystemStructures.TearingState{ModelingToolkit.ODESystem}, Dict{Any, Any}, Vector{SymbolicUtils.Code.Assignment}, Tuple{Vector{Vector{Int64}}, Vector{BitSet}}, SymbolicUtils.Code.NameState, Dict{Any, Int64}}, Nothing}, Base.Iterators.Pairs{Symbol, SciMLBase.VectorContinuousCallback{ModelingToolkit.var"#248#258"{RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:ˍ₋out, :ˍ₋arg1, :ˍ₋arg2, :t), Symbolics.var"#_RGF_ModTag", Symbolics.var"#_RGF_ModTag", (0xe789e85d, 0xe1bdd0de, 0xcf5e9c2d, 0xad52a705, 0xc6e37bad)}}, ModelingToolkit.var"#250#260"{Vector{Function}, Vector{Int64}}, ModelingToolkit.var"#250#260"{Vector{Function}, Vector{Int64}}, typeof(SciMLBase.INITIALIZE_DEFAULT), typeof(SciMLBase.FINALIZE_DEFAULT), Float64, Int64, Rational{Int64}, Nothing, Int64}, Tuple{Symbol}, NamedTuple{(:callback,), Tuple{SciMLBase.VectorContinuousCallback{ModelingToolkit.var"#248#258"{RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:ˍ₋out, :ˍ₋arg1, :ˍ₋arg2, :t), Symbolics.var"#_RGF_ModTag", Symbolics.var"#_RGF_ModTag", (0xe789e85d, 0xe1bdd0de, 0xcf5e9c2d, 0xad52a705, 0xc6e37bad)}}, ModelingToolkit.var"#250#260"{Vector{Function}, Vector{Int64}}, ModelingToolkit.var"#250#260"{Vector{Function}, Vector{Int64}}, typeof(SciMLBase.INITIALIZE_DEFAULT), typeof(SciMLBase.FINALIZE_DEFAULT), Float64, Int64, Rational{Int64}, Nothing, Int64}}}}, SciMLBase.StandardODEProblem}, ::OrdinaryDiffEq.Tsit5{typeof(OrdinaryDiffEq.trivial_limiter!), typeof(OrdinaryDiffEq.trivial_limiter!), Static.False}, ::Tuple{}, ::Tuple{}, ::Tuple{}, ::Type{Val{true}})</mark>@ *solve.jl:456*
10. <mark> **#__solve#495** </mark>@ *solve.jl:4* [inlined]
11. <mark> **#solve_call#37** </mark>@ *solve.jl:61* [inlined]
12. <mark> **var"#solve_up#39"** (::Base.Iterators.Pairs{Symbol, Float64, Tuple{Symbol}, NamedTuple{(:saveat,), Tuple{Float64}}}, ::typeof(DiffEqBase.solve_up), ::SciMLBase.ODEProblem{Vector{Float64}, Tuple{Int64, Int64}, true, Vector{Float64}, SciMLBase.ODEFunction{true, RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(Symbol("##out#7673"), Symbol("##arg#14895969777671410020"), Symbol("##arg#12397454687446245267"), :t), ModelingToolkit.StructuralTransformations.var"#_RGF_ModTag", ModelingToolkit.StructuralTransformations.var"#_RGF_ModTag", (0xc101f4de, 0x01f1b297, 0xa7adcaa8, 0x3608c6d6, 0x144371da)}, LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, SparseArrays.SparseMatrixCSC{Bool, Int64}, Nothing, Nothing, Nothing, Vector{Symbol}, Nothing, ModelingToolkit.StructuralTransformations.var"#generated_observed#186"{Bool, ModelingToolkit.BipartiteGraphs.Matching{ModelingToolkit.BipartiteGraphs.Unassigned, Vector{Union{ModelingToolkit.BipartiteGraphs.Unassigned, Int64}}}, ModelingToolkit.SystemStructures.TearingState{ModelingToolkit.ODESystem}, Dict{Any, Any}, Vector{SymbolicUtils.Code.Assignment}, Tuple{Vector{Vector{Int64}}, Vector{BitSet}}, SymbolicUtils.Code.NameState, Dict{Any, Int64}}, Nothing}, Base.Iterators.Pairs{Symbol, SciMLBase.VectorContinuousCallback{ModelingToolkit.var"#248#258"{RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:ˍ₋out, :ˍ₋arg1, :ˍ₋arg2, :t), Symbolics.var"#_RGF_ModTag", Symbolics.var"#_RGF_ModTag", (0xe789e85d, 0xe1bdd0de, 0xcf5e9c2d, 0xad52a705, 0xc6e37bad)}}, ModelingToolkit.var"#250#260"{Vector{Function}, Vector{Int64}}, ModelingToolkit.var"#250#260"{Vector{Function}, Vector{Int64}}, typeof(SciMLBase.INITIALIZE_DEFAULT), typeof(SciMLBase.FINALIZE_DEFAULT), Float64, Int64, Rational{Int64}, Nothing, Int64}, Tuple{Symbol}, NamedTuple{(:callback,), Tuple{SciMLBase.VectorContinuousCallback{ModelingToolkit.var"#248#258"{RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:ˍ₋out, :ˍ₋arg1, :ˍ₋arg2, :t), Symbolics.var"#_RGF_ModTag", Symbolics.var"#_RGF_ModTag", (0xe789e85d, 0xe1bdd0de, 0xcf5e9c2d, 0xad52a705, 0xc6e37bad)}}, ModelingToolkit.var"#250#260"{Vector{Function}, Vector{Int64}}, ModelingToolkit.var"#250#260"{Vector{Function}, Vector{Int64}}, typeof(SciMLBase.INITIALIZE_DEFAULT), typeof(SciMLBase.FINALIZE_DEFAULT), Float64, Int64, Rational{Int64}, Nothing, Int64}}}}, SciMLBase.StandardODEProblem}, ::Nothing, ::Vector{Float64}, ::Vector{Float64}, ::OrdinaryDiffEq.Tsit5{typeof(OrdinaryDiffEq.trivial_limiter!), typeof(OrdinaryDiffEq.trivial_limiter!), Static.False})</mark>@ *solve.jl:87*
13. <mark> **#solve#38** </mark>@ *solve.jl:73* [inlined]
14. <mark> **top-level scope** </mark>@ *[Local: 39](http://localhost:1234/edit?id=ef931f06-9d73-11ec-0625-d34dd6714ba6#)*

```

I have seen a simillar issue in this post:

> [@ODEFunction throwing "ERROR: LoadError: mul\_float: types of a and b must match"](https://discourse.julialang.org/t/odefunction-throwing-error-loaderror-mul-float-types-of-a-and-b-must-match/61024):
>
> What does the following error mean: “ERROR: LoadError: mul\_float: types of a and b must match”? I am running a code that repeatedly calls a function that creates an ODE problem and solves it. The function is called in a for loop, at each called only one parameter in the ODE changes. I get the error message most of the time that I run the code. The unusual thing is that the error is raised at different iterations of the for loop, usually after 10 or so successful executions of the function. Som…

I am attaching the relevant parts of my code below :

# 

```julia-auto
This loop does the following :
    # 1) generates an array of ODESystem nrn_network
    # 2) connects the array of ODESystems using adjacency matrix syn 
    # 3) construct an ODAEProblem and solve it
    # 4) use the solution to update the adjacency matrix syn which will be used to connect the ODESystem in next loop iteration 
    # In every iteration some we update some parameters of ODESystem array nrn_network and update the adjacency matrix syn
    # The error will not show if we do not update the adjacency matrix syn
    for loop = 1:20
     
      # nrn_network is an array of ODESystems using function IF_neurons
        nrn_network=[]
            for ii = 1:Nrns
        
                 nn = IF_neuron(name=Symbol("nrn$ii"),E_syn=E_syn[ii],G_syn=G_syn[ii],I_in=I_in[ii],freq=freq[ii], phase=phase[ii], τ=τ[ii])
        
                 push!(nrn_network,nn)
            end
         
            #this function takes the array of ODESystems nrn_network and connects them using adjacensy matrix syn 
            #creating a larger ODESystem syn_net
        @named syn_net = synaptic_network(sys=nrn_network,adj_matrix=syn)
    
        prob = ODAEProblem(syn_net, [], (0, simtime))
        
        solt = solve(prob,Tsit5(),saveat=0.01)
        sol = DataFrame(solt)	
    
    
        for ii = 1:length(targ)
                    ###

                    # this hidden portion of the code generates an array act_syn using the solution of ODAEProblem

                    ###

               #THIS LOOP MODIFIES THE ADJACENCY MATRIX syn
            for jj = 1:length(act_syn)
                    syn[targ[ii],act_syn[jj]] = syn[targ[ii],act_syn[jj]] + 0.02*length(tt)
            end
    
        end
            
    end

    # This function takes an array of ODESystem and connects them, generates a larger ODESystem using 'compose' and does 'structural_simplify'

    function synaptic_network(;name, sys=sys, adj_matrix=adj_matrix)
        syn_eqs= [0~sys[1].V - sys[1].V]
                
        for ii = 1:length(sys)
               
            presyn = findall(x-> x>0, adj_matrix[ii,:])
            wts = adj_matrix[ii,presyn]		
            presyn_nrn = sys[presyn]
            postsyn_nrn = sys[ii]
                
            if length(presyn)>0
                        
                ind = [i for i = 1:length(presyn)];
                eq = [0 ~ sum(p-> (presyn_nrn[p].E_syn-postsyn_nrn.V)*presyn_nrn[p].G*wts[p],ind)-postsyn_nrn.Isyn]
                push!(syn_eqs,eq[1])
                
            else
                eq = [0~postsyn_nrn.Isyn];
                push!(syn_eqs,eq[1]);
             
            end
        end
        popfirst!(syn_eqs)
        
        @named synaptic_eqs = ODESystem(syn_eqs,t)
        
        sys_ode = [sys[ii] for ii = 1:length(sys)]
    
        @named synaptic_network = compose(synaptic_eqs, sys_ode)
        return structural_simplify(synaptic_network)   
    end

```

Important thing to note is that the loop does not breakdown if I do not update the adjacency matrix ‘syn’ and only update the parameters of nrn\_network. Also, the error only shows up after few successful iterations of the loop. Please help me how to resolve this error. I am using the latest version of MTK.

---

<div class="post-metadata">

### Author: ![anandpathak31](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/anandpathak31/32/33527_2.png) [@anandpathak31](https://discourse.julialang.org/u/anandpathak31)
#### Post date: [March 7, 2022, 1:42am UTC](https://discourse.julialang.org/t/mul-float-types-of-a-and-b-must-match-error-in-modelingtoolkit/77485/2 "2022-03-07T01:42:18Z")

</div>

@ChrisRackauckas

---

<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: [March 8, 2022, 11:07pm UTC](https://discourse.julialang.org/t/mul-float-types-of-a-and-b-must-match-error-in-modelingtoolkit/77485/3 "2022-03-08T23:07:15Z")

</div>

Following up privately.

---

<div class="post-metadata">

### Author: ![TimKnab](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/timknab/32/22256_2.png) [@TimKnab](https://discourse.julialang.org/u/TimKnab)
#### Post date: [March 23, 2022, 12:25pm UTC](https://discourse.julialang.org/t/mul-float-types-of-a-and-b-must-match-error-in-modelingtoolkit/77485/4 "2022-03-23T12:25:42Z")

</div>

I have also just stumbled on this error using compose and structural simplify to build a network of Izhikevich neurons connected by multiple synapses. In general the first iteration/version of the network runs fine, but subsequent changes to the network connectivity and solves throw the error as described by @anandpathak31.

Was the cause and/or a solution found?

---

<div class="post-metadata">

### Author: ![anandpathak31](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/anandpathak31/32/33527_2.png) [@anandpathak31](https://discourse.julialang.org/u/anandpathak31)
#### Post date: [March 23, 2022, 4:44pm UTC](https://discourse.julialang.org/t/mul-float-types-of-a-and-b-must-match-error-in-modelingtoolkit/77485/5 "2022-03-23T16:44:13Z")

</div>

No. I am still working on finding the cause with @ChrisRackauckas. First step  
is to create a minimal version of the code which will produce the same error.  
I am working to create the minimal example. It is still not clear if the error is due to structural\_simplify and compose or simply just creating and recreating  
any ODESystem within a loop will give that error.

---

<div class="post-metadata">

### Author: ![TimKnab](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/timknab/32/22256_2.png) [@TimKnab](https://discourse.julialang.org/u/TimKnab)
#### Post date: [March 23, 2022, 4:58pm UTC](https://discourse.julialang.org/t/mul-float-types-of-a-and-b-must-match-error-in-modelingtoolkit/77485/6 "2022-03-23T16:58:51Z")

</div>

I see. I, unfortunately don’t have anything helpful to add to that end, but if I manage to write/change some code that causes the error in a reproducible way I’ll be sure to follow up, here. Thanks for the update, much appreciated

---

<div class="post-metadata">

### Author: ![ap2013](https://avatars.discourse-cdn.com/v4/letter/a/4491bb/32.png) [@ap2013](https://discourse.julialang.org/u/ap2013)
#### Post date: [May 10, 2022, 9:18am UTC](https://discourse.julialang.org/t/mul-float-types-of-a-and-b-must-match-error-in-modelingtoolkit/77485/7 "2022-05-10T09:18:47Z")

</div>

I am getting the same error in a similar situation. Have you found a solution @anandpathak31 @ChrisRackauckas ?

---

<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: [May 10, 2022, 12:16pm UTC](https://discourse.julialang.org/t/mul-float-types-of-a-and-b-must-match-error-in-modelingtoolkit/77485/8 "2022-05-10T12:16:20Z")

</div>

It needs a fix in Julia Base. Follow this issue for details:

[https://github.com/SciML/RuntimeGeneratedFunctions.jl/issues/13](https://github.com/SciML/RuntimeGeneratedFunctions.jl/issues/13)
