interactiveTutorial.py

You can view and download this file on Github: interactiveTutorial.py

 1#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2# This is an EXUDYN example
 3#
 4# Details:  Example for interactive mode; NOTE: the following lines can be entered using mbs.interactiveMode=True
 5#
 6# Author:   Johannes Gerstmayr
 7# Date:     2020-03-15
 8#
 9# 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.
10#
11#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
12
13#%%+++++++++++++++++++++++++++++++++++++++
14#import according libraries
15import exudyn as exu
16from exudyn.itemInterface import *
17
18#setup multibody system
19SC = exu.SystemContainer()
20mbs = SC.AddSystem()
21
22#show properties
23mbs
24
25#%%+++++++++++++++++++++++++++++++++++++++
26#start interactive mode
27mbs.interactiveMode=True
28
29#start graphics visualization
30exu.StartRenderer()
31
32#better visible nodes:
33SC.visualizationSettings.nodes.drawNodesAsPoint=False
34#make nodes bigger
35SC.visualizationSettings.nodes.defaultSize=0.1
36#modify system online
37
38#add nodes
39mbs.AddNode(NodePoint())
40mbs.AddNode(NodePoint(referenceCoordinates=[1,0,0]))
41
42#add objects
43mbs.AddObject(ObjectMassPoint(nodeNumber=0,physicsMass=1))
44mbs.AddObject(ObjectMassPoint(nodeNumber=1,physicsMass=1))
45
46
47#add marker
48m0=mbs.AddMarker(MarkerNodePosition(nodeNumber=0))
49
50#add load
51mbs.AddLoad(LoadForceVector(markerNumber=m0,loadVector=[0,-1,0]))
52
53#prepare system for simulation
54mbs.Assemble()
55
56#simulate with default parameters
57mbs.SolveDynamic(exu.SimulationSettings())
58
59#stop rendering window
60exu.StopRenderer()
61
62#visualize results:
63mbs.SolutionViewer()
64
65#mbs can be still modified and work can be continued!