LShapeGeomExactBeam2D.py

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

  1#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  2# This is an EXUDYN example
  3#
  4# Details:  Test model for GeometricallyExactBeam2D, evaluating behavior of rotated beam
  5#
  6# Model:    Planar model of L-shaped beams with tip load; the beam has 4 elements at each part of the L-shape:
  7#           the element length is 0.25m, the material is steel and height is 0.05m and with 0.1m; 
  8#           the L-shape is fixed at the left end to ground and a tip load of [1e6,0,0] is applied to the tip.
  9#
 10# Author:   Johannes Gerstmayr
 11# Date:     2021-03-25
 12#
 13# 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.
 14#
 15# *clean example*
 16#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 17
 18## import libaries
 19import exudyn as exu
 20from exudyn.utilities import * #includes itemInterface and rigidBodyUtilities
 21import exudyn.graphics as graphics
 22
 23import numpy as np
 24from math import sin, cos, pi
 25
 26testIsActive = exu.sys.get('testIsActive', False)
 27
 28## setup system container and mbs
 29SC = exu.SystemContainer()
 30mbs = SC.AddSystem()
 31
 32## define parameters for beams
 33a = 0.25
 34lElem = a              # length of one finite element 
 35E=2.1e11               # Steel; Young's modulus of beam element in N/m^2
 36rho=7800               # Steel; density of beam element in kg/m^3
 37b=0.1                  # width of rectangular beam element in m
 38h=0.05                 # height of rectangular beam element in m
 39A=b*h                  # cross sectional area of beam element in m^2
 40I=b*h**3/12            # second moment of area of beam element in m^4
 41nu = 0.3               # Poisson's ratio for steel
 42    
 43EI = E*I
 44EA = E*A
 45rhoA = rho*A
 46rhoI = rho*I
 47ks = 10*(1+nu)/(12+11*nu) # shear correction factor
 48G = E/(2*(1+nu))          # shear modulus
 49GA = ks*G*A               # shear stiffness of beam
 50
 51
 52## create position list for nodes:
 53nodeList=[]
 54pRefList=[[0,0],
 55          [1*a,0],
 56          [2*a,0],
 57          [3*a,0],
 58          [4*a,0],
 59          [4*a,1*a],
 60          [4*a,2*a],
 61          [4*a,3*a],
 62          [4*a,4*a],
 63          ]
 64
 65## create nodes
 66for p in pRefList:
 67    pRef = [p[0],p[1],0] #always angle zero, which is not considered in beam for includeReferenceRotations=False
 68    ni=mbs.AddNode(NodeRigidBody2D(referenceCoordinates = pRef, 
 69                                   initialCoordinates = [0,0,0], 
 70                                   initialVelocities= [0,0,0]))
 71    nodeList += [ni]
 72
 73## create beam elements:
 74for i in range(len(nodeList)-1):
 75    mbs.AddObject(ObjectBeamGeometricallyExact2D(nodeNumbers = [nodeList[i],nodeList[i+1]], 
 76                                                 length=lElem,
 77                                                 massPerLength=rhoA,
 78                                                 crossSectionInertia=rhoI,
 79                                                 bendingStiffness=EI,
 80                                                 axialStiffness=EA,
 81                                                 shearStiffness=GA,
 82                                                 includeReferenceRotations=False, #to connect beams at 90° at same node
 83                                                 visualization=VObjectBeamGeometricallyExact2D(drawHeight = h) ))
 84    
 85
 86#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 87## create ground node with marker for coordinate constraints
 88nGround = mbs.AddNode(NodePointGround(referenceCoordinates=[0,0,0]))    
 89mNCground = mbs.AddMarker(MarkerNodeCoordinate(nodeNumber=nGround, coordinate=0))
 90
 91## add markers and constraints for fixed support
 92n0 = nodeList[0]
 93mC0 = mbs.AddMarker(MarkerNodeCoordinate(nodeNumber=n0, coordinate=0))
 94mC1 = mbs.AddMarker(MarkerNodeCoordinate(nodeNumber=n0, coordinate=1))
 95mC2 = mbs.AddMarker(MarkerNodeCoordinate(nodeNumber=n0, coordinate=2))
 96mbs.AddObject(CoordinateConstraint(markerNumbers=[mNCground, mC0]))
 97mbs.AddObject(CoordinateConstraint(markerNumbers=[mNCground, mC1]))
 98mbs.AddObject(CoordinateConstraint(markerNumbers=[mNCground, mC2]))
 99
100#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
101## add tip load
102tipNodeMarker = mbs.AddMarker(MarkerNodeRigid(nodeNumber=nodeList[-1]))
103mbs.AddLoad(Force(markerNumber = tipNodeMarker, loadVector = [1e6, 0, 0]))
104    
105
106## assemble system and define simulation settings
107mbs.Assemble()
108
109simulationSettings = exu.SimulationSettings()
110    
111tEnd = 1
112steps = 2000
113simulationSettings.timeIntegration.numberOfSteps = steps
114simulationSettings.timeIntegration.endTime = tEnd
115simulationSettings.solution.file.writePeriod = tEnd/steps
116simulationSettings.timeIntegration.verboseMode = 1
117simulationSettings.solution.file.write = False
118
119#simulationSettings.solution.file.writePeriod = tEnd/steps
120simulationSettings.linearSolver.solverType = exu.LinearSolverType.EigenSparse
121    
122simulationSettings.timeIntegration.newton.useModifiedNewton = True
123
124
125simulationSettings.staticSolver.newton.maxIterations = 50
126simulationSettings.staticSolver.numberOfLoadSteps = 10
127# simulationSettings.show.computationTime = True
128# simulationSettings.show.statistics = True
129simulationSettings.staticSolver.newton.relativeTolerance = 1e-6
130
131## add some visualization settings
132SC.visualizationSettings.nodes.defaultSize = 0.005
133SC.visualizationSettings.bodies.beams.crossSectionFilled = False
134
135## start graphics
136if not testIsActive:
137    SC.renderer.Start()
138    SC.renderer.DoIdleTasks()
139
140## start static solver
141mbs.SolveStatic(simulationSettings)
142
143## print some output        
144uLast = mbs.GetNodeOutput(nodeList[-1], exu.OutputVariableType.Coordinates)
145exu.Print("uTip =", uLast[0:2])
146
147## stop graphics
148if not testIsActive:
149    SC.renderer.DoIdleTasks()
150    SC.renderer.Stop() #safely close rendering window!
151
152exu.Print('solution of LShapeGeomExactBeam2D=',uLast[1]) #use y-coordinate
153
154exu.sys['testResult'] = uLast[1]