.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/Lattices/custom_auxetic_lattice.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_Lattices_custom_auxetic_lattice.py: Custom auxetic lattice ====================== A re-entrant auxetic strut lattice built with :class:`microgen.CustomLattice` from its vertices and strut connectivity, following `doi:10.1007/s00707-019-02387-x `_ and `doi:10.1016/j.ijmecsci.2017.05.048 `_. Requires the CAD backend: ``pip install microgen[cad]``. .. GENERATED FROM PYTHON SOURCE LINES 13-107 .. code-block:: Python from itertools import product import numpy as np import pyvista as pv from microgen import CustomLattice theta = np.pi / 3 l2 = 1.0 / (2.0 * np.sin(theta)) # l l1 = 0.5 + l2 * np.cos(theta) # h l3 = (l1 / 2.0) - np.cos(theta) outer_cube_vertices = np.array(list(product([-0.5, 0.5], repeat=3))) z_axis_faces_centers = np.array([[0, 0, z] for z in [0.5, -0.5]]) z_axis_reentrant_vertices = np.array([[0, 0, z] for z in [l3, -l3]]) xy_face_reentrant_vertices = np.array( [[x, y, z] for x, y in product([0.5, -0.5], [0.0]) for z in [l1 / 2, -l1 / 2]] + [[x, y, z] for x, y in product([0.0], [0.5, -0.5]) for z in [l1 / 2, -l1 / 2]] ) outer_cube_edges_reentrant_vertices = np.array( list(product([0.5, -0.5], [0.5, -0.5], [l3, -l3])) ) base_vertices = np.vstack( [ outer_cube_vertices, outer_cube_edges_reentrant_vertices, xy_face_reentrant_vertices, z_axis_faces_centers, z_axis_reentrant_vertices, ] ) strut_heights = np.array([l1] * 4 + [l2] * 24 + [l3 + 0.5] * 10) l1_strut_vertex_pairs = np.array([[16, 17], [20, 21], [18, 19], [22, 23]]) l2_strut_vertex_pairs = np.array( [ [18, 15], [19, 14], [18, 13], [12, 19], [15, 22], [14, 23], [23, 10], [11, 22], [11, 16], [10, 17], [16, 9], [8, 17], [9, 20], [8, 21], [13, 20], [12, 21], [20, 27], [18, 27], [27, 22], [16, 27], [23, 26], [17, 26], [26, 21], [26, 19], ] ) half_l1_strut_vertex_pairs = np.array( [ [9, 7], [11, 5], [8, 6], [10, 4], [26, 25], [12, 2], [13, 3], [27, 24], [15, 1], [14, 0], ] ) strut_vertex_pairs = np.vstack( [l1_strut_vertex_pairs, l2_strut_vertex_pairs, half_l1_strut_vertex_pairs] ) auxetic_lattice = CustomLattice( strut_radius=0.1, strut_heights=strut_heights, base_vertices=base_vertices, strut_vertex_pairs=strut_vertex_pairs, strut_joints=True, ) shape = auxetic_lattice.generate_cad() stl_file = "custom_auxetic_lattice.stl" shape.export_stl(stl_file) .. GENERATED FROM PYTHON SOURCE LINES 108-109 .. code-block:: Python pv.read(stl_file).plot(smooth_shading=True, split_sharp_edges=True, color="#ef7d2d") .. tab-set:: .. tab-item:: Static Scene .. image-sg:: /examples/Lattices/images/sphx_glr_custom_auxetic_lattice_001.png :alt: custom auxetic lattice :srcset: /examples/Lattices/images/sphx_glr_custom_auxetic_lattice_001.png :class: sphx-glr-single-img .. tab-item:: Interactive Scene .. offlineviewer:: /home/runner/work/microgen/microgen/docs/examples/Lattices/images/sphx_glr_custom_auxetic_lattice_001.vtksz .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 7.252 seconds) .. _sphx_glr_download_examples_Lattices_custom_auxetic_lattice.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: custom_auxetic_lattice.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: custom_auxetic_lattice.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: custom_auxetic_lattice.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_