coordinateSpringDamperExtVelocityOffsetTest.py
You can view and download this file on Github: coordinateSpringDamperExtVelocityOffsetTest.py
1#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2# This is an EXUDYN example
3#
4# Details: The velocityOffset of ObjectConnectorCoordinateSpringDamperExt in the built-in force law
5# k*(q - x_off) + d*(v - v_off) (#2867): a mass on a damper to the ground, started at rest, is driven by the
6# damper to the velocity v_off - after many time constants m/d its velocity is v_off.
7#
8# Author: Johannes Gerstmayr
9# Date: 2026-10-07
10#
11# Copyright:This file is part of Exudyn. Exudyn is free software. You can redistribute it and/or modify it under the terms of the Exudyn license. See 'LICENSE.txt' for more details.
12#
13#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
14
15import exudyn as exu
16from exudyn.utilities import * #includes itemInterface and rigidBodyUtilities
17
18testIsActive = exu.sys.get('testIsActive', False)
19
20mass, damping, velocityOffset = 1., 50., 0.7
21
22SC = exu.SystemContainer()
23mbs = SC.AddSystem()
24nGround = mbs.AddNode(NodePointGround())
25node = mbs.AddNode(Node1D(referenceCoordinates=[0], initialCoordinates=[0], initialVelocities=[0]))
26mbs.AddObject(ObjectMass1D(nodeNumber=node, mass=mass))
27mGround = mbs.AddMarker(MarkerNodeCoordinate(nodeNumber=nGround, coordinate=0))
28mNode = mbs.AddMarker(MarkerNodeCoordinate(nodeNumber=node, coordinate=0))
29nData = mbs.AddNode(NodeGenericData(numberOfDataCoordinates=3, initialCoordinates=[0,0,0]))
30mbs.AddObject(ObjectConnectorCoordinateSpringDamperExt(markerNumbers=[mGround, mNode], nodeNumber=nData,
31 stiffness=0, damping=damping, velocityOffset=velocityOffset))
32mbs.Assemble()
33
34simulationSettings = exu.SimulationSettings()
35simulationSettings.timeIntegration.numberOfSteps = 1000
36simulationSettings.timeIntegration.endTime = 1 #50 time constants m/d
37simulationSettings.timeIntegration.verboseMode = 0
38simulationSettings.solution.file.write = False
39mbs.SolveDynamic(simulationSettings)
40
41velocity = mbs.GetNodeOutput(node, exu.OutputVariableType.Coordinates_t) #a float, one coordinate
42exu.Print('velocity', velocity, ', expected', velocityOffset)
43errors = int(abs(velocity - velocityOffset) > 1e-8)
44exu.Print('coordinateSpringDamperExtVelocityOffsetTest: errors', errors)
45u = errors + velocity
46exu.Print('solution of coordinateSpringDamperExtVelocityOffsetTest=', u)
47exu.sys['testResult'] = u