Skip to content

Commit fbdfdbc

Browse files
authored
Merge branch 'main' into zhanqun/prev5
2 parents 27f6e10 + ea1fbe9 commit fbdfdbc

File tree

12 files changed

+507
-53
lines changed

12 files changed

+507
-53
lines changed

.github/workflows/ci_cd.yml

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
runs-on: ubuntu-latest
2626
steps:
2727
- name: PyAnsys documentation style checks
28-
uses: pyansys/actions/doc-style@v4
28+
uses: ansys/actions/doc-style@v4
2929
with:
3030
token: ${{ secrets.GITHUB_TOKEN }}
3131

@@ -49,6 +49,18 @@ jobs:
4949
pip install --upgrade build
5050
pip install .[doc]
5151
52+
- name: Login to GitHub Container Registry
53+
uses: docker/login-action@v2
54+
with:
55+
registry: ghcr.io
56+
username: ${{ github.actor }}
57+
password: ${{ secrets.GITHUB_TOKEN }}
58+
59+
- name: DPF server activation
60+
run: |
61+
docker pull ghcr.io/ansys/dpf-core:22.2dev
62+
docker run -d --name dpfserver -p 50054:50052 ghcr.io/ansys/dpf-core:22.2dev && echo "DPF Server active on port 50054."
63+
5264
- name: Run server
5365
run: |
5466
cd src/ansys/dyna/core/pre/Server
@@ -84,13 +96,19 @@ jobs:
8496
with:
8597
name: server-logs-docs
8698
path: src/ansys/dyna/core/pre/Server/server_output_docs.txt
99+
100+
- name: DPF Logs (on screen)
101+
if: always()
102+
run: |
103+
docker logs dpfserver
104+
docker stop dpfserver
87105
88106
style:
89107
name: Code style
90108
runs-on: ubuntu-latest
91109
steps:
92110
- name: PyAnsys code style checks
93-
uses: pyansys/actions/code-style@v4
111+
uses: ansys/actions/code-style@v4
94112
with:
95113
python-version: ${{ env.MAIN_PYTHON_VERSION }}
96114

@@ -106,7 +124,7 @@ jobs:
106124

107125
steps:
108126
- name: Build wheelhouse and perform smoke test
109-
uses: pyansys/actions/build-wheelhouse@v4
127+
uses: ansys/actions/build-wheelhouse@v4
110128
with:
111129
library-name: ${{ env.PACKAGE_NAME }}
112130
library-namespace: ${{ env.PACKAGE_NAMESPACE }}
@@ -174,7 +192,7 @@ jobs:
174192
runs-on: ubuntu-latest
175193
steps:
176194
- name: Build library source and wheel artifacts
177-
uses: pyansys/actions/build-library@v4
195+
uses: ansys/actions/build-library@v4
178196
with:
179197
library-name: ${{ env.PACKAGE_NAME }}
180198
python-version: ${{ env.MAIN_PYTHON_VERSION }}
@@ -186,14 +204,14 @@ jobs:
186204
runs-on: ubuntu-latest
187205
steps:
188206
- name: Release to the private PyPI repository
189-
uses: pyansys/actions/release-pypi-private@v4
207+
uses: ansys/actions/release-pypi-private@v4
190208
with:
191209
library-name: ${{ env.PACKAGE_NAME }}
192210
twine-username: "__token__"
193211
twine-token: ${{ secrets.PYANSYS_PYPI_PRIVATE_PAT }}
194212

195213
- name: Release to GitHub
196-
uses: pyansys/actions/release-github@v4
214+
uses: ansys/actions/release-github@v4
197215
with:
198216
library-name: ${{ env.PACKAGE_NAME }}
199217

@@ -204,7 +222,7 @@ jobs:
204222
needs: [package]
205223
steps:
206224
- name: Deploy the latest documentation
207-
uses: pyansys/actions/doc-deploy-dev@v4
225+
uses: ansys/actions/doc-deploy-dev@v4
208226
with:
209227
cname: ${{ env.DOCUMENTATION_CNAME }}
210228
token: ${{ secrets.GITHUB_TOKEN }}
@@ -216,7 +234,7 @@ jobs:
216234
needs: [release]
217235
steps:
218236
- name: Deploy the stable documentation
219-
uses: pyansys/actions/doc-deploy-stable@v4
237+
uses: ansys/actions/doc-deploy-stable@v4
220238
with:
221239
cname: ${{ env.DOCUMENTATION_CNAME }}
222240
token: ${{ secrets.GITHUB_TOKEN }}

README.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,15 @@ and install using the preceding command.
113113

114114
Consider installing using a `virtual environment <https://docs.python.org/3/library/venv.html>`_.
115115

