Simulations#
The EasyFEA.Simulations module 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#
Parabolic#
Hyperbolic#
Methods: Newmark, HHT, Midpoint
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:
_SimuEuler-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]
- 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]]
- 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
- 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 structure: BeamStructure[source]#
Beam structure.
- class EasyFEA.Simulations.DIC(mesh, imgRef, lr=0.0, verbosity=False)[source]#
Bases:
_IObserverDigital Image Correlation (DIC) analysis
- static Get_Circle(img, threshold, boundary=None, radiusCoef=1.0)[source]#
Returns the circle properties in the image.
- Parameters:
img (_types.FloatArray) – image used
threshold (float) – threshold for pixel color
boundary (tuple[tuple[float, float], tuple[float, float]], optional) – ((xMin, xMax),(yMin, yMax)), by default None
radiusCoef (float, optional) – multiplier coef for radius, by default 1.0
- Returns:
circle coordinates and radius
- Return type:
XC, YC, radius
- Calc_pixelDisplacement(u)[source]#
Computes pixel displacements based on the finite element displacement field.
- Return type:
tuple[ndarray[tuple[Any,...],dtype[floating]],ndarray[tuple[Any,...],dtype[floating]]]
- Calc_r_dic(u, img, imgRef=None)[source]#
Computes the dic residual between img and imgRef (as a Np x Np matrix).
r_dic = f(x) - g(x + u(x))
- Parameters:
u (_types.FloatArray) – finite element displacement field (Ndof)
img (_types.FloatArray) – deformed image
imgRef (_types.FloatArray, optional) – reference image, by default None
- Returns:
the dic residual between images (as a Np x Np matrix)
- Return type:
_types.FloatArray
- Save(folder, filename='dic')[source]#
Saves the dic analysis in folder as ‘filename.pickle’.
- Return type:
None
- Solve(img, u0=None, iterMax=1000, tolConv=1e-06, imgRef=None, verbosity=True)[source]#
Computes the displacement field between the two images.
- Parameters:
img (_types.FloatArray) – deformed image (g)
u0 (_types.FloatArray, optional) – initial displacement field, by default None If None, the field is initialized using the _Get_u_from_images(imgRef, img) function if opencv-python is installed; otherwise, it is initialized to zeros.
iterMax (int, optional) – maximum number of iterations, by default 1000
tolConv (float, optional) – convergence tolerance (converged once ||b|| <= tolConv), by default 1e-6
imgRef (_types.FloatArray, optional) – reference image (f), by default None
verbosity (bool, optional) – display iterations, by default True
- Returns:
computed displacement field (Ndof)
- Return type:
_types.FloatArray
- _Get_ldic(coef=8.0)[source]#
Get the characteristic length of the mesh, i.e. coef * the average mesh size.
- Return type:
float
- _Get_u_from_images(img1, img2)[source]#
Use open cv to calculate displacements between images.
- Return type:
ndarray[tuple[Any,...],dtype[floating]]
- _Get_w()[source]#
Returns the 2D periodic vector field.
- Return type:
ndarray[tuple[Any,...],dtype[floating]]
- _Update(observable, event)[source]#
Receive an update/event from an observable object (observer pattern).
- Return type:
None
- class EasyFEA.Simulations.Elastic(mesh, model, verbosity=False)[source]#
Bases:
_SimuLinearized 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]
- 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]]
- 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:
- _Calc_Psi_Elas(
- returnScalar=True,
- smoothedStress=False,
- matrixType=MatrixType.rigi,
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:
- _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, …]
- class EasyFEA.Simulations.HyperElastic(mesh, model, tolConv=1e-05, maxIter=20, verbosity=False)[source]#
Bases:
_SimuHyperelastic 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 were 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_unknowns(problemType=None)[source]#
Returns a list of unknowns available in the simulation.
- Return type:
list[str]
- 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.
- 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.
- 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:
_SimuPhaseField 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,
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]
- 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_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_Iteration_Summary(
- iter,
- load,
- unitLoad,
- percentage=0.0,
- remove=False,
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]]
- 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:
- _Calc_Psi_Elas()[source]#
Computes of the kinematically admissible damaged deformation energy.
Psi_Elas = 1/2 int_Ω Sig : Eps dΩ
- 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:
- _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='',
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='',
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='',
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='',
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='',
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 displacement: ndarray[tuple[Any, ...], dtype[floating]][source]#
Displacement vector field.
2D [uxi, uyi, …]
3D [uxi, uyi, uzi, …]
- property phaseFieldModel: PhaseField[source]#
damage model
- class EasyFEA.Simulations.Thermal(mesh, model, verbosity=False)[source]#
Bases:
_SimuThermal 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]
- 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]]
- 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, ….]
- 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]
- 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]]
- 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
- 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.
- 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]
- 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.
- 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,
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_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]]
- _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:
kspType (str, optional) –
PETSc Krylov method, by default “cg” e.g. ‘cg’, ‘bicg’, ‘gmres’, ‘bcgs’, ‘groppcg’, …
pcType (str, optional) –
PETSc preconditioner, by default “none” e.g. ‘none’, ‘ilu’, ‘bjacobi’, ‘icc’, ‘lu’, ‘jacobi’, ‘cholesky’, …
solverType (str, optional) –
PETSc Linear Solver, by default “petsc” e.g. ‘petsc’, ‘mumps’, ‘superlu’, ‘superlu_dist’, ‘umfpack’, ‘cholesky’ …
https://petsc.org/release/manual/ksp/#using-external-linear-solvers
- 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 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 results: list[dict][source]#
Returns a copy of the list of dictionary containing the results from each iteration.
- rho#
mass density
- EasyFEA.Simulations.Load_DIC(folder, filename='dic')[source]#
Loads the dic analysis from the specified folder.
- Parameters:
folder (str) – The name of the folder where the dic analysis is saved.
filename (str, optional) – The dic’s file name, by default “dic”.
- Returns:
The loaded dic analysis.
- Return type:
- 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:
- 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