Bending a cantilever beam

Using PatchMesher to model the beam

import math
import sys
import numpy as np

from femedu.examples import Example

from femedu.domain import System, Node
from femedu.solver import NewtonRaphsonSolver
#from femedu.elements.linear import Quad
from femedu.elements.finite import Quad
from femedu.materials import PlaneStress
from femedu.mesher import *


class ExamplePlate11(Example):

    def problem(self):
        # ========== setting mesh parameters ==============

        Nx = 24       # number of elements in the mesh
        Ny = 8        # number of elements in the mesh
        Lx = 120.0    # length of plate in the x-direction
        Ly =  20.0    # length of plate in the y-direction

        # ========== setting material parameters ==============

        params = dict(
            E  = 20000.,    # Young's modulus
            nu = 0.250,     # Poisson's ratio
            t  = 1.00       # thickness of the plate
        )

        # ========== setting load parameters ==============

        px  =  0.0         # uniform load normal to x=Lx
        py  =  0.0         # uniform load normal to y=Ly
        pxy =  1.5         # uniform shear load on x=L

        # ========== setting analysis parameters ==============

        target_load_level = 100.00    # reference load
        max_steps = 21                # number of load steps: 2 -> [0.0, 1.0]

        # target_load_level = 10.00    # reference load
        # max_steps = 3                # number of load steps: 2 -> [0.0, 1.0]

        # define a list of target load levels
        load_levels = np.linspace(0, target_load_level, max_steps)

        #
        # ==== Build the system model ====
        #

        model = System()
        model.setSolver(NewtonRaphsonSolver())

        # create nodes

        mesher = PatchMesher(model, (0.,0.),(Lx,0.),(Lx,Ly),(0.,Ly) )
        nodes, elements = mesher.quadMesh(Nx, Ny, Quad, PlaneStress(params))

        # define support(s)

        ## find nodes at y==0 and x==0

        for node in nodes:
            X = node.getPos()
            if math.isclose(X[0], 0.0):
                node.fixDOF('ux','uy')    # fix left side

        # ==== complete the reference load ====

        Xo = np.array([Lx, 0.0])
        No = np.array([1.0, 0.0])

        for node in nodes:
            X = node.getPos()
            if math.isclose(X[0],Lx):
                # locate the node at the centerline
                if math.isclose(X[1],Ly/2.):
                    end_node = node
                # load the end faces
                for elem in node.elements:
                    for face in elem.faces:
                        for x, area in zip(face.pos, face.area):
                            if np.abs( (x - Xo) @ No ) < 1.0e-2 and  No @ area / np.linalg.norm(area):
                                face.setLoad(px, -pxy)

        Xo = np.array([0.0, Ly])
        No = np.array([0.0, 1.0])

        for node in nodes:
            X = node.getPos()
            if math.isclose(X[1],Ly):
                for elem in node.elements:
                    for face in elem.faces:
                        for x, area in zip(face.pos, face.area):
                            if np.abs( (x - Xo) @ No ) < 1.0e-2 and  No @ area / np.linalg.norm(area):
                                face.setLoad(-py, 0.0)

        #model.report()

        # set up a recorder
        model.initRecorder(variables=['ux','uy'], nodes=[end_node])
        model.startRecorder()

        model.plot(factor=0, title="undeformed system", filename="plate11_undeformed.png", show_bc=1, show_loads=1)

        for lf in np.linspace(0.0, target_load_level, max_steps):

            model.setLoadFactor(lf)
            model.solve(verbose=True)

            #model.report()


        model.plot(factor=1., filename=f"plate11_deformed_lf{lf:.2f}.png", show_bc=1, show_loads=1, show_reactions=1)

        model.valuePlot('ux', filename=f"plate11_ux_lf{lf:.2f}.png")
        model.valuePlot('uy', show_mesh=True, filename=f"plate11_uy_lf{lf:.2f}.png")

        # create a history plot for the end node

        model.historyPlot('lam', ['ux','uy'], nodes=[end_node,end_node])
        model.historyPlot(('ux',end_node), 'uy', node=end_node)

Run the example by creating an instance of the problem and executing it by calling Example.run()

if __name__ == "__main__":
    ex = ExamplePlate11()
    ex.run()
  • undeformed system
  • Deformed System (magnification=1.00)
  • Contours of 'ux'
  • Contours of 'uy'
  • Load History Plot
  • Load History Plot