116+
Install Solver Docker
117+
^^^^^^^^^^^^^^^^^^^^^
118+
119+
Once pydyna is installed, the docker-compose.yml file to build and launch the dyna solver docker can be located
120+
under /src/ansys/dyna/core/solver/. The yml file can be copied locally. To run the docker the following command can be used
121+
122+
.. code:: bash
123+
124+
docker-compose up
116125
117126
Documentation
118127
-------------

examples/Airbag/airbag_deploy.py

Lines changed: 76 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
"""
2+
.. _ref_airbag_deploy:
23
Airbag deploy example
3-
=====================
4+
---------------------
45
5-
This example show how to create an Airbag deploy model with Pydyna-pre module. \n
6+
This example show how to create an Airbag deploy model with Pydyna-pre module.
67
LS-DYNA version : ls-dyna_smp_d_R13.0_365-gf8a97bda2a_winx64_ifort190.exe
8+
79
"""
810

911
import os
@@ -24,25 +26,62 @@
2426
ShellPart,
2527
ShellFormulation,
2628
)
29+
30+
###############################################################################
31+
# Manually start the dyna.core.pre server
32+
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
33+
# Copy the folder pyDyna/src/ansys/dyna/core/pre/Server to a desired location
34+
# Start the dyna.core.pre server at this location as shown below
35+
#
36+
# python kwserver.py
37+
#
38+
# Now the pre server is up and running and is waiting to be connected to the client
39+
# Connect to the server using the hostname and the port. In this example, default
40+
# "localhost" and port "50051" are used
41+
2742
from ansys.dyna.core.pre.dynamaterial import MatRigid, MatFabric
2843
from ansys.dyna.core.pre import examples
2944
# sphinx_gallery_thumbnail_path = '_static/pre/airbag/airbag.png'
3045

3146
hostname = "localhost"
3247
if len(sys.argv) > 1:
3348
hostname = sys.argv[1]
49+
50+
51+
###############################################################################
52+
# Start the Solution workflow
53+
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~
54+
# Dynasolution class is like a workflow orchestrator.
55+
# It inherits methods from other classes and helps create a complete workflow
56+
#
3457
airbag_solution = DynaSolution(hostname)
3558
fns = []
3659
# path = sys.path[0] + os.sep + "input" + os.sep + "airbag_deploy" + os.sep
3760
path = examples.airbag_deploy + os.sep
3861
fns.append(path + "airbag_deploy.k")
3962
airbag_solution.open_files(fns)
40-
63+
###############################################################################
64+
# Create standard explicit control cards
65+
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
66+
# Dynasolution class is like a workflow orchestrator.
67+
# It inherits methods from other classes and helps create a complete workflow.
68+
# "set_termination" method here is used to set the termination time to 0.03 in *CONTROL_TERMINATION.
69+
# DynaMech class automatically generates the common control cards used in
70+
# explicit problems. CONTROL_ACCURACY, CONTACT, BULK VISCOCITY, CONTACT
71+
# are all automatically generated
4172
airbag_solution.set_termination(0.03)
4273

4374
airbagdeploy = DynaMech()
4475
airbag_solution.add(airbagdeploy)
4576

77+
###############################################################################
78+
# Define *AIRBAG_SIMPLE_AIRBAG_MODEL
79+
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
80+
# DynaMech class has Airbag function that can be used to create this keyword.
81+
# LSDYNA has many different AIRBAG models. Only SIMPLE_AIRBAG_MODEL is supported
82+
# by pydyna at this moment. Please contact us if there is an urgent need for other
83+
# Airbag models.
84+
4685
airbag = Airbag(
4786
set=PartSet([3]),
4887
heat_capacity_at_constant_volume=1.736e3,
@@ -55,9 +94,19 @@
5594
)
5695
airbagdeploy.add(airbag)
5796

97+
###############################################################################
98+
# Define *RIGIDWALL_PLANAR
99+
# ~~~~~~~~~~~~~~~~~~~~~~~~
100+
# Infinite planar rigidwall is generated by defining the coordinates of the heat vector
101+
# and the tail vector of the plane.
58102
rigidwall = RigidwallPlanar(Point(0, 0, 0), Point(0, 1, 0), coulomb_friction_coefficient=0.5)
59103
airbagdeploy.add(rigidwall)
60104

