.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/boundary_conditions/periodic_bc_2d_plate_with_hole.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_examples_boundary_conditions_periodic_bc_2d_plate_with_hole.py: 2D periodic boundary condition ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Periodic boundary conditions are enforced with :class:`fedoo.constraint.PeriodicBC` on a 2D unit cell with a central hole, under the plane stress assumption. A mean shear strain :math:`\gamma_{xy} = 0.1` is prescribed on the mean strain degrees of freedom added by the constraint, and the resulting mean stress is computed by integrating the stress field over the cell. .. GENERATED FROM PYTHON SOURCE LINES 12-15 .. code-block:: Python import fedoo as fd .. GENERATED FROM PYTHON SOURCE LINES 16-20 Dimension of the problem and geometry ------------------------------------- Any mesh with matching nodes on opposite edges can be used, for instance ``fd.mesh.rectangle_mesh(nx=51, ny=51)`` for a homogeneous cell. .. GENERATED FROM PYTHON SOURCE LINES 20-24 .. code-block:: Python fd.ModelingSpace("2Dstress") mesh = fd.mesh.hole_plate_mesh() .. GENERATED FROM PYTHON SOURCE LINES 25-27 Material, weak form, assembly and linear problem ------------------------------------------------ .. GENERATED FROM PYTHON SOURCE LINES 27-33 .. code-block:: Python fd.constitutivelaw.ElasticIsotrop(1e5, 0.3, name="ElasticLaw") wf = fd.weakform.StressEquilibrium("ElasticLaw") fd.Assembly.create(wf, mesh, name="Assembly") pb = fd.problem.Linear("Assembly") .. GENERATED FROM PYTHON SOURCE LINES 34-43 Add periodic constraint ----------------------- The periodic condition is a set of multipoint constraints linking the nodes of opposite edges. Some global dofs are automatically added to the problem: - ``E_xx``, ``E_yy``, ``E_xy``, the mean strain components (Voigt notation: ``E_xy`` is the engineering shear strain :math:`\gamma_{xy} = 2\varepsilon_{xy}`), - the global vector ``MeanStrain`` that gathers them. .. GENERATED FROM PYTHON SOURCE LINES 43-46 .. code-block:: Python pb.bc.add(fd.constraint.PeriodicBC(periodicity_type="small_strain")) .. rst-class:: sphx-glr-script-out .. code-block:: none 2D Periodic Boundary Condition: name = 'Periodicity' .. GENERATED FROM PYTHON SOURCE LINES 47-51 Add standard boundary conditions -------------------------------- Each mean strain component accepts a Dirichlet condition (strain) or a Neumann condition (associated mean stress times the cell area). .. GENERATED FROM PYTHON SOURCE LINES 51-64 .. code-block:: Python Exx = 0 Eyy = 0 Exy = 0.1 # engineering shear strain gamma_xy pb.bc.add("Dirichlet", "E_xx", Exx) pb.bc.add("Dirichlet", "E_xy", Exy) pb.bc.add("Dirichlet", "E_yy", Eyy) # Block one node to avoid singularity center = mesh.nearest_node(mesh.bounding_box.center) pb.bc.add("Dirichlet", center, "Disp", 0) .. rst-class:: sphx-glr-script-out .. code-block:: none List of boundary conditions: number of bc = 2 0: Dirichlet -> 'DispX' for 1 nodes set to 0 1: Dirichlet -> 'DispY' for 1 nodes set to 0 .. GENERATED FROM PYTHON SOURCE LINES 65-67 Solve and plot the stress field ------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 67-75 .. code-block:: Python pb.solve() res = pb.get_results("Assembly", ["Disp", "Stress", "MeanStrain"]) # plot the deformed mesh with the shear stress res.plot("Stress", "XY", "Node") .. image-sg:: /examples/boundary_conditions/images/sphx_glr_periodic_bc_2d_plate_with_hole_001.png :alt: periodic bc 2d plate with hole :srcset: /examples/boundary_conditions/images/sphx_glr_periodic_bc_2d_plate_with_hole_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 76-80 Macroscopic strain and stress ----------------------------- Both are printed as Voigt vectors; the strain uses the engineering shear strain :math:`\gamma_{xy}`. .. GENERATED FROM PYTHON SOURCE LINES 80-91 .. code-block:: Python print( "Mean strain, Voigt vector ([Exx, Eyy, gamma_xy]): ", [pb.get_dof_solution(component)[0] for component in ["E_xx", "E_yy", "E_xy"]], ) # Compute the mean stress tensor surf = mesh.bounding_box.volume # total surface of the domain = volume in 2d mean_stress = [1 / surf * mesh.integrate_field(res["Stress"][i]) for i in [0, 1, 3]] print("Mean stress, Voigt vector ([Sxx, Syy, Sxy]): ", mean_stress) .. rst-class:: sphx-glr-script-out .. code-block:: none Mean strain, Voigt vector ([Exx, Eyy, gamma_xy]): [np.float64(0.0), np.float64(0.0), np.float64(0.1)] Mean stress, Voigt vector ([Sxx, Syy, Sxy]): [np.float64(-3.834512085632014e-12), np.float64(-5.082836196379503e-12), np.float64(2497.6680151186256)] .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.300 seconds) .. _sphx_glr_download_examples_boundary_conditions_periodic_bc_2d_plate_with_hole.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: periodic_bc_2d_plate_with_hole.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: periodic_bc_2d_plate_with_hole.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: periodic_bc_2d_plate_with_hole.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_