pendulumGeomExactBeam2Dsimple.py

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

 1#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2# This is an EXUDYN example
 3#
 4# Details:  Example for GeometricallyExactBeam2D, connected with 2D revolute joint; uses GenerateStraightBeam
 5#
 6# Model:    Planar model of a highly flexible pendulum of length 0.5m with h=0.002m, b=0.01m, E=1e8 and density rho=1000kg/m^3;
 7#           The pendulum is released from the horizontal position under gravity acting in -y direction;
 8#
 9# Author:   Johannes Gerstmayr
10# Date:     2021-03-25
11#
12# 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.
13#
14# *clean example*
15#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
16
17## import libaries
18import exudyn as exu
19from exudyn.utilities import * #includes itemInterface and rigidBodyUtilities
20import exudyn.graphics as graphics #only import if it does not conflict
21
22import numpy as np
23# from math import sin, cos, pi
24
25## setup system container and mbs
26SC = exu.SystemContainer()
27mbs = SC.AddSystem()
28
29## define parameters for beams
30L = 0.5                # length of pendulum
31E=1e8                  # very soft elastomer
32rho=1000               # elastomer
33h=0.002                # height of rectangular beam element in m
34b=0.01                 # width of rectangular beam element in m
35A=b*h                  # cross sectional area of beam element in m^2
36I=b*h**3/12            # second moment of area of beam element in m^4
37nu = 0.3               # Poisson's ratio
38ks = 10*(1+nu)/(12+11*nu) # shear correction factor
39G = E/(2*(1+nu))          # shear modulus
40
41## create beam template with beam parameters
42beamTemplate = ObjectBeamGeometricallyExact2D(physicsMassPerLength=rho*A,
43                                              physicsCrossSectionInertia=rho*I,
44                                              physicsBendingStiffness=E*I,
45                                              physicsAxialStiffness=E*A,
46                                              physicsShearStiffness=ks*G*A,
47                                              visualization=VObjectBeamGeometricallyExact2D(drawHeight = h), )
48
49## create straight beam with 10 elements, apply gravity and fix (x,y) position of node 0 (rotation left free)
50beamInfo = GenerateStraightBeam(mbs, positionOfNode0=[0,0,0], positionOfNode1=[L,0,0],
51                                numberOfElements=10, beamTemplate=beamTemplate,
52                                gravity=[0,-9.81,0], fixedConstraintsNode0=[1,1,0],)
53#beamInfo contains [nodeList, beamList, ...]
54
55## assemble system and define simulation settings
56mbs.Assemble()
57
58simulationSettings = exu.SimulationSettings()
59
60tEnd = 1
61stepSize = 0.0025
62simulationSettings.timeIntegration.numberOfSteps = int(tEnd/stepSize)
63simulationSettings.timeIntegration.endTime = tEnd
64simulationSettings.timeIntegration.verboseMode = 1
65simulationSettings.solutionSettings.solutionWritePeriod = 0.005
66simulationSettings.solutionSettings.writeSolutionToFile = True
67
68simulationSettings.linearSolverType = exu.LinearSolverType.EigenSparse
69simulationSettings.timeIntegration.newton.useModifiedNewton = True #for faster simulation
70
71
72## add some visualization settings
73SC.visualizationSettings.nodes.defaultSize = 0.01
74SC.visualizationSettings.nodes.drawNodesAsPoint = False
75SC.visualizationSettings.bodies.beams.crossSectionFilled = True
76
77## run dynamic simulation
78mbs.SolveDynamic(simulationSettings)
79
80## visualize computed solution:
81mbs.SolutionViewer()