105+
###############################################################################
106+
# Define *CONTACT_NODES_TO_SURFACE
107+
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
108+
# A contact NODES_TO_SURFACE is defined here by passing a master set and a slave part set.
109+
61110
contact = Contact(category=ContactCategory.NODES_TO_SURFACE)
62111
contact.set_friction_coefficient(static=0.5, dynamic=0.5)
63112
surf1 = ContactSurface(PartSet([3]))
@@ -66,6 +115,15 @@
66115
contact.set_slave_surface(surf1)
67116
contact.set_master_surface(surf2)
68117
airbagdeploy.contacts.add(contact)
118+
###############################################################################
119+
# Define Material cards
120+
# ~~~~~~~~~~~~~~~~~~~~~
121+
# Dyna as we all know has over 300 materials that are used for varied applications.
122+
# Not all material cards are supported at this time. Some of the most commonly used materials
123+
# like MAT_ELASTIC, RIGID, PIECEWISE_LINEAR_PLASTICITY, FABRIC are currently supported in pydyna.
124+
# All the supported material can be accessed from the dynamaterial() class.
125+
# In the code block below, we define MAT_RIGID for the cylindrical tube and the bottom plate and MAT_FABRIC for
126+
# the airbag volume. Note here that the "platemat" has the contraints defined as well.
69127

70128
platemat = MatRigid(
71129
mass_density=7.84e-4,
@@ -82,6 +140,14 @@
82140
shear_modulus=1.53e6,
83141
)
84142

143+
###############################################################################
144+
# Define Sectional Properties
145+
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~
146+
# We now define the sectional properties of the parts. In this example we have three
147+
# shell parts. Each part is initialized as a ShellPart with a unique ID and the appropriate
148+
# shell formulation have been assigned. Again, not all element formulations are supported at this time.
149+
# The supported formulations can be found in the "dynabase" class
150+
85151
plate = ShellPart(1)
86152
plate.set_material(platemat)
87153
plate.set_element_formulation(ShellFormulation.BELYTSCHKO_TSAY)
@@ -101,6 +167,13 @@
101167
airbagpart.set_integration_points(4)
102168
airbagdeploy.parts.add(airbagpart)
103169

170+
###############################################################################
171+
# Define Database Outputs ASCII and Binary
172+
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
173+
# "set_output_database" and "create_database_binary" methods are used here to define the
174+
# output frequency of the ASCII and Binary D3PLOT files. Finally the model is written out as
175+
# an input dyna key file by calling the save_file()
176+
104177
airbag_solution.set_output_database(
105178
abstat=2.0e-4, glstat=2.0e-4, matsum=2.0e-4, rcforc=2.0e-4, rbdout=2.0e-4, rwforc=2.0e-4
106179
)

examples/Airbag/airbag_post.py

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
"""
2+
.. _ref_airbag_deploy_post:
3+
Airbag deploy post processing example
4+
-------------------------------------
5+
6+
This example show how to animate the d3plot and display the stress on the airbag.
7+
8+
"""
9+
# from ansys.dpf import core as dpf
10+
# from ansys.dpf.core import examples
11+
###############################################################################
12+
# Connect to DPF
13+
# ~~~~~~~~~~~~~~
14+
# dpf.connect_to_server()
15+
16+
###############################################################################
17+
# Load the model
18+
# ~~~~~~~~~~~~~~
19+
# Load the model and print the contents of the model. All parts in the model are shell parts.
20+
# Model info lists the result components as well as the number of states available in the d3plot
21+
#
22+
# ds = dpf.DataSources()
23+
# ds.set_result_file_path(r'D:\PYDYNA_BETA_V.0.1\example-data\pydyna\Airbag\d3plot', 'd3plot')
24+
# model = dpf.Model(ds)
25+
# print(model)
26+
27+
###############################################################################
28+
# Let's extract the stress on all the parts. The stress field container is scoped to all time frequencies
29+
# so as to be able to animate the change in stress on the airbag fabric.
30+
#
31+
# stress = model.results.stress.on_all_time_freqs()
32+
# stress.inputs.data_sources(ds)
33+
# stress.inputs.requested_location.connect("Nodal")
34+
# fieldsStr = stress.outputs.fields_container()
35+
36+
###############################################################################
37+
# Since the shell stress is reported at three through thickness points as default
38+
# in the d3plot file, the next few lines depicts how the stress
39+
# can be extracted on the mid integration point.
40+
#
41+
# shell_layer_extract = dpf.operators.utility.change_shell_layers()
42+
# shell_layer_extract.inputs.fields_container.connect(fieldsStr)
43+
# shell_layer_extract.inputs.e_shell_layer.connect(dpf.common.shell_layers.mid.value)
44+
# fields_top = shell_layer_extract.outputs.fields_container_as_fields_container()
45+
46+
###############################################################################
47+
# Plot the deformed state at 9ms
48+
#
49+
# N = fields_top[19]
50+
# D = model.results.displacement(time_scoping=[19]).eval()
51+
# N.plot(deform_by=D[0],show_edges=False)
52+
53+
###############################################################################
54+
# Finally display the stress field and set the mesh to deform by the displacement of the nodes.
55+
#
56+
# disp = model.results.displacement.on_all_time_freqs.eval()
57+
# fields_top.animate(deform_by=disp,show_edges=False)

0 commit comments

Comments
 (0)