.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/Airbag/airbag_deploy.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_deploy.py: Airbag deploy ------------- This example shows how to create an airbag deploy model with the PyDNYA ``pre`` service. The executable file for LS-DYNA is ``ls-dyna_smp_d_R13.0_365-gf8a97bda2a_winx64_ifort190.exe``. .. GENERATED FROM PYTHON SOURCE LINES 10-13 Perform required imports ~~~~~~~~~~~~~~~~~~~~~~~~ Perform required imports. .. GENERATED FROM PYTHON SOURCE LINES 13-19 .. code-block:: Python import os import sys from ansys.dyna.core.pre import examples, launch_dynapre .. GENERATED FROM PYTHON SOURCE LINES 20-34 Start the ``pre`` service ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Before starting the ``pre`` service, you must ensure that the Docker container for this service has been started. For more information, see "Start the Docker container for the ``pre`` service" in https://dyna.docs.pyansys.com/version/stable/index.html. The ``pre`` service can also be started locally, please download the latest version of ansys-pydyna-pre-server.zip package from https://github.com/ansys/pydyna/releases and start it referring to the README.rst file in this server package. Once the ``pre`` service is running, you can connect a client to it using the hostname and port. This example uses the default localhost and port (``"localhost"`` and ``"50051"`` respectively). .. GENERATED FROM PYTHON SOURCE LINES 34-55 .. code-block:: Python from ansys.dyna.core.pre.dynamaterial import MatFabric, MatRigid from ansys.dyna.core.pre.dynamech import ( Airbag, Contact, ContactCategory, ContactSurface, Curve, DynaMech, PartSet, Point, RigidwallPlanar, ShellFormulation, ShellPart, ) from ansys.dyna.core.pre.misc import check_valid_ip hostname = "localhost" if len(sys.argv) > 1 and check_valid_ip(sys.argv[1]): hostname = sys.argv[1] .. GENERATED FROM PYTHON SOURCE LINES 57-62 Start the solution workflow ~~~~~~~~~~~~~~~~~~~~~~~~~~~ The ``DynaSolution`` class is like a workflow orchestrator. It inherits methods from other classes and helps create a complete workflow. .. GENERATED FROM PYTHON SOURCE LINES 62-69 .. code-block:: Python airbag_solution = launch_dynapre(ip=hostname) fns = [] # path = sys.path[0] + os.sep + "input" + os.sep + "airbag_deploy" + os.sep path = examples.airbag_deploy + os.sep fns.append(path + "airbag_deploy.k") airbag_solution.open_files(fns) .. rst-class:: sphx-glr-script-out .. code-block:: none 2024-11-20 15:20:21 : Connected to kwServer... 2024-11-20 15:20:21 : /opt/hostedtoolcache/Python/3.10.15/x64/lib/python3.10/site-packages/ansys/dyna/core/pre/examples/airbag/airbag_deploy/airbag_deploy.k uploaded to server... ret: true .. GENERATED FROM PYTHON SOURCE LINES 70-78 Create standard explicit control cards ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The following code uses the ``set_termination`` method to set the termination time to ``0.03`` in *CONTROL_TERMINATION*. The ``DynaMech`` class automatically generates the common control cards used in explicit problems. ``CONTROL_ACCURACY``, ``CONTACT``, ``BULK VISCOCITY``, and ``CONTACT`` are all automatically generated. .. GENERATED FROM PYTHON SOURCE LINES 78-83 .. code-block:: Python airbag_solution.set_termination(0.03) airbagdeploy = DynaMech() airbag_solution.add(airbagdeploy) .. rst-class:: sphx-glr-script-out .. code-block:: none 2024-11-20 15:20:21 : Setting termination time ... .. GENERATED FROM PYTHON SOURCE LINES 84-91 Define a keyword ~~~~~~~~~~~~~~~~ Use the ``Airbag`` function in the ``DynaMech`` class to define *AIRBAG_SIMPLE_AIRBAG_MODEL* as a keyword. While LS-DYNA has many different airbag models, PyDYNA currently supports only one: SIMPLE_AIRBAG_MODEL. If you have an urgent need for PyDYNA to support another airbag model, email `pyansys.core@ansys.com `_ with your request. .. GENERATED FROM PYTHON SOURCE LINES 91-104 .. code-block:: Python airbag = Airbag( set=PartSet([3]), heat_capacity_at_constant_volume=1.736e3, heat_capacity_at_constant_pressure=2.43e3, input_gas_temperature=1.2e3, input_mass_flow_rate=Curve(x=[0, 0.032, 0.045, 0.08], y=[0, 26, 0.6, 0.1]), shape_factor_for_exit_hole=0.7, ambient_pressure=14.7, ambient_density=3.821e-6, ) airbagdeploy.add(airbag) .. rst-class:: sphx-glr-script-out .. code-block:: none 2024-11-20 15:20:21 : Curve 1 defined... .. GENERATED FROM PYTHON SOURCE LINES 105-110 Generate an infinite planar rigid wall ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ To generate an infinite planar rigidwall, define the coordinates of the heat vector and the tail vector of the plane. .. GENERATED FROM PYTHON SOURCE LINES 110-113 .. code-block:: Python rigidwall = RigidwallPlanar(Point(0, 0, 0), Point(0, 1, 0), coulomb_friction_coefficient=0.5) airbagdeploy.add(rigidwall) .. GENERATED FROM PYTHON SOURCE LINES 114-118 Define a node-to-surface contact ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Define a node-to-surface contact by passing a master part set and a slave part set. .. GENERATED FROM PYTHON SOURCE LINES 118-128 .. code-block:: Python contact = Contact(category=ContactCategory.NODES_TO_SURFACE) contact.set_friction_coefficient(static=0.5, dynamic=0.5) surf1 = ContactSurface(PartSet([3])) surf2 = ContactSurface(PartSet([2])) surf2.set_penalty_stiffness_scale_factor(0.06667) contact.set_slave_surface(surf1) contact.set_master_surface(surf2) airbagdeploy.contacts.add(contact) .. GENERATED FROM PYTHON SOURCE LINES 129-139 Define material cards ~~~~~~~~~~~~~~~~~~~~~ LS-DYNA has over 300 materials that are used for varied applications. While PyDYNA does not yet support all material cards, it does support most commonly used materials, including ``FABRIC``, ``MAT_ELASTIC``, ``PIECEWISE_LINEAR_PLASTICITY``, and ``RIGID``. All supported materials are accessed from the ``dynamaterial`` class. In the following code, ``MAT_RIGID`` is defined as the material for the cylindrical tube and the bottom plate. ``MAT_FABRIC`` is defined as the material for the airbag volume. Note that ``platemat`` also has constraints defined. .. GENERATED FROM PYTHON SOURCE LINES 139-155 .. code-block:: Python platemat = MatRigid( mass_density=7.84e-4, young_modulus=30e6, center_of_mass_constraint=1, translational_constraint=7, rotational_constraint=7, ) cylindermat = MatRigid(mass_density=1.96e-4, young_modulus=30e6) airbagmat = MatFabric( mass_density=1e-4, young_modulus_longitudinal_direction=2e6, young_modulus_transverse_direction=2e6, shear_modulus=1.53e6, ) .. GENERATED FROM PYTHON SOURCE LINES 156-163 Define sectional properties ~~~~~~~~~~~~~~~~~~~~~~~~~~~ The following code defines the sectional properties of the parts. This example has three shell parts. Each shell part is initialized as ``ShellPart`` with a unique ID and an appropriate shell formulation is assigned. Again, PyDYNA does not yet support all element formulations. You can find the supported formulations in the ``dynabase`` class. .. GENERATED FROM PYTHON SOURCE LINES 163-183 .. code-block:: Python plate = ShellPart(1) plate.set_material(platemat) plate.set_element_formulation(ShellFormulation.BELYTSCHKO_TSAY) plate.set_thickness(0.5) airbagdeploy.parts.add(plate) cylinder = ShellPart(2) cylinder.set_material(cylindermat) cylinder.set_element_formulation(ShellFormulation.BELYTSCHKO_TSAY) cylinder.set_thickness(0.5) airbagdeploy.parts.add(cylinder) airbagpart = ShellPart(3) airbagpart.set_material(airbagmat) airbagpart.set_element_formulation(ShellFormulation.FULLY_INTEGRATED_BELYTSCHKO_TSAY_MEMBRANE) airbagpart.set_thickness(0.015) airbagpart.set_integration_points(4) airbagdeploy.parts.add(airbagpart) .. rst-class:: sphx-glr-script-out .. code-block:: none 2024-11-20 15:20:21 : Material RIGID Created... 2024-11-20 15:20:21 : Material RIGID Created... 2024-11-20 15:20:21 : Material Fabric Created... .. GENERATED FROM PYTHON SOURCE LINES 184-189 Define database outputs ~~~~~~~~~~~~~~~~~~~~~~~ Use the ``set_output_database()`` and ``create_database_binary()`` methods to define the output frequency of the ASCII and binary D3PLOT files. Then, use the ``save_file()`` method to write out the model as an input DYNA key file. .. GENERATED FROM PYTHON SOURCE LINES 189-195 .. code-block:: Python airbag_solution.set_output_database( abstat=2.0e-4, glstat=2.0e-4, matsum=2.0e-4, rcforc=2.0e-4, rbdout=2.0e-4, rwforc=2.0e-4 ) airbag_solution.create_database_binary(dt=5e-4, ieverp=1) airbag_solution.save_file() .. rst-class:: sphx-glr-script-out .. code-block:: none 2024-11-20 15:20:21 : Output Setting... 2024-11-20 15:20:21 : DB Binary Created... 2024-11-20 15:20:21 : Control Accuracy Created... 2024-11-20 15:20:21 : Control Bulk Viscosity Created... 2024-11-20 15:20:21 : Control Energy Created... 2024-11-20 15:20:21 : Control Hourglass Created... 2024-11-20 15:20:21 : Control Shell Created... 2024-11-20 15:20:21 : Control Contact Created... 2024-11-20 15:20:21 : Contact Created... 2024-11-20 15:20:21 : Airbag Model Created... 2024-11-20 15:20:21 : Rigidwall Planar Created... 2024-11-20 15:20:21 : airbag_deploy.k is outputed... '/server/output' .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.109 seconds) .. _sphx_glr_download_examples_Airbag_airbag_deploy.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: airbag_deploy.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: airbag_deploy.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: airbag_deploy.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_