Simulations#

The EasyFEA.Simulations module in EasyFEA provides essential tools for creating and managing simulations. These simulations are built using a Mesh and a _IModel (material).

With this module, you can construct:

  • Linear elastic simulations with Elastic.

  • Nonlinear hyperelastic simulations with HyperElastic.

  • Euler-Bernoulli beam simulations with Beam.

  • PhaseField damage simulations for quasi-static brittle fracture with PhaseField.

  • Thermal simulations with Thermal.

  • Weak form simulations with WeakForms.

Matrix System Solvers#

EasyFEA automatically manages the resolution of elliptic, parabolic and hyperbolic matrix systems, allowing developers to focus exclusively on constructing local matrices via the Construct_local_matrix_system method.

Elliptic#

(1)#\[ \Krm \, \urm = \Frm \]

Parabolic#

(2)#\[ \Krm \, \urm + \Crm \, \vrm = \Frm \]

Hyperbolic#

  • Methods: Newmark, HHT, Midpoint

(3)#\[ \Krm \, \urm + \Crm \, \vrm + \Mrm \, \arm = \Frm \]

How to create new simulations in EasyFEA ?#

To create new simulation classes, you can take inspiration from existing implementations.
Make sure to follow the _Simu interface.
The Thermal class is relatively simple and can serve as a good starting point.

Simulations API#

This module contains all available simulation classes.

class EasyFEA.Simulations.Beam(mesh, model, verbosity=False)[source]#

Bases: _Simu

Euler-Bernoulli beam simulation.

Construct_local_matrix_system(problemType)[source]#

Construct the local matrix system \(\Krm \, \mathrm{u} + \Crm \, \vrm + \Mrm \, \arm = \Frm\) for the given problem.

Get_dof_n(problemType=None)[source]#

Returns the number of degrees of freedom per node.

Return type:

int

Get_problemTypes()[source]#

Returns the problem types available through the simulation.

Return type:

list[ModelType]

Get_unknowns(problemType=None)[source]#

Returns a list of unknowns available in the simulation.

Return type:

list[str]

Get_x0(problemType=None)[source]#

Returns the solution from the previous iteration.

Result(result, nodeValues=True, iter=None)[source]#

Returns the result. Use Results_Available() to know the available results.

Return type:

Union[ndarray[tuple[Any, ...], dtype[floating]], float]

Results_Available()[source]#

Returns a list of available results in the simulation.

Return type:

list[str]

Results_Get_Iteration_Summary()[source]#

Returns the iteration’s summary.

Return type:

str

Results_Iter_Summary()[source]#

Returns the values to be displayed in Plot_Iter_Summary.

Return type:

tuple[list[int], list[tuple[str, ndarray[tuple[Any, ...], dtype[floating]]]]]

Results_dict_Energy()[source]#

Returns a dictionary containing the names and values of the calculated energies.

Return type:

dict[str, float]

Results_displacement_matrix()[source]#

Returns displacements as a matrix [dx, dy, dz] (Nn,3).

Return type:

ndarray[tuple[Any, ...], dtype[floating]]

Results_nodeFields_elementFields(details=False)[source]#

Returns lists of nodesFields and elementsFields displayed in paraview.

Return type:

tuple[list[str], list[str]]

Save_Iter()[source]#

Saves iteration results in _results.

Set_Iter(iter=-1, resetAll=False)[source]#

Sets the simulation to the specified iteration (usually the last one) and then reset the required variables if necessary (resetAll).

Returns the simulation results dictionary.

Return type:

dict

_Calc_Epsilon_e_pg(sol)[source]#

Construct deformations for each element and each Gauss point.

a’ denotes here da/dx

1D -> [ux’]

2D -> [ux’, rz’]

3D -> [ux’, rx’, ry’, rz’]

Return type:

Union[FeArray, ndarray[tuple[Any, ...], dtype[Any]]]

_Calc_InternalForces_e_pg(Epsilon_e_pg)[source]#

Calculation of internal forces.

1D -> [N]

2D -> [N, Mz]

3D -> [N, Mx, My, Mz]

Return type:

Union[FeArray, ndarray[tuple[Any, ...], dtype[Any]]]

_Calc_Sigma_e_pg(Epsilon_e_pg)[source]#

Calculates stresses from strains.

1D -> [Sxx]

2D -> [Sxx, Syy, Sxy]

3D -> [Sxx, Syy, Szz, Syz, Sxz, Sxy]

Return type:

Union[FeArray, ndarray[tuple[Any, ...], dtype[Any]]]

_Check_dim_mesh_material()[source]#

Checks that the material dim matches the mesh dim.

Return type:

None

_indexResult(result)[source]#
Return type:

int

add_connection(nodes, unknowns, description)[source]#

Connects beams together in the specified unknowns.

Parameters:
  • nodes (_types.IntArray) – nodes

  • unknowns (list[str]) – unknowns

  • description (str) – description

add_connection_fixed(nodes, description='Fixed')[source]#

Adds a fixed connection.

Parameters:
  • nodes (_types.IntArray) – nodes

  • description (str, optional) – description, by default “Fixed”

add_connection_hinged(nodes, unknowns=[''], description='Hinged')[source]#

Adds a hinged connection.

Parameters:
  • nodes (_types.IntArray) – nodes

  • unknowns (list, optional) – unknowns, by default [‘’]

  • description (str, optional) – description, by default “Hinged”

add_surfLoad(nodes, values, unknowns, problemType=None, description='')[source]#

Adds a surface load.

Parameters:
  • nodes (_types.IntArray) – nodes

  • values (list) –

    list of values that can contain floats, arrays or functions or lambda functions.

    e.g = [10, lambda x,y,z: 10*x - 20*y + x*z, _types.FloatArray]

    functions use x, y and z integration points coordinates (x,y,z are in this case arrays of dim (e,p))

    Please note that the functions must take 3 input parameters in the order x, y, z, whether the problem is 1D, 2D or 3D.

  • unknowns (list[str]) – unknowns where values will be applied (e.g [‘y’, ‘x’])

  • problemType (ModelType, optional) – problem type, if not specified, we take the basic problem of the problem

  • description (str, optional) – Description of the condition, by default “”.

add_volumeLoad(nodes, values, unknowns, problemType=None, description='')[source]#

Adds a volumetric load.

Parameters:
  • nodes (_types.IntArray) – nodes

  • values (list) –

    list of values that can contain floats, arrays or functions or lambda functions.

    e.g = [10, lambda x,y,z: 10*x - 20*y + x*z, _types.FloatArray]

    functions use x, y and z integration points coordinates (x,y,z are in this case arrays of dim (e,p))

    Please note that the functions must take 3 input parameters in the order x, y, z, whether the problem is 1D, 2D or 3D.

  • unknowns (list[str]) – unknowns where values will be applied (e.g [‘y’, ‘x’])

  • problemType (ModelType, optional) – problem type, if not specified, we take the basic problem of the problem

  • description (str, optional) – Description of the condition, by default “”.

property center: ndarray[tuple[Any, ...], dtype[floating]][source]#

Center of mass / barycenter / inertia center

property displacement: ndarray[tuple[Any, ...], dtype[floating]][source]#

Displacement vector field.

1D [uxi, …]

2D [uxi, uyi, rzi, …]

