Note
Click here to download the full example code
Linear Elastostatics of a Console in 1d¶
A short comparison of different modeling techniques of a simple console. The beam has a rectangular prismatic cross-section and a linear elastic material model, governed by the following parameters:
The resistance of a rectangular section can be characterized by the following constants (the cross section lies in the y-z plane):
cross section
# 1d Solution - Exact Analytical
Analytic solution for the tip displacement of an 1d Euler-Bernoulli beam:
Bernoulli solution
-0.19047619047619047
# 1d Solution - Approximate Numerical
from sigmaepsilon.solid import Structure, LineMesh, PointData
from neumann.linalg import linspace, Vector
from polymesh.space import StandardFrame, PointCloud, frames_of_lines
from sigmaepsilon.solid.fem.cells import B2 as Beam
import numpy as np
# model stiffness matrix
G = E / (2 * (1 + nu))
Hooke = np.array([
[E*A, 0, 0, 0],
[0, G*Ix, 0, 0],
[0, 0, E*Iy, 0],
[0, 0, 0, E*Iz]
])
# space
GlobalFrame = StandardFrame(dim=3)
# mesh
nElem = 20 # number of finite elements to use
p0 = np.array([0., 0., 0.])
p1 = np.array([L, 0., 0.])
coords = linspace(p0, p1, nElem+1)
coords = PointCloud(coords, frame=GlobalFrame).show()
topo = np.zeros((nElem, 2), dtype=int)
topo[:, 0] = np.arange(nElem)
topo[:, 1] = np.arange(nElem) + 1
# support at the leftmost, load at the rightmost node
loads = np.zeros((coords.shape[0], 6))
fixity = np.zeros((coords.shape[0], 6)).astype(bool)
global_load_vector = Vector([0., 0, F], frame=GlobalFrame).show()
loads[-1, :3] = global_load_vector
fixity[0, :] = True
# pointdata
pd = PointData(coords=coords, frame=GlobalFrame,
loads=loads, fixity=fixity)
# celldata
frames = frames_of_lines(coords, topo)
cd = Beam(topo=topo, frames=frames)
# set up mesh and structure
mesh = LineMesh(pd, cd, model=Hooke, frame=GlobalFrame)
structure = Structure(mesh=mesh)
structure.linsolve()
# postproc
# 1) displace the mesh
structure.nodal_dof_solution(store='dofsol')
dofsol = structure.mesh.pd['dofsol'].to_numpy()[:, :3]
local_dof_solution = dofsol[-1, :3]
sol_fem_1d_B2 = local_dof_solution[2]
sol_fem_1d_B2
-0.19047719057503856
mesh.config['pyvista', 'plot', 'scalars'] = dofsol[:, 2]
mesh.config['pyvista', 'plot', 'line_width'] = 4
mesh.pvplot(notebook=True, jupyter_backend='static', window_size=(600, 400),
config_key=('pyvista', 'plot'), cmap='plasma')

<PIL.Image.Image image mode=RGB size=600x400 at 0x1579C98E6A0>
Total running time of the script: ( 1 minutes 6.926 seconds)
Estimated memory usage: 331 MB