@@ -17,21 +17,36 @@ fieldnames(typeof(integrator)) = (:sol, :u, :du, :k, :t, :dt, :f, :p, :uprev, :u
1717"""
1818 baseType(T)
1919
20- Return the base type of a type T.
20+ Return the base type of a type T, according to the following definition.
21+
22+ ```julia
23+ baseType(::Type{T}) where {T} = T
24+ baseType(::Type{Unitful.Quantity{T,D,U}}) where {T,D,U} = T
25+ baseType(::Type{Measurements.Measurement{T}}) where {T} = T
26+ baseType(::Type{MonteCarloMeasurements.Particles{T,N}}) where {T,N} = T
27+ baseType(::Type{MonteCarloMeasurements.StaticParticles{T,N}}) where {T,N} = T
28+ ```
2129
2230# Examples
2331```
2432baseType(Float32) # Float32
2533baseType(Measurement{Float64}) # Float64
2634```
2735"""
28- baseType (:: Type{T} ) where {T} = T
29- baseType (:: Type{Measurements.Measurement{T}} ) where {T<: AbstractFloat } = T
30- baseType (:: Type{MonteCarloMeasurements.Particles{T,N}} ) where {T<: AbstractFloat ,N} = T
31- baseType (:: Type{MonteCarloMeasurements.StaticParticles{T,N}} ) where {T<: AbstractFloat ,N} = T
36+ baseType (:: Type{T} ) where {T} = T
37+ baseType (:: Type{Unitful.Quantity{T,D,U}} ) where {T,D,U} = T
38+ baseType (:: Type{Measurements.Measurement{T}} ) where {T} = T
39+ baseType (:: Type{MonteCarloMeasurements.Particles{T,N}} ) where {T,N} = T
40+ baseType (:: Type{MonteCarloMeasurements.StaticParticles{T,N}} ) where {T,N} = T
41+
42+ isQuantity ( :: Type{T} ) where {T} = T <: Unitful.Quantity || T <: MonteCarloMeasurements.AbstractParticles && baseType (T) <: Unitful.Quantity
43+ isMeasurements ( :: Type{T} ) where {T} = T <: Measurements.Measurement || T <: Unitful.Quantity && baseType (T) <: Measurements.Measurement
44+ isMonteCarloMeasurements (:: Type{T} ) where {T} = T <: MonteCarloMeasurements.AbstractParticles
3245
33- Base. floatmax (:: Type{MonteCarloMeasurements.Particles{T,N}} ) where {T<: AbstractFloat ,N} = Base. floatmax (T)
34- Base. floatmax (:: Type{MonteCarloMeasurements.StaticParticles{T,N}} ) where {T<: AbstractFloat ,N} = Base. floatmax (T)
46+ Base. floatmax (:: Type{Unitful.Quantity{T,D,U}} ) where {T,D,U} = Base. floatmax (T)
47+ Base. floatmax (:: Type{Measurements.Measurement{T}} ) where {T} = Base. floatmax (T)
48+ Base. floatmax (:: Type{MonteCarloMeasurements.Particles{T,N}} ) where {T,N} = Base. floatmax (T)
49+ Base. floatmax (:: Type{MonteCarloMeasurements.StaticParticles{T,N}} ) where {T,N} = Base. floatmax (T)
3550
3651
3752"""
@@ -1528,7 +1543,7 @@ Symbol `functionName` as function name. By `eval(code)` or
15281543
15291544- `hasUnits::Bool`: = true, if variables have units. Note, the units of the state vector are defined in equationinfo.
15301545"""
1531- function generate_getDerivatives! (AST:: Vector{Expr} , equationInfo:: Modia.EquationInfo ,
1546+ function generate_getDerivatives! (FloatType, TimeType, AST:: Vector{Expr} , equationInfo:: Modia.EquationInfo ,
15321547 parameters, variables, previousVars, preVars, holdVars, functionName:: Symbol ;
15331548 pre:: Vector{Symbol} = Symbol[], hasUnits= false )
15341549
@@ -1643,9 +1658,12 @@ function generate_getDerivatives!(AST::Vector{Expr}, equationInfo::Modia.Equatio
16431658 end
16441659
16451660 # Generate code of the function
1661+ # temporarily removed: _m.time = $TimeType(Modia.getValue(_time))
16461662 code = quote
1647- function $functionName (_x, _m:: Modia.SimulationModel{_FloatType,_TimeType} , _time):: Nothing where {_FloatType,_TimeType}
1648- _m. time = _TimeType (Modia. getValue (_time))
1663+ function $functionName (_x, _m:: Modia.SimulationModel{$FloatType,$TimeType} , _time:: $TimeType ):: Nothing
1664+ _FloatType = $ FloatType
1665+ _TimeType = $ TimeType
1666+ _m. time = _time
16491667 _m. nGetDerivatives += 1
16501668 instantiatedModel = _m
16511669 _p = _m. evaluatedParameters
0 commit comments