Note
Go to the end to download the full example code.
Hyperelas2#
A hyper elastic cube in compression.


===== hyperelastic problem at iteration 0 =====
At Newton iteration 1 norm is 3.873448821042e-01
At Newton iteration 2 norm is 9.538664605952e-03
At Newton iteration 3 norm is 8.884193859163e-04
At Newton iteration 4 norm is 5.678328312556e-05
At Newton iteration 5 norm is 4.665333617482e-07
13 import numpy as np
14
15 from EasyFEA import Display, ElemType, Models, Simulations, PyVista
16 from EasyFEA.Geoms import Domain
17
18 if __name__ == "__main__":
19 Display.Clear()
20
21 # ----------------------------------------------
22 # Configuration
23 # ----------------------------------------------
24 dim = 3
25
26 # geom
27 L = 1
28 h = 1
29
30 # ----------------------------------------------
31 # Mesh
32 # ----------------------------------------------
33 meshSize = h / 10
34
35 contour = Domain((0, 0), (L, h), meshSize)
36
37 if dim == 2:
38 mesh = contour.Mesh_2D([], ElemType.QUAD8, isOrganised=True)
39 else:
40 mesh = contour.Mesh_Extrude(
41 [], [0, 0, h], [h / meshSize], ElemType.HEXA8, isOrganised=True
42 )
43
44 nodesX0 = mesh.Nodes_Conditions(lambda x, y, z: x == 0)
45 nodesXL = mesh.Nodes_Conditions(lambda x, y, z: x == L)
46
47 # ----------------------------------------------
48 # Simulation
49 # ----------------------------------------------
50
51 isot = Models.Elastic.Isotropic(dim, E=1, v=0.3)
52 lmbda = isot.get_lambda()
53 mu = isot.get_mu()
54 mat = Models.HyperElastic.SaintVenantKirchhoff(dim, lmbda, mu, thickness=h)
55
56 simu = Simulations.HyperElastic(mesh, mat)
57
58 uc = -0.3
59 simu.add_dirichlet(nodesX0, [0] * dim, simu.Get_unknowns())
60 values = np.zeros_like(simu.Get_unknowns(), dtype=float)
61 values[0] = uc
62 simu.add_dirichlet(nodesXL, values, simu.Get_unknowns())
63
64 simu.Solve()
65
66 # ----------------------------------------------
67 # Results
68 # ----------------------------------------------
69
70 PyVista.Plot_BoundaryConditions(simu).show()
71 PyVista.Plot(simu, "ux", 1, plotMesh=True).show()
Total running time of the script: (0 minutes 1.794 seconds)