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

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

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

Gallery generated by Sphinx-Gallery