ModiaSim / Modia.jl

Modeling and simulation of multidomain engineering systems
MIT License
323 stars 38 forks source link

Bool parameter converted to Float64 #142

Closed johhell closed 2 years ago

johhell commented 2 years ago

description

when using a Bool type parameter with the latest version of Modia, an error message is issues. was working ~ 1 week ago.

testcase

BoolPara.zip

Btest = Model(
    BoolPARA = true,   
    equations = :[
        der(y) = x
        x = sin(time)
        z = if BoolPARA; y; else; 0.0; end;
    ],

)

error message

ERROR: LoadError: TypeError: non-boolean (Float64) used in boolean context
Stacktrace:
  [1] getDerivatives(_x::Vector{Float64}, _m::SimulationModel{Float64, Float64}, _time::Float64)
    @ Main ~/.julia/packages/Modia/XUrJM/src/CodeGeneration.jl:1673
  [2] #invokelatest#2
...

function getDerivatives

Parameter of type Bool is now converted to Float64

...
        z = if (Float64)(_p[:BoolPARA])::Float64
                y
            else
                0.0
            end
...

used versions

latest versions of Modia, ModiaBase

MartinOtter commented 2 years ago

Fixed in release v0.8.3