|
| 1 | +module BouncingEllipsoidSimulation |
| 2 | + |
| 3 | +using ModiaLang |
| 4 | +import Modia3D |
| 5 | +using Modia3D.ModiaInterface |
| 6 | + |
| 7 | +BouncingEllipsoid = Model( |
| 8 | + boxHeigth = 0.1, |
| 9 | + gravField = UniformGravityField(g=9.81, n=[0, -1, 0]), |
| 10 | + world = Object3D(feature=Scene(gravityField=:gravField, |
| 11 | + mprTolerance=1.0e-19, |
| 12 | + defaultFrameLength=0.2, |
| 13 | + enableContactDetection=true)), |
| 14 | + worldFrame = Object3D(parent=:world, feature=Visual(shape=CoordinateSystem(length=0.5))), |
| 15 | + ground = Object3D(parent=:world, |
| 16 | + translation=:[0.0,-boxHeigth/2,0.0], |
| 17 | + feature=Solid(shape=Sphere(diameter=1.5), |
| 18 | + visualMaterial=VisualMaterial(color="DarkGreen", transparency=0.5), |
| 19 | + solidMaterial="Steel", |
| 20 | + collision=true)), |
| 21 | + ellipsoid = Object3D(feature=Solid(shape=Ellipsoid(lengthX=0.1, lengthY=0.2, lengthZ=0.3), |
| 22 | + visualMaterial=VisualMaterial(color="Blue"), |
| 23 | + solidMaterial="Steel", |
| 24 | + collision=true)), |
| 25 | + free = FreeMotion(obj1=:world, obj2=:ellipsoid, r=Var(init=[0.0, 1.0, 0.0]), w=Var(init=[5.0, 0.0, -2.0])) |
| 26 | +) |
| 27 | + |
| 28 | +bouncingEllipsoid = @instantiateModel(buildModia3D(BouncingEllipsoid), unitless=true, log=false, logStateSelection=false, logCode=false) |
| 29 | + |
| 30 | + |
| 31 | +stopTime = 2.0 |
| 32 | +tolerance = 1e-8 |
| 33 | +requiredFinalStates = [1.9013751140911312, -5.182612613347552, -0.6285338998457255, 1.3889960373284438, -10.631628266236548, -0.35235710867283077, 2.6873629925159035, 0.23896916015991412, -8.030636545239265, 6.713810967152868, -1.2032068837594854, -12.984033346958665] |
| 34 | +simulate!(bouncingEllipsoid, stopTime=stopTime, tolerance=tolerance, log=true, requiredFinalStates=requiredFinalStates) |
| 35 | + |
| 36 | +@usingModiaPlot |
| 37 | +plot(bouncingEllipsoid, ["free.r" "free.rot"; "free.v" "free.w"], figure=1) |
| 38 | + |
| 39 | +end |
0 commit comments