pendulumGeomExactBeam2D.py

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

  1#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  2# This is an EXUDYN example
  3#
  4# Details:  Example for GeometricallyExactBeam2D, connected with 2D revolute joint; pendulum is modeled with 10 element
  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 *
 20
 21import numpy as np
 22# from math import sin, cos, pi
 23
 24## setup system container and mbs
 25SC = exu.SystemContainer()
 26mbs = SC.AddSystem()
 27
 28## define parameters for beams
 29nElements = 10
 30L = 0.5                # length of pendulum
 31lElem = L/nElements    # length of one finite element
 32E=1e8                  # very soft elastomer
 33rho=1000               # elastomer
 34h=0.002                # height of rectangular beam element in m
 35b=0.01                 # width of rectangular beam element in m
 36A=b*h                  # cross sectional area of beam element in m^2
 37I=b*h**3/12            # second moment of area of beam element in m^4
 38nu = 0.3               # Poisson's ratio
 39
 40EI = E*I
 41EA = E*A
 42rhoA = rho*A
 43rhoI = rho*I
 44ks = 10*(1+nu)/(12+11*nu) # shear correction factor
 45G = E/(2*(1+nu))          # shear modulus
 46GA = ks*G*A               # shear stiffness of beam
 47
 48g = [0,-9.81,0]           # gravity load
 49
 50## create nodes (one more than number of elements)
 51for i in range(nElements+1):
 52    pRef = [i*lElem,0,0]
 53    n = mbs.AddNode(NodeRigidBody2D(referenceCoordinates = pRef))
 54    if i==0: firstNode = n
 55
 56## create beam elements:
 57listBeams = []
 58for i in range(nElements):
 59    oBeam = mbs.AddObject(ObjectBeamGeometricallyExact2D(nodeNumbers = [firstNode+i,firstNode+i+1],
 60                                                            physicsLength=lElem,
 61                                                            physicsMassPerLength=rhoA,
 62                                                            physicsCrossSectionInertia=rhoI,
 63                                                            physicsBendingStiffness=EI,
 64                                                            physicsAxialStiffness=EA,
 65                                                            physicsShearStiffness=GA,
 66                                                            visualization=VObjectBeamGeometricallyExact2D(drawHeight = h)
 67                                                ))
 68    listBeams += [oBeam]
 69
 70## create ground node with marker for coordinate constraints
 71oGround = mbs.CreateGround(referencePosition=[0,0,0])
 72mGround = mbs.AddMarker(MarkerBodyPosition(bodyNumber=oGround, localPosition=[0,0,0]))
 73
 74## add revolute joint between ground and first node
 75mNode0 = mbs.AddMarker(MarkerNodePosition(nodeNumber=firstNode))
 76mbs.AddObject(ObjectJointRevolute2D(markerNumbers=[mGround, mNode0]))
 77
 78#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 79## add gravity loading for beams
 80for beam in listBeams:
 81    marker = mbs.AddMarker(MarkerBodyMass(bodyNumber=beam))
 82    mbs.AddLoad(LoadMassProportional(markerNumber=marker, loadVector=g))
 83
 84
 85## assemble system and define simulation settings
 86mbs.Assemble()
 87
 88simulationSettings = exu.SimulationSettings()
 89
 90tEnd = 5
 91stepSize = 0.0025
 92simulationSettings.timeIntegration.numberOfSteps = int(tEnd/stepSize)
 93simulationSettings.timeIntegration.endTime = tEnd
 94simulationSettings.timeIntegration.verboseMode = 1
 95simulationSettings.solutionSettings.solutionWritePeriod = 0.005
 96simulationSettings.solutionSettings.writeSolutionToFile = True
 97
 98simulationSettings.linearSolverType = exu.LinearSolverType.EigenSparse
 99simulationSettings.timeIntegration.newton.useModifiedNewton = True #for faster simulation
100
101
102## add some visualization settings
103SC.visualizationSettings.nodes.defaultSize = 0.01
104SC.visualizationSettings.nodes.drawNodesAsPoint = False
105SC.visualizationSettings.bodies.beams.crossSectionFilled = True
106
107## run dynamic simulation
108mbs.SolveDynamic(simulationSettings)
109
110## visualize computed solution:
111mbs.SolutionViewer()