Skip to content

Commit be4d1bf

Browse files
Add adaptive rotation sequence test
- Add test model ShaftFreeMotionAdaptiveRotSequence.jl. - Update reference results of BouncingCapsules.jl and CollidingCylinders.jl.
1 parent 826fb7e commit be4d1bf

File tree

4 files changed

+43
-2
lines changed

4 files changed

+43
-2
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
module ShaftFreeMotionAdaptiveRotSequence
2+
3+
using ModiaLang
4+
5+
import Modia3D
6+
using Modia3D.ModiaInterface
7+
8+
Shaft = Model(
9+
Length = 1.0,
10+
Diameter = 0.2,
11+
visualMaterial = VisualMaterial(color="IndianRed1", transparency=0.5),
12+
world = Object3D(feature=Scene(gravityField=UniformGravityField(g=0.3, n=[0, 0, -1]))),
13+
worldFrame = Object3D(parent=:world,
14+
feature=Visual(shape=CoordinateSystem(length=:Diameter))),
15+
shaft = Object3D(feature=Solid(shape=Cylinder(axis=3, diameter=:Diameter, length=:Length),
16+
massProperties=MassProperties(; mass=84.7154, Ixx=7.2711, Iyy=7.2711, Izz=0.4230),
17+
visualMaterial=:(visualMaterial))),
18+
shaftFrame = Object3D(parent=:shaft, feature=Visual(shape=CoordinateSystem(length=0.4))),
19+
free = FreeMotion(obj1=:world, obj2=:shaft, v = Var(init = [0.0, 0.1, 0.0]),
20+
rot = Var(start = [deg2rad(30), deg2rad(90), deg2rad(10)]),
21+
w = Var(init = [-2.0, 0.0, 0.0]))
22+
)
23+
24+
#@showModel model
25+
26+
shaft = @instantiateModel(buildModia3D(Shaft), aliasReduction=false, unitless=true, log=false, logStateSelection=false, logCode=true)
27+
28+
#@showModel shaft.p[1]
29+
30+
stopTime = 7.0
31+
dtmax = 0.1
32+
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]
33+
simulate!(shaft, stopTime=stopTime, dtmax=dtmax, log=true, logEvents=true, logStates=true, requiredFinalStates=requiredFinalStates)
34+
35+
@usingModiaPlot
36+
plot(shaft, "free.rot", figure=1)
37+
plot(shaft, ["free.r", "free.v", "free.w"], figure=2)
38+
plot(shaft, "free.isrot123", figure=3)
39+
40+
end

test/Collision/BouncingCapsules.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ bouncingCapsules = @instantiateModel(buildModia3D(BouncingCapsules), unitless=tr
7171

7272
stopTime = 1.7
7373
tolerance = 1e-8
74-
requiredFinalStates = [-0.7964014792034407, 1.078911579441921, 0.23035036015771998, -0.10969534535624982, 0.4797449365169936, -0.08174820851332286, 4.48271590323064, 1.340697608488989, -1.5392203655926255, 2.4243895450782937, 0.15531689730526202, -0.03915705292205236, 0.22862079147109046, -0.7970862046473598, 1.0806110815754162, -0.06460242891125959, -0.11431031161481991, 0.4851429973131076, 3.385569081576411, 0.1916283718909546, -1.6236830622142888, -0.06474401604033102, 2.4344556240272657, 0.2553659880626085, 1.0818397597553406, 0.22945140558263866, -0.7966137267737096, 0.4853616788402741, -0.07085422346062514, -0.09972138522555073, -1.5640086933709134, 0.19867779732620508, 3.386466331485274, 0.21808527847860343, -0.05743721435841237, 2.4419014448796816]
74+
requiredFinalStates = [-0.7964020579786201, 1.078911664590739, 0.23035071499249554, -0.11077716509170218, 0.4796475444580211, -0.08226573462808072, 2.944349048428646, -0.22998195076361025, 1.5634033775705642, 2.4243768357473545, 0.1525224150890733, -0.038478509902694046, 0.22862096684511138, -0.7970870633627486, 1.080611113333237, -0.06458397074339108, -0.11429374835354875, 0.4851467302974838, 3.3855692118273724, 0.19162868836235442, -1.6236815609521178, -0.06476968434945787, 2.4344563197987243, 0.25547076791303613, 1.0818397999295593, 0.22945161590171845, -0.7966147351633047, 0.4853706855582012, -0.07080711655835899, -0.09965214358471511, -1.5640102628973194, 0.198677718499869, 3.386466629188658, 0.2183469805758011, -0.05750372064225383, 2.441900102029629]
7575
simulate!(bouncingCapsules, stopTime=stopTime, tolerance=tolerance, log=true, logStates=true, logEvents=true, requiredFinalStates=requiredFinalStates)
7676

7777
@usingModiaPlot

test/Collision/CollidingCylinders.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ CollidingCylinders = @instantiateModel(buildModia3D(collidingCylinders), unitles
6464
stopTime = 0.7
6565
interval = 0.001
6666
tolerance = 1e-8
67-
finalStates = [-0.3000014767733773, -1.082193896696148, -0.538807311042302, -3.7592282983652485e-6, -2.5117143103911763, -3.747655431035406, 3.434780596077875, -1.557228662514374, 1.617103948525645, 0.03212608204313396, 0.005364383932787988, 0.5421088990973728, -3.042579138039232e-7, -1.0813130417689532, -0.5361375150624056, -7.007175995563201e-7, -2.5091653603011435, -3.740308350308572, 0.27706268760792585, 0.011027339253852072, -0.0002832776767408359, -0.4592873394400626, 0.021172006600497985, -0.005240358556866595, 0.3000003035109844, -1.0823403796115827, -0.5378963004593084, 8.132044608411955e-7, -2.5121486704670146, -3.7451155263449594, 1.8287413219661708, 0.0005856583646075422, -0.019142491087689967, -0.511322469433515, -0.007676420293499906, -0.04351478584418659]
67+
finalStates = [-0.30000147673424027, -1.0821894508242909, -0.538811852088862, -3.759119556479151e-6, -2.5117018573833905, -3.7476680296826625, 1.817608404169296, 0.013553105247564751, -1.5714244416104344, 0.03212606979536095, 0.00536665196342571, 0.542287981818279, -3.047652067403568e-7, -1.0812725451928507, -0.5361775639705109, -7.021337266687022e-7, -2.5090523241255, -3.740419958819709, 0.27649518909889026, 0.011027463354492903, -0.0002830538200861146, -0.46087185173271833, 0.021172020323051804, -0.005256602277424596, 0.3000003035209966, -1.082336688455465, -0.5378999423616966, 8.132331099978069e-7, -2.512138357077455, -3.745125586833228, 1.8286909350734994, 0.0005856724448846079, -0.019142484609771897, -0.5114636872268571, -0.007678927847461636, -0.04351478288763072]
6868
simulate!(CollidingCylinders, stopTime=stopTime, interval=interval, tolerance=tolerance, log=true, logStates=true, logEvents=true, requiredFinalStates=finalStates)
6969

7070
@usingModiaPlot

test/includeTests.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Test.@testset "Basic" begin
1212
include(joinpath("Basic", "Mobile.jl"))
1313
include(joinpath("Basic", "BoxPlanarMotion.jl"))
1414
include(joinpath("Basic", "ShaftFreeMotion.jl"))
15+
include(joinpath("Basic", "ShaftFreeMotionAdaptiveRotSequence.jl"))
1516
Test.@test_throws LoadError include(joinpath("Basic", "Object3DWithoutParentError.jl"))
1617
end
1718

0 commit comments

Comments
 (0)