.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/DIC/DIC1.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_DIC_DIC1.py: DIC1 ==== Performs digital image correlation analyses on images obtained experimentally in this scientific article: https://univ-eiffel.hal.science/hal-05115523. The images were downloaded from `Recherche Data Gouv `_ and are distributed under the `Etalab Open License 2.0 `_. For further details, see the `DATA_LICENSE.md `_ file. Further implementation details are available in my `PhD thesis `_ (Section 2, Chapter 2, written in French). .. GENERATED FROM PYTHON SOURCE LINES 17-107 .. rst-class:: sphx-glr-horizontal * .. image-sg:: /examples/DIC/images/sphx_glr_DIC1_001.png :alt: TRI3: Ne = 1924, Nn = 1031 :srcset: /examples/DIC/images/sphx_glr_DIC1_001.png :class: sphx-glr-multi-img * .. image-sg:: /examples/DIC/images/sphx_glr_DIC1_002.png :alt: /img26.png ux :srcset: /examples/DIC/images/sphx_glr_DIC1_002.png :class: sphx-glr-multi-img * .. image-sg:: /examples/DIC/images/sphx_glr_DIC1_003.png :alt: /img26.png uy :srcset: /examples/DIC/images/sphx_glr_DIC1_003.png :class: sphx-glr-multi-img * .. image-sg:: /examples/DIC/images/sphx_glr_DIC1_004.png :alt: /img26.png Exx :srcset: /examples/DIC/images/sphx_glr_DIC1_004.png :class: sphx-glr-multi-img .. rst-class:: sphx-glr-script-out .. code-block:: none ROI (951.274 ms) N_x and N_y (110.381 ms) Laplacian operator (4.517 ms) Construct L and M (87.605 ms) /img10.png Iter 1 ||b|| 4.9e-02 Iter 2 ||b|| 1.9e-02 Iter 3 ||b|| 9.4e-03 Iter 4 ||b|| 4.8e-03 Iter 5 ||b|| 2.5e-03 Iter 6 ||b|| 1.3e-03 Iter 7 ||b|| 6.6e-04 Iter 8 ||b|| 3.5e-04 Iter 9 ||b|| 1.8e-04 Iter 10 ||b|| 9.4e-05 Iter 11 ||b|| 4.9e-05 Iter 12 ||b|| 2.6e-05 Iter 13 ||b|| 1.3e-05 Iter 14 ||b|| 7.0e-06 Iter 15 ||b|| 3.7e-06 Iter 16 ||b|| 1.9e-06 Iter 17 ||b|| 1.0e-06 Iter 18 ||b|| 5.3e-07 /img18.png Iter 1 ||b|| 7.3e-02 Iter 2 ||b|| 1.2e-02 Iter 3 ||b|| 5.3e-03 Iter 4 ||b|| 2.5e-03 Iter 5 ||b|| 1.2e-03 Iter 6 ||b|| 5.7e-04 Iter 7 ||b|| 2.7e-04 Iter 8 ||b|| 1.3e-04 Iter 9 ||b|| 6.3e-05 Iter 10 ||b|| 3.0e-05 Iter 11 ||b|| 1.5e-05 Iter 12 ||b|| 7.1e-06 Iter 13 ||b|| 3.4e-06 Iter 14 ||b|| 1.7e-06 Iter 15 ||b|| 8.2e-07 /img26.png Iter 1 ||b|| 7.1e-02 Iter 2 ||b|| 4.0e-02 Iter 3 ||b|| 1.2e-02 Iter 4 ||b|| 5.4e-03 Iter 5 ||b|| 2.6e-03 Iter 6 ||b|| 1.2e-03 Iter 7 ||b|| 5.9e-04 Iter 8 ||b|| 2.8e-04 Iter 9 ||b|| 1.4e-04 Iter 10 ||b|| 6.7e-05 Iter 11 ||b|| 3.3e-05 Iter 12 ||b|| 1.6e-05 Iter 13 ||b|| 7.8e-06 Iter 14 ||b|| 3.8e-06 Iter 15 ||b|| 1.9e-06 Iter 16 ||b|| 9.2e-07 | .. code-block:: Python :lineno-start: 18 import matplotlib.pyplot as plt from PIL import Image # matplotlib dependency import numpy as np from EasyFEA import Display, Folder, Models from EasyFEA.Simulations import Elastic, DIC from EasyFEA.Geoms import Circle, Domain def Plot_Result(simu: Elastic, result: str, img=None, title="", plotMesh=True): ax = Display.Init_Axes() if img is not None: ax.imshow(img, cmap="gray") Display.Plot_Result(simu, result, title=title, plotMesh=plotMesh, ax=ax) if __name__ == "__main__": # ---------------------------------------------- # Config # ---------------------------------------------- useRegularization = True imagesDir = Folder.Join(Folder.Dir(), "_images1") # ---------------------------------------------- # Load images # ---------------------------------------------- images = [ Folder.Join(imagesDir, image) for image in sorted(Folder.os.listdir(imagesDir)) if image.endswith(".png") ] imgRef = np.asarray(Image.open(images[0]), dtype=int) ax = Display.Init_Axes() ax.imshow(imgRef, cmap="gray") # ---------------------------------------------- # Create Mesh # ---------------------------------------------- imgScale = 0.11479591836734694 # mm/px x0, y0 = 35, 25 x1, y1 = 423, 814 meshSize = (x1 - x0) / 20 contour = Domain((x0, y0), (x1, y1), meshSize) contour.Plot(ax) xC, yC, radius = DIC.Get_Circle(imgRef, 30.0, [(150, 350), (350, 500)]) circle = Circle((xC, yC), 2 * radius, meshSize) circle.Plot(ax) mesh = contour.Mesh_2D([circle]) Display.Plot_Mesh(mesh, alpha=0, edgecolor="black", ax=ax) ax.legend() # ---------------------------------------------- # Conduct DIC analyses # ---------------------------------------------- lr = int(np.sqrt(0.25) * 8 * meshSize) if useRegularization else 0 dic = DIC(mesh, imgRef, lr, verbosity=True) # Generate an elastic simulation to streamline the visualization of results. simu = Elastic(mesh, Models.Elastic.Isotropic(2, E=1, v=0.3)) for image in images[1:]: imgStr = image.removeprefix(imagesDir) print(f"\n {imgStr}") img = np.asarray(Image.open(image), dtype=int) u = dic.Solve(img) simu._Set_solutions(simu.problemType, u * imgScale) simu.Save_Iter() if image == images[-1]: Plot_Result(simu, "ux", img, f"{imgStr} ux") Plot_Result(simu, "uy", img, f"{imgStr} uy") Plot_Result(simu, "Exx", img, f"{imgStr} Exx") plt.show() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 9.470 seconds) .. _sphx_glr_download_examples_DIC_DIC1.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: DIC1.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: DIC1.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: DIC1.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_