Skip to content

Commit 2b7ce07

Browse files
committed
Merge branch 'hidden_states' of https://github.com/ModiaSim/Modia3D.jl into hidden_states
2 parents 9cbaac9 + 758a815 commit 2b7ce07

33 files changed

+118
-116
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
fail-fast: false
1515
matrix:
1616
version:
17-
- '1.7.2'
17+
- '1.7.3'
1818
os:
1919
- ubuntu-latest
2020
- windows-latest

src/Composition/object3D.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ mutable struct Object3D{F <: Modia3D.VarFloatType} <: Modia3D.AbstractObject3D
185185
velocity = Modia3D.ZeroVector3D(F),
186186
angularVelocity = Modia3D.ZeroVector3D(F),
187187
feature = nothing,
188-
angularVelocityResolvedInParent = false,
188+
angularVelocityResolvedInParent = true,
189189
kwargs...) where F <: Modia3D.VarFloatType
190190
interactionBehavior = Modia3D.NoInteraction
191191

test/Basic/AllShapes.jl

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ vmatYellow = VisualMaterial(color="Yellow", transparency=0.5)
1212
font2 = Font(fontFamily="FreeSans", bold=false, italic=false, charSize=0.1, color="LightBlue", transparency=0.0)
1313

1414
# material for massProperties where all MassProperties are defined
15-
m = 2.0
16-
rCM = [1,2,3]
15+
m = 2.0
16+
rCM = [1, 2, 3]
1717
massDefined = MassProperties(mass=m, centerOfMass=rCM, Ixx=3.0, Iyy=4.0, Izz=4.0, Ixy=6.0, Ixz=7.0, Iyz=9.0)
1818

