.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/gallery_examples/003_short_fiber_example.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_examples_gallery_examples_003_short_fiber_example.py: .. _short_fiber_example: Failure analysis for short fiber composites ------------------------------------------- This example shows how to evaluate failures of a short fiber reinforced part. As part of the short fiber workflows, you can evaluate and plot Tsai-Hill type orientation tensor-dependent failure criteria. This example shows how to configure the DPF operator ``short_fiber_failure_criterion_evaluator`` to compute such failure criteria. The model shown in this example consists of a tensile specimen made of a short glass fiber reinforced thermoplastic injection molded from both sides. .. note:: The evaluation of failure criteria in short fiber workflows is a beta feature, introduced in Ansys 2021 R2. .. GENERATED FROM PYTHON SOURCE LINES 47-53 Set up analysis ~~~~~~~~~~~~~~~ Setting up the analysis consists of loading Ansys libraries, connecting to the DPF server, and retrieving the example files. Load Ansys libraries. .. GENERATED FROM PYTHON SOURCE LINES 53-60 .. code-block:: default import ansys.dpf.core as dpf from ansys.dpf.composites.constants import FailureOutput from ansys.dpf.composites.data_sources import get_short_fiber_composites_data_sources from ansys.dpf.composites.example_helper import get_short_fiber_example_files from ansys.dpf.composites.server_helpers import connect_to_or_start_server .. GENERATED FROM PYTHON SOURCE LINES 61-67 Start a DPF server and copy the example files into the current working directory. These files are needed: * Mechanical APDL result (RST) file containing the simulation results * Engineering Data (MATML) file containing the material properties of the composite * Mechanical APDL input file (DS.DAT) containing the fiber orientation tensor data .. GENERATED FROM PYTHON SOURCE LINES 67-70 .. code-block:: default server = connect_to_or_start_server() composite_files_on_server = get_short_fiber_example_files(server, "short_fiber") .. GENERATED FROM PYTHON SOURCE LINES 71-74 Set up data sources ~~~~~~~~~~~~~~~~~~~ Set up the data sources. .. GENERATED FROM PYTHON SOURCE LINES 74-76 .. code-block:: default data_sources = get_short_fiber_composites_data_sources(composite_files_on_server) .. GENERATED FROM PYTHON SOURCE LINES 77-80 Initialize DPF model ~~~~~~~~~~~~~~~~~~~~ Initialize the DPF model. .. GENERATED FROM PYTHON SOURCE LINES 80-83 .. code-block:: default model = dpf.Model(data_sources=data_sources) mesh = model.metadata.meshed_region .. GENERATED FROM PYTHON SOURCE LINES 84-88 Plot results ~~~~~~~~~~~~ Plot the two largest eigenvalues (a11 and a22) of the fiber orientation tensor. Note that the plots reveal the presence of a weld line in the middle of the specimen. .. GENERATED FROM PYTHON SOURCE LINES 88-97 .. code-block:: default field_variable_provider = dpf.Operator("composite::inistate_field_variables_provider") field_variable_provider.inputs.data_sources(data_sources) field_variable_provider.inputs.mesh(model.metadata.mesh_provider) field_variables = field_variable_provider.outputs.fields_container.get_data() a11 = field_variables[0] a11.plot() .. tab-set:: .. tab-item:: Static Scene .. image-sg:: /examples/gallery_examples/images/sphx_glr_003_short_fiber_example_001.png :alt: 003 short fiber example :srcset: /examples/gallery_examples/images/sphx_glr_003_short_fiber_example_001.png :class: sphx-glr-single-img .. tab-item:: Interactive Scene .. offlineviewer:: /home/runner/work/pydpf-composites/pydpf-composites/doc/source/examples/gallery_examples/images/sphx_glr_003_short_fiber_example_001.vtksz .. GENERATED FROM PYTHON SOURCE LINES 98-102 .. code-block:: default a22 = field_variables[1] a22.plot() .. tab-set:: .. tab-item:: Static Scene .. image-sg:: /examples/gallery_examples/images/sphx_glr_003_short_fiber_example_002.png :alt: 003 short fiber example :srcset: /examples/gallery_examples/images/sphx_glr_003_short_fiber_example_002.png :class: sphx-glr-single-img .. tab-item:: Interactive Scene .. offlineviewer:: /home/runner/work/pydpf-composites/pydpf-composites/doc/source/examples/gallery_examples/images/sphx_glr_003_short_fiber_example_002.vtksz .. GENERATED FROM PYTHON SOURCE LINES 103-107 Configure and evaluate ~~~~~~~~~~~~~~~~~~~~~~ Configure the short fiber failure criterion evaluator and evaluate. Note that you can specify optional time and mesh scoping inputs. .. GENERATED FROM PYTHON SOURCE LINES 107-113 .. code-block:: default sf_op = dpf.Operator("composite::short_fiber_failure_criterion_evaluator") sf_op.inputs.streams_container(model.metadata.streams_provider) sf_op.inputs.data_sources(data_sources) sf_op.inputs.stress_limit_type("ultimate") # "yield" or "ultimate" (default) sf_op.run() .. GENERATED FROM PYTHON SOURCE LINES 114-117 Compute and plot results ~~~~~~~~~~~~~~~~~~~~~~~~ Compute and plot the maximum failure value per element. .. GENERATED FROM PYTHON SOURCE LINES 117-128 .. code-block:: default mat_support_operator = dpf.Operator("mat_support_provider") mat_support_operator.connect(4, data_sources) minmax_per_element = dpf.Operator("composite::minmax_per_element_operator") minmax_per_element.inputs.fields_container(sf_op) minmax_per_element.inputs.mesh(mesh) minmax_per_element.inputs.material_support(mat_support_operator) max_failure = minmax_per_element.outputs.field_max.get_data() max_failure_value = max_failure.get_field({"failure_label": FailureOutput.FAILURE_VALUE}) mesh.plot(max_failure_value, show_edges=True) .. tab-set:: .. tab-item:: Static Scene .. image-sg:: /examples/gallery_examples/images/sphx_glr_003_short_fiber_example_003.png :alt: 003 short fiber example :srcset: /examples/gallery_examples/images/sphx_glr_003_short_fiber_example_003.png :class: sphx-glr-single-img .. tab-item:: Interactive Scene .. offlineviewer:: /home/runner/work/pydpf-composites/pydpf-composites/doc/source/examples/gallery_examples/images/sphx_glr_003_short_fiber_example_003.vtksz .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 4.106 seconds) .. _sphx_glr_download_examples_gallery_examples_003_short_fiber_example.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: 003_short_fiber_example.py <003_short_fiber_example.py>` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: 003_short_fiber_example.ipynb <003_short_fiber_example.ipynb>` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_