xExudynConfigSpecial.py
You can view and download this file on Github: xExudynConfigSpecial.py
1#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2# This is an EXUDYN example
3#
4# Details: A test for exudyn variables and functions, config, special, ...
5# Mainly to check if something crashes
6#
7# Author: Johannes Gerstmayr
8# Date: 2025-05-22
9#
10# 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.
11#
12#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
13
14import exudyn as exu #EXUDYN package including C++ core part
15from exudyn.utilities import *
16import time
17
18exu.Help()
19
20#++++++++++++++++++++++++++++++++++++++++
21SC = exu.SystemContainer() #container of systems
22mbs = SC.AddSystem() #add a new system to work with
23
24nMP = mbs.AddNode(NodePoint2D(referenceCoordinates=[0,0]))
25mbs.AddObject(ObjectMassPoint2D(physicsMass=10, nodeNumber=nMP ))
26mMP = mbs.AddMarker(MarkerNodePosition(nodeNumber = nMP))
27mbs.AddLoad(Force(markerNumber = mMP, loadVector=[0.001,0,0]))
28
29mbs.Assemble() #assemble system and solve
30
31#++++++++++++++++++++++++++++++++++++++++
32#test some special exudyn member variables and functions:
33exu.Print('EXUDYN version='+exu.config.Version())
34exu.Print('EXUDYN version with details='+exu.config.Version(addDetails=True))
35
36#+++++++++++++++++++++++++++++++++++++++++++++++++++++
37#store old settings
38outputPrecision = exu.config.outputPrecision
39suppressWarnings = exu.config.suppressWarnings
40timeout = exu.special.solver.timeout
41throwErrorWithCtrlC = exu.special.solver.throwErrorWithCtrlC
42eigenFullPivotLUsolverDebugLevel = exu.experimental.eigenFullPivotLUsolverDebugLevel
43markerSuperElementRigidTexpSO3 = exu.experimental.markerSuperElementRigidTexpSO3
44
45printToConsole = exu.config.printToConsole
46printFileName = exu.config.printFileName
47printToFile = exu.config.printToFile
48printToFileAppend = exu.config.printToFileAppend
49printFlushAlways = exu.config.printFlushAlways
50printDelayMilliSeconds = exu.config.printDelayMilliSeconds
51linalgOutputFormatPython = exu.config.linalgOutputFormatPython
52#+++++++++++++++++++++++++++++++++++++++++++++++++++++
53
54exu.config.outputPrecision = 4
55exu.config.suppressWarnings = True
56exu.config.printFlushAlways = True
57exu.config.printDelayMilliSeconds = 10
58
59exu.special.solver.timeout=2
60exu.special.solver.throwErrorWithCtrlC=0
61exu.special.exceptions.dictionaryVersionMismatch=False
62exu.special.exceptions.dictionaryNonCopyable=False
63exu.experimental.eigenFullPivotLUsolverDebugLevel=True
64exu.experimental.markerSuperElementRigidTexpSO3=False
65
66exu.Print(exu.config)
67exu.Print(exu.special)
68exu.Print(exu.experimental)
69exu.Print(exu.special.exceptions)
70exu.special.InfoStat()
71
72
73#during test, we have to store current behavior
74
75exu.SetWriteToFile('solution/test.txt')
76exu.config.printToConsole = True
77exu.Print('\n*****\nThis should be visible in testExamples: test:',42,{'a':'b'},end="\n*****\n", sep=" - ", flush=True)
78exu.config.printToConsole = printToConsole
79#exu.SetWriteToFile('',False)
80
81for i in range(10):
82 exu.Print('\rtest flush=True',42+i,end=" *", sep=":", flush=True)
83 time.sleep(0.01)
84exu.Print('\n')
85for i in range(10):
86 exu.Print('\rtest flush=False:',i,end=" *", flush=False)
87 time.sleep(0.01)
88exu.Print('\n')
89exu.Print('\rtest flush=False with end="\\n":',i,sep='',end="\n", flush=False)
90
91exu.Print('\nend')
92
93
94
95#++++++++++++++++++++++++++++++++++++++++
96
97simulationSettings = exu.SimulationSettings()
98simulationSettings.timeIntegration.verboseMode=3 #provide detailed output
99simulationSettings.timeIntegration.endTime=0.001
100simulationSettings.timeIntegration.numberOfSteps=1
101mbs.SolveDynamic(simulationSettings)
102exu.config.linalgOutputFormatPython = False
103mbs.SolveDynamic(simulationSettings) #now writing matlab format
104
105#run demo
106exu.demos.Demo1()
107exu.Print(exu.graphics.color.red)
108
109#+++++++++++++++++++++++++++++++++++++++++++++++++++++
110#store old settings
111exu.config.outputPrecision = outputPrecision
112exu.config.suppressWarnings = suppressWarnings
113exu.special.solver.timeout = timeout
114exu.special.solver.throwErrorWithCtrlC = throwErrorWithCtrlC
115exu.experimental.eigenFullPivotLUsolverDebugLevel = eigenFullPivotLUsolverDebugLevel
116exu.experimental.markerSuperElementRigidTexpSO3 = markerSuperElementRigidTexpSO3
117exu.SetWriteToFile(printFileName, flagWriteToFile=printToFile, flagAppend=True)
118exu.config.printFlushAlways = printFlushAlways
119exu.config.printDelayMilliSeconds = printDelayMilliSeconds
120exu.config.linalgOutputFormatPython = linalgOutputFormatPython
121#+++++++++++++++++++++++++++++++++++++++++++++++++++++
122
123exu.Print('*** Within runExampleTests.py: This text should only be visible in file, not in console ***')