3D [uxi, uyi, uzi, rxi, ryi, rzi, …]

property mass: float[source]#
property structure: BeamStructure[source]#

Beam structure.

class EasyFEA.Simulations.Elastic(mesh, model, verbosity=False)[source]#

Bases: _Simu

Linearized elasticity.

Strong form:

\[\begin{split}\diver{\Sig(\ub)} + \fb &= \rho \, \ddot{\ub} && \quad \text{in } \Omega, \\ % \Sig(\ub) \cdot \nb &= \tb && \quad \text{on } \partial\Omega_t, \\ % \Sig(\ub) &= \Cbb : \Eps(\ub) && \quad \text{in } \Omega, \\ % \ub &= \ub_D && \quad \text{on } \partial\Omega_u,\end{split}\]

Weak form:

\[\int_\Omega \Sig(\ub) : \Eps(\vb) \, \dO + \int_\Omega \rho \, \ddot{\ub} \cdot \vb \, \dO = \int _{\partial\Omega_t} \tb\cdot\vb \, \dS + \int _{\Omega} \fb\cdot\vb \, \dO \quad \forall \, \vb \in V\]

The implemented elastic laws are available here.

Construct_local_matrix_system(problemType)[source]#

Construct the local matrix system \(\Krm \, \mathrm{u} + \Crm \, \vrm + \Mrm \, \arm = \Frm\) for the given problem.

Get_dof_n(problemType=None)[source]#

Returns the number of degrees of freedom per node.

Return type:

int

Get_problemTypes()[source]#

Returns the problem types available through the simulation.

Return type:

list[ModelType]

Get_unknowns(problemType=None)[source]#

Returns a list of unknowns available in the simulation.

Return type:

list[str]

Get_x0(problemType=None)[source]#

Returns the solution from the previous iteration.

Result(result, nodeValues=True, iter=None)[source]#

Returns the result. Use Results_Available() to know the available results.

Return type:

Union[ndarray[tuple[Any, ...], dtype[floating]], float]

Results_Available()[source]#

Returns a list of available results in the simulation.

Return type:

list[str]

Results_Get_Iteration_Summary()[source]#

Returns the iteration’s summary.

Return type:

str

Results_Iter_Summary()[source]#

Returns the values to be displayed in Plot_Iter_Summary.

Return type:

tuple[list[int], list[tuple[str, ndarray[tuple[Any, ...], dtype[floating]]]]]

Results_dict_Energy()[source]#

Returns a dictionary containing the names and values of the calculated energies.

Return type:

dict[str, float]

Results_displacement_matrix()[source]#

Returns displacements as a matrix [dx, dy, dz] (Nn,3).

Return type:

ndarray[tuple[Any, ...], dtype[floating]]

Results_nodeFields_elementFields(details=False)[source]#

Returns lists of nodesFields and elementsFields displayed in paraview.

Return type:

tuple[list[str], list[str]]

Save_Iter()[source]#

Saves iteration results in _results.

Set_Iter(iter=-1, resetAll=False)[source]#

Sets the simulation to the specified iteration (usually the last one) and then reset the required variables if necessary (resetAll).

Returns the simulation results dictionary.

Return type:

dict

Set_Rayleigh_Damping_Coefs(coefM=0.0, coefK=0.0)[source]#

Sets damping coefficients ( C = coefK * K + coefM * M ).

_Calc_Epsilon_e_pg(u, matrixType=MatrixType.rigi)[source]#

Computes strain field from the displacement vector field.

2D : [Exx Eyy sqrt(2)*Exy]

3D : [Exx Eyy Ezz sqrt(2)*Eyz sqrt(2)*Exz sqrt(2)*Exy]

Parameters:

u (_types.FloatArray) – displacement vector (Ndof)

Returns:

Computed strain field (Ne,pg,(3 or 6))

Return type:

FeArray

_Calc_Psi_Elas(
returnScalar=True,
smoothedStress=False,
matrixType=MatrixType.rigi,
)[source]#

Computes the kinematically admissible deformation energy. Wdef = 1/2 int_Ω Sig : Eps dΩ

_Calc_Sigma_e_pg(Epsilon_e_pg, matrixType=MatrixType.rigi)[source]#

Computes stress field from strain field.

2D : [Sxx Syy sqrt(2)*Sxy]

3D : [Sxx Syy Szz sqrt(2)*Syz sqrt(2)*Sxz sqrt(2)*Sxy]

Parameters:

Epsilon_e_pg (FeArray.FeArrayALike) – Strain field (Ne,pg,(3 or 6))

Returns:

Computed stress field (Ne,pg,(3 or 6))

Return type:

FeArray

_Calc_ZZ1()[source]#

Computes the ZZ1 error.

For more details, [F.Pled, Vers une stratégie robuste … ingénierie mécanique] page 20/21

Returns the global error and the error on each element.

Return type:

error, error_e

property accel: ndarray[tuple[Any, ...], dtype[floating]][source]#

Acceleration vector field.

2D [axi, ayi, …]

3D [axi, ayi, azi, …]

property displacement: ndarray[tuple[Any, ...], dtype[floating]][source]#

Displacement vector field.

2D [uxi, uyi, …]

3D [uxi, uyi, uzi, …]

property material: _Elastic[source]#

elastic material

property speed: ndarray[tuple[Any, ...], dtype[floating]][source]#

Velocity vector field.

2D [vxi, vyi, …]

3D [vxi, vyi, vzi, …]

class EasyFEA.Simulations.HyperElastic(mesh, model, tolConv=1e-05, maxIter=20, verbosity=False)[source]#

Bases: _Simu

Hyperelastic simulation.

Weak form:

\[R(\ub; \vb) = \int_{\Omega_0} \boldsymbol{\Sigma}(\ub) : \Drm_\ub \eb(\ub) \cdot \vb \, \dO + \int_{\Omega_0} \rho \, \ddot{\ub} \cdot \vb \, \dO - \int_{\partial\Omega_0^t} \tb\cdot\vb \, \dS - \int_{\Omega_0} \fb\cdot\vb \, \dO \quad \forall \, \vb \in V\]

where \(\boldsymbol{\Sigma} := J \, \Fb^{-1} \cdot \Sig \cdot \Fb^{-T}\), is the second Piola Kirchhoff stress tensor (PK2), \(\eb := \frac{1}{2} \left( \Cb - \boldsymbol{1} \right) = \frac{1}{2} \left( \Fb^T \cdot \Fb - \boldsymbol{1} \right)\) is the Green-Lagrange strain tensor and \(\Fb := \boldsymbol{1} + \grad \ub\) the deformation gradient.

This non linear problem is solve using the newton rapshon algorithm:

\[A(\ub; \vb, \wb) \, \Delta \ub = - R(\ub; \vb) \quad \forall \, (\vb, \wb) \in \Vc \times \Wc,\]

where the tangent \(A(\ub; \vb, \wb)\) is defined \(\forall \, (\vb, \wb) \in \Vc \times \Wc\) as:

\[\begin{split}A(\ub; \vb, \wb) &= \dpartial{R(\ub; \vb)}{\ub} \cdot \wb \\ &= \int_{\Omega_0} \Drm_\ub \eb(\ub) \cdot \wb : \dNpartial{2}{W}{\eb}(\ub) : \Drm_\ub \eb(\vb) \, \dO + \int_{\Omega_0} \dpartial{W}{\eb}(\ub) : \Drm_\ub^2 \eb(\vb, \wb) \, \dO\end{split}\]

