.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/Airbag/airbag_post.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_Airbag_airbag_post.py: Airbag deploy postprocessing ---------------------------- This example shows how to animate the d3plot and display the stress on the airbag. .. GENERATED FROM PYTHON SOURCE LINES 9-14 Perform required imports ~~~~~~~~~~~~~~~~~~~~~~~~ Import required imports. from ansys.dpf import core as dpf .. GENERATED FROM PYTHON SOURCE LINES 16-21 Connect to DPF Server ~~~~~~~~~~~~~~~~~~~~~ Connect to the DPF Server. dpf.connect_to_server() .. GENERATED FROM PYTHON SOURCE LINES 23-29 Load model ~~~~~~~~~~ Load the model and print the contents of the model. All parts in the model are shell parts. Model information includes the result components and the number of states available in the d3plot. .. GENERATED FROM PYTHON SOURCE LINES 29-34 .. code-block:: Python """ ds = dpf.DataSources() ds.set_result_file_path(r'D:\PYDYNA_BETA_V.0.1\example-data\pydyna\Airbag\d3plot', 'd3plot') model = dpf.Model(ds) print(model) """ .. rst-class:: sphx-glr-script-out .. code-block:: none " ds = dpf.DataSources()\nds.set_result_file_path(r'D:\\PYDYNA_BETA_V.0.1\\example-data\\pydyna\\Airbag\\d3plot', 'd3plot')\nmodel = dpf.Model(ds)\nprint(model) " .. GENERATED FROM PYTHON SOURCE LINES 35-41 Extract stress on all parts ~~~~~~~~~~~~~~~~~~~~~~~~~~~ Extract the stress on all the parts. The stress fields container is scoped to all time frequencies to be able to animate the change in stress on the airbag fabric. .. GENERATED FROM PYTHON SOURCE LINES 41-46 .. code-block:: Python """ stress = model.results.stress.on_all_time_freqs() stress.inputs.data_sources(ds) stress.inputs.requested_location.connect("Nodal") fieldsStr = stress.outputs.fields_container()""" .. rst-class:: sphx-glr-script-out .. code-block:: none ' stress = model.results.stress.on_all_time_freqs()\nstress.inputs.data_sources(ds)\nstress.inputs.requested_location.connect("Nodal")\nfieldsStr = stress.outputs.fields_container()' .. GENERATED FROM PYTHON SOURCE LINES 47-52 Extract stress on mid integration point ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In the d3plot file, the shell stress is reported at three through-thickness points by default. Extract the stress on the mid integration point. .. GENERATED FROM PYTHON SOURCE LINES 52-57 .. code-block:: Python """ shell_layer_extract = dpf.operators.utility.change_shell_layers() shell_layer_extract.inputs.fields_container.connect(fieldsStr) shell_layer_extract.inputs.e_shell_layer.connect(dpf.common.shell_layers.mid.value) fields_top = shell_layer_extract.outputs.fields_container_as_fields_container() """ .. rst-class:: sphx-glr-script-out .. code-block:: none ' shell_layer_extract = dpf.operators.utility.change_shell_layers()\nshell_layer_extract.inputs.fields_container.connect(fieldsStr)\nshell_layer_extract.inputs.e_shell_layer.connect(dpf.common.shell_layers.mid.value)\nfields_top = shell_layer_extract.outputs.fields_container_as_fields_container() ' .. GENERATED FROM PYTHON SOURCE LINES 58-62 Plot deformed state ~~~~~~~~~~~~~~~~~~~ Plot the deformed state at 9 milliseconds. .. GENERATED FROM PYTHON SOURCE LINES 62-66 .. code-block:: Python """ N = fields_top[19] D = model.results.displacement(time_scoping=[19]).eval() N.plot(deform_by=D[0],show_edges=False) """ .. rst-class:: sphx-glr-script-out .. code-block:: none ' N = fields_top[19]\nD = model.results.displacement(time_scoping=[19]).eval()\nN.plot(deform_by=D[0],show_edges=False) ' .. GENERATED FROM PYTHON SOURCE LINES 67-72 Display stress field and set mesh ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Display the stress field and set the mesh to deform by the displacement of the nodes. .. GENERATED FROM PYTHON SOURCE LINES 72-74 .. code-block:: Python """ disp = model.results.displacement.on_all_time_freqs.eval() fields_top.animate(deform_by=disp,show_edges=False) """ .. rst-class:: sphx-glr-script-out .. code-block:: none ' disp = model.results.displacement.on_all_time_freqs.eval()\nfields_top.animate(deform_by=disp,show_edges=False) ' .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.001 seconds) .. _sphx_glr_download_examples_Airbag_airbag_post.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: airbag_post.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: airbag_post.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: airbag_post.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_