Homog3#

Conduct full-field homogenization.

  • non hom
  • RVE
  • hom
  • Periodic boundary conditions
  • $ux$
  • $uy$
  • $\sigma_{xx}$
  • $\sigma_{yy}$
  • $\sigma_{xy}$
  • inclusions uy
  • non hom uy
  • hom uy
inclusions: dy = -1.658
non hom: dy = -0.929
hom: dy = -1.960

 12 from EasyFEA import Display, Models, plt, np, Geoms, ElemType, Simulations
 13 from EasyFEA.FEM import FeArray
 14
 15 from Homog1 import Compute_ukl
 16
 17 if __name__ == "__main__":
 18     Display.Clear()
 19
 20     # ----------------------------------------------
 21     # Configuration
 22     # ----------------------------------------------
 23     # use Periodic boundary conditions ?
 24     usePBC = True
 25
 26     # geom
 27     L = 120  # mm
 28     h = 13
 29     b = 13
 30
 31     # inclusions
 32     nL = 40  # number of inclusions following x
 33     nH = 4  # number of inclusions following y
 34     cL = L / (2 * nL)
 35     cH = h / (2 * nH)
 36     isHollow = True  # hollow inclusions
 37
 38     # model
 39     E = 210000
 40     v = 0.3
 41
 42     # load
 43     load = 800
 44
 45     # ----------------------------------------------
 46     # Mesh
 47     # ----------------------------------------------
 48     elemType = ElemType.TRI6
 49     meshSize = h / 10
 50
 51     pt1 = Geoms.Point()
 52     pt2 = Geoms.Point(L, 0)
 53     pt3 = Geoms.Point(L, h)
 54     pt4 = Geoms.Point(0, h)
 55
 56     domain = Geoms.Domain(pt1, pt2, meshSize)
 57
 58     inclusions = []
 59     for i in range(nL):
 60         x = cL + cL * (2 * i)
 61         for j in range(nH):
 62             y = cH + cH * (2 * j)
 63
 64             ptd1 = Geoms.Point(x - cL / 2, y - cH / 2)
 65             ptd2 = Geoms.Point(x + cL / 2, y + cH / 2)
 66
 67             inclusion = Geoms.Domain(ptd1, ptd2, meshSize, isHollow)
 68
 69             inclusions.append(inclusion)
 70
 71     inclusion = Geoms.Domain(ptd1, ptd2, meshSize)
 72     area_inclusion = inclusion.Mesh_2D().area
 73
 74     points = Geoms.Points([pt1, pt2, pt3, pt4], meshSize)
 75
 76     # mesh with inclusions
 77     mesh_inclusions = points.Mesh_2D(inclusions, elemType)
 78
 79     # mesh without inclusions
 80     mesh = points.Mesh_2D([], elemType)
 81
 82     ptI1 = Geoms.Point(-cL, -cH)
 83     ptI2 = Geoms.Point(cL, -cH)
 84     ptI3 = Geoms.Point(cL, cH)
 85     ptI4 = Geoms.Point(-cL, cH)
 86
 87     pointsI = Geoms.Points([ptI1, ptI2, ptI3, ptI4], meshSize / 4)
 88
 89     mesh_RVE = pointsI.Mesh_2D(
 90         [
 91             Geoms.Domain(
 92                 Geoms.Point(-cL / 2, -cH / 2),
 93                 Geoms.Point(cL / 2, cH / 2),
 94                 meshSize / 4,
 95                 isHollow,
 96             )
 97         ],
 98         elemType,
 99     )
