|
| 1 | +module BoxSpringDamperPtP |
| 2 | + |
| 3 | +using ModiaLang |
| 4 | + |
| 5 | +import Modia3D |
| 6 | +using Modia3D.ModiaInterface |
| 7 | + |
| 8 | +SpringDamper = Model( |
| 9 | + Length = 0.1, |
| 10 | + Mass = 1.0, |
| 11 | + Stiffness = 100.0, |
| 12 | + Damping = 2.0, |
| 13 | + visualMaterial = VisualMaterial(color="IndianRed1", transparency=0.5), |
| 14 | + world = Object3D(feature=Scene(gravityField=UniformGravityField(g=9.81, n=[0, 0, -1]), nominalLength=:Length)), |
| 15 | + worldFrame = Object3D(parent=:world, |
| 16 | + feature=Visual(shape=CoordinateSystem(length=:Length))), |
| 17 | + box = Object3D(feature=Solid(shape=Box(lengthX=:Length, lengthY=:Length, lengthZ=:Length), |
| 18 | + massProperties=MassProperties(; mass=1.0, Ixx=0.1, Iyy=0.1, Izz=0.1), |
| 19 | + visualMaterial=:(visualMaterial))), |
| 20 | + joint = FreeMotion(obj1=:world, obj2=:box, r=Var(init=[0.1, 0.2, 0.3])), |
| 21 | + force = SpringDamperPtP(obj1=:world, obj2=:box, stiffness=:Stiffness, damping=:Damping) |
| 22 | +) |
| 23 | + |
| 24 | +springDamper = @instantiateModel(buildModia3D(SpringDamper), aliasReduction=false, unitless=true) |
| 25 | + |
| 26 | +stopTime = 6.0 |
| 27 | +dtmax = 0.1 |
| 28 | +requiredFinalStates = [-0.026549009773552276, -0.05309801954749593, -0.10117097852565102, 0.0144068779028959, 0.028813755813570235, 0.02595802582858583, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0] |
| 29 | +simulate!(springDamper, stopTime=stopTime, dtmax=dtmax, log=true, requiredFinalStates=requiredFinalStates) |
| 30 | + |
| 31 | +@usingModiaPlot |
| 32 | +plot(springDamper, ["joint.r", "joint.v"], figure=1) |
| 33 | + |
| 34 | +end |
0 commit comments