.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/gallery_examples/011_rst_workflow.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_gallery_examples_011_rst_workflow.py: .. _rst_workflow_example: Failure analysis of a MAPDL (RST) model --------------------------------------- This example shows the postprocessing of an MAPDL (RST) model with layered elements that was not preprocessed by ACP. The difference between the RST-only and ACP-based workflow is that the section data are loaded from the RST file instead of the ACP layup file. This happens automatically if the parameter `composite` of the :class:`.ContinuousFiberCompositesFiles` class is not set. The engineering data file (XML or ENGD) with the material properties is needed anyway. Otherwise, the material properties cannot be mapped. At the end of this example, two workflows are shown on how to create the engineering data file based on a MAPDL model and how to set the material UUIDs in MAPDL. .. important:: The material UUIDs in the engineering data file must be identical to the UUIDs in Mechanical APDL (RST file). A detailed explanation can be found at the end of this example. The postprocessing of MAPDL models is supported in 2024 R2 (DPF Server version 8.0) and later. A few advanced features are not supported with the RST only workflow. For more information, see :ref:`limitations`. .. note:: When using a Workbench project, use the :func:`.composite_files_from_workbench_harmonic_analysis` method to obtain the input files. .. GENERATED FROM PYTHON SOURCE LINES 58-64 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 64-81 .. code-block:: Python import ansys.dpf.core as dpf from ansys.dpf.composites.composite_model import CompositeModel from ansys.dpf.composites.constants import FailureOutput from ansys.dpf.composites.example_helper import get_continuous_fiber_example_files from ansys.dpf.composites.failure_criteria import ( CombinedFailureCriterion, CoreFailureCriterion, FaceSheetWrinklingCriterion, MaxStrainCriterion, MaxStressCriterion, VonMisesCriterion, ) from ansys.dpf.composites.select_indices import get_selected_indices from ansys.dpf.composites.server_helpers import connect_to_or_start_server .. GENERATED FROM PYTHON SOURCE LINES 82-83 Start a DPF server and copy the example files into the current working directory. .. GENERATED FROM PYTHON SOURCE LINES 83-85 .. code-block:: Python server = connect_to_or_start_server() .. GENERATED FROM PYTHON SOURCE LINES 86-87 Get input files (RST and material.engd but skip the ACP layup file). .. GENERATED FROM PYTHON SOURCE LINES 87-90 .. code-block:: Python composite_files_on_server = get_continuous_fiber_example_files(server, "shell", True) print(composite_files_on_server) .. rst-class:: sphx-glr-script-out .. code-block:: none ContinuousFiberCompositesFiles(result_files=['/tmp/dataProcessingTemp140043834353408/eb4ba432-16a0-468c-b454-2c943d7f1295/shell.rst'], composite={}, engineering_data='/tmp/dataProcessingTemp140043834353408/f17a52bc-4371-489c-a86a-dc9683249037/material.engd', solver_input_file=None, files_are_local=False, solver_type=) .. GENERATED FROM PYTHON SOURCE LINES 91-94 Configure combined failure criterion ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Configure the combined failure criterion. .. GENERATED FROM PYTHON SOURCE LINES 94-106 .. code-block:: Python combined_fc = CombinedFailureCriterion( name="failure of all materials", failure_criteria=[ MaxStrainCriterion(), MaxStressCriterion(), CoreFailureCriterion(), VonMisesCriterion(vme=True, vms=False), FaceSheetWrinklingCriterion(), ], ) .. GENERATED FROM PYTHON SOURCE LINES 107-110 Set up model and evaluate failures ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Set up the composite model. .. GENERATED FROM PYTHON SOURCE LINES 110-113 .. code-block:: Python composite_model = CompositeModel(composite_files_on_server, server) .. GENERATED FROM PYTHON SOURCE LINES 114-115 Evaluate failures for the entire model .. GENERATED FROM PYTHON SOURCE LINES 115-121 .. code-block:: Python output_all_elements = composite_model.evaluate_failure_criteria( combined_criterion=combined_fc, ) irf_field = output_all_elements.get_field({"failure_label": FailureOutput.FAILURE_VALUE}) irf_field.plot() .. tab-set:: .. tab-item:: Static Scene .. image-sg:: /examples/gallery_examples/images/sphx_glr_011_rst_workflow_001.png :alt: 011 rst workflow :srcset: /examples/gallery_examples/images/sphx_glr_011_rst_workflow_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_011_rst_workflow_001.vtksz .. GENERATED FROM PYTHON SOURCE LINES 122-124 Create and plot a sampling point ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. GENERATED FROM PYTHON SOURCE LINES 124-128 .. code-block:: Python sampling_point = composite_model.get_sampling_point(combined_criterion=combined_fc, element_id=2) sampling_plot = sampling_point.get_result_plots(core_scale_factor=0.1) sampling_plot.figure.show() .. image-sg:: /examples/gallery_examples/images/sphx_glr_011_rst_workflow_002.png :alt: Strains, Stresses, Failures :srcset: /examples/gallery_examples/images/sphx_glr_011_rst_workflow_002.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 129-136 Layer-wise failure criteria ~~~~~~~~~~~~~~~~~~~~~~~~~~~ The next lines show how to compute layer-wise failure criteria data and how to access it. Ply-wise filtering (by analysis ply name) is not supported in the RST workflow because the plies are not available in the RST file. .. GENERATED FROM PYTHON SOURCE LINES 138-140 First, the inputs for the multiple failure criteria operator have to be prepared. .. GENERATED FROM PYTHON SOURCE LINES 140-147 .. code-block:: Python strain_operator = composite_model.core_model.results.elastic_strain() strain_operator.inputs.bool_rotate_to_global(False) stress_operator = composite_model.core_model.results.stress() stress_operator.inputs.bool_rotate_to_global(False) .. GENERATED FROM PYTHON SOURCE LINES 148-152 Then, the operator is initialized and the inputs are connected. Note: the output of the multiple failure criteria operator has the same format as the input (strain and stress fields). So there is one failure value and mode for each integration point, layer and element, for all time steps. .. GENERATED FROM PYTHON SOURCE LINES 152-168 .. code-block:: Python failure_evaluator = dpf.Operator("composite::multiple_failure_criteria_operator") failure_evaluator.inputs.configuration(combined_fc.to_json()) failure_evaluator.inputs.materials_container( composite_model.material_operators.material_provider.outputs ) failure_evaluator.inputs.strains_container(strain_operator.outputs.fields_container) failure_evaluator.inputs.stresses_container(stress_operator.outputs.fields_container) failure_evaluator.inputs.mesh(composite_model.get_mesh()) failure_evaluator.inputs.section_data_container( composite_model.get_layup_operator().outputs.section_data_container ) irf_field = failure_evaluator.outputs.fields_container.get_data().get_field( {"failure_label": FailureOutput.FAILURE_VALUE, "time": 1} ) .. GENERATED FROM PYTHON SOURCE LINES 169-170 failure_mode_field is not used further, but it is demonstrated how to access it. .. GENERATED FROM PYTHON SOURCE LINES 170-174 .. code-block:: Python failure_mode_field = failure_evaluator.outputs.fields_container.get_data().get_field( {"failure_label": FailureOutput.FAILURE_MODE, "time": 1} ) .. GENERATED FROM PYTHON SOURCE LINES 175-180 This example computes a "failure intensity" which is in this case the difference between the maxima of the most critical and the lowest critical layer. Or in other words, it shows how uniform the laminate is loaded. A high intensity means there is a big difference between the maxima failure values of the layers. .. GENERATED FROM PYTHON SOURCE LINES 180-205 .. code-block:: Python failure_intensity_field = dpf.field.Field( location=dpf.locations.elemental, nature=dpf.natures.scalar ) with failure_intensity_field.as_local_field() as local_field: for element_id in irf_field.scoping.ids: irf_data = irf_field.get_entity_data_by_id(element_id) element_info = composite_model.get_element_info(element_id) most_critical_layer_irf = 0.0 lowest_critical_layer_irf = 1e9 for layer_index, dpf_material_id in enumerate(element_info.dpf_material_ids): selected_indices = get_selected_indices(element_info, layers=[layer_index]) layer_irf_values = irf_data[selected_indices] max_value = layer_irf_values.max() if max_value > most_critical_layer_irf: most_critical_layer_irf = max_value if max_value < lowest_critical_layer_irf: lowest_critical_layer_irf = max_value local_field.append([most_critical_layer_irf - lowest_critical_layer_irf], element_id) composite_model.get_mesh().plot(failure_intensity_field) .. tab-set:: .. tab-item:: Static Scene .. image-sg:: /examples/gallery_examples/images/sphx_glr_011_rst_workflow_003.png :alt: 011 rst workflow :srcset: /examples/gallery_examples/images/sphx_glr_011_rst_workflow_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_011_rst_workflow_003.vtksz .. GENERATED FROM PYTHON SOURCE LINES 206-224 Create Engineering Data file and set material UUIDs in MAPDL ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Here are two workflows for setting up the engineering data file and the material UUIDs in MAPDL. The material UUIDs must be set in MAPDL before the model is solved. With WB and Engineering Data: - Create an External Model system in WB and load the solver input file - Link the External Model with an Engineering Data system and update it - Save the project and copy the generated engineering data file (EngineeringData.xml) - For each material, look for the ``DataTransferID``, go to MAPDL and set the material UUIDs with the ``MP,UVID,,`` command With ACP Standalone (for constant material properties only): - Start ACP, go to *File - Import Model* and load the solver input file (CDB) - Go to the Materials folder and export the engineering data file (Ansys Workbench XML) - For each material, look for the ``DataTransferID``, go to MAPDL and set the material UUID with the ``MP,UVID,,`` command. .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 8.960 seconds) .. _sphx_glr_download_examples_gallery_examples_011_rst_workflow.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: 011_rst_workflow.ipynb <011_rst_workflow.ipynb>` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: 011_rst_workflow.py <011_rst_workflow.py>` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: 011_rst_workflow.zip <011_rst_workflow.zip>` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_