Homog1#

Conduct homogenization using an example outlined in Computational Homogenization of Heterogeneous Materials with Finite Elements.

Section 4.7 with corrected values on page 89 (Erratum).

  • RVE
  • Periodic boundary conditions
  • E [MPa]
  • v
  • $ux$
  • $uy$
  • $\sigma_{xx}$
  • $\sigma_{yy}$
  • $\sigma_{xy}$
f = 0.4
c1111 = 6.74333603905545
c1122 = 4.594425395508209
c1212 = 0.6256584299841417

 15 import matplotlib.pyplot as plt
 16 import numpy as np
 17
 18 from EasyFEA import Display, Models, ElemType, Simulations
 19 from EasyFEA.Geoms import Points, Circle
 20 from EasyFEA.FEM import LagrangeCondition, FeArray
 21 from typing import Optional
 22
 23
 24 def Compute_ukl(
 25     simu: Simulations.Elastic,
 26     nodes_kubc: np.ndarray,
 27     Ekl: np.ndarray,
 28     paired_nodes: Optional[np.ndarray] = None,
 29     pltSol=False,
 30     useMean0=False,
 31 ):
 32     simu.Bc_Init()
 33     mesh = simu.mesh
 34     coord = mesh.coord
 35
 36     usePBC = paired_nodes is not None
 37
 38     def func_ux(x, y, z):
 39         return Ekl.dot([x, y])[0]
 40
 41     def func_uy(x, y, z):
 42         return Ekl.dot([x, y])[1]
 43
 44     directions = ["x", "y"]
 45     simu.add_dirichlet(nodes_kubc, [func_ux, func_uy], directions)
 46
 47     if usePBC:
 48         for n0, n1 in paired_nodes:
 49             nodes = np.array([n0, n1])
 50
 51             delta = (coord[n0] - coord[n1])[:2]
 52             values = Ekl @ delta
 53
 54             for d, direction in enumerate(directions):
 55                 dofs = simu.Bc_dofs_nodes(nodes, [direction])
 56
 57                 condition = LagrangeCondition(
 58                     "elastic", nodes, dofs, [direction], [values[d]], [1, -1]
 59                 )
 60                 simu._Bc_Add_Lagrange(condition)
 61
 62     if useMean0:
 63         nodes = mesh.nodes
 64         vect = np.ones(mesh.Nn) * 1 / mesh.Nn
 65         for direction in directions:
 66             # sum d_i / Nn = 0
 67             dofs = simu.Bc_dofs_nodes(nodes, [direction])
 68             condition = LagrangeCondition(
 69                 "elastic", nodes, dofs, [direction], [0], [vect]
 70             )
 71             simu._Bc_Add_Lagrange(condition)
 72
 73     ukl = simu.Solve()
 74
 75     simu.Save_Iter()
 76
 77     if pltSol:
 78         Display.Plot_Result(simu, "ux", deformFactor=0.3)
 79         Display.Plot_Result(simu, "uy", deformFactor=0.3)
 80
 81         Display.Plot_Result(simu, "Sxx", deformFactor=0.3)
 82         Display.Plot_Result(simu, "Syy", deformFactor=0.3)
 83         Display.Plot_Result(simu, "Sxy", deformFactor=0.3)
 84
 85     return ukl
 86
 87
 88 if __name__ == "__main__":
 89     Display.Clear()
 90
 91     # ----------------------------------------------
 92     # Configuration
 93     # ----------------------------------------------
 94
 95     # use Periodic boundary conditions ?
 96     usePBC = True
 97
 98     # ----------------------------------------------
 99     # Mesh
