Skip to content
This repository was archived by the owner on Mar 2, 2022. It is now read-only.

Commit a6621e4

Browse files
committed
- Minor (efficiency) improvement if states are SVectors.
- Require ModiaBase 0.9.2 (to get rid of performance issues in Modia3D). - Replace ustrip(..) with ustrip.(..) at some places to get rid of warnings. - Increment version number and provide release notes
1 parent 0beaaf0 commit a6621e4

File tree

8 files changed

+65
-28
lines changed

8 files changed

+65
-28
lines changed

Manifest.toml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -183,9 +183,9 @@ version = "2.20.1"
183183

184184
[[deps.DiffEqJump]]
185185
deps = ["ArrayInterface", "Compat", "DataStructures", "DiffEqBase", "FunctionWrappers", "Graphs", "LinearAlgebra", "PoissonRandom", "Random", "RandomNumbers", "RecursiveArrayTools", "Reexport", "StaticArrays", "TreeViews", "UnPack"]
186-
git-tree-sha1 = "ec1f3a5b4eac6502e45dcf79d213b200afd61990"
186+
git-tree-sha1 = "e30f058eb600407e3fd4ea082e2527e3a3671238"
187187
uuid = "c894b116-72e5-5b58-be3c-e6d8d4ac2b12"
188-
version = "8.2.0"
188+
version = "8.2.1"
189189

190190
[[deps.DiffEqNoiseProcess]]
191191
deps = ["DiffEqBase", "Distributions", "LinearAlgebra", "Optim", "PoissonRandom", "QuadGK", "Random", "Random123", "RandomNumbers", "RecipesBase", "RecursiveArrayTools", "Requires", "ResettableStacks", "SciMLBase", "StaticArrays", "Statistics"]
@@ -497,9 +497,9 @@ uuid = "a63ad114-7e13-5084-954f-fe012c677804"
497497

498498
[[deps.ModiaBase]]
499499
deps = ["DataFrames", "DiffRules", "LinearAlgebra", "Measurements", "MonteCarloMeasurements", "OrderedCollections", "RecursiveFactorization", "StaticArrays", "TimerOutputs", "Unitful"]
500-
git-tree-sha1 = "9e678c9f7ce692bb30855083b83fa35db09c0d32"
500+
git-tree-sha1 = "e32f09c491f569f254d3c7776326539f4b3c5f24"
501501
uuid = "ec7bf1ca-419d-4510-bbab-199861c55244"
502-
version = "0.9.1"
502+
version = "0.9.2"
503503

504504
[[deps.ModiaResult]]
505505
deps = ["DataFrames", "Measurements", "MonteCarloMeasurements", "OrderedCollections", "Pkg", "Tables", "Unitful"]
@@ -614,9 +614,9 @@ version = "0.4.0"
614614

615615
[[deps.Polyester]]
616616
deps = ["ArrayInterface", "BitTwiddlingConvenienceFunctions", "CPUSummary", "IfElse", "ManualMemory", "PolyesterWeave", "Requires", "Static", "StrideArraysCore", "ThreadingUtilities"]
617-
git-tree-sha1 = "93b829eedfc466c844c233f285fae94dcaa1870a"
617+
git-tree-sha1 = "2232d3865bc9a098e664f69cbe340b960d48217f"
618618
uuid = "f517fe37-dbe3-4b94-8317-1923a5111588"
619-
version = "0.6.5"
619+
version = "0.6.6"
620620

621621
[[deps.PolyesterWeave]]
622622
deps = ["BitTwiddlingConvenienceFunctions", "CPUSummary", "IfElse", "Static", "ThreadingUtilities"]
@@ -746,9 +746,9 @@ version = "0.1.0"
746746

