Skip to content

Commit

Permalink
switch to exudyn.graphics, fixes for stable-baselines, compute linear…
Browse files Browse the repository at this point in the history
…ized system and eigenvalues for constraints; more fixes see issue tracker
  • Loading branch information
jgerstmayr committed Jun 4, 2024
1 parent 5f89826 commit 30ec2d5
Show file tree
Hide file tree
Showing 526 changed files with 10,188 additions and 7,583 deletions.
4 changes: 3 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,15 @@ Exudyn

**A flexible multibody dynamics systems simulation code with Python and C++**

Exudyn version = 1.8.32.dev1 (Jones)
Exudyn version = 1.8.52.dev1 (Jones)

+ **University of Innsbruck**, Department of Mechatronics, Innsbruck, Austria

If you like using Exudyn, please add a *star* on github and follow us on
`Twitter @RExudyn <https://twitter.com/RExudyn>`_ !

+ **Update on Exudyn V1.8.52**: newer examples use ``exudyn.graphics`` instead of ``GraphicsData`` functions. The old models are backwards-compatible, but the updated examples and test models require version 1.8.52 or newer! Install with ``pip install exudyn --pre -U``

+ **NOTE**: for pure installation, use **pip install exudyn** (see further description below)
+ *free, open source* and with plenty of *documentation* and *examples*
+ **pre-built** for Python 3.8 - 3.12 under **Windows** , **Linux** and **MacOS** available ( **NEW** : now with manylinux2014 compatibility and PEP518 build); build wheels yourself, see `theDoc.pdf <https://github.com/jgerstmayr/EXUDYN/blob/master/docs/theDoc/theDoc.pdf>`_ )
Expand Down
21 changes: 7 additions & 14 deletions docs/RST/Examples/ANCFALEtest.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ You can view and download this file on Github: `ANCFALEtest.py <https://github.c
# This is an EXUDYN example
#
# Details: ANCF ALE with under gravity
# Notes: This example fails to solve with the current settings; needs to be reworked
#
# Author: Johannes Gerstmayr
# Date: 2020-02-17
Expand All @@ -24,11 +23,8 @@ You can view and download this file on Github: `ANCFALEtest.py <https://github.c
#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
import exudyn as exu
from exudyn.itemInterface import *
# from exudyn.basicUtilities import *
# from exudyn.graphicsDataUtilities import *
from exudyn.utilities import *
from exudyn.utilities import * #includes itemInterface and rigidBodyUtilities
import exudyn.graphics as graphics #only import if it does not conflict
import numpy as np
from math import sqrt, sin, cos
Expand All @@ -51,16 +47,13 @@ You can view and download this file on Github: `ANCFALEtest.py <https://github.c
#++++++++++++++++++++++++++++++++++
#initialize variables
vALE0=1 #initial velocity
useGraphics = True
if useGraphics:
nElements = 32 #16
else:
nElements = 4
vALE0=2 #initial velocity
h= 4e-3
tEnd = 2
nElements = 8
vALE0=1 #initial velocity
h= 2e-3
tEnd = 2 #fails at higher times ... check if this is just unstable due to very flexible beam
damper = 0.01 #0.1: standard for parameter variation; 0.001: almost no damping, but solution is still oscillating at evaluation period
Expand Down
3 changes: 2 additions & 1 deletion docs/RST/Examples/ANCFcableCantilevered.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ You can view and download this file on Github: `ANCFcableCantilevered.py <https:
#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
import exudyn as exu
from exudyn.utilities import *
from exudyn.utilities import * #includes itemInterface and rigidBodyUtilities
import exudyn.graphics as graphics #only import if it does not conflict
from exudyn.beams import *
import numpy as np
Expand Down
3 changes: 2 additions & 1 deletion docs/RST/Examples/ANCFcantileverTest.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ You can view and download this file on Github: `ANCFcantileverTest.py <https://g
## import exudyn and utilities
import exudyn as exu
from exudyn.utilities import *
from exudyn.utilities import * #includes itemInterface and rigidBodyUtilities
import exudyn.graphics as graphics #only import if it does not conflict
## create container and main system to work with
SC = exu.SystemContainer()
Expand Down
13 changes: 7 additions & 6 deletions docs/RST/Examples/ANCFcontactCircle2.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ You can view and download this file on Github: `ANCFcontactCircle2.py <https://g
#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
import exudyn as exu
from exudyn.utilities import *
from exudyn.utilities import * #includes itemInterface and rigidBodyUtilities
import exudyn.graphics as graphics #only import if it does not conflict
SC = exu.SystemContainer()
Expand All @@ -40,11 +41,11 @@ You can view and download this file on Github: `ANCFcontactCircle2.py <https://g
background1 = {'type':'Line', 'color':[0.1,0.1,0.8,1], 'data':[0,-1,0, 2,-1,0]} #background
background = [GraphicsDataRectangle(-0.5,-1,2.5,1, color=color4blue)]
background += [GraphicsDataLine([[0,-1,0], [2,-1,0]], color=color4green)]
background += [GraphicsDataCircle(point=pCircle, radius = circleRadius-0.002, color=color4blue)] #not necessary, as it is drawn by connector
background += [GraphicsDataCircle(point=pCircle2, radius = circleRadius2-0.002, color=color4blue)] #not necessary, as it is drawn by connector
background += [GraphicsDataText(point=[0.,0.2,0], text = 'ANCF contact with circle', color=color4black)]
background = [GraphicsDataRectangle(-0.5,-1,2.5,1, color=graphics.color.blue)]
background += [graphics.Lines([[0,-1,0], [2,-1,0]], color=graphics.color.green)]
background += [graphics.Circle(point=pCircle, radius = circleRadius-0.002, color=graphics.color.blue)] #not necessary, as it is drawn by connector
background += [graphics.Circle(point=pCircle2, radius = circleRadius2-0.002, color=graphics.color.blue)] #not necessary, as it is drawn by connector
background += [graphics.Text(point=[0.,0.2,0], text = 'ANCF contact with circle', color=graphics.color.black)]
oGround=mbs.AddObject(ObjectGround(referencePosition= [0,0,0], visualization=VObjectGround(graphicsData= background)))
Expand Down
7 changes: 4 additions & 3 deletions docs/RST/Examples/ANCFrotatingCable2D.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,15 @@ You can view and download this file on Github: `ANCFrotatingCable2D.py <https://
#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
import exudyn as exu
from exudyn.utilities import *
from exudyn.utilities import * #includes itemInterface and rigidBodyUtilities
import exudyn.graphics as graphics #only import if it does not conflict
SC = exu.SystemContainer()
mbs = SC.AddSystem()
#background
background = GraphicsDataCheckerBoard(point=[0,0,-0.1],size = 5)
background = graphics.CheckerBoard(point=[0,0,-0.1],size = 5)
oGround=mbs.AddObject(ObjectGround(referencePosition= [0,0,0], visualization=VObjectGround(graphicsData= [background])))
#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Expand Down Expand Up @@ -83,7 +84,7 @@ You can view and download this file on Github: `ANCFrotatingCable2D.py <https://
if True:
#create rigid body:
gBody = GraphicsDataOrthoCubePoint(size = [h,h,h], color=color4red)
gBody = graphics.Brick(size = [h,h,h], color=graphics.color.red)
dictBody = mbs.CreateRigidBody(referencePosition=[0,0,0],
inertia = InertiaCuboid(1000, [h,h,h]),
graphicsDataList=[gBody],
Expand Down
3 changes: 2 additions & 1 deletion docs/RST/Examples/ANCFswitchingSlidingJoint2D.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ You can view and download this file on Github: `ANCFswitchingSlidingJoint2D.py <
import exudyn as exu
from exudyn.itemInterface import *
from exudyn.utilities import *
from exudyn.utilities import * #includes itemInterface and rigidBodyUtilities
import exudyn.graphics as graphics #only import if it does not conflict
SC = exu.SystemContainer()
mbs = SC.AddSystem()
Expand Down
3 changes: 2 additions & 1 deletion docs/RST/Examples/CMSexampleCourse.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ You can view and download this file on Github: `CMSexampleCourse.py <https://git
import exudyn as exu
from exudyn.utilities import *
from exudyn.utilities import * #includes itemInterface and rigidBodyUtilities
import exudyn.graphics as graphics #only import if it does not conflict
from exudyn.FEM import *
import numpy as np
from math import sqrt, sin, cos, pi
Expand Down
27 changes: 11 additions & 16 deletions docs/RST/Examples/ComputeSensitivitiesExample.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ You can view and download this file on Github: `ComputeSensitivitiesExample.py <
import numpy as np #for postprocessing
useGraphics = True
#this is the function which is repeatedly called from ComputeSensitivities
#parameterSet contains dictinary with varied parameters
def ParameterFunction(parameterSet):
Expand Down Expand Up @@ -82,10 +84,9 @@ You can view and download this file on Github: `ComputeSensitivitiesExample.py <
mbs.AddLoad(LoadCoordinate(markerNumber = nodeMarker,
load = P.force))
#add sensor:
fileName = 'solution/paramVarDisplacement'+ str(P.computationIndex) +'.txt'#
flagWriteFile = False
if P.computationIndex == 'Ref': flagWriteFile = True
sData = mbs.AddSensor(SensorObject(objectNumber=nC, fileName=fileName,
sData = mbs.AddSensor(SensorObject(objectNumber=nC, storeInternal=True,
outputVariableType=exu.OutputVariableType.Force,
writeToFile=flagWriteFile))
Expand All @@ -100,8 +101,8 @@ You can view and download this file on Github: `ComputeSensitivitiesExample.py <
simulationSettings.timeIntegration.endTime = tEnd
simulationSettings.timeIntegration.generalizedAlpha.spectralRadius = 1 #no damping
if not(flagWriteFile):
sRecorder = AddSensorRecorder(mbs, sData, tEnd, simulationSettings.solutionSettings.sensorsWritePeriod, sensorOutputSize=1)
# if not(flagWriteFile):
# sRecorder = AddSensorRecorder(mbs, sData, tEnd, simulationSettings.solutionSettings.sensorsWritePeriod, sensorOutputSize=1)
#exu.StartRenderer() #start graphics visualization
#mbs.WaitForUserToContinue() #wait for pressing SPACE bar to continue
Expand All @@ -115,13 +116,7 @@ You can view and download this file on Github: `ComputeSensitivitiesExample.py <
#+++++++++++++++++++++++++++++++++++++++++++++++++++++
#evaluate difference between reference and optimized solution
#reference solution:
if flagWriteFile:
data = np.loadtxt(fileName, comments='#', delimiter=',')
else:
data = mbs.variables['sensorRecord0']
data = mbs.GetSensorStoredData(sData)
avgPos = np.average(np.abs(data))
#+++++++++++++++++++++++++++++++++++++++++++++++++++++
#compute exact solution:
Expand All @@ -148,26 +143,26 @@ You can view and download this file on Github: `ComputeSensitivitiesExample.py <
import time
useMultiProcessing = exudyn
start_time = time.time()
n = [2, 2]
fVar = [1e-3, 1.5e-3, 1]
n = [2, 2] #number of variations
fVar = [1e-3, 1.5e-3, 1] #differentiation eps
mRef = 1.5
kRef = 4000
[pList, valRef, valuesSorted, sensitivity] = ComputeSensitivities(parameterFunction=ParameterFunction,
parameters = {'mass': (mRef, fVar[0], n[0]),
'spring': (kRef,fVar[1], n[1]),
},
scaledByReference=False,
debugMode=True,
debugMode=useGraphics,
addComputationIndex=True,
useMultiProcessing=False,
showProgress=True,)
showProgress=useGraphics)
testResult = np.average(np.abs(sensitivity))
if True:
print("--- %s seconds ---" % (time.time() - start_time))
PlotSensitivityResults(valRef, valuesSorted, sensitivity, strYAxis=['avg. $|x|$', 'x0', ''])
else:
exu.Print('result of ConvexContactTest=',testResult)
exu.Print('result of Sensitivities Examaple=',testResult)
Expand Down
Loading

0 comments on commit 30ec2d5

Please sign in to comment.