100     # ----------------------------------------------
101     meshSize = 1 / 15
102
103     p0 = (-1 / 2, -1 / 2)
104     p1 = (1 / 2, -1 / 2)
105     p2 = (1 / 2, 1 / 2)
106     p3 = (-1 / 2, 1 / 2)
107     pts = [p0, p1, p2, p3]
108     contour = Points(pts, meshSize)
109     area = (p1[0] - p0[0]) * (p2[1] - p1[1])
110
111     # inclusion
112     f = 0.4
113     r = 1 * np.sqrt(f / np.pi)
114     inclusion = Circle((0, 0), 2 * r, meshSize, isFilled=True)
115
116     mesh = contour.Mesh_2D([inclusion], ElemType.TRI6)
117
118     Display.Plot_Mesh(mesh, title="RVE")
119
120     if usePBC:
121         nodes_kubc = mesh.Nodes_Tags(["P0", "P1", "P2", "P3"])
122         paired_nodes = mesh.Get_Paired_Nodes(nodes_kubc, True)
123     else:
124         nodes_kubc = mesh.Nodes_Tags(["L0", "L1", "L2", "L3"])
125         paired_nodes = None
126
127     # ----------------------------------------------
128     # Material and Simulation
129     # ----------------------------------------------
130     elements_inclusion = mesh.Elements_Tags(["S1"])
131     elements_matrix = mesh.Elements_Tags(["S0"])
132
133     E = np.zeros_like(mesh.groupElem.elements, dtype=float)
134     v = np.zeros_like(mesh.groupElem.elements, dtype=float)
135
136     E[elements_matrix] = 1  # MPa
137     v[elements_matrix] = 0.45
138
139     if elements_inclusion.size > 0:
140         E[elements_inclusion] = 50
141         v[elements_inclusion] = 0.3
142
143     material = Models.Elastic.Isotropic(2, E, v, planeStress=False)
144
145     simu = Simulations.Elastic(mesh, material)
146
147     Display.Plot_Result(simu, E, nodeValues=False, title="E [MPa]")
148     Display.Plot_Result(simu, v, nodeValues=False, title="v")
149
150     # ----------------------------------------------
151     # Homogenization
152     # ----------------------------------------------
153     r2 = np.sqrt(2)
154     E11 = np.array([[1, 0], [0, 0]])
155     E22 = np.array([[0, 0], [0, 1]])
156     E12 = np.array([[0, 1 / r2], [1 / r2, 0]])
157
158     u11 = Compute_ukl(simu, nodes_kubc, E11, paired_nodes)
159     u22 = Compute_ukl(simu, nodes_kubc, E22, paired_nodes)
160     u12 = Compute_ukl(simu, nodes_kubc, E12, paired_nodes, True)
161
162     u11_e = mesh.Locates_sol_e(u11, asFeArray=True)
163     u22_e = mesh.Locates_sol_e(u22, asFeArray=True)
164     u12_e = mesh.Locates_sol_e(u12, asFeArray=True)
165
166     # ----------------------------------------------
167     # Effective elasticity tensor (C_hom)
168     # ----------------------------------------------
169     U_e = FeArray.zeros(*u11_e.shape, 3)
170
171     U_e[..., 0] = u11_e
172     U_e[..., 1] = u22_e
173     U_e[..., 2] = u12_e
174
175     matrixType = "mass"
176     wJ_e_pg = mesh.Get_weightedJacobian_e_pg(matrixType)
177     B_e_pg = mesh.Get_B_e_pg(matrixType)
178
179     C_Mat = Models.Reshape_variable(material.C, *B_e_pg.shape[:2])
180
181     C_hom = (wJ_e_pg * C_Mat @ B_e_pg @ U_e).sum((0, 1)) / area
182
183     # Display.Plot_BoundaryConditions(simu)
184
185     print(f"f = {f}")
186     print(f"c1111 = {C_hom[0, 0]}")
187     print(f"c1122 = {C_hom[0, 1]}")
188     print(f"c1212 = {C_hom[2, 2] / 2}")
189
190     plt.show()

Total running time of the script: (0 minutes 1.109 seconds)

Gallery generated by Sphinx-Gallery