100
101     Display.Plot_Mesh(mesh_inclusions, title="non hom")
102     Display.Plot_Mesh(mesh_RVE, title="RVE")
103     Display.Plot_Mesh(mesh, title="hom")
104
105     # ----------------------------------------------
106     # Material
107     # ----------------------------------------------
108
109     # elastic behavior of the beam
110     material_inclsuion = Models.Elastic.Isotropic(
111         2, E=E, v=v, planeStress=True, thickness=b
112     )
113     CMandel = material_inclsuion.C
114
115     material = Models.Elastic.Anisotropic(2, CMandel, False)
116     testC = np.linalg.norm(material_inclsuion.C - material.C) / np.linalg.norm(
117         material_inclsuion.C
118     )
119     assert testC < 1e-12, "the matrices are different"
120
121     # ----------------------------------------------
122     # Homogenization
123     # ----------------------------------------------
124     simu_inclusions = Simulations.Elastic(mesh_inclusions, material_inclsuion)
125     simu_VER = Simulations.Elastic(mesh_RVE, material_inclsuion)
126     simu = Simulations.Elastic(mesh, material)
127
128     r2 = np.sqrt(2)
129     E11 = np.array([[1, 0], [0, 0]])
130     E22 = np.array([[0, 0], [0, 1]])
131     E12 = np.array([[0, 1 / r2], [1 / r2, 0]])
132
133     if usePBC:
134         nodes_kubc = mesh_RVE.Nodes_Tags(["P0", "P1", "P2", "P3"])
135         paired_nodes = mesh_RVE.Get_Paired_Nodes(nodes_kubc, True)
136     else:
137         nodes_kubc = mesh_RVE.Nodes_Tags(["L0", "L1", "L2", "L3"])
138         paired_nodes = None
139
140     u11 = Compute_ukl(simu_VER, nodes_kubc, E11, paired_nodes)
141     u22 = Compute_ukl(simu_VER, nodes_kubc, E22, paired_nodes)
142     u12 = Compute_ukl(simu_VER, nodes_kubc, E12, paired_nodes, True)
143
144     u11_e = mesh_RVE.Locates_sol_e(u11, asFeArray=True)
145     u22_e = mesh_RVE.Locates_sol_e(u22, asFeArray=True)
146     u12_e = mesh_RVE.Locates_sol_e(u12, asFeArray=True)
147
148     U_e = FeArray.zeros(*u11_e.shape, 3)
149
150     U_e[..., 0] = u11_e
151     U_e[..., 1] = u22_e
152     U_e[..., 2] = u12_e
153
154     matrixType = "rigi"
155     wJ_e_pg = mesh_RVE.Get_weightedJacobian_e_pg(matrixType)
156     B_e_pg = mesh_RVE.Get_B_e_pg(matrixType)
157
158     C_hom = (wJ_e_pg * CMandel @ B_e_pg @ U_e).sum((0, 1)) / mesh_RVE.area
159
160     if isHollow:
161         coef = 1 - area_inclusion / mesh_RVE.area
162         C_hom *= coef
163
164     # print(np.linalg.eigvals(C_hom))
165
166     # ----------------------------------------------
167     # Comparison
168     # ----------------------------------------------
169     def Simulation(simu: Simulations._Simu, title=""):
170         simu.Bc_Init()
171
172         simu.add_dirichlet(simu.mesh.Nodes_Tags(["L3"]), [0, 0], ["x", "y"])
173         simu.add_surfLoad(simu.mesh.Nodes_Tags(["L1"]), [-load / (b * h)], ["y"])
174
175         simu.Solve()
176
177         # Display.Plot_BoundaryConditions(simu)
178         Display.Plot_Result(simu, "uy", title=f"{title} uy")
179         # Display.Plot_Result(simu, "Eyy")
180
181         print(
182             f"{title}: dy = {np.max(simu.Result('uy')[simu.mesh.Nodes_Point(Geoms.Point(L, 0))]):.3f}"
183         )
184
185     Simulation(simu_inclusions, "inclusions")
186     Simulation(simu, "non hom")
187
188     testSym = np.linalg.norm(C_hom.T - C_hom) / np.linalg.norm(C_hom)
189
190     if testSym >= 1e-12 and testSym <= 1e-3:
191         C_hom = 1 / 2 * (C_hom.T + C_hom)
192
193     material.Set_C(C_hom, False)
194     Simulation(simu, "hom")
195
196     # ax = Display.Plot_Result(simu, "uy")
197     # Display.Plot_Result(simuInclusions, "uy", ax=ax)
198
199     plt.show()

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

Gallery generated by Sphinx-Gallery