1919
# mass properties are computed from shape and mass
@@ -150,8 +150,6 @@ AllShapes = Model3D(
150150

151151
allShapes = @instantiateModel(AllShapes, unitless=true, log=false, logStateSelection=false, logCode=false, FloatType=Float32)
152152

153-
154-
155153
simulate!(allShapes, stopTime=0.0, log=false, logStates=false, logEvents=false)
156154

157155
println("... Basics/AllShapes.jl completed.")

test/Basic/BouncingSphere3D.jl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
module BouncingSphere3D
2+
23
using Modia3D
34

45
BouncingSphere = Model3D(
56
boxHeigth = 0.1,
67
world = Object3D(feature=Scene()),
7-
ground = Object3D(parent=:world, translation=:[0.0,-boxHeigth/2,0.0],
8+
ground = Object3D(parent=:world,
9+
translation=:[0.0,-boxHeigth/2,0.0],
810
feature=Solid(shape=Box(lengthX=4.0, lengthY=:boxHeigth, lengthZ=0.7),
911
visualMaterial=VisualMaterial(color="DarkGreen"),
1012
solidMaterial="Steel",
1113
collision=true)),
12-
sphere = Object3D(parent=:world, fixedToParent=false, translation=[0.0, 1.0, 0.0], angularVelocityResolvedInParent=true,
14+
sphere = Object3D(parent=:world, fixedToParent=false,
15+
translation=[0.0, 1.0, 0.0],
1316
feature=Solid(shape=Sphere(diameter=0.2),
1417
visualMaterial=VisualMaterial(color="Blue"),
1518
solidMaterial="Steel",

test/Basic/FreeShaft.jl

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@ Shaft = Model(
99
world = Object3D(feature=Scene(gravityField=UniformGravityField(g=0.3, n=[0, 0, -1]))),
1010
worldFrame = Object3D(parent=:world,
1111
feature=Visual(shape=CoordinateSystem(length=:Diameter))),
12-
shaft = Object3D(parent=:world, fixedToParent=false, angularVelocityResolvedInParent=true,
13-
feature=Solid(shape=Cylinder(axis=3, diameter=:Diameter, length=:Length),
12+
shaft = Object3D(parent=:world, fixedToParent=false,
13+
feature=Solid(shape=Cylinder(axis=3, diameter=:Diameter, length=:Length),
1414
massProperties=MassProperties(; mass=84.7154, Ixx=7.2711, Iyy=7.2711, Izz=0.4230),
1515
visualMaterial=:(visualMaterial))),
1616
)
1717

1818
model = Model3D(
1919
shaft = Shaft | Map(Length=1.0, Diameter=0.2, shaft = Map(velocity=[0.0, 0.1, 0.6],
2020
rotation=[30, 20, 10]u"°",
21-
angularVelocity=Modia3D.resolve1([30, 20, 10]u"°",[1.0, 2.0, 3.0]), angularVelocityResolvedInParent=true)
21+
angularVelocity=Modia3D.resolve1([30, 20, 10]u"°", [1.0, 2.0, 3.0]))
2222
)
2323
)
2424
#@showModel model
@@ -28,8 +28,7 @@ shaft = @instantiateModel(model, unitless=true, log=false, logStateSelection=fal
2828
#@showModel shaft.p[1]
2929

3030
stopTime = 5.0
31-
requiredFinalStates=[-1.7224720653038268e-14, 0.4999999999999575, -0.750000016852883, -1.5681975307975595e-14, 0.0999999999999862, -0.8999999999999555, 12.518049838490617, -0.9018643787079454, 13.979844144766544, 2.0096818051930816, -0.9803470582617598, 2.9999999999999933]
32-
Modia3D.angularVelocityResolvedInParentStates!(requiredFinalStates, 7, true)
31+
requiredFinalStates=[0.0, 0.5, -0.75, 0.0, 0.1, -0.9, 12.518049845080435, -0.901864379852841, 13.979844149553378, -1.556318674959713, 1.9667313208626755, 2.776623306112369]
3332
simulate!(shaft, stopTime=stopTime, log=true, logStates=false, requiredFinalStates=requiredFinalStates)
3433

3534
@usingModiaPlot

test/Basic/FreeShaftAdaptiveRotSequence.jl

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,35 +3,34 @@ module FreeShaftAdaptiveRotSequence
33
using Modia3D
44
using Modia3D.Unitful
55

6+
startRotation = [30.0, 90.0, 10.0]u"°"
7+
68
Shaft = Model3D(
79
Length = 1.0,
810
Diameter = 0.2,
911
visualMaterial = VisualMaterial(color="IndianRed1", transparency=0.5),
1012
world = Object3D(feature=Scene(gravityField=UniformGravityField(g=0.3, n=[0, 0, -1]))),
1113
worldFrame = Object3D(parent=:world,
1214
feature=Visual(shape=CoordinateSystem(length=:Diameter))),
13-
shaft = Object3D(parent = :world, fixedToParent = false,
14-
rotation=[30.0, 90.0, 10.0]u"°",
15+
shaft = Object3D(parent=:world, fixedToParent=false,
16+
rotation=startRotation,
1517
velocity=[0.0, 0.1, 0.0]u"m/s",
16-
angularVelocity=Modia3D.resolve1([30.0, 90.0, 10.0]u"°", [-2.0, 0.0, 0.0]u"rad/s"), angularVelocityResolvedInParent=true,
18+
angularVelocity=Modia3D.resolve1(startRotation, [-2.0, 0.0, 0.0]u"rad/s"),
1719
feature=Solid(shape=Cylinder(axis=3, diameter=:Diameter, length=:Length),
1820
massProperties=MassProperties(; mass=84.7154, Ixx=7.2711, Iyy=7.2711, Izz=0.4230),
1921
visualMaterial=:(visualMaterial))),
2022
shaftFrame = Object3D(parent=:shaft, feature=Visual(shape=CoordinateSystem(length=0.4))),
2123
)
2224

23-
2425
shaft = @instantiateModel(Shaft, unitless=true, log=false, logStateSelection=false, logCode=false)
2526

2627
stopTime = 7.0
2728
dtmax = 0.1
28-
#requiredFinalStates = [0.0, 0.7, -7.350074420637136, 0.6981317007977381, 1.4336293856408397, 1.5707963267949017, 0.0, 0.1, -2.1, -2.0, 0.0, 0.0]
29-
requiredFinalStates = [0.0, 0.7, -7.350074420637136, 0.0, 0.1, -2.1, 0.6981317007977381, 1.4336293856408397, 1.5707963267949017, -2.0, 0.0, 0.0]
30-
Modia3D.angularVelocityResolvedInParentStates!(requiredFinalStates, 7, false)
29+
requiredFinalStates = [0.0, 0.7, -7.350074420637136, 0.0, 0.1, -2.1, 0.6981317007977381, 1.4336293856408397, 1.5707963267949017, 0.0, -1.2855752193730614, 1.5320888862379711]
3130
simulate!(shaft, stopTime=stopTime, dtmax=dtmax, log=true, logEvents=true, logStates=false, requiredFinalStates=requiredFinalStates)
3231
showInfo(shaft)
3332

3433
@usingModiaPlot
35-
plot(shaft, ["shaft.rotation", "shaft.rotation123", "shaft.angularVelocity", "shaft.translation", "shaft.velocity"], figure=2)
34+
plot(shaft, ["shaft.rotation", "shaft.rotation123", "shaft.angularVelocity", "shaft.translation", "shaft.velocity"], figure=1)
3635

3736
end

test/Basic/ModelsForPrecompilation.jl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,17 @@ Dummy = Model3D(
1616
prism = Prismatic(obj1=:world , obj2=:body2, axis=[0.0, 20.0, 0.0]),
1717

1818
body3 = Object3D(parent=:world, fixedToParent=:false,
19-
translation=[0.0, 1.0, 0.0],
20-
angularVelocity=[10.0, 0.0, -5.0],
21-
feature=Solid(shape=Sphere(diameter=0.2),
19+
translation=[0.0, 1.0, 0.0],
20+
angularVelocity=[10.0, 0.0, -5.0],
21+
feature=Solid(shape=Sphere(diameter=0.2),
2222
visualMaterial=VisualMaterial(color="Blue"),
2323
solidMaterial="Steel",
2424
massProperties=MassPropertiesFromShapeAndMass(mass=0.001),
2525
collision=true))
2626
)
2727

2828
dummy = @instantiateModel(Dummy, unitless=true)
29+
2930
requiredFinalStates = [-0.01409972769199364, -7.0596959177668255e-6, -0.009809999999999998, -4.911840743732473e-6, 1.911668227391551e-18, 0.9999950881592562, -5.650237323663999e-19, 5.421091995435263e-15, -0.009810000000000728, -1.6124980940930281e-15, 0.009999952436232525, -2.5034486890006063e-5, -0.004999904940503696, 10.0, 0.0, -5.0]
3031
simulate!(dummy, stopTime=0.001, interval=0.001, requiredFinalStates=requiredFinalStates)
3132

test/Collision/Billard16Balls.jl

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,10 +162,7 @@ stopTime = 5.0
162162
testTime = 1.5
163163
tolerance = 1e-7
164164
interval = 0.01
165-
requiredFinalStates = [0.9332483106072544, -0.18187312532441693, 0.02999849671681763, -0.7095832048149922, 0.6368707654369432, 1.143171041101384e-6, -13.553942563593557, -0.4195243794435807, -51.79233008660278, 11.807007209726729, -27.975810451969565, -9.384295654892883, 0.3251502055431403, 0.02772819926252931, 0.0299976678693217, -0.04538254491852899, 0.024939912003186206, 7.070612097816354e-8, 0.9632341714743309, -0.5877775478177794, 1.5143189193110465, -0.8619057261773254, -0.04563751290039998, 1.493753202547408, 0.3929865232660756, 0.3144313176017014, 0.02999755994676683, -0.029575936325025438, 0.2585011782116537, 6.561905218417997e-8, -7.840063597155187, -0.2277908945852809, -0.00019226199038493234, -8.615970964912231, -0.015375784664400687, 0.9854859077520338, 0.35264619603819136, -0.1455217831653319, 0.029998721964137057, -0.057010908229208075,
166-
-0.09065260935706018, -8.653447595525189e-8, 6.459702521706873, 0.5652888666079168, -0.6639992091264718, 3.020935678454475, -0.010981861879533573, 1.8999486180785712, 0.4767000746505306, 0.3099041129858934, 0.029997421533340347, -0.000677475986573399, 0.22299475711912944, 2.9194977603015673e-8, -6.655776509123009, -0.004144753260705207, 0.0028197921641742747, -7.432365696094535, -7.313664045288635e-5, 0.022585451684508966, 0.37840223311722093, -0.012962335005372607, 0.029998759665832785, -0.04484894718050894, -0.018709076016894303, -7.208853680055674e-8, 1.6964858028612126, 0.1977112296712567, 3.295519051579319, -0.3448993355673044, -0.1360257577294032, 1.575852345040146, 0.4633745589270613, -0.09377988839444025, 0.029998896986993488, -0.0015649341362523825, -0.003652013551363397, -2.4981817856544117e-9, 2.656330472428428, 0.23638530230275412, 0.38603973735519714, 0.1208249566227207, 0.00032866611117734275, 0.051774433544048655, 0.543108869560303, 0.294825435037727, 0.029997306373749883, -0.13739876028170375, -0.18509290020490796, 2.0018394912833252e-7, -5.392323206693009, -0.19893911728985575, 0.09891875505772645, 6.433873311561829,
167-
-3.5319763124007437, 2.2716379105590336, 0.5280319930400308, 0.029427616694857592, 0.029997345415267766, 6.188799580920981e-20, 2.4903463163550593e-21, 4.911639361450669e-16, 1.58895399725716, 0.0005110489112549728, 0.04694833800247477, -6.34969334816791e-20, -2.3228133668370105e-20, -1.4418272517450767e-18, 0.5298438369751591, -0.03183889801132204, 0.029999002925945182, -3.528350416143663e-21, 6.617194627952165e-20, 1.0661056375916704e-15, 1.6267735556275007, -0.00012555443489016495, -0.005204036469135774, -1.5570145480554775e-18, -3.457487981432338e-21, 8.309401741933345e-20, 0.5381964461760903, -0.09511652750222786, 0.029998935973198977, 3.3952835589304447e-19, 4.564806492215736e-20, -1.5820947449642875e-16, 1.7301528615002686, -0.022586636896998424, -0.28101511497365944, -8.512851070761004e-19, -1.56519884944499e-18, -7.861488949920675e-18, 0.5927031648245079, 0.36786146767471367, 0.029997236552983333, 0.15845614558647408, -0.021331046796790255, -2.6683180694948455e-7, -6.1506936540955435, 0.3850250268876852, -0.06208674136021588, 0.5943245171790156, 5.281798549535106, -0.3795624991282996, 0.6246051141249892, 0.06692601485006958,
168-
0.029997185771465026, -0.7827343505535713, 0.0063040893634809525, 1.253509421990429e-6, 1.5554333188869556, -0.0003679414861786754, -0.43663920366531234, -0.012217027572522585, -0.4480160765048617, 26.087850149346753, 0.7644107912334863, -0.10684167972512111, 0.029998770977880018, 0.15888674304279835, -0.09284910325102662, -2.5561782366711e-7, 1.9038478829272165, -0.10274259951709455, -6.876910249442725, 3.0945533634136773, 2.7134425786966793e-6, -5.295509584063961, 0.7873305258304856, -0.17885453451990208, 0.029998734191221205, 0.18240322785924398, -0.10527871347180867, -2.9341817035907206e-7, 2.154470220878549, -0.43523449284704646, -7.552206447838509, 3.5088892765009883, 9.132940300022019e-8, -6.07941081639718, 0.797699578168697, -0.2449449301094816, 0.029998695457177985, 0.19311625283414027, -0.11146703795842461, -1.7920530914190386e-7, 2.1859263471360704, -0.6278127900525268, -7.875763426542622, 3.7151718402931464, 1.9768906588609457e-7, -6.436521510513785]
165+
requiredFinalStates = [0.9332444148719927, -0.18186375946917482, 0.029998496723088863, -0.7095844351271156, 0.6368810796715084, 1.1431730539638052e-6, -13.55399177130368, -0.4195497307485026, -51.792329122005135, -21.229276583242317, -23.65271117843232, 7.760065977747092e-9, 0.32515150301575696, 0.02772732166338023, 0.029997667867321085, -0.045381716219676516, 0.02493897962956464, 7.070490674697964e-8, 0.9632401023828058, -0.587752107356861, 1.5142775723756114, -0.8308437907785791, -1.5118949410141513, -3.060402901758649e-10, 0.3929844289831643, 0.314433585122503, 0.029997559950336535, -0.029577874153518823, 0.2585035512496271, 6.562161546067983e-8, -7.840146246994674, -0.22780371618092327, -0.00020162400471457242, -8.616030351812999, -0.9858427871373034, -2.3612472293523234e-14, 0.35264703636149797, -0.14552149720426033, 0.02999872196545602, -0.057010164154041615, -0.09065225367155805, -8.653334203030665e-8, 6.4596790771415185, 0.5652982391883927, -0.6639956770706141, 3.0209829305889535, -1.8998615677380526, -3.721276589601545e-13, 0.47670041160434445, 0.3099020989631557, 0.02999742153252809, -0.0006771745035541265, 0.22299271411893493, 2.919510869411837e-8, -6.655710784224243, -0.004142759835172187, 0.0028186385660788622, -7.4322976108058185, -0.02257007572982667, -2.4790485630984114e-14, 0.3784043982268263, -0.012961976882662853, 0.029998759669299754, -0.04484621513685559, -0.018708473694112566, -7.208415990952376e-8, 1.696489265865553, 0.19770858382045625, 3.2954453850929006, 0.6232505252921184, -1.4939982597406876, -9.35266437450517e-11, 0.4633750773149139, -0.09377922898977689, 0.029998896987810348, -0.0015645848841219327, -0.0036512588493669246, -2.4976340466597957e-9, 2.656310601906443, 0.23637320741757925, 0.38602862990868586, 0.12079995980327145, -0.051763459921091576, -1.461410786250726e-17, 0.5431124217021193, 0.29482608052132353, 0.029997306367926288, -0.1373855246094424, -0.18509962057213744, 2.001605865571896e-7, -5.39236263389228, -0.19889516549128008, 0.09887028605103103, 6.169356127157017, -4.579048975962779, -2.756359955610583e-7, 0.5280322170861772, 0.029427663883163837, 0.02999734541490908, -1.1833800627228365e-19, -8.094474377232591e-21, 7.763826098786717e-17, 1.5889525688422277, 0.0005109396265548114, 0.046941118029524914, 1.8869591285393446e-19, -2.7527864363061138e-18, -2.1533611818933007e-36, 0.529843831576939, -0.03183878092969242, 0.02999900292593586, -5.8525596822436425e-21, -8.850182301368374e-21, 5.424843831620457e-16, 1.6267696790823423, -0.00012554063443316778, -0.005203877134152655, 2.08224161064226e-19, -1.3771645654742136e-19, -2.234919255877932e-36, 0.5381962700678454, -0.0951164266937725, 0.02999893597336097, 1.5087698845429358e-19, 5.912941216301715e-19, 2.1154381102488334e-16, 1.7301497001246133, -0.02258572430603368, -0.28100943887992064, -1.0917573384104563e-17, -7.381005727929696e-18, 2.3864512407351505e-32, 0.5927013302100363, 0.3678637189458646, 0.029997236556235103, 0.15844415347968727, -0.02131857192060813, -2.668097451793402e-7, -6.150776532309457, 0.38497287054741813, -0.06205687194704301, 0.7105058084277128, 5.280630043042688, -7.971472641188731e-9, 0.6246104386396446, 0.0669260214680636, 0.02999718576297974, -0.7827277924590241, 0.006304138587312076, 1.2534990629022721e-6, 1.555434445063634, -0.0003655522498851595, -0.43682627899981, -0.21013560502219034, -26.090634899286027, -1.3792679481687907e-10, 0.7644091593117449, -0.1068407152605166, 0.029998770980499467, 0.15888508724273556, -0.09284811916351207, -2.556151624667579e-7, 1.9038214920984562, -0.1027251696101419, -6.876859354817521, 3.0945196732121394, 5.295454907242669, -1.251811534378311e-12, 0.7873286476747228, -0.17885345102980393, 0.029998734194235585, 0.18240132001945608, -0.10527761167550502, -2.9341510496949545e-7, 2.1544586495625873, -0.4352003315815502, -7.552149739610728, 3.5088518053833653, 6.0793476492161975, 1.0573636616729651e-11, 0.7976924087312456, -0.2449407983426695, 0.02999869546380472, 0.19310891589363471, -0.11146281220155453, -1.791985202250327e-7, 2.1859305170863688, -0.6276776519171341, -7.875527052625196, 3.715030679234973, 6.4362771117007025, 7.752285500022615e-13]
169166
simulate!(billard, stopTime=testTime, tolerance=tolerance, interval=interval, log=true, useRecursiveFactorizationUptoSize=500, logStates=false, logEvents=false, requiredFinalStates=requiredFinalStates) # logTiming=true,
170167

171168
@usingModiaPlot

test/Collision/Billard4Balls.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,7 @@ stopTime = 5.0
109109
testTime = 2.5
110110
tolerance = 1e-8
111111
interval = 0.01
112-
requiredFinalStates = [-0.07276225904925236, 0.2453456530297493, 0.029998084681964913, -0.8131729732525697, 0.5077564852782904, -1.3054330162748875e-6, -42.63423883478191, 1.057147543314802, -60.857759531439584, 6.792698034233983, 31.176405211463067, -1.7514957638408275, -0.16326113730274155, 0.18382050752887918, 0.029997938439605354, -0.5825412482752137, 0.19956045698679084, -9.35615015465449e-7, 1.7229244023445067, -0.035543362353461956, 18.391320766547988,
113-
-6.6518712571402085, 2.4718947541234226e-5, 19.417623095449052, 0.41573795678955616, -0.26010343483884174, 0.029997529974735922, -0.004214932154558947, -0.5004735821234532, 4.336935240904981e-9, 11.774329191872447, 0.0041356928296786815, 0.009594145569267762, 16.680464236463397, -0.25872571383738985, -0.03100956782463096, 0.14788438085905078, -0.19122222797434096, 0.029997959251799728, -0.3027500332956257, -0.18012193238323354, 4.870923313573792e-7, 0.9532991179253845, 0.5248074513493877, 13.134794408356132, -2.240587263789671, -5.501727604570828, 10.128445467657514]
112+
requiredFinalStates = [-0.07275931054522237, 0.245345929634687, 0.029998084686692236, -0.8131715869137905, 0.5077564513202036, -1.3054307952123734e-6, -42.63401141766014, 1.0572321974473446, -60.85792815772321, -16.92514249042554, -27.10560336928497, -2.0098190928760517e-7, -0.16326306297598359, 0.1838211724164155, 0.02999793843651809, -0.5825422921046868, 0.1995608242777997, -9.356166915346368e-7, 1.7229051326940281, -0.03553401956048332, 18.391382536425706, -6.651884042852161, -19.41765770491842, -1.5008949570945262e-10, 0.41573792401066556, -0.26010411034360825, 0.029997529974785185, -0.0042149501111542675, -0.5004738043885597, 4.337011224944419e-9, 11.774352676190583, 0.004135604875985572, 0.009594011344653352, 16.681915255777486, -0.14049374801446188, 9.991754111353087e-13, 0.14788382539760303, -0.1912228312019073, 0.029997959252692587, -0.3027500651996917, -0.18012221710117013, 4.87092389687382e-7, 0.9533014101224873, 0.524794916392587, 13.134822395629266, 6.003727678413058, -10.091086903842799, -9.90430599231809e-12]
114113
simulate!(billard, stopTime=testTime, tolerance=tolerance, interval=interval, log=true, logStates=false, logEvents=false, useRecursiveFactorizationUptoSize=500, requiredFinalStates=requiredFinalStates) # logTiming=true,
115114

116115
@usingModiaPlot

0 commit comments

Comments
 (0)