747747
[[deps.SLEEFPirates]]
748748
deps = ["IfElse", "Static", "VectorizationBase"]
749-
git-tree-sha1 = "3a5ae1db486e4ce3ccd2b392389943481e20401f"
749+
git-tree-sha1 = "61a96d8b89083a53fb2b745f3b59a05359651bbe"
750750
uuid = "476501e8-09a2-5ece-8869-fb82de89a1fa"
751-
version = "0.6.29"
751+
version = "0.6.30"
752752

753753
[[deps.SciMLBase]]
754754
deps = ["ArrayInterface", "CommonSolve", "ConstructionBase", "Distributed", "DocStringExtensions", "IteratorInterfaceExtensions", "LinearAlgebra", "Logging", "RecipesBase", "RecursiveArrayTools", "StaticArrays", "Statistics", "Tables", "TreeViews"]
@@ -808,9 +808,9 @@ version = "0.4.1"
808808

809809
[[deps.StaticArrays]]
810810
deps = ["LinearAlgebra", "Random", "Statistics"]
811-
git-tree-sha1 = "95c6a5d0e8c69555842fc4a927fc485040ccc31c"
811+
git-tree-sha1 = "6354dfaf95d398a1a70e0b28238321d5d17b2530"
812812
uuid = "90137ffa-7385-5640-81b9-e52037218182"
813-
version = "1.3.5"
813+
version = "1.4.0"
814814

815815
[[deps.Statistics]]
816816
deps = ["LinearAlgebra", "SparseArrays"]
@@ -848,9 +848,9 @@ version = "6.44.0"
848848

849849
[[deps.StrideArraysCore]]
850850
deps = ["ArrayInterface", "CloseOpenIntervals", "IfElse", "LayoutPointers", "ManualMemory", "Requires", "SIMDTypes", "Static", "ThreadingUtilities"]
851-
git-tree-sha1 = "2025a5d6564a93fa5b499dd216c0bc44537fb0d4"
851+
git-tree-sha1 = "e0a02838565c4600ecd1d8874db8cfe263aaa6c7"
852852
uuid = "7792a7ef-975c-4747-a70f-980b88e8d1da"
853-
version = "0.2.11"
853+
version = "0.2.12"
854854

855855
[[deps.SuiteSparse]]
856856
deps = ["Libdl", "LinearAlgebra", "Serialization", "SparseArrays"]

Project.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "ModiaLang"
22
uuid = "34b37210-eaa3-4b48-8781-0b87bf559981"
33
authors = ["Hilding Elmqvist <Hilding.Elmqvist@Mogram.net>", "Martin Otter <Martin.Otter@dlr.de>"]
4-
version = "0.11.1"
4+
version = "0.11.2"
55

66
[deps]
77
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
@@ -30,7 +30,7 @@ FiniteDiff = "2"
3030
ForwardDiff = "0.10"
3131
JSON = "0.21"
3232
Measurements = "2"
33-
ModiaBase = "0.9.1"
33+
ModiaBase = "0.9.2"
3434
ModiaResult = "0.4.1"
3535
MonteCarloMeasurements = "1"
3636
OrderedCollections = "1"

docs/src/index.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,18 @@ julia> ]add ModiaPlot_PyPlot # if plotting with PyPlot desired
2828

2929
## Release Notes
3030

31+
### Version 0.11.2
32+
33+
- Minor (efficiency) improvement if states are SVectors.
34+
-
35+
36+
37+
### Version 0.11.1
38+
39+
- Update of Manifest.toml file
40+
- Require ModiaBase 0.9.1 (with updated Manifest.toml file)
41+
42+
3143
### Version 0.11.0
3244

3345
Non-backwards compatible changes
@@ -94,6 +106,19 @@ Bug fixes
94106
- Function `ModiaLang.firstInitialOfAllSegments(..)` now correctly returns true for the first call of the getDerivatives function during the simulation.
95107

96108

109+
### Version 0.10.2
110+
111+
- Minor (efficiency) improvement if states are SVectors.
112+
- Require ModiaBase 0.9.2 (to get rid of performance issues in Modia3D).
113+
- Replace ustrip(..) with ustrip.(..) at some places to get rid of warnings.
114+
115+
116+
### Version 0.10.1
117+
118+
- Update of Manifest.toml file
119+
- Require ModiaBase 0.9.1 (with updated Manifest.toml file).
120+
121+
97122
### Version 0.10.0
98123

