@@ -17,21 +17,36 @@ fieldnames(typeof(integrator)) = (:sol, :u, :du, :k, :t, :dt, :f, :p, :uprev, :u
17
17
"""
18
18
baseType(T)
19
19
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
+ ```
21
29
22
30
# Examples
23
31
```
24
32
baseType(Float32) # Float32
25
33
baseType(Measurement{Float64}) # Float64
26
34
```
27
35
"""
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
32
45
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)
35
50
36
51
37
52
"""
@@ -1528,7 +1543,7 @@ Symbol `functionName` as function name. By `eval(code)` or
1528
1543
1529
1544
- `hasUnits::Bool`: = true, if variables have units. Note, the units of the state vector are defined in equationinfo.
1530
1545
"""
1531
- function generate_getDerivatives! (AST:: Vector{Expr} , equationInfo:: Modia.EquationInfo ,
1546
+ function generate_getDerivatives! (FloatType, TimeType, AST:: Vector{Expr} , equationInfo:: Modia.EquationInfo ,
1532
1547
parameters, variables, previousVars, preVars, holdVars, functionName:: Symbol ;
1533
1548
pre:: Vector{Symbol} = Symbol[], hasUnits= false )
1534
1549
@@ -1643,9 +1658,12 @@ function generate_getDerivatives!(AST::Vector{Expr}, equationInfo::Modia.Equatio
1643
1658
end
1644
1659
1645
1660
# Generate code of the function
1661
+ # temporarily removed: _m.time = $TimeType(Modia.getValue(_time))
1646
1662
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
1649
1667
_m. nGetDerivatives += 1
1650
1668
instantiatedModel = _m
1651
1669
_p = _m. evaluatedParameters
0 commit comments