This package solves the linear elasticity assuming the plane stress constitutive model. The solution is obtained via the finite element method.
The program input is a mesh (.geo
and .msh
files), material properties and boundary conditions.
The boundary conditions are create using python functions.
The results obtained from the function statics.solver()
are the nodal displacements and nodal stresses.
pip install elastopy
In order to use you need the .geo
and .msh
from gmsh. See the test folder for an example.
First we import the necessary classes and functions
import numpy as np
from elastopy import gmsh, Build, Material, statics, plotter
Then we create the model by parsing the mesh file and instanciante the Build
class.
mesh_file = 'test/patch'
mesh = gmsh.Parse(mesh_file)
model = Build(mesh)
plotter.model(model, ele=True, nodes_label=True, ele_label=True, edges_label=True)
plotter.show()
Next we define material parameters using the Material
class which takes as argument keyword dictionaries where the key is the surface label,
surf = list(model.surf.keys())
material = Material(E={surf[0]: 1000}, nu={surf[0]: 0.3})
Then we define body forces and boundary conditions as functions,
def b_force(x1, x2, t=1):
return np.array([0.0,
0.0])
def trac_bc(x1, x2, t=1):
return {
('line', 3): [-1, 0],
('line', 1): [1, 0]}
def displ_bc(x1, x2):
return {('node', 0): [0, 0],
('node', 1): ['free', 0]}
finally we call the statics solver
U, SIG = statics.solver(model, material, b_force,
trac_bc, displ_bc)
Starting statics solver at 0.000h Solution completed!
We then proceed to process the results
plotter.model_deformed(model, U, magf=100, ele=True)
print(np.round(SIG[:, 0], 2)) # s11 on all nodes
plotter.show()