Modia.jl icon indicating copy to clipboard operation
Modia.jl copied to clipboard

Multiplying der() with 0 gives strange error

Open tpdsantos opened this issue 6 years ago • 0 comments

Hi, Since I updated Modia and ModiaMath, some code that I had does not work now. What my code did was:

NC = 2
NX = 13
@model model begin
    c = Var(start=fill(0.0,NC,NX))
                
    Cout = Var(start=fill(0.0,NC))
    Cin  = Var(start=fill(0.0,NC))
    Fin  = Var(start=fill(0.0,NC))
    Fout = Var(start=fill(0.0,NC))
                
    τ   = 1.0
    Q0  = 1.0
    V   = 1.0
    Pe  = 250.0
               
    @equations begin
        Array(Cin) = Array( pf.inlet )
        Array(Fin) = broadcast(*,Cin,Q0)
                    
        broadcast(*,boolean_vector,der(c)) = customfunction(c,τ,Q0,V,Pe,Cin)
                           
        Array(Cout) = Array( c[:,NX] )
        Array(Fout) = broadcast(*,Cout,Q0)
    end    
end

The problem is in broadcast(*,boolean_vector,der(c)). customfunction is a function that I created to partition variable c into algebraic or differential equations. the indices where the equation must be algebraic, boolean_vector has the value false, and it worked perfectly. Now with the last update, when boolean_vector is false, it gives me this error:

ERROR: MethodError: no method matching *(::String, ::Array{String,1})

Was this change intentional? If so, how can I proceed to obtain the same behaviour that I had?

I'm using Julia 1.1.0, Modia 0.2.4-dev and ModiaMath 0.3.1

Thanks in advance.

tpdsantos avatar Feb 20 '19 19:02 tpdsantos