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.665333617484e-07
12 from EasyFEA import Display, ElemType, Models, Simulations, PyVista, np
13 from EasyFEA.Geoms import Domain
14
15 if __name__ == "__main__":
16 Display.Clear()
17
18 # ----------------------------------------------
19 # Configuration
20 # ----------------------------------------------
21 dim = 3
22
23 # geom
24 L = 1
25 h = 1
26
27 # ----------------------------------------------
28 # Mesh
29 # ----------------------------------------------
30 meshSize = h / 10
31
32 contour = Domain((0, 0), (L, h), h / 10)
33
34 if dim == 2:
35 mesh = contour.Mesh_2D([], ElemType.QUAD8, isOrganised=True)
36 else:
37 mesh = contour.Mesh_Extrude(
38 [], [0, 0, h], [h / meshSize], ElemType.HEXA8, isOrganised=True
39 )
40
41 nodesX0 = mesh.Nodes_Conditions(lambda x, y, z: x == 0)
42 nodesXL = mesh.Nodes_Conditions(lambda x, y, z: x == L)
43
44 # ----------------------------------------------
45 # Simulation
46 # ----------------------------------------------
47
48 isot = Models.ElasIsot(dim, E=1, v=0.3)
49 lmbda = isot.get_lambda()
50 mu = isot.get_mu()
51 mat = Models.SaintVenantKirchhoff(dim, lmbda, mu, thickness=h)
52
53 simu = Simulations.HyperElasticSimu(mesh, mat)
54
55 uc = -0.3
56 simu.add_dirichlet(nodesX0, [0] * dim, simu.Get_unknowns())
57 values = np.zeros_like(simu.Get_unknowns(), dtype=float)
58 values[0] = uc
59 simu.add_dirichlet(nodesXL, values, simu.Get_unknowns())
60
61 simu.Solve()
62
63 # ----------------------------------------------
64 # Results
65 # ----------------------------------------------
66
67 PyVista.Plot_BoundaryConditions(simu).show()
68 PyVista.Plot(simu, "ux", 1, plotMesh=True).show()
Total running time of the script: (0 minutes 1.951 seconds)