The implemented hyperelastic laws are available here and where constructed by the ComputeHyperelasticLaws script.

Construct_local_matrix_system(problemType)[source]#

Construct the local matrix system \(\Krm \, \mathrm{u} + \Crm \, \vrm + \Mrm \, \arm = \Frm\) for the given problem.

Get_dof_n(problemType=None)[source]#

Returns the number of degrees of freedom per node.

Return type:

int

Get_problemTypes()[source]#

Returns the problem types available through the simulation.

Get_unknowns(problemType=None)[source]#

Returns a list of unknowns available in the simulation.

Return type:

list[str]

Get_x0(problemType=None)[source]#

Returns the solution from the previous iteration.

Result(result, nodeValues=True, iter=None)[source]#

Returns the result. Use Results_Available() to know the available results.

Return type:

Union[ndarray[tuple[Any, ...], dtype[floating]], float]

Results_Available()[source]#

Returns a list of available results in the simulation.

Return type:

list[str]

Results_Iter_Summary()[source]#

Returns the values to be displayed in Plot_Iter_Summary.

Return type:

tuple[list[int], list[tuple[str, ndarray[tuple[Any, ...], dtype[floating]]]]]

Results_dict_Energy()[source]#

Returns a dictionary containing the names and values of the calculated energies.

Results_displacement_matrix()[source]#

Returns displacements as a matrix [dx, dy, dz] (Nn,3).

Return type:

ndarray[tuple[Any, ...], dtype[floating]]

Results_nodeFields_elementFields(details=False)[source]#

Returns lists of nodesFields and elementsFields displayed in paraview.

Save_Iter()[source]#

Saves iteration results in _results.

Set_Iter(iter=-1, resetAll=False)[source]#

Sets the simulation to the specified iteration (usually the last one) and then reset the required variables if necessary (resetAll).

Returns the simulation results dictionary.

_Calc_GreenLagrange(matrixType=MatrixType.rigi)[source]#
_Calc_SecondPiolaKirchhoff(matrixType=MatrixType.rigi)[source]#
_Calc_W(returnScalar=True, matrixType=MatrixType.rigi)[source]#
property displacement: ndarray[tuple[Any, ...], dtype[floating]][source]#

Displacement vector field.

[uxi, uyi, uzi, …]

property material: _HyperElastic[source]#

hyperelastic material

class EasyFEA.Simulations.PhaseField(mesh, model, verbosity=False)[source]#

Bases: _Simu

PhaseField damage simulations for quasi-static brittle fracture.

Strong form:#

Damaged linear elastic problem

\[\begin{split}-\diver{\Sig(\ub, \phi)} &= \fb && \quad \text{in } \Omega, \\ % \Sig(\ub, \phi) \cdot \nb &= \tb && \quad \text{on } \partial\Omega_t, \\ % \Sig(\ub, \phi) &= \Cbb(\phi) : \Eps(\ub) && \quad \text{in } \Omega, \\ % \ub &= \ub && \quad \text{on } \partial\Omega_u,\end{split}\]

Damage problem

