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 *
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
29L = 0.5                # length of pendulum
30E=1e8                  # very soft elastomer
31rho=1000               # elastomer
32h=0.002                # height of rectangular beam element in m
33b=0.01                 # width of rectangular beam element in m
34A=b*h                  # cross sectional area of beam element in m^2
35I=b*h**3/12            # second moment of area of beam element in m^4
36nu = 0.3               # Poisson's ratio
37ks = 10*(1+nu)/(12+11*nu) # shear correction factor
38G = E/(2*(1+nu))          # shear modulus
39
40## create beam template with beam parameters
41beamTemplate = ObjectBeamGeometricallyExact2D(physicsMassPerLength=rho*A,
42                                              physicsCrossSectionInertia=rho*I,
43                                              physicsBendingStiffness=E*I,
44                                              physicsAxialStiffness=E*A,
45                                              physicsShearStiffness=ks*G*A,
46                                              visualization=VObjectBeamGeometricallyExact2D(drawHeight = h), )
47
48## create straight beam with 10 elements, apply gravity and fix (x,y) position of node 0 (rotation left free)
49beamInfo = GenerateStraightBeam(mbs, positionOfNode0=[0,0,0], positionOfNode1=[L,0,0],
50                                numberOfElements=10, beamTemplate=beamTemplate,
51                                gravity=[0,-9.81,0], fixedConstraintsNode0=[1,1,0],)
52#beamInfo contains [nodeList, beamList, ...]
53
54## assemble system and define simulation settings
55mbs.Assemble()
56
57simulationSettings = exu.SimulationSettings()
58
59tEnd = 1
60stepSize = 0.0025
61simulationSettings.timeIntegration.numberOfSteps = int(tEnd/stepSize)
62simulationSettings.timeIntegration.endTime = tEnd
63simulationSettings.timeIntegration.verboseMode = 1
64simulationSettings.solutionSettings.solutionWritePeriod = 0.005
65simulationSettings.solutionSettings.writeSolutionToFile = True
66
67simulationSettings.linearSolverType = exu.LinearSolverType.EigenSparse
68simulationSettings.timeIntegration.newton.useModifiedNewton = True #for faster simulation
69
70
71## add some visualization settings
72SC.visualizationSettings.nodes.defaultSize = 0.01
73SC.visualizationSettings.nodes.drawNodesAsPoint = False
74SC.visualizationSettings.bodies.beams.crossSectionFilled = True
75
76## run dynamic simulation
77mbs.SolveDynamic(simulationSettings)
78
79## visualize computed solution:
80mbs.SolutionViewer()