.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/workflows/02-advanced-pymapdl-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_workflows_02-advanced-pymapdl-workflow.py: .. _advanced_pymapdl_workflow_example: Advanced PyMAPDL workflow ========================= This example shows how to define a composite lay-up with PyACP, solve the resulting model with PyMAPDL, and run a failure analysis with PyDPF Composites. Begin with an MAPDL CDB file that contains the mesh, material data, and boundary conditions. Import the file to PyACP to define the lay-up, and then export the resulting model to PyMAPDL. Once the results are available, the RST file is loaded in PyDPF Composites for postprocessing. The additional input files (``material.xml`` and ``ACPCompositeDefinitions.h5``) can also be stored with PyACP and passed to PyDPF Composites. .. GENERATED FROM PYTHON SOURCE LINES 41-43 Import modules and start ACP ---------------------------- .. GENERATED FROM PYTHON SOURCE LINES 45-46 Import the standard library and third-party dependencies. .. GENERATED FROM PYTHON SOURCE LINES 46-51 .. code-block:: Python import pathlib import tempfile import pyvista .. GENERATED FROM PYTHON SOURCE LINES 52-53 Import the Ansys libraries. .. GENERATED FROM PYTHON SOURCE LINES 53-57 .. code-block:: Python import ansys.acp.core as pyacp .. GENERATED FROM PYTHON SOURCE LINES 59-60 Launch the PyACP server and connect to it. .. GENERATED FROM PYTHON SOURCE LINES 60-62 .. code-block:: Python acp = pyacp.launch_acp() .. GENERATED FROM PYTHON SOURCE LINES 63-68 Get example input files ----------------------- Create a temporary working directory, and download the example input files to this directory. .. GENERATED FROM PYTHON SOURCE LINES 68-75 .. code-block:: Python working_dir = tempfile.TemporaryDirectory() working_dir_path = pathlib.Path(working_dir.name) input_file = pyacp.extras.example_helpers.get_example_file( pyacp.extras.example_helpers.ExampleKeys.CLASS40_CDB, working_dir_path ) .. GENERATED FROM PYTHON SOURCE LINES 76-78 Load mesh and materials from CDB file ------------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 81-82 Load the CDB file into PyACP and set the unit system. .. GENERATED FROM PYTHON SOURCE LINES 82-86 .. code-block:: Python model = acp.import_model(path=input_file, format="ansys:cdb", unit_system=pyacp.UnitSystemType.MPA) model .. rst-class:: sphx-glr-script-out .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 87-88 Visualize the loaded mesh. .. GENERATED FROM PYTHON SOURCE LINES 88-91 .. code-block:: Python mesh = model.mesh.to_pyvista() mesh.plot() .. tab-set:: .. tab-item:: Static Scene .. image-sg:: /examples/workflows/images/sphx_glr_02-advanced-pymapdl-workflow_001.png :alt: 02 advanced pymapdl workflow :srcset: /examples/workflows/images/sphx_glr_02-advanced-pymapdl-workflow_001.png :class: sphx-glr-single-img .. tab-item:: Interactive Scene .. offlineviewer:: /home/runner/work/pyacp/pyacp/doc/source/examples/workflows/images/sphx_glr_02-advanced-pymapdl-workflow_001.vtksz .. GENERATED FROM PYTHON SOURCE LINES 92-96 Build Composite Lay-up ---------------------- Create the model (MPA unit system). .. GENERATED FROM PYTHON SOURCE LINES 99-101 Materials ''''''''' .. GENERATED FROM PYTHON SOURCE LINES 101-114 .. code-block:: Python mat_corecell_81kg = model.materials["1"] mat_corecell_81kg.name = "Core Cell 81kg" mat_corecell_81kg.ply_type = "isotropic_homogeneous_core" mat_corecell_103kg = model.materials["2"] mat_corecell_103kg.name = "Core Cell 103kg" mat_corecell_103kg.ply_type = "isotropic_homogeneous_core" mat_eglass_ud = model.materials["3"] mat_eglass_ud.name = "E-Glass (uni-directional)" mat_eglass_ud.ply_type = "regular" .. GENERATED FROM PYTHON SOURCE LINES 115-117 Fabrics ''''''' .. GENERATED FROM PYTHON SOURCE LINES 117-126 .. code-block:: Python corecell_81kg_5mm = model.create_fabric( name="Corecell 81kg", thickness=0.005, material=mat_corecell_81kg ) corecell_103kg_10mm = model.create_fabric( name="Corecell 103kg", thickness=0.01, material=mat_corecell_103kg ) eglass_ud_02mm = model.create_fabric(name="eglass UD", thickness=0.0002, material=mat_eglass_ud) .. GENERATED FROM PYTHON SOURCE LINES 127-129 Rosettes '''''''' .. GENERATED FROM PYTHON SOURCE LINES 129-139 .. code-block:: Python ros_deck = model.create_rosette(name="ros_deck", origin=(-5.9334, -0.0481, 1.693)) ros_hull = model.create_rosette(name="ros_hull", origin=(-5.3711, -0.0506, -0.2551)) ros_bulkhead = model.create_rosette( name="ros_bulkhead", origin=(-5.622, 0.0022, 0.0847), dir1=(0.0, 1.0, 0.0), dir2=(0.0, 0.0, 1.0) ) ros_keeltower = model.create_rosette( name="ros_keeltower", origin=(-6.0699, -0.0502, 0.623), dir1=(0.0, 0.0, 1.0) ) .. GENERATED FROM PYTHON SOURCE LINES 140-144 Oriented Selection Sets ''''''''''''''''''''''' Note that the element sets are imported from the initial mesh (CBD file). .. GENERATED FROM PYTHON SOURCE LINES 144-184 .. code-block:: Python oss_deck = model.create_oriented_selection_set( name="oss_deck", orientation_point=(-5.3806, -0.0016, 1.6449), orientation_direction=(0.0, 0.0, -1.0), element_sets=[model.element_sets["DECK"]], rosettes=[ros_deck], ) oss_hull = model.create_oriented_selection_set( name="oss_hull", orientation_point=(-5.12, 0.1949, -0.2487), orientation_direction=(0.0, 0.0, 1.0), element_sets=[model.element_sets["HULL_ALL"]], rosettes=[ros_hull], ) oss_bulkhead = model.create_oriented_selection_set( name="oss_bulkhead", orientation_point=(-5.622, -0.0465, -0.094), orientation_direction=(1.0, 0.0, 0.0), element_sets=[model.element_sets["BULKHEAD_ALL"]], rosettes=[ros_bulkhead], ) esets = [ model.element_sets["KEELTOWER_AFT"], model.element_sets["KEELTOWER_FRONT"], model.element_sets["KEELTOWER_PORT"], model.element_sets["KEELTOWER_STB"], ] oss_keeltower = model.create_oriented_selection_set( name="oss_keeltower", orientation_point=(-6.1019, 0.0001, 1.162), orientation_direction=(-1.0, 0.0, 0.0), element_sets=esets, rosettes=[ros_keeltower], ) .. GENERATED FROM PYTHON SOURCE LINES 185-188 Show the orientations on the hull oriented selection set (OSS). Note that the model must be updated before the orientations are available. .. GENERATED FROM PYTHON SOURCE LINES 188-202 .. code-block:: Python model.update() plotter = pyvista.Plotter() plotter.add_mesh(model.mesh.to_pyvista(), color="white") orientation = oss_hull.elemental_data.orientation assert orientation is not None plotter.add_mesh( orientation.get_pyvista_glyphs(mesh=model.mesh, factor=0.2, culling_factor=5), color="blue", ) plotter.show() .. tab-set:: .. tab-item:: Static Scene .. image-sg:: /examples/workflows/images/sphx_glr_02-advanced-pymapdl-workflow_002.png :alt: 02 advanced pymapdl workflow :srcset: /examples/workflows/images/sphx_glr_02-advanced-pymapdl-workflow_002.png :class: sphx-glr-single-img .. tab-item:: Interactive Scene .. offlineviewer:: /home/runner/work/pyacp/pyacp/doc/source/examples/workflows/images/sphx_glr_02-advanced-pymapdl-workflow_002.vtksz .. GENERATED FROM PYTHON SOURCE LINES 203-205 Modeling Plies '''''''''''''' .. GENERATED FROM PYTHON SOURCE LINES 205-218 .. code-block:: Python def add_ply(mg, name, ply_material, angle, oss): return mg.create_modeling_ply( name=name, ply_material=ply_material, oriented_selection_sets=oss, ply_angle=angle, number_of_layers=1, global_ply_nr=0, # add at the end ) .. GENERATED FROM PYTHON SOURCE LINES 219-220 Define plies for the hull, deck, and bulkhead. .. GENERATED FROM PYTHON SOURCE LINES 220-231 .. code-block:: Python angles = [-90.0, -60.0, -45.0 - 30.0, 0.0, 0.0, 30.0, 45.0, 60.0, 90.0] for mg_name in ["hull", "deck", "bulkhead"]: mg = model.create_modeling_group(name=mg_name) oss_list = [model.oriented_selection_sets["oss_" + mg_name]] for angle in angles: add_ply(mg, "eglass_ud_02mm_" + str(angle), eglass_ud_02mm, angle, oss_list) add_ply(mg, "corecell_103kg_10mm", corecell_103kg_10mm, 0.0, oss_list) for angle in angles: add_ply(mg, "eglass_ud_02mm_" + str(angle), eglass_ud_02mm, angle, oss_list) .. GENERATED FROM PYTHON SOURCE LINES 232-233 Add plies to the keeltower. .. GENERATED FROM PYTHON SOURCE LINES 233-243 .. code-block:: Python mg = model.create_modeling_group(name="keeltower") oss_list = [model.oriented_selection_sets["oss_keeltower"]] for angle in angles: add_ply(mg, "eglass_ud_02mm_" + str(angle), eglass_ud_02mm, angle, oss_list) add_ply(mg, "corecell_81kg_5mm", corecell_81kg_5mm, 0.0, oss_list) for angle in angles: add_ply(mg, "eglass_ud_02mm_" + str(angle), eglass_ud_02mm, angle, oss_list) .. GENERATED FROM PYTHON SOURCE LINES 244-245 Inspect the number of modeling groups and plies. .. GENERATED FROM PYTHON SOURCE LINES 245-252 .. code-block:: Python print(len(model.modeling_groups)) print(len(model.modeling_groups["hull"].modeling_plies)) print(len(model.modeling_groups["deck"].modeling_plies)) print(len(model.modeling_groups["bulkhead"].modeling_plies)) print(len(model.modeling_groups["keeltower"].modeling_plies)) .. rst-class:: sphx-glr-script-out .. code-block:: none 4 19 19 19 19 .. GENERATED FROM PYTHON SOURCE LINES 253-254 Show the thickness of one of the plies. .. GENERATED FROM PYTHON SOURCE LINES 254-260 .. code-block:: Python model.update() modeling_ply = model.modeling_groups["deck"].modeling_plies["eglass_ud_02mm_0.5"] thickness = modeling_ply.elemental_data.thickness assert thickness is not None thickness.get_pyvista_mesh(mesh=model.mesh).plot() .. tab-set:: .. tab-item:: Static Scene .. image-sg:: /examples/workflows/images/sphx_glr_02-advanced-pymapdl-workflow_003.png :alt: 02 advanced pymapdl workflow :srcset: /examples/workflows/images/sphx_glr_02-advanced-pymapdl-workflow_003.png :class: sphx-glr-single-img .. tab-item:: Interactive Scene .. offlineviewer:: /home/runner/work/pyacp/pyacp/doc/source/examples/workflows/images/sphx_glr_02-advanced-pymapdl-workflow_003.vtksz .. GENERATED FROM PYTHON SOURCE LINES 261-262 Show the ply offsets that are scaled by a factor of 200. .. GENERATED FROM PYTHON SOURCE LINES 262-271 .. code-block:: Python plotter = pyvista.Plotter() plotter.add_mesh(model.mesh.to_pyvista(), color="white") ply_offset = modeling_ply.nodal_data.ply_offset assert ply_offset is not None plotter.add_mesh( ply_offset.get_pyvista_glyphs(mesh=model.mesh, factor=200), ) plotter.show() .. tab-set:: .. tab-item:: Static Scene .. image-sg:: /examples/workflows/images/sphx_glr_02-advanced-pymapdl-workflow_004.png :alt: 02 advanced pymapdl workflow :srcset: /examples/workflows/images/sphx_glr_02-advanced-pymapdl-workflow_004.png :class: sphx-glr-single-img .. tab-item:: Interactive Scene .. offlineviewer:: /home/runner/work/pyacp/pyacp/doc/source/examples/workflows/images/sphx_glr_02-advanced-pymapdl-workflow_004.vtksz .. GENERATED FROM PYTHON SOURCE LINES 272-273 Show the thickness of the entire lay-up. .. GENERATED FROM PYTHON SOURCE LINES 273-277 .. code-block:: Python thickness = model.elemental_data.thickness assert thickness is not None thickness.get_pyvista_mesh(mesh=model.mesh).plot() .. tab-set:: .. tab-item:: Static Scene .. image-sg:: /examples/workflows/images/sphx_glr_02-advanced-pymapdl-workflow_005.png :alt: 02 advanced pymapdl workflow :srcset: /examples/workflows/images/sphx_glr_02-advanced-pymapdl-workflow_005.png :class: sphx-glr-single-img .. tab-item:: Interactive Scene .. offlineviewer:: /home/runner/work/pyacp/pyacp/doc/source/examples/workflows/images/sphx_glr_02-advanced-pymapdl-workflow_005.vtksz .. GENERATED FROM PYTHON SOURCE LINES 278-280 Write out ACP Model ------------------- .. GENERATED FROM PYTHON SOURCE LINES 281-287 .. code-block:: Python acph5_filename = "class40.acph5" cdb_filename_out = "class40_analysis_model.cdb" composite_definition_h5_filename = "ACPCompositeDefinitions.h5" matml_filename = "materials.xml" .. GENERATED FROM PYTHON SOURCE LINES 288-289 Update and save the ACP model. .. GENERATED FROM PYTHON SOURCE LINES 289-292 .. code-block:: Python model.update() model.save(working_dir_path / acph5_filename, save_cache=True) .. GENERATED FROM PYTHON SOURCE LINES 293-294 Save the model as a CDB file for solving with PyMAPDL. .. GENERATED FROM PYTHON SOURCE LINES 294-300 .. code-block:: Python model.export_analysis_model(working_dir_path / cdb_filename_out) # Export the shell lay-up and material file for PyDPF Composites. model.export_shell_composite_definitions(working_dir_path / composite_definition_h5_filename) model.export_materials(working_dir_path / matml_filename) .. GENERATED FROM PYTHON SOURCE LINES 301-303 Solve with PyMAPDL ------------------ .. GENERATED FROM PYTHON SOURCE LINES 305-306 Import PyMAPDL and connect to its server. .. GENERATED FROM PYTHON SOURCE LINES 306-311 .. code-block:: Python from ansys.mapdl.core import launch_mapdl mapdl = launch_mapdl() mapdl.clear() .. GENERATED FROM PYTHON SOURCE LINES 312-313 Load the CDB file into PyMAPDL. .. GENERATED FROM PYTHON SOURCE LINES 313-315 .. code-block:: Python mapdl.input(str(working_dir_path / cdb_filename_out)) .. rst-class:: sphx-glr-script-out .. code-block:: none '\n /INPUT FILE= class40_analysis_model.cdb LINE= 0\n ANSYS RELEASE 11.0 UP20070125 16:39:41 03/10/2009\n\n *** MAPDL - ENGINEERING ANALYSIS SYSTEM RELEASE 25.2BETA ***\n Ansys Mechanical Enterprise \n 00000000 VERSION=LINUX x64 16:02:41 DEC 03, 2024 CP= 1.269\n\n \n\n\n\n ** WARNING: PRE-RELEASE VERSION OF MAPDL 25.2BETA\n ANSYS,INC TESTING IS NOT COMPLETE - CHECK RESULTS CAREFULLY **\n\n ***** MAPDL ANALYSIS DEFINITION (PREP7) *****\n\n\n ***** ROUTINE COMPLETED ***** CP = 1.330\n\n\n' .. GENERATED FROM PYTHON SOURCE LINES 316-317 Solve the model. .. GENERATED FROM PYTHON SOURCE LINES 317-321 .. code-block:: Python mapdl.allsel() mapdl.slashsolu() mapdl.solve() .. rst-class:: sphx-glr-script-out .. code-block:: none ***** MAPDL SOLVE COMMAND ***** *** NOTE *** CP = 1.342 TIME= 16:02:41 There is no title defined for this analysis. *** SELECTION OF ELEMENT TECHNOLOGIES FOR APPLICABLE ELEMENTS *** ---GIVE SUGGESTIONS ONLY--- ELEMENT TYPE 1 IS SHELL181. IT IS ASSOCIATED WITH ELASTOPLASTIC MATERIALS ONLY. KEYOPT(8) IS ALREADY SET AS SUGGESTED. KEYOPT(3)=2 IS SUGGESTED FOR HIGHER ACCURACY OF MEMBRANE STRESSES; OTHERWISE, KEYOPT(3)=0 IS SUGGESTED. ELEMENT TYPE 2 IS BEAM188 . KEYOPT(1)=1 IS SUGGESTED FOR NON-CIRCULAR CROSS SECTIONS AND KEYOPT(3)=2 IS ALWAYS SUGGESTED. ELEMENT TYPE 2 IS BEAM188 . KEYOPT(15) IS ALREADY SET AS SUGGESTED. ELEMENT TYPE 3 IS SHELL181. IT IS ASSOCIATED WITH ELASTOPLASTIC MATERIALS ONLY. KEYOPT(8) IS ALREADY SET AS SUGGESTED. KEYOPT(3)=2 IS SUGGESTED FOR HIGHER ACCURACY OF MEMBRANE STRESSES; OTHERWISE, KEYOPT(3)=0 IS SUGGESTED. *** MAPDL - ENGINEERING ANALYSIS SYSTEM RELEASE 25.2BETA *** Ansys Mechanical Enterprise 00000000 VERSION=LINUX x64 16:02:41 DEC 03, 2024 CP= 1.378 ** WARNING: PRE-RELEASE VERSION OF MAPDL 25.2BETA ANSYS,INC TESTING IS NOT COMPLETE - CHECK RESULTS CAREFULLY ** S O L U T I O N O P T I O N S PROBLEM DIMENSIONALITY. . . . . . . . . . . . .3-D DEGREES OF FREEDOM. . . . . . UX UY UZ ROTX ROTY ROTZ ANALYSIS TYPE . . . . . . . . . . . . . . . . .STATIC (STEADY-STATE) GLOBALLY ASSEMBLED MATRIX . . . . . . . . . . .SYMMETRIC *** NOTE *** CP = 1.380 TIME= 16:02:41 Poisson's ratio PR input has been converted to NU input. *** NOTE *** CP = 1.384 TIME= 16:02:41 Present time 0 is less than or equal to the previous time. Time will default to 1. *** NOTE *** CP = 1.384 TIME= 16:02:41 The conditions for direct assembly have been met. No .emat or .erot files will be produced. L O A D S T E P O P T I O N S LOAD STEP NUMBER. . . . . . . . . . . . . . . . 1 TIME AT END OF THE LOAD STEP. . . . . . . . . . 1.0000 NUMBER OF SUBSTEPS. . . . . . . . . . . . . . . 1 STEP CHANGE BOUNDARY CONDITIONS . . . . . . . . NO COPY INTEGRATION POINT VALUES TO NODE . . . . . YES PRINT OUTPUT CONTROLS . . . . . . . . . . . . .NO PRINTOUT DATABASE OUTPUT CONTROLS. . . . . . . . . . . .ALL DATA WRITTEN FOR THE LAST SUBSTEP SOLUTION MONITORING INFO IS WRITTEN TO FILE= file.mntr *** NOTE *** CP = 1.451 TIME= 16:02:41 Predictor is ON by default for structural elements with rotational degrees of freedom. Use the PRED,OFF command to turn the predictor OFF if it adversely affects the convergence. *********** PRECISE MASS SUMMARY *********** TOTAL RIGID BODY MASS MATRIX ABOUT ORIGIN Translational mass | Coupled translational/rotational mass 324.96 0.46544E-18 0.14304E-17 | -0.11582E-16 211.44 -0.36088E-02 0.46544E-18 324.96 -0.49693E-17 | -211.44 -0.96175E-17 -2015.3 0.14304E-17 -0.49693E-17 324.96 | 0.36088E-02 2015.3 0.20783E-16 ------------------------------------------ | ------------------------------------------ | Rotational mass (inertia) | 759.66 0.20436E-01 1316.9 | 0.20436E-01 13054. -0.32469E-02 | 1316.9 -0.32469E-02 13218. TOTAL MASS = 324.96 The mass principal axes coincide with the global Cartesian axes CENTER OF MASS (X,Y,Z)= -6.2017 0.11105E-04 0.65067 TOTAL INERTIA ABOUT CENTER OF MASS 622.08 -0.19444E-02 5.6093 -0.19444E-02 418.20 -0.89877E-03 5.6093 -0.89877E-03 719.59 PRINCIPAL INERTIAS = 621.76 418.20 719.92 ORIENTATION VECTORS OF THE INERTIA PRINCIPAL AXES IN GLOBAL CARTESIAN ( 0.998,-0.000,-0.057) ( 0.000, 1.000, 0.000) ( 0.057,-0.000, 0.998) *** MASS SUMMARY BY ELEMENT TYPE *** TYPE MASS 1 322.570 2 1.65744 3 0.729815 Range of element maximum matrix coefficients in global coordinates Maximum = 104467551 at element 771. Minimum = 31671440.9 at element 4058. *** ELEMENT MATRIX FORMULATION TIMES TYPE NUMBER ENAME TOTAL CP AVE CP 1 3973 SHELL181 2.347 0.000591 2 88 BEAM188 0.003 0.000032 3 22 SHELL181 0.004 0.000184 Time at end of element matrix formulation CP = 3.82273006. SPARSE MATRIX DIRECT SOLVER. Number of equations = 24096, Maximum wavefront = 66 Memory allocated on this process ------------------------------------------------------------------- Equation solver memory allocated = 66.685 MB Equation solver memory required for in-core mode = 64.079 MB Equation solver memory required for out-of-core mode = 28.690 MB Total (solver and non-solver) memory allocated = 686.607 MB *** NOTE *** CP = 3.867 TIME= 16:02:44 The Sparse Matrix Solver is currently running in the in-core memory mode. This memory mode uses the most amount of memory in order to avoid using the hard drive as much as possible, which most often results in the fastest solution time. This mode is recommended if enough physical memory is present to accommodate all of the solver data. Sparse solver maximum pivot= 266668835 at node 2542 UY. Sparse solver minimum pivot= 1.78586102 at node 586 ROTZ. Sparse solver minimum pivot in absolute value= 1.78586102 at node 586 ROTZ. *** ELEMENT RESULT CALCULATION TIMES TYPE NUMBER ENAME TOTAL CP AVE CP 1 3973 SHELL181 5.196 0.001308 2 88 BEAM188 0.006 0.000068 3 22 SHELL181 0.007 0.000319 *** NODAL LOAD CALCULATION TIMES TYPE NUMBER ENAME TOTAL CP AVE CP 1 3973 SHELL181 0.056 0.000014 2 88 BEAM188 0.001 0.000016 3 22 SHELL181 0.000 0.000014 *** LOAD STEP 1 SUBSTEP 1 COMPLETED. CUM ITER = 1 *** TIME = 1.00000 TIME INC = 1.00000 NEW TRIANG MATRIX *** MAPDL BINARY FILE STATISTICS BUFFER SIZE USED= 16384 8.562 MB WRITTEN ON ASSEMBLED MATRIX FILE: file.full 58.125 MB WRITTEN ON RESULTS FILE: file.rst .. GENERATED FROM PYTHON SOURCE LINES 322-323 Show the displacements in postprocessing. .. GENERATED FROM PYTHON SOURCE LINES 323-331 .. code-block:: Python mapdl.post1() mapdl.set("last") mapdl.post_processing.plot_nodal_displacement(component="NORM") # Download the RST file for further postprocessing. rstfile_name = f"{mapdl.jobname}.rst" mapdl.download(rstfile_name, working_dir_path) .. tab-set:: .. tab-item:: Static Scene .. image-sg:: /examples/workflows/images/sphx_glr_02-advanced-pymapdl-workflow_006.png :alt: 02 advanced pymapdl workflow :srcset: /examples/workflows/images/sphx_glr_02-advanced-pymapdl-workflow_006.png :class: sphx-glr-single-img .. tab-item:: Interactive Scene .. offlineviewer:: /home/runner/work/pyacp/pyacp/doc/source/examples/workflows/images/sphx_glr_02-advanced-pymapdl-workflow_006.vtksz .. rst-class:: sphx-glr-script-out .. code-block:: none ['file.rst'] .. GENERATED FROM PYTHON SOURCE LINES 332-337 Postprocessing with PyDPF Composites ------------------------------------ To postprocess the results, you must configure the imports, connect to the PyDPF Composites server, and load its plugin. .. GENERATED FROM PYTHON SOURCE LINES 337-353 .. code-block:: Python from ansys.dpf.composites.composite_model import CompositeModel from ansys.dpf.composites.constants import FailureOutput from ansys.dpf.composites.data_sources import ( CompositeDefinitionFiles, ContinuousFiberCompositesFiles, ) from ansys.dpf.composites.failure_criteria import ( CombinedFailureCriterion, CoreFailureCriterion, MaxStrainCriterion, MaxStressCriterion, ) from ansys.dpf.composites.server_helpers import connect_to_or_start_server from ansys.dpf.core.unit_system import unit_systems .. GENERATED FROM PYTHON SOURCE LINES 354-356 Connect to the server. The ``connect_to_or_start_server`` function automatically loads the composites plugin. .. GENERATED FROM PYTHON SOURCE LINES 356-358 .. code-block:: Python dpf_server = connect_to_or_start_server() .. GENERATED FROM PYTHON SOURCE LINES 359-360 Specify the combined failure criterion. .. GENERATED FROM PYTHON SOURCE LINES 360-369 .. code-block:: Python max_strain = MaxStrainCriterion() max_stress = MaxStressCriterion() core_failure = CoreFailureCriterion() cfc = CombinedFailureCriterion( name="Combined Failure Criterion", failure_criteria=[max_strain, max_stress, core_failure], ) .. GENERATED FROM PYTHON SOURCE LINES 370-371 Create the composite model and configure its input. .. GENERATED FROM PYTHON SOURCE LINES 371-385 .. code-block:: Python composite_model = CompositeModel( composite_files=ContinuousFiberCompositesFiles( rst=working_dir_path / rstfile_name, composite={ "shell": CompositeDefinitionFiles( definition=working_dir_path / composite_definition_h5_filename ), }, engineering_data=working_dir_path / matml_filename, ), default_unit_system=unit_systems.solver_nmm, server=dpf_server, ) .. GENERATED FROM PYTHON SOURCE LINES 386-387 Evaluate the failure criteria. .. GENERATED FROM PYTHON SOURCE LINES 387-389 .. code-block:: Python output_all_elements = composite_model.evaluate_failure_criteria(cfc) .. GENERATED FROM PYTHON SOURCE LINES 390-391 Query and plot the results. .. GENERATED FROM PYTHON SOURCE LINES 391-393 .. code-block:: Python irf_field = output_all_elements.get_field({"failure_label": FailureOutput.FAILURE_VALUE}) irf_field.plot() .. tab-set:: .. tab-item:: Static Scene .. image-sg:: /examples/workflows/images/sphx_glr_02-advanced-pymapdl-workflow_007.png :alt: 02 advanced pymapdl workflow :srcset: /examples/workflows/images/sphx_glr_02-advanced-pymapdl-workflow_007.png :class: sphx-glr-single-img .. tab-item:: Interactive Scene .. offlineviewer:: /home/runner/work/pyacp/pyacp/doc/source/examples/workflows/images/sphx_glr_02-advanced-pymapdl-workflow_007.vtksz .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 25.779 seconds) .. _sphx_glr_download_examples_workflows_02-advanced-pymapdl-workflow.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: 02-advanced-pymapdl-workflow.ipynb <02-advanced-pymapdl-workflow.ipynb>` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: 02-advanced-pymapdl-workflow.py <02-advanced-pymapdl-workflow.py>` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: 02-advanced-pymapdl-workflow.zip <02-advanced-pymapdl-workflow.zip>` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_