norm of the out-of-balance force:   1.2214e-09
Recorder.addData: 'stability' not initialized by the recorder: ignored
+
norm of the out-of-balance force:   5.1349e+01
norm of the out-of-balance force:   1.9467e+03
norm of the out-of-balance force:   7.9605e+00
norm of the out-of-balance force:   2.3934e-04
norm of the out-of-balance force:   3.0140e-09
Recorder.addData: 'stability' not initialized by the recorder: ignored
+
norm of the out-of-balance force:   5.1349e+01
norm of the out-of-balance force:   1.9219e+03
norm of the out-of-balance force:   7.7868e+00
norm of the out-of-balance force:   2.3191e-02
norm of the out-of-balance force:   4.4781e-07
Recorder.addData: 'stability' not initialized by the recorder: ignored
+
norm of the out-of-balance force:   5.1349e+01
norm of the out-of-balance force:   1.8506e+03
norm of the out-of-balance force:   7.2971e+00
norm of the out-of-balance force:   7.4489e-02
norm of the out-of-balance force:   1.2426e-06
norm of the out-of-balance force:   2.5485e-09
Recorder.addData: 'stability' not initialized by the recorder: ignored
+
norm of the out-of-balance force:   5.1349e+01
norm of the out-of-balance force:   1.7413e+03
norm of the out-of-balance force:   6.5823e+00
norm of the out-of-balance force:   1.2884e-01
norm of the out-of-balance force:   1.7002e-06
norm of the out-of-balance force:   2.8543e-09
Recorder.addData: 'stability' not initialized by the recorder: ignored
+
norm of the out-of-balance force:   5.1349e+01
norm of the out-of-balance force:   1.6056e+03
norm of the out-of-balance force:   5.7552e+00
norm of the out-of-balance force:   1.6477e-01
norm of the out-of-balance force:   1.6049e-06
norm of the out-of-balance force:   3.0527e-09
Recorder.addData: 'stability' not initialized by the recorder: ignored
+
norm of the out-of-balance force:   5.1349e+01
norm of the out-of-balance force:   1.4556e+03
norm of the out-of-balance force:   4.9154e+00
norm of the out-of-balance force:   1.7389e-01
norm of the out-of-balance force:   1.1863e-06
norm of the out-of-balance force:   3.0253e-09
Recorder.addData: 'stability' not initialized by the recorder: ignored
+
norm of the out-of-balance force:   5.1349e+01
norm of the out-of-balance force:   1.3020e+03
norm of the out-of-balance force:   4.1306e+00
norm of the out-of-balance force:   1.6004e-01
norm of the out-of-balance force:   7.3543e-07
Recorder.addData: 'stability' not initialized by the recorder: ignored
+
norm of the out-of-balance force:   5.1349e+01
norm of the out-of-balance force:   1.1528e+03
norm of the out-of-balance force:   3.4348e+00
norm of the out-of-balance force:   1.3294e-01
norm of the out-of-balance force:   4.0033e-07
Recorder.addData: 'stability' not initialized by the recorder: ignored
+
norm of the out-of-balance force:   5.1349e+01
norm of the out-of-balance force:   1.0133e+03
norm of the out-of-balance force:   2.8379e+00
norm of the out-of-balance force:   1.0211e-01
norm of the out-of-balance force:   1.9726e-07
Recorder.addData: 'stability' not initialized by the recorder: ignored
+
norm of the out-of-balance force:   5.1349e+01
norm of the out-of-balance force:   8.8641e+02
norm of the out-of-balance force:   2.3355e+00
norm of the out-of-balance force:   7.3852e-02
norm of the out-of-balance force:   9.0733e-08
Recorder.addData: 'stability' not initialized by the recorder: ignored
+
norm of the out-of-balance force:   5.1349e+01
norm of the out-of-balance force:   7.7324e+02
norm of the out-of-balance force:   1.9174e+00
norm of the out-of-balance force:   5.1028e-02
norm of the out-of-balance force:   3.9545e-08
Recorder.addData: 'stability' not initialized by the recorder: ignored
+
norm of the out-of-balance force:   5.1349e+01
norm of the out-of-balance force:   6.7371e+02
norm of the out-of-balance force:   1.5719e+00
norm of the out-of-balance force:   3.4075e-02
norm of the out-of-balance force:   1.6925e-08
Recorder.addData: 'stability' not initialized by the recorder: ignored
+
norm of the out-of-balance force:   5.1349e+01
norm of the out-of-balance force:   5.8699e+02
norm of the out-of-balance force:   1.2876e+00
norm of the out-of-balance force:   2.2197e-02
norm of the out-of-balance force:   7.5164e-09
Recorder.addData: 'stability' not initialized by the recorder: ignored
+
norm of the out-of-balance force:   5.1349e+01
norm of the out-of-balance force:   5.1193e+02
norm of the out-of-balance force:   1.0547e+00
norm of the out-of-balance force:   1.4212e-02
norm of the out-of-balance force:   4.4972e-09
Recorder.addData: 'stability' not initialized by the recorder: ignored
+
norm of the out-of-balance force:   5.1349e+01
norm of the out-of-balance force:   4.4719e+02
norm of the out-of-balance force:   8.6434e-01
norm of the out-of-balance force:   8.9976e-03
norm of the out-of-balance force:   4.3767e-09
Recorder.addData: 'stability' not initialized by the recorder: ignored
+
norm of the out-of-balance force:   5.1349e+01
norm of the out-of-balance force:   3.9148e+02
norm of the out-of-balance force:   7.0914e-01
norm of the out-of-balance force:   5.6599e-03
norm of the out-of-balance force:   3.7459e-09
Recorder.addData: 'stability' not initialized by the recorder: ignored
+
norm of the out-of-balance force:   5.1349e+01
norm of the out-of-balance force:   3.4356e+02
norm of the out-of-balance force:   5.8278e-01
norm of the out-of-balance force:   3.5509e-03
norm of the out-of-balance force:   3.9089e-09
Recorder.addData: 'stability' not initialized by the recorder: ignored
+
norm of the out-of-balance force:   5.1349e+01
norm of the out-of-balance force:   3.0233e+02
norm of the out-of-balance force:   4.7996e-01
norm of the out-of-balance force:   2.2284e-03
norm of the out-of-balance force:   3.5516e-09
Recorder.addData: 'stability' not initialized by the recorder: ignored
+
norm of the out-of-balance force:   5.1349e+01
norm of the out-of-balance force:   2.6682e+02
norm of the out-of-balance force:   3.9630e-01
norm of the out-of-balance force:   1.4021e-03
norm of the out-of-balance force:   3.7406e-09
Recorder.addData: 'stability' not initialized by the recorder: ignored
+
norm of the out-of-balance force:   5.1349e+01
norm of the out-of-balance force:   2.3618e+02
norm of the out-of-balance force:   3.2818e-01
norm of the out-of-balance force:   8.8593e-04
norm of the out-of-balance force:   4.0110e-09
Recorder.addData: 'stability' not initialized by the recorder: ignored
+

Total running time of the script: (0 minutes 52.046 seconds)

Gallery generated by Sphinx-Gallery