\[\begin{split}- \nabla \cdot \left( \dfrac{2 \, G_c \, \ell}{c_w} \, \nabla\phi \right) + \dfrac{G_c}{c_w \, \ell} \, w'(\phi) &= Y(\Eps, \phi) && \quad \text{in } \Omega, \\ % \nabla \phi \cdot \nb &= 0 && \quad \text{on } \partial\Omega,\end{split}\]

Weak form:#

Damaged linear elastic problem

\[\int_\Omega \Sig(\ub, \phi) : \Eps(\vb) \, \dO = \int _{\partial\Omega_t} \tb\cdot\vb \, \dS + \int _{\Omega} \fb\cdot\vb \, \dO \quad \forall \, \vb \in V\]

Damage problem

\[\int_\Omega k_w \, \nabla \phi \cdot \nabla \delta \phi + r_w \, \phi \, \delta \phi \, \dO = \int_\Omega f_w \, \delta \phi \, \dO \quad \forall \, \delta \phi \in V,\]

Further Reading#

See section 3.1. of https://univ-eiffel.hal.science/hal-05115523 for additional mathematical details.

static Folder(
folder,
material,
split,
regu,
simpli2D,
tolConv,
solver,
test,
optimMesh=False,
closeCrack=False,
nL=0,
theta=0.0,
)[source]#

Creates a phase field folder based on the specified arguments.

Return type:

str

Bc_dofs_nodes(nodes, unknowns, problemType=ModelType.elastic)[source]#

Returns degrees of freedom associated with the nodes, based on the problem type and unknowns.

Parameters:
  • nodes (_types.IntArray) – nodes.

  • unknowns (list) – unknowns (e.g [“x”,”y”,”rz”])

  • problemType (str) – Problem type.

Returns:

Degrees of freedom.

Return type:

_types.IntArray

Construct_local_matrix_system(problemType)[source]#

Construct the local matrix system \(\Krm \, \mathrm{u} + \Crm \, \vrm + \Mrm \, \arm = \Frm\) for the given problem.

Get_K_C_M_F(problemType=None)[source]#

Returns the assembled matrices of \(\Krm \, \mathrm{u} + \Crm \, \vrm + \Mrm \, \arm = \Frm\) for the given problem.

Return type:

tuple[csr_matrix, csr_matrix, csr_matrix, csr_matrix]

Get_dof_n(problemType=None)[source]#

Returns the number of degrees of freedom per node.

Return type:

int

Get_lb_ub(problemType)[source]#

Returns the lower bound and upper bound.

Return type:

tuple[ndarray[tuple[Any, ...], dtype[floating]], ndarray[tuple[Any, ...], dtype[floating]]]

Get_problemTypes()[source]#

Returns the problem types available through the simulation.

Return type:

list[ModelType]

Get_unknowns(problemType=None)[source]#

Returns a list of unknowns available in the simulation.

Return type:

list[str]

Get_x0(problemType=None)[source]#

Returns the solution from the previous iteration.

Need_Update(value=True)[source]#

Sets whether the simulation needs to reconstruct matrices K, C, M and F.

Return type:

None

Result(result, nodeValues=True, iter=None)[source]#

Returns the result. Use Results_Available() to know the available results.

Return type:

Union[ndarray[tuple[Any, ...], dtype[floating]], float, None]

Results_Available()[source]#

Returns a list of available results in the simulation.

Return type:

list[str]

Results_Get_Bc_Summary()[source]#

Returns the simulation loading summary.

Return type:

str

Results_Get_Iteration_Summary()[source]#

Returns the iteration’s summary.

Return type:

str

Results_Iter_Summary()[source]#

Returns the values to be displayed in Plot_Iter_Summary.

Return type:

tuple[list[int], list[tuple[str, ndarray[tuple[Any, ...], dtype[floating]]]]]

Results_Set_Bc_Summary(config)[source]#

Sets the simulation loading summary.

Results_Set_Iteration_Summary(
iter,
load,
unitLoad,
percentage=0.0,
remove=False,
)[source]#

Creates the iteration summary for the damage problem.

Parameters:
  • iter (int) – iteration

  • load (float) – loading

  • unitLoad (str) – loading unit

  • percentage (float, optional) – percentage of simualtion performed, by default 0.0

  • remove (bool, optional) – removes line from terminal after display, by default False

Return type:

str

Results_dict_Energy()[source]#

Returns a dictionary containing the names and values of the calculated energies.

Return type:

dict[str, float]

Results_displacement_matrix()[source]#

Returns displacements as a matrix [dx, dy, dz] (Nn,3).

Return type:

ndarray[tuple[Any, ...], dtype[floating]]

Results_nodeFields_elementFields(details=False)[source]#

Returns lists of nodesFields and elementsFields displayed in paraview.

Return type:

tuple[list[str], list[str]]

Save_Iter()[source]#

Saves iteration results in _results.

Set_Iter(iter=-1, resetAll=False)[source]#

Sets the simulation to the specified iteration (usually the last one) and then reset the required variables if necessary (resetAll).

Returns the simulation results dictionary.

Return type:

dict

Solve(tolConv=1.0, maxIter=500, convOption=2)[source]#

Solves the iterative damage problem using the staggered scheme.

Parameters:
  • tolConv (float, optional) – threshold used to check convergence (𝜖), by default 1.0

  • maxIter (int, optional) – Maximum iterations for convergence, by default 500

  • convOption (int, optional) –

    • 0 -> convergence on damage np.max(np.abs(d_np1-dk)) equivalent normInf(d_np1-dk)

    • 1 -> convergence on crack energy np.abs(psi_crack_n - psi_crack_np1)/psi_crack_np1

    • 2 -> convergence on total energy np.abs(psi_tot_n - psi_tot_np1)/psi_tot_np1

    eq (39) Ambati 2015 10.1007/s00466-014-1109-y

    • 3 -> (convD <= tolConv) and (convU <= tolConv*0.999)

    eq (25) Pech 2022 10.1016/j.engfracmech.2022.108591

Returns:

u_np1, d_np1, Ku, converged

such that:

  • u_np1: displacement vector field

  • d_np1: damage scalar field

  • Ku: displacement stiffness matrix

  • converged: the solution has converged

Return type:

_types.FloatArray, _types.FloatArray, csr_matrix, bool

_Calc_Epsilon_e_pg(sol, matrixType=MatrixType.rigi)[source]#

Computes strain field (Ne,pg,(3 or 6)).

2D : [Exx Eyy sqrt(2)*Exy]

3D : [Exx Eyy Ezz sqrt(2)*Eyz sqrt(2)*Exz sqrt(2)*Exy]

Parameters:

sol (_types.FloatArray) – Displacement vector

Returns:

Computed strain field (Ne,pg,(3 or 6))

Return type:

FeArray

_Calc_Psi_Crack()[source]#

Computes crack’s energy.

Return type:

float

_Calc_Psi_Elas()[source]#

Computes of the kinematically admissible damaged deformation energy.

Psi_Elas = 1/2 int_Ω Sig : Eps dΩ

Return type:

float

_Calc_Psi_Ext(f_n)[source]#

Computes external’s energy.

Return type:

float

_Calc_Sigma_e_pg(Epsilon_e_pg, matrixType=MatrixType.rigi)[source]#

Computes stress field from strain field.

2D : [Sxx Syy sqrt(2)*Sxy]

3D : [Sxx Syy Szz sqrt(2)*Syz sqrt(2)*Sxz sqrt(2)*Sxy]

Parameters:

Epsilon_e_pg (FeArray.FeArrayALike) – Strain field (Ne,pg,(3 or 6))

Returns:

Computed damaged stress field.

Return type:

FeArray

_Update(observable, event)[source]#

Receive an update/event from an observable object (observer pattern).

Return type:

None

add_dirichlet(
nodes,
values,
unknowns,
problemType=ModelType.elastic,
description='',
)[source]#

Adds Dirichlet’s boundary conditions.

Parameters:
  • nodes (_types.IntArray) – nodes

  • values (list) –

    list of values that can contains floats, arrays or functions or functions.

    e.g [10, lambda x,y,z: 10*x - 20*y + x*z, _types.FloatArray]

    The functions use the x, y and z nodes coordinates.

    Please note that the functions must take 3 input parameters in the order x, y, z, whether the problem is 1D, 2D or 3D.

  • unknowns (list[str]) – unknowns where values will be applied (e.g [‘y’, ‘x’])

  • problemType (ModelType, optional) – problem type, if not specified, we take the basic problem of the problem

  • description (str, optional) – Description of the condition, by default “”.

add_lineLoad(
nodes,
values,
unknowns,
problemType=ModelType.elastic,
description='',
)[source]#

Adds a linear load.

Parameters:
  • nodes (_types.IntArray) – nodes

  • values (list) –

    list of values that can contain floats, arrays or functions or lambda functions.

    e.g = [10, lambda x,y,z: 10*x - 20*y + x*z, _types.FloatArray]

    functions use x, y and z integration points coordinates (x,y,z are in this case arrays of dim (e,p))

    Please note that the functions must take 3 input parameters in the order x, y, z, whether the problem is 1D, 2D or 3D.

  • unknowns (list[str]) – unknowns where values will be applied (e.g [‘y’, ‘x’])

  • problemType (ModelType, optional) – problem type, if not specified, we take the basic problem of the problem

  • description (str, optional) – Description of the condition, by default “”.

add_neumann(
nodes,
values,
unknowns,
problemType=ModelType.elastic,
description='',
)[source]#

Adds Neumann’s boundary conditions.

Parameters:
  • nodes (_types.IntArray) – nodes

  • values (list) –

    list of values that can contains floats, arrays or functions or functions.

    e.g [10, lambda x,y,z: 10*x - 20*y + x*z, _types.FloatArray]

    The functions use the x, y and z nodes coordinates.

    Please note that the functions must take 3 input parameters in the order x, y, z, whether the problem is 1D, 2D or 3D.

  • unknowns (list[str]) – unknowns where values will be applied (e.g [‘y’, ‘x’])

  • problemType (ModelType, optional) – problem type, if not specified, we take the basic problem of the problem

  • description (str, optional) – Description of the condition, by default “”.

add_pressureLoad(
nodes,
magnitude,
problemType=ModelType.elastic,
description='',
)[source]#

Adds a pressure.

Parameters:
  • nodes (_types.IntArray) – nodes. (must belong to the edge of the mesh.)

  • magnitude (float) – pressure magnitude

  • problemType (str, optional) – problem type, if not specified, we take the basic problem of the problem

  • description (str, optional) – Description of the condition, by default “”.

Return type:

None

add_surfLoad(
nodes,
values,
unknowns,
problemType=ModelType.elastic,
description='',
)[source]#

Adds a surface load.

Parameters:
  • nodes (_types.IntArray) – nodes

  • values (list) –

    list of values that can contain floats, arrays or functions or lambda functions.

    e.g = [10, lambda x,y,z: 10*x - 20*y + x*z, _types.FloatArray]

    functions use x, y and z integration points coordinates (x,y,z are in this case arrays of dim (e,p))

    Please note that the functions must take 3 input parameters in the order x, y, z, whether the problem is 1D, 2D or 3D.

  • unknowns (list[str]) – unknowns where values will be applied (e.g [‘y’, ‘x’])

  • problemType (ModelType, optional) – problem type, if not specified, we take the basic problem of the problem

  • description (str, optional) – Description of the condition, by default “”.

property damage: ndarray[tuple[Any, ...], dtype[floating]][source]#

Damage scalar field.

[di, …]

property displacement: ndarray[tuple[Any, ...], dtype[floating]][source]#

Displacement vector field.

2D [uxi, uyi, …]

3D [uxi, uyi, uzi, …]

property needUpdate: bool[source]#

The object needs to be updated.

property phaseFieldModel: PhaseField[source]#

damage model

class EasyFEA.Simulations.Thermal(mesh, model, verbosity=False)[source]#

Bases: _Simu

Thermal simulation.

Strong form:

\[\begin{split}\diver q + \rho \, c \, \dot{t} &= r && \quad \text{in } \Omega, \\ % q &= -k \, \nabla t && \quad \text{in } \Omega, \\ % q \cdot \nb &= -q_n && \quad \text{on } \partial\Omega_q, \\ % t &= t_D && \quad \text{on } \partial\Omega_t,\end{split}\]

Weak form:

\[\int_\Omega k \, \nabla t \cdot \nabla \delta t \, \dO + \int_\Omega \rho \, c \, \dot{t} \, \delta t \, \dO = \int_{\partial\Omega_q} q_n \, \delta t \, \dS + \int_{\partial\Omega_t} r \, \delta t \, \dO \quad \forall \, \delta t \in V\]
Construct_local_matrix_system(problemType)[source]#

Construct the local matrix system \(\Krm \, \mathrm{u} + \Crm \, \vrm + \Mrm \, \arm = \Frm\) for the given problem.

Get_dof_n(problemType=None)[source]#

Returns the number of degrees of freedom per node.

Return type:

int

Get_problemTypes()[source]#

Returns the problem types available through the simulation.

Return type:

list[ModelType]

Get_unknowns(problemType=None)[source]#

Returns a list of unknowns available in the simulation.

Return type:

list[str]

Get_x0(problemType=None)[source]#

Returns the solution from the previous iteration.

Result(result, nodeValues=True, iter=None)[source]#

Returns the result. Use Results_Available() to know the available results.

Return type:

Union[ndarray[tuple[Any, ...], dtype[floating]], float]

Results_Available()[source]#

Returns a list of available results in the simulation.

Return type:

list[str]

Results_Iter_Summary()[source]#

Returns the values to be displayed in Plot_Iter_Summary.

Return type:

tuple[list[int], list[tuple[str, ndarray[tuple[Any, ...], dtype[floating]]]]]

Results_dict_Energy()[source]#

Returns a dictionary containing the names and values of the calculated energies.

Return type:

dict[str, float]

Results_displacement_matrix()[source]#

Returns displacements as a matrix [dx, dy, dz] (Nn,3).

Return type:

ndarray[tuple[Any, ...], dtype[floating]]

Results_nodeFields_elementFields(details=False)[source]#

Returns lists of nodesFields and elementsFields displayed in paraview.

Return type:

tuple[list[str], list[str]]

Save_Iter()[source]#

Saves iteration results in _results.

Set_Iter(iter=-1, resetAll=False)[source]#

Sets the simulation to the specified iteration (usually the last one) and then reset the required variables if necessary (resetAll).

Returns the simulation results dictionary.

Return type:

dict

_Check_dim_mesh_material()[source]#

Checks that the material dim matches the mesh dim.

Return type:

None

property thermal: ndarray[tuple[Any, ...], dtype[floating]][source]#

Scalar temperature field.

[ti, ….]

property thermalDot: ndarray[tuple[Any, ...], dtype[floating]][source]#

Time derivative of the scalar temperature field.

[d(ti)/dt, ….]

property thermalModel: Thermal[source]#

Thermal simulation model.

class EasyFEA.Simulations.WeakForms(mesh, model, isNonLinear=False, tolConv=1e-05, maxIter=20, verbosity=False)[source]#

Bases: _Simu

Construct_local_matrix_system(problemType)[source]#

Construct the local matrix system \(\Krm \, \mathrm{u} + \Crm \, \vrm + \Mrm \, \arm = \Frm\) for the given problem.

Get_dof_n(problemType=None)[source]#

Returns the number of degrees of freedom per node.

Return type:

int

Get_problemTypes()[source]#

Returns the problem types available through the simulation.

Return type:

list[ModelType]

Get_unknowns(problemType=None)[source]#

Returns a list of unknowns available in the simulation.

Return type:

list[str]

Get_x0(problemType=None)[source]#

Returns the solution from the previous iteration.

Result(result, nodeValues=True, iter=None)[source]#

Returns the result. Use Results_Available() to know the available results.

Return type:

Union[ndarray[tuple[Any, ...], dtype[floating]], float]

Results_Available()[source]#

Returns a list of available results in the simulation.

Return type:

list[str]

Results_Iter_Summary()[source]#

Returns the values to be displayed in Plot_Iter_Summary.

Return type:

tuple[list[int], list[tuple[str, ndarray[tuple[Any, ...], dtype[floating]]]]]

Results_dict_Energy()[source]#

Returns a dictionary containing the names and values of the calculated energies.

Return type:

dict[str, float]

Results_displacement_matrix()[source]#

Returns displacements as a matrix [dx, dy, dz] (Nn,3).

Return type:

ndarray[tuple[Any, ...], dtype[floating]]

Results_nodeFields_elementFields(details=False)[source]#

Returns lists of nodesFields and elementsFields displayed in paraview.

Return type:

tuple[list[str], list[str]]

Save_Iter()[source]#

Saves iteration results in _results.

Set_Iter(iter=-1, resetAll=False)[source]#

Sets the simulation to the specified iteration (usually the last one) and then reset the required variables if necessary (resetAll).

Returns the simulation results dictionary.

Return type:

dict

_Check_dim_mesh_material()[source]#

Checks that the material dim matches the mesh dim.

Return type:

None

property a: ndarray[tuple[Any, ...], dtype[floating]][source]#

node field a = d2udt2

property u: ndarray[tuple[Any, ...], dtype[floating]][source]#

node field u.

property v: ndarray[tuple[Any, ...], dtype[floating]][source]#

node field v = dudt

property weakForms: WeakForms[source]#

Weak form manager.

class EasyFEA.Simulations._Simu(mesh, model, verbosity=True)[source]#

Bases: _IObserver, Updatable, ABC

The following classes inherit from the parent class _Simu:
  • Elastic

  • HyperElastic

  • PhaseField

  • Beam

  • Thermal

  • WeakForm

To create new simulation classes, you can take inspiration from existing implementations.n Make sure to follow this interface.n The ThermalSimuclass is relatively simple and can serve as a good starting point.n See simulations/_thermal.py for more details.

To use the interface/inheritance, 13 methods need to be defined.

General:#

  • def Get_problemTypes(self) -> list[ModelType]:

  • def Get_unknowns(self, problemType=None) -> list[str]:

  • def Get_dof_n(self, problemType=None) -> int:

These functions provides access to the available unknowns and degrees of freedom (dofs).

Solve:#

  • def Get_x0(self, problemType=None):

  • def Construct_local_matrix_system(self, problemType):

These functions assemble the matrix system \(\Krm \, \mathrm{u} + \Crm \, \vrm + \Mrm \, \arm = \Frm\).

Iterations:#

  • def Save_Iter(self) -> None:

  • def Set_Iter(self, index=-1) -> None:

These functions are used to save or load iterations.

Results:#

  • def Results_Available(self) -> list[str]:

  • def Result(self, result: str, nodeValues=True, iter=None) -> float | _types.FloatArray:

  • def Results_Iter_Summary(self) -> tuple[list[int], list[tuple[str, _types.FloatArray]]]:

  • def Results_dict_Energy(self) -> dict[str, float]:

  • def Results_displacement_matrix(self) -> _types.FloatArray:

  • def Results_nodesField_elementsField(self, details=False) -> tuple[list[str], list[str]]:

These functions are used to process the results.

Assembly(problemType)[source]#

Assemble the matrix system \(\Krm \, \mathrm{u} + \Crm \, \vrm + \Mrm \, \arm = \Frm\) for the given problemType.

Return type:

tuple[csr_matrix, csr_matrix, csr_matrix, csr_matrix]

Bc_Init()[source]#

Initializes Dirichlet, Neumann and Lagrange boundary conditions

Return type:

None

Bc_dofs_Dirichlet(problemType=None)[source]#

Returns dofs related to Dirichlet conditions.

Return type:

ndarray[tuple[Any, ...], dtype[int64]]

Bc_dofs_Neumann(problemType=None)[source]#

Returns dofs related to Neumann conditions.

Return type:

ndarray[tuple[Any, ...], dtype[int64]]

Bc_dofs_known_unknown(problemType)[source]#

Returns known and unknown dofs.

Return type:

tuple[ndarray[tuple[Any, ...], dtype[int64]], ndarray[tuple[Any, ...], dtype[int64]]]

Bc_dofs_nodes(nodes, unknowns, problemType=None)[source]#

Returns degrees of freedom associated with the nodes, based on the problem type and unknowns.

Parameters:
  • nodes (_types.IntArray) – nodes.

  • unknowns (list) – unknowns (e.g [“x”,”y”,”rz”])

  • problemType (str) – Problem type.

Returns:

Degrees of freedom.

Return type:

_types.IntArray

Bc_values_Dirichlet(problemType=None)[source]#

Returns dofs values related to Dirichlet conditions.

Return type:

ndarray[tuple[Any, ...], dtype[floating]]

Bc_values_Neumann(problemType=None)[source]#

Returns dofs values related to Neumann conditions.

Return type:

ndarray[tuple[Any, ...], dtype[floating]]

Bc_vector_Dirichlet(problemType=None)[source]#

Returns a vector filled with Dirichlet boundary conditions values.

Return type:

ndarray[tuple[Any, ...], dtype[floating]]

Bc_vector_Neumann(problemType=None)[source]#

Returns a vector filled with Neuman boundary conditions values.

Return type:

ndarray[tuple[Any, ...], dtype[floating]]

abstractmethod Construct_local_matrix_system(problemType)[source]#

Construct the local matrix system \(\Krm \, \mathrm{u} + \Crm \, \vrm + \Mrm \, \arm = \Frm\) for the given problem.

Return type:

tuple[Optional[FeArray], Optional[FeArray], Optional[FeArray], Optional[FeArray]]

Get_K_C_M_F(problemType=None)[source]#

Returns the assembled matrices of \(\Krm \, \mathrm{u} + \Crm \, \vrm + \Mrm \, \arm = \Frm\) for the given problem.

Return type:

tuple[csr_matrix, csr_matrix, csr_matrix, csr_matrix]

Get_contact(masterMesh, slaveNodes=None, masterNodes=None)[source]#

Returns the simulation nodes detected in the master mesh with the associated displacement matrix to the interface.

Parameters:
  • masterMesh (Mesh) – master mesh

  • slavenodes (_types.IntArray, optional) – slave nodes, by default None

  • masternodes (_types.IntArray, optional) – master nodes, by default None

Returns:

nodes, displacementMatrix

Return type:

tuple[_types.IntArray, _types.FloatArray]

abstractmethod Get_dof_n(problemType=None)[source]#

Returns the number of degrees of freedom per node.

Return type:

int

Get_lb_ub(problemType)[source]#

Returns the lower bound and upper bound.

Return type:

tuple[ndarray[tuple[Any, ...], dtype[floating]], ndarray[tuple[Any, ...], dtype[floating]]]

abstractmethod Get_problemTypes()[source]#

Returns the problem types available through the simulation.

Return type:

list[ModelType]

abstractmethod Get_unknowns(problemType=None)[source]#

Returns a list of unknowns available in the simulation.

Return type:

list[str]

abstractmethod Get_x0(problemType=None)[source]#

Returns the solution from the previous iteration.

Return type:

ndarray[tuple[Any, ...], dtype[floating]]

Need_Update(value=True)[source]#

Sets whether the simulation needs to reconstruct matrices K, C, M and F.

abstractmethod Result(option, nodeValues=True, iter=None)[source]#

Returns the result. Use Results_Available() to know the available results.

Return type:

Union[ndarray[tuple[Any, ...], dtype[floating]], float]

abstractmethod Results_Available()[source]#

Returns a list of available results in the simulation.

Return type:

list[str]

Results_Get_Bc_Summary()[source]#

Returns the simulation loading summary.

Return type:

str

Results_Get_Iteration_Summary()[source]#

Returns the iteration’s summary.

Return type:

str

abstractmethod Results_Iter_Summary()[source]#

Returns the values to be displayed in Plot_Iter_Summary.

Return type:

tuple[list[int], list[tuple[str, ndarray[tuple[Any, ...], dtype[floating]]]]]

Results_Reshape_values(values, nodeValues)[source]#

Reshapes input values based on whether they are stored at nodes or elements.

Parameters:
  • values (_types.FloatArray) – Input values to reshape.

  • nodeValues (bool) – If True, the output will represent values at nodes; if False, values on elements will be derived.

Returns:

Reshaped values on nodes or elements.

Return type:

_types.FloatArray

Raises:

Exception – Raised if unexpected conditions occur during the calculation.

Results_Set_Bc_Summary()[source]#

Sets the simulation loading summary.

Return type:

None

Results_Set_Iteration_Summary()[source]#

Sets the iteration’s summary.

Return type:

None

abstractmethod Results_dict_Energy()[source]#

Returns a dictionary containing the names and values of the calculated energies.

Return type:

dict[str, float]

abstractmethod Results_displacement_matrix()[source]#

Returns displacements as a matrix [dx, dy, dz] (Nn,3).

Return type:

ndarray[tuple[Any, ...], dtype[floating]]

abstractmethod Results_nodeFields_elementFields(details=False)[source]#

Returns lists of nodesFields and elementsFields displayed in paraview.

Return type:

tuple[list[str], list[str]]

Save(folder, filename='simulation', additionalInfos='')[source]#

Saves the simulation and its summary in the folder. Saves the simulation as ‘filename.pickle’.

Return type:

None

abstractmethod Save_Iter()[source]#

Saves iteration results in _results.

Return type:

dict[str, Any]

abstractmethod Set_Iter(iter=-1, resetAll=False)[source]#

Sets the simulation to the specified iteration (usually the last one) and then reset the required variables if necessary (resetAll).

Returns the simulation results dictionary.

Return type:

dict

Solve()[source]#

Computes the solution field for the current boundary conditions.

Returns:

The solution of the simulation.

Return type:

_types.FloatArray

Solver_Set_Elliptic_Algorithm()[source]#

Sets the algorithm’s resolution properties for an elliptic problem.

Used to solve \(\Krm \, \mathrm{u} = \Frm\).

Return type:

None

Solver_Set_Hyperbolic_Algorithm(
dt,
beta=0.25,
gamma=0.5,
algo=AlgoType.newmark,
alpha=0.5,
)[source]#

Sets the algorithm’s resolution properties for a Hyperbolic problem.

Used to solve \(\Krm \, \mathrm{u} + \Crm \, \vrm + \Mrm \, \arm = \Frm\).

Parameters:
  • dt (float) – The time increment.

  • beta (float, optional) – The coefficient beta, by default 1/4.

  • gamma (float, optional) – The coefficient gamma, by default 1/2.

  • algo (AlgoType, optional) – Algo used to solve \(\Krm \, \mathrm{u} + \Crm \, \vrm + \Mrm \, \arm = \Frm\), by default AlgoType.newmark \(\Krm \, \mathrm{u}^{n+1} + \Crm \, \vrm^{n+1} + \Mrm \, \arm^{n+1} = \Frm^{n+1}\).

  • alpha (float, optional) – The coefficient alpha, by default 1/2.

Return type:

None

Solver_Set_Parabolic_Algorithm(dt, alpha=0.5)[source]#

Sets the algorithm’s resolution properties for a parabolic problem.

Used to solve \(\Krm \, u^{n+1} + \Crm \, \vrm^{n+1} = F^{n+1}\) with:

\(\mathrm{u}^{n+1} = \mathrm{u}^n + \dt \, \vrm^{n+\alpha}\)

Parameters:
  • dt (float) – The time increment.

  • alpha (float, optional) – The alpha criterion, by default 1/2n - 0 -> Forward Euler - 1 -> Backward Euler - 1/2 -> midpoint

Return type:

None

_Bc_Add_Dirichlet(problemType, nodes, dofsValues, dofs, unknowns, description='')[source]#

Adds Dirichlet’s boundary conditions.

If a Dirichlet’s dof is entered more than once, the conditions are added together.

Return type:

None

_Bc_Add_Display(nodes, unknowns, description, problemType=None)[source]#

Adds a display condition.

Return type:

None

_Bc_Add_Lagrange(newBc)[source]#

Adds Lagrange conditions.

_Bc_Add_Neumann(problemType, nodes, dofsValues, dofs, unknowns, description='')[source]#

Adds Neumann’s boundary conditions.

If a neumann condition is already applied to the dof, the condition will not be taken into account for the dof.

Return type:

None

_Bc_Lagrange_dim(problemType=None)[source]#

Calculates the dimension required to resize the system to use Lagrange multipliers.

Return type:

int

_Check_dim_mesh_material()[source]#

Checks that the material dim matches the mesh dim.

Return type:

None

_Check_dofs(problemType, unknowns)[source]#

Checks whether the specified unknowns are available for the problem.

Return type:

None

_Get_a_n(problemType)[source]#

Returns the acceleration solution associated with the given problem.

Return type:

ndarray[tuple[Any, ...], dtype[floating]]

_Get_u_n(problemType)[source]#

Returns the solution associated with the given problem.

Return type:

ndarray[tuple[Any, ...], dtype[floating]]

_Get_v_n(problemType)[source]#

Returns the speed solution associated with the given problem.

Return type:

ndarray[tuple[Any, ...], dtype[floating]]

_Results_Check_Available(result)[source]#

Check that the result is available

Return type:

bool

_Set_solutions(problemType, u, v=None, a=None)[source]#
Return type:

None

_Solver_Apply_Dirichlet(problemType, b, resolution)[source]#

Fill in the Dirichlet conditions by constructing A and x from A x = b.

Parameters:
  • problemType (ModelType) – The type of problem.

  • b (sparse.csr_matrix) – The b matrix.

  • resolution (ResolutionType) – The resolution type.

Returns:

The A and x matrices.

Return type:

tuple[sparse.csr_matrix, sparse.csr_matrix]

_Solver_Apply_Neumann(problemType)[source]#

Fill in the Neumann boundary conditions by constructing b from A x = b.

Parameters:

problemType (ModelType) – problem type

Returns:

The b vector as a csr_matrix.

Return type:

sparse.csr_matrix

_Solver_Evaluate_u_v_a_for_time_scheme(problemType, u_np1)[source]#

Returns u_t, v_t, and a_t vectors according to the time scheme.

Parameters:
  • problemType (ModelType) – problem type

  • u_np1 (np.ndarray) – the u_np1 vector

Returns:

the evaluated solutions u_t, v_t, a_t.

Return type:

tuple[np.ndarray, np.ndarray, np.ndarray]

_Solver_Get_Newton_Raphson_current_solution()[source]#

Returns the current newton raphson solution.

Return type:

ndarray

_Solver_Get_PETSc4Py_Options()[source]#

Returns (kspType, pcType, solverType) petsc4py options.

Return type:

tuple[str, str, str]

_Solver_Set_Newton_Raphson_Algorithm(tolConv=1e-05, maxIter=20)[source]#

Sets the algorithm’s resolution properties for an non linear problem.

Used to solve A(u) Δu = - R(u).

Parameters:
  • tolConv (float, optional) – threshold used to check convergence, by default 1e-5

  • maxIter (int, optional) – Maximum iterations for convergence, by default 20

Return type:

None

_Solver_Set_PETSc4Py_Options(kspType='cg', pcType='none', solverType='petsc')[source]#

Sets petsc4py options.

Parameters:
Return type:

None

_Solver_Solve_Newton_Raphson(problemType=None, tolConv=1e-05, maxIter=20)[source]#

Solves the non-linear problem using the newton raphson algorithm.

Used to solve A(u) Δu = - R(u).

Parameters:
  • problemType (ModelType, optional) – The problem type, by default self.problemType

  • tolConv (float, optional) – threshold used to check convergence, by default 1e-5

  • maxIter (int, optional) – Maximum iterations for convergence, by default 20

Returns:

return u, Niter, timeIter, list_norm_r

Return type:

tuple[_types.FloatArray, int, float, list[float]]

Warning

The Construct_local_matrix_system function must return K and F, where K contains the tangent matrix and F contains the residual.

_Solver_Solve_problemType(problemType)[source]#

Solves the problem.

It is recommended to call the resolution via the Solve() function.

Return type:

ndarray[tuple[Any, ...], dtype[floating]]

_Solver_Update_solutions(problemType, u_np1)[source]#

Update solutions u, v and a according to x array.

Parameters:
  • problemType (ModelType) – The type of problem.

  • u_np1 (_types.FloatArray) – computed array in _Solver_Solve()

Returns:

returns u_np1, v_np1, a_np1

Return type:

tuple[ _types.FloatArray, Optional[_types.FloatArray], Optional[_types.FloatArray] ]

_Update(observable, event)[source]#

Receive an update/event from an observable object (observer pattern).

Return type:

None

add_dirichlet(nodes, values, unknowns, problemType=None, description='')[source]#

Adds Dirichlet’s boundary conditions.

Parameters:
  • nodes (_types.IntArray) – nodes

  • values (list) –

    list of values that can contains floats, arrays or functions or functions.

    e.g [10, lambda x,y,z: 10*x - 20*y + x*z, _types.FloatArray]

    The functions use the x, y and z nodes coordinates.

    Please note that the functions must take 3 input parameters in the order x, y, z, whether the problem is 1D, 2D or 3D.

  • unknowns (list[str]) – unknowns where values will be applied (e.g [‘y’, ‘x’])

  • problemType (ModelType, optional) – problem type, if not specified, we take the basic problem of the problem

  • description (str, optional) – Description of the condition, by default “”.

Return type:

None

add_lineLoad(nodes, values, unknowns, problemType=None, description='')[source]#

Adds a linear load.

Parameters:
  • nodes (_types.IntArray) – nodes

  • values (list) –

    list of values that can contain floats, arrays or functions or lambda functions.

    e.g = [10, lambda x,y,z: 10*x - 20*y + x*z, _types.FloatArray]

    functions use x, y and z integration points coordinates (x,y,z are in this case arrays of dim (e,p))

    Please note that the functions must take 3 input parameters in the order x, y, z, whether the problem is 1D, 2D or 3D.

  • unknowns (list[str]) – unknowns where values will be applied (e.g [‘y’, ‘x’])

  • problemType (ModelType, optional) – problem type, if not specified, we take the basic problem of the problem

  • description (str, optional) – Description of the condition, by default “”.

Return type:

None

add_neumann(nodes, values, unknowns, problemType=None, description='')[source]#

Adds Neumann’s boundary conditions.

Parameters:
  • nodes (_types.IntArray) – nodes

  • values (list) –

    list of values that can contains floats, arrays or functions or functions.

    e.g [10, lambda x,y,z: 10*x - 20*y + x*z, _types.FloatArray]

    The functions use the x, y and z nodes coordinates.

    Please note that the functions must take 3 input parameters in the order x, y, z, whether the problem is 1D, 2D or 3D.

  • unknowns (list[str]) – unknowns where values will be applied (e.g [‘y’, ‘x’])

  • problemType (ModelType, optional) – problem type, if not specified, we take the basic problem of the problem

  • description (str, optional) – Description of the condition, by default “”.

Return type:

None

add_pressureLoad(nodes, magnitude, problemType=None, description='')[source]#

Adds a pressure.

Parameters:
  • nodes (_types.IntArray) – nodes. (must belong to the edge of the mesh.)

  • magnitude (float) – pressure magnitude

  • problemType (str, optional) – problem type, if not specified, we take the basic problem of the problem

  • description (str, optional) – Description of the condition, by default “”.

Return type:

None

add_surfLoad(nodes, values, unknowns, problemType=None, description='')[source]#

Adds a surface load.

Parameters:
  • nodes (_types.IntArray) – nodes

  • values (list) –

    list of values that can contain floats, arrays or functions or lambda functions.

    e.g = [10, lambda x,y,z: 10*x - 20*y + x*z, _types.FloatArray]

    functions use x, y and z integration points coordinates (x,y,z are in this case arrays of dim (e,p))

    Please note that the functions must take 3 input parameters in the order x, y, z, whether the problem is 1D, 2D or 3D.

  • unknowns (list[str]) – unknowns where values will be applied (e.g [‘y’, ‘x’])

  • problemType (ModelType, optional) – problem type, if not specified, we take the basic problem of the problem

  • description (str, optional) – Description of the condition, by default “”.

Return type:

None

add_volumeLoad(nodes, values, unknowns, problemType=None, description='')[source]#

Adds a volumetric load.

Parameters:
  • nodes (_types.IntArray) – nodes

  • values (list) –

    list of values that can contain floats, arrays or functions or lambda functions.

    e.g = [10, lambda x,y,z: 10*x - 20*y + x*z, _types.FloatArray]

    functions use x, y and z integration points coordinates (x,y,z are in this case arrays of dim (e,p))

    Please note that the functions must take 3 input parameters in the order x, y, z, whether the problem is 1D, 2D or 3D.

  • unknowns (list[str]) – unknowns where values will be applied (e.g [‘y’, ‘x’])

  • problemType (ModelType, optional) – problem type, if not specified, we take the basic problem of the problem

  • description (str, optional) – Description of the condition, by default “”.

Return type:

None

property Bc_Dirichlet: list[BoundaryCondition][source]#

Returns a copy of the Dirichlet conditions.

property Bc_Display: list[BoundaryCondition | LagrangeCondition][source]#

Returns a copy of the boundary conditions for display.

property Bc_Lagrange: list[LagrangeCondition][source]#

Returns a copy of the Lagrange conditions.

property Bc_Neuman: list[BoundaryCondition][source]#

Returns a copy of the Neumann conditions.

property Niter: int[source]#

Number of iterations

property algo: AlgoType[source]#

The algorithm used to solve the problem. (elliptic, parabolic, hyperbolic) see:

  • Solver_Set_Elliptic_Algorithm() \(\Krm \, \mathrm{u} = \Frm\)

  • Solver_Set_Parabolic_Algorithm() \(\Krm \, \mathrm{u} + \Crm \, \vrm = \Frm\)

  • Solver_Set_Hyperbolic_Algorithm() \(\Krm \, \mathrm{u} + \Crm \, \vrm + \Mrm \, \arm = \Frm\)

property center: ndarray[tuple[Any, ...], dtype[floating]][source]#

Center of mass / barycenter / inertia center

property dim: int[source]#

simulation’s dimension

property isNonLinear[source]#

Returns whether the simulation is non linear.

property mass: float[source]#
property mesh: Mesh[source]#

simulation’s mesh.

property model: _IModel[source]#

model used

property problemType: ModelType[source]#

Get the simulation problem type.

property results: list[dict][source]#

Returns a copy of the list of dictionary containing the results from each iteration.

rho#

mass density

property solver: str[source]#

Solver used to solve the simulation.

EasyFEA.Simulations.Load_Simu(folder, filename='simulation')[source]#

Loads the simulation from the specified folder.

Parameters:
  • folder (str) – simulation’s folder.

  • filename (str, optional) – The simualtion’s name, by default “simulation”.

Returns:

The loaded simulation.

Return type:

_Simu

EasyFEA.Simulations.Load_pickle(folder, filename)[source]#

Returns folder/filename.pickle object.

EasyFEA.Simulations.Mesh_Optim_ZZ1(DoSimu, folder, threshold=0.01, iterMax=20, coef=0.5)[source]#

Optimizes the mesh using ZZ1 error criterion.

Parameters:
  • DoSimu (Callable[[str], Displacement]) – Function that runs a simulation and takes a .pos file as argument for mesh optimization. The function must return a Displacement simulation.

  • folder (str) – Folder in which .pos files are created and then deleted.

  • threshold (float, optional) – targeted error, by default 1e-2

  • iterMax (int, optional) – Maximum number of iterations, by default 20

  • coef (float, optional) – mesh size division ratio, by default 1/2

Returns:

Displacement simulation

Return type:

Displacement

EasyFEA.Simulations.Save_pickle(obj, folder, filename)[source]#

Saves the object in folder/filename.pickle.

Return type:

None