99124
- Require DifferentialEquations.jl version 7.

src/CodeGeneration.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1562,7 +1562,7 @@ function generate_getDerivatives!(AST::Vector{Expr}, equationInfo::ModiaBase.Equ
15621562
i2 = i1 + xe.length - 1
15631563
v_length = xe.length
15641564
if !hasUnits || xe.unit == ""
1565-
push!(code_x, :( $x_name = ModiaBase.SVector{$v_length,_FloatType}(_x[$i1:$i2])::ModiaBase.SVector{$v_length,_FloatType}) )
1565+
push!(code_x, :( $x_name::ModiaBase.SVector{$v_length,_FloatType} = ModiaBase.SVector{$v_length,_FloatType}(_x[$i1:$i2])) )
15661566
else
15671567
x_unit = xe.unit
15681568
push!(code_x, :( $x_name = ModiaBase.SVector{$v_length,_FloatType}(_x[$i1:$i2])::ModiaBase.SVector{$v_length,_FloatType}*@u_str($x_unit)) )

src/JSONModel.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ function encodeModel(model, expressionsAsStrings=true)
3131
Base.remove_linenums!(model)
3232
model = removeBlock(model)
3333
if typeof(model) <: Quantity
34-
return Dict(:_value => ustrip(model), :_unit=>string(unit(model)))
34+
return Dict(:_value => ustrip.(model), :_unit=>string(unit(model)))
3535
elseif expressionsAsStrings && typeof(model) == Expr
3636
return Dict(:_Expr=>string(model))
3737
elseif typeof(model) == Expr

src/ModiaLang.jl

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,8 @@ const drawIncidence = false
110110

111111
const path = dirname(dirname(@__FILE__)) # Absolute path of package directory
112112

113-
const Version = "0.11.1"
114-
const Date = "2022-02-21"
113+
const Version = "0.11.2"
114+
const Date = "2022-02-23"
115115

116116
#println(" \n\nWelcome to Modia - Dynamic MODeling and Simulation in julIA")
117117
#=
@@ -598,16 +598,28 @@ function stateSelectionAndCodeGeneration(modStructure, Gexplicit, name, modelMod
598598
end
599599
if isexpr(lhs, :tuple) && all(a == 0 for a in lhs.args) || lhs == :(0)
600600
eq_rhs = makeDerVar(:($rhs), parameters, inputs, evaluateParameters)
601-
eqs = :(ModiaLang.Unitful.ustrip.($eq_rhs))
601+
if unitless
602+
eqs = eq_rhs
603+
else
604+
eqs = :(ModiaLang.Unitful.ustrip.($eq_rhs))
605+
end
606+
#elseif isexpr(lhs, :tuple) && isexpr(rhs, :call) && unitless
607+
# eq_rhs = makeDerVar(:($rhs), parameters, inputs, evaluateParameters)
608+
# eq_lhs = makeDerVar(:($lhs), parameters, inputs, evaluateParameters)
609+
# eqs = :( ($eq_rhs .-= $eq_lhs) )
602610
else
603611
eq_rhs = makeDerVar(:($rhs), parameters, inputs, evaluateParameters)
604612
eq_lhs = makeDerVar(:($lhs), parameters, inputs, evaluateParameters)
605-
eqs = :( ModiaLang.Unitful.ustrip.($eq_rhs) .- ModiaLang.Unitful.ustrip.($eq_lhs))
613+
if unitless
614+
eqs = :( $eq_rhs .- $eq_lhs )
615+
else
616+
eqs = :( ModiaLang.Unitful.ustrip.($eq_rhs) .- ModiaLang.Unitful.ustrip.($eq_lhs))
617+
end
606618
end
607619
residual = :(ModiaBase.appendVariable!(_leq_mode.residuals, $eqs))
608620
residString = string(eqs)
609621
if logCalculations
610-
return :(println("Calculating residual: ", $residString); $residualName = $eqs; println(" Residual: ", $residualName) )
622+
return :(println("Calculating residual: ", $residString); $residualName = $eqs; println(" Residual: ", $residualName) )
611623
# return makeDerVar(:(dump($(makeDerVar(eq.args[2]))); dump($(makeDerVar(eq.args[1]))); $residual; println($residualName, " = ", upreferred.(($(eq.args[2]) - $(eq.args[1]))))))
612624
else
613625
return residual

src/NamedTupleModels.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ function flattenModelTuple!(model, modelStructure, modelName; unitless = false,
424424
for (x,x0) in zip(keys(v), v)
425425
if x != :class
426426
if unitless && typeof(x0) != Expr
427-
x0 = ustrip(x0)
427+
x0 = ustrip.(x0)
428428
end
429429
modelStructure.init[x] = x0
430430
modelStructure.mappedParameters = (;modelStructure.mappedParameters..., x => x0)
@@ -436,7 +436,7 @@ function flattenModelTuple!(model, modelStructure, modelName; unitless = false,
436436
for (s,s0) in zip(keys(v), v)
437437
if s != :class
438438
if unitless
439-
s0 = ustrip(s0)
439+
s0 = ustrip.(s0)
440440
end
441441
modelStructure.start[s] = s0
442442
modelStructure.mappedParameters = (;modelStructure.mappedParameters..., s => s0)
@@ -449,7 +449,7 @@ function flattenModelTuple!(model, modelStructure, modelName; unitless = false,
449449
typeof(v) <: NamedTuple && :class in keys(v) && v.class == :Par ||
450450
typeof(v) <: NamedTuple && :parameter in keys(v) && v.parameter
451451
if unitless && !(typeof(v) <: NamedTuple)
452-
v = ustrip(v)
452+
v = ustrip.(v)
453453
end
454454
modelStructure.parameters[k] = v
455455
modelStructure.mappedParameters = (;modelStructure.mappedParameters..., k => v)
@@ -468,15 +468,15 @@ function flattenModelTuple!(model, modelStructure, modelName; unitless = false,
468468
if :init in keys(v)
469469
x0 = v.init
470470
if unitless && typeof(x0) != Expr
471-
x0 = ustrip(x0)
471+
x0 = ustrip.(x0)
472472
end
473473
modelStructure.init[k] = x0
474474
modelStructure.mappedParameters = (;modelStructure.mappedParameters..., k => x0)
475475
end
476476
if :start in keys(v)
477477
s0 = v.start
478478
if unitless && typeof(s0) != Expr
479-
s0 = ustrip(s0)
479+
s0 = ustrip.(s0)
480480
end
481481
modelStructure.start[k] = s0
482482
modelStructure.mappedParameters = (;modelStructure.mappedParameters..., k => s0)

test/TestTwoInertiasAndIdealGearWithUnits.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ using Test
77
TwoInertiasAndIdealGearWithUnits = Model(
88
J1 = 0.0025u"kg*m^2",
99
J2 = 170u"kg*m^2",
10-
r = 105,
10+
r = 105.0,
1111
tau_max = 1u"N*m",
1212

1313
phi2 = Var(start = 0.5u"rad"),
@@ -31,7 +31,7 @@ TwoInertiasAndIdealGearWithUnits = Model(
3131
]
3232
)
3333

34-
twoInertiasAndIdealGearWithUnits = @instantiateModel(TwoInertiasAndIdealGearWithUnits)
34+
twoInertiasAndIdealGearWithUnits = @instantiateModel(TwoInertiasAndIdealGearWithUnits, logCode=true)
3535

3636

3737
simulate!(twoInertiasAndIdealGearWithUnits, Tsit5(), stopTime = 4.0,

0 commit comments

Comments
 (0)