Beginner’s Guide#

Like any Python script, you should start by importing the core modules from the EasyFEA package:

from EasyFEA import Display, ElemType, Models, Simulations
from EasyFEA.Geoms import Domain

The most commonly used modules in EasyFEA are:

Display

Module containing functions used to display simulations and meshes with matplotlib (https://matplotlib.org/).

ElemType(value)

Implemented Lagrange isoparametric element types.

Models

Module implementing constitutive laws used in simulations.

Simulations

This module contains all available simulation classes.

Geoms

Module containing the geometric functions used to build meshes.

Let’s now create a 2D Mesh using a simple rectangular domain:

# ----------------------------------------------
# Mesh
# ----------------------------------------------
L = 120  # mm
h = 13

domain = Domain((0, 0), (L, h), h / 3)
mesh = domain.Mesh_2D([], ElemType.QUAD9, isOrganised=True)
Display.Plot_Mesh(mesh)
<Axes: title={'center': 'QUAD9: Ne = 81, Nn = 385'}, xlabel='$x$', ylabel='$y$'>
_images/begin_1_1.png

Next, define a linear Isotropic material and set up the Elastic simulation:

# ----------------------------------------------
# Simulation
# ----------------------------------------------
E = 210000  # MPa
v = 0.3
F = -800  # N

mat = Models.Elastic.Isotropic(2, E, v, planeStress=True, thickness=h)

simu = Simulations.Elastic(mesh, mat)

Once the simulation has been set up, defining the boundary conditions, solving the problem and visualizing the results is straightforward.

nodesX0 = mesh.Nodes_Conditions(lambda x, y, z: x == 0)
nodesXL = mesh.Nodes_Conditions(lambda x, y, z: x == L)

simu.add_dirichlet(nodesX0, [0, 0], ["x", "y"])
simu.add_surfLoad(nodesXL, [F / h / h], ["y"])

simu.Solve()

# ----------------------------------------------
# Results
# ----------------------------------------------
Display.Plot_Mesh(simu, deformFactor=10)
Display.Plot_BoundaryConditions(simu)
Display.Plot_Result(simu, "uy", plotMesh=True)
Display.Plot_Result(simu, "Svm", plotMesh=True, ncolors=11)
<Axes: title={'center': '$\\sigma_{vm}$'}, xlabel='$x$', ylabel='$y$'>
_images/begin_3_1.png _images/begin_3_2.png _images/begin_3_3.png _images/begin_3_4.png

This script is available in the HelloWorld example.

For additional details, please refer to either the EasyFEA API documentation or the comprehensive collection of examples.