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.742

 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     isFilled = False
 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, isFilled)
 72
 73             inclusions.append(inclusion)
 74
 75     inclusion = Geoms.Domain(ptd1, ptd2, meshSize)
 76
 77     points = Geoms.Points([pt1, pt2, pt3, pt4], meshSize)
 78
 79     # mesh with inclusions
 80     mesh_inclusions = points.Mesh_2D(inclusions, elemType)
 81
 82     # mesh without inclusions
 83     mesh = points.Mesh_2D([], elemType)
 84
 85     ptI1 = Geoms.Point(-cL, -cH)
 86     ptI2 = Geoms.Point(cL, -cH)
 87     ptI3 = Geoms.Point(cL, cH)
 88     ptI4 = Geoms.Point(-cL, cH)
 89
 90     pointsI = Geoms.Points([ptI1, ptI2, ptI3, ptI4], meshSize / 4)
 91
 92     mesh_RVE = pointsI.Mesh_2D(
 93         [
 94             Geoms.Domain(
 95                 Geoms.Point(-cL / 2, -cH / 2),
 96                 Geoms.Point(cL / 2, cH / 2),
 97                 meshSize / 4,
 98                 isFilled,
 99             )
100         ],
101         elemType,
102     )
103     area = 4 * cL * cH
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)) / area
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 2.944 seconds)

Gallery generated by Sphinx-Gallery