Skip to content

Commit 685f4f2

Browse files
authored
Merge branch 'main' into pr_metalforming
2 parents b1a4af5 + c35e1f2 commit 685f4f2

File tree

20 files changed

+5095
-41
lines changed

20 files changed

+5095
-41
lines changed

.github/workflows/ci_cd.yml

Lines changed: 54 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
name: "Code style"
2525
runs-on: ubuntu-latest
2626
steps:
27-
- uses: ansys/actions/code-style@v7
27+
- uses: ansys/actions/code-style@v8
2828
with:
2929
python-version: ${{ env.MAIN_PYTHON_VERSION }}
3030

@@ -33,7 +33,7 @@ jobs:
3333
runs-on: ubuntu-latest
3434
steps:
3535
- name: PyAnsys documentation style checks
36-
uses: ansys/actions/doc-style@v7
36+
uses: ansys/actions/doc-style@v8
3737
with:
3838
token: ${{ secrets.GITHUB_TOKEN }}
3939

@@ -99,7 +99,7 @@ jobs:
9999
name: documentation-pdf
100100
path: doc/_build/latex/*.pdf
101101
retention-days: 7
102-
102+
103103
- name: Extract the server logs
104104
if: always()
105105
run: |
@@ -111,7 +111,7 @@ jobs:
111111
with:
112112
name: server_output_docs.txt
113113
path: server_output.txt
114-
114+
115115
- name: DPF Logs (on screen)
116116
if: always()
117117
run: |
@@ -128,7 +128,7 @@ jobs:
128128
os: [windows-latest, ubuntu-latest]
129129
python-version: ['3.9', '3.10', '3.11', '3.12']
130130
steps:
131-
- uses: ansys/actions/build-wheelhouse@v7
131+
- uses: ansys/actions/build-wheelhouse@v8
132132
with:
133133
library-name: ${{ env.PACKAGE_NAME }}
134134
operating-system: ${{ matrix.os }}
@@ -188,12 +188,49 @@ jobs:
188188
path: .cov/html
189189
retention-days: 7
190190

191+
run-testing:
192+
name: Test the "run" subpackage
193+
runs-on: ubuntu-latest
194+
needs: [code-style]
195+
container:
196+
image: ghcr.io/ansys/mechanical:24.1.0
197+
options: --entrypoint /bin/bash
198+
199+
steps:
200+
- uses: actions/checkout@v4
201+
202+
- name: Install dependencies
203+
run: |
204+
apt update
205+
apt install --reinstall ca-certificates
206+
apt install software-properties-common git -y
207+
add-apt-repository ppa:deadsnakes/ppa -y
208+
apt install python3.11 python3.11-venv -y
209+
python3.11 -m ensurepip --default-pip
210+
python3.11 -m pip install --upgrade pip
211+
python3.11 -m venv /env
212+
213+
- name: Install library
214+
run: |
215+
. /env/bin/activate
216+
pip install .[tests]
217+
218+
- name: Unit testing
219+
env:
220+
ANSYSLI_SERVERS: 2325@${{secrets.LICENSE_SERVER}}
221+
ANSYSLMD_LICENSE_FILE: 1055@${{secrets.LICENSE_SERVER}}
222+
LSTC_LICENSE: ansys
223+
run: |
224+
. /env/bin/activate
225+
save-ansys-path --name dyna /install/ansys_inc/v241/ansys/bin/linx64/lsdyna_dp.e
226+
pytest -m run
227+
191228
build-library:
192229
name: "Build library"
193-
needs: [doc, tests]
230+
needs: [doc, tests, run-testing]
194231
runs-on: ubuntu-latest
195232
steps:
196-
- uses: ansys/actions/build-library@v7
233+
- uses: ansys/actions/build-library@v8
197234
with:
198235
library-name: ${{ env.PACKAGE_NAME }}
199236
python-version: ${{ env.MAIN_PYTHON_VERSION }}
@@ -205,14 +242,14 @@ jobs:
205242
runs-on: ubuntu-latest
206243
steps:
207244
- name: "Release to the public PyPI repository"
208-
uses: ansys/actions/release-pypi-public@v7
245+
uses: ansys/actions/release-pypi-public@v8
209246
with:
210247
library-name: ${{ env.PACKAGE_NAME }}
211248
twine-username: "__token__"
212249
twine-token: ${{ secrets.PYPI_TOKEN }}
213250

214251
- name: "Release to GitHub"
215-
uses: ansys/actions/release-github@v7
252+
uses: ansys/actions/release-github@v8
216253
with:
217254
library-name: ${{ env.PACKAGE_NAME }}
218255

@@ -222,18 +259,22 @@ jobs:
222259
runs-on: ubuntu-latest
223260
needs: [build-library]
224261
steps:
225-
- uses: ansys/actions/doc-deploy-dev@v7
262+
- uses: ansys/actions/doc-deploy-dev@v8
226263
with:
227264
cname: ${{ env.DOCUMENTATION_CNAME }}
228-
token: ${{ secrets.GITHUB_TOKEN }}
265+
token: ${{ secrets.PYANSYS_CI_BOT_TOKEN }}
266+
bot-user: ${{ secrets.PYANSYS_CI_BOT_USERNAME }}
267+
bot-email: ${{ secrets.PYANSYS_CI_BOT_EMAIL }}
229268

230269
doc-deploy-stable:
231270
name: "Deploy stable documentation"
232271
if: github.event_name == 'push' && contains(github.ref, 'refs/tags')
233272
runs-on: ubuntu-latest
234273
needs: [release]
235274
steps:
236-
- uses: ansys/actions/doc-deploy-stable@v7
275+
- uses: ansys/actions/doc-deploy-stable@v8
237276
with:
238277
cname: ${{ env.DOCUMENTATION_CNAME }}
239-
token: ${{ secrets.GITHUB_TOKEN }}
278+
token: ${{ secrets.PYANSYS_CI_BOT_TOKEN }}
279+
bot-user: ${{ secrets.PYANSYS_CI_BOT_USERNAME }}
280+
bot-email: ${{ secrets.PYANSYS_CI_BOT_EMAIL }}

AUTHORS

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
# For contributions made under a Corporate CLA, the organization is
66
# added to this file.
77
#
8-
# If you have contributed to the repository and wish to be added to this file
9-
# please submit a request.
8+
# If you have contributed to the repository and want to be added to this file,
9+
# submit a request.
1010
#
1111
#
1212
ANSYS, Inc.

CONTRIBUTORS.md

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,17 @@
11
# Contributors
22

3-
## Individual contributors
3+
## Project Lead
44

5-
* [Zhanqun Zhang](https://github.com/zhangzhanqun)
6-
* [Wenhui Yu](https://github.com/wenhuiuy)
75
* [Srikanth Adya](https://github.com/kanthadya)
6+
* [Wenhui Yu](https://github.com/wenhuiuy)
7+
* [Zhanqun Zhang](https://github.com/zhangzhanqun)
8+
9+
## Individual Contributors
10+
11+
* [Alexander Kaszynski](https://github.com/akaszynski)
12+
* [Dominik Gresch](https://github.com/greschd)
13+
* [Fabian de Leon](https://github.com/fdeleonm)
14+
* [Jorge Martínez](https://github.com/jorgepiloto)
15+
* [Maxime Rey](https://github.com/MaxJPRey)
16+
* [Revathy Venugopal](https://github.com/Revathyvenugopal162)
17+
* [Roberto Pastor](https://github.com/RobPasMue)

README.rst

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ Overview
3737
========
3838
PyDYNA is a Pythonic package for providing a more convenient and complete way to
3939
build an Ansys DYNA input deck, submit it to the Ansys LS-DYNA solver, and
40-
finally postprocess the results.
40+
finally postprocess the results.
4141

42-
PyDYNA contains two submodules, ``ansys.dyna.core.pre`` and ``ansys.dyna.core.solver``
42+
PyDYNA contains three submodules, ``ansys.dyna.core.pre``, ``ansys.dyna.core.solver``, and ``ansys.dyna.core.run``.
4343

4444
- ``pre``: This module provides highly abstracted APIs for creating and
4545
setting up DYNA input decks. There are many classes supported, namely,
@@ -52,6 +52,8 @@ PyDYNA contains two submodules, ``ansys.dyna.core.pre`` and ``ansys.dyna.core.so
5252
``solver`` service provides a way to push input files to the LS-DYNA solver, monitor the state
5353
of the running job, change the value of a load curve and finally retrieve result files back from
5454
the server
55+
- ``run``: This module provides the ability to start the LS-DYNA solver. This does not require any
56+
client-server library or Docker container.
5557

5658
Once you have results, you can use the Ansys Data Processing Framework (DPF),
5759
which is designed to provide numerical simulation users and engineers
@@ -80,7 +82,7 @@ development version or previously released versions.
8082
On the `PyDYNA Issues <https://github.com/ansys/pydyna/issues>`_ page, you can create issues to
8183
report bugs and request new features. On the `PyDYNA Discussions <https://github.com/ansys/pydyna/discussions>`_
8284
page or the `Discussions <https://discuss.ansys.com/>`_ page on the Ansys Developer portal,
83-
you can post questions, share ideas, and get community feedback.
85+
you can post questions, share ideas, and get community feedback.
8486

8587
To reach the project support team, email `[email protected] <[email protected]>`_.
8688

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
Use PyDYNA to run LSDYNA locally
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
4+
Run LS-DYNA using ansys.dyna.core.run
5+
*************************************
6+
7+
.. code:: python
8+
9+
import os
10+
from ansys.dyna.core.run import run_dyna
11+
12+
dynafile = "input.k"
13+
working_directory = os.path.getcwd()
14+
filepath = run_dyna(dynafile, working_directory=dynadir)
15+
16+
......
17+
18+
How it works
19+
************
20+
21+
``run_dyna`` attempts to find an installation of the LS-DYNA solver on your machine.
22+
It uses the Python dependency ``ansys-tools-path`` to discover where LS-DYNA is installed.
23+
After installing ``ansys-tools-path``, the location of LS-DYNA can be saved by running
24+
``save-ansys-path --name dyna {path/to/dyna}`` so that subsequent usages of ``run_dyna``
25+
look there.

doc/source/getting-started/index.rst

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@ page on the Ansys website.
99

1010
Installation
1111
============
12-
PyDYNA consists of two modules, ``ansys.dyna.core.pre`` and ``ansys.dyna.core.solver``.
13-
Both these modules are gRPC enabled and hence need to be run using server-client connection.
12+
PyDYNA consists of three modules, ``ansys.dyna.core.pre``, ``ansys.dyna.core.solver``, and
13+
``ansys.dyna.core.run``.
14+
15+
``ansys.dyna.core.pre`` and ``ansys.dyna.core.solver`` use gRPC and hence need to be run
16+
using server-client connection.
1417

1518
Install the client
1619
------------------
@@ -80,7 +83,7 @@ with these commands:
8083
If you're on Windows with Python 3.9, unzip the wheelhouse archive to a ``wheelhouse``
8184
directory and install PyDYNA using the preceding command.
8285

83-
Run PyDYNA server locally
86+
Run PyDYNA server locally
8487
-------------------------
8588
Launching the servers directly on local machines.
8689

@@ -96,6 +99,11 @@ PyDYNA server can be run in a Docker container.
9699

97100
.. include:: ../../../docker/solver/README.rst
98101

102+
Run DYNA using ``ansys.dyna.core.run`` on a local machine,
103+
this does not require Docker.
104+
105+
.. include:: ./RUN_README.rst
106+
99107
Example
100108
-------
101109

pyproject.toml

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,48 +27,49 @@ classifiers = [
2727

2828
dependencies = ["ansys-dpf-core>=0.7.2",
2929
"ansys-api-dyna==0.4.1",
30-
"ansys-platform-instancemanagement~=1.0",
30+
"ansys-tools-path>=0.6.0",
31+
"ansys-platform-instancemanagement~=1.0",
3132
"pyvista>=0.43.4",
3233
]
3334

3435
[project.optional-dependencies]
3536
tests = [
3637
"matplotlib==3.9.2",
37-
"numpy==2.1.1",
38+
"numpy==2.1.2",
3839
"pytest==8.3.3",
3940
"pytest-cov==5.0.0",
4041
"joblib==1.4.2",
4142
"pandas==2.2.3",
4243
"openpyxl==3.1.5",
4344
"scikit-learn==1.5.2",
4445
"pytest-xdist==3.6.1",
45-
"ipython==8.27.0",
46+
"ipython==8.29.0",
4647
"pyvista==0.44.1",
4748
]
4849
doc = [
4950
"recommonmark==0.7.1",
5051
"matplotlib==3.9.2",
51-
"imageio==2.35.1",
52+
"imageio==2.36.0",
5253
"imageio-ffmpeg==0.5.1",
5354
"numpydoc==1.8.0",
54-
"Sphinx==8.0.2",
55-
"sphinx-autobuild==2024.9.19",
55+
"Sphinx==8.1.3",
56+
"sphinx-autobuild==2024.10.3",
5657
"sphinxcontrib-websupport==2.0.0",
5758
"pytest-sphinx==0.6.3",
5859
"sphinx-notfound-page==1.0.4",
5960
"sphinx-copybutton==0.5.2",
60-
"sphinx-gallery==0.17.1",
61-
"sphinx-autodoc-typehints==2.4.4",
62-
"ansys-sphinx-theme==1.0.11",
63-
"pypandoc==1.13",
61+
"sphinx-gallery==0.18.0",
62+
"sphinx-autodoc-typehints==2.5.0",
63+
"ansys-sphinx-theme==1.1.7",
64+
"pypandoc==1.14",
6465
"nbsphinx==0.9.5",
6566
"ipywidgets==8.1.5",
6667
"joblib==1.4.2",
6768
"scikit-learn==1.5.2",
68-
"ipython==8.27.0",
69+
"ipython==8.29.0",
6970
"jupyterlab==4.2.5",
7071
"sphinx-jinja==2.0.2",
71-
"sphinx-autoapi==3.3.1",
72+
"sphinx-autoapi==3.3.3",
7273
"pyvista==0.44.1",
7374
]
7475

pytest.ini

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[pytest]
2+
markers =
3+
run: tests that exercise the `run` subpackage
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Copyright (C) 2021 - 2024 ANSYS, Inc. and/or its affiliates.
2+
# SPDX-License-Identifier: MIT
3+
#
4+
#
5+
# Permission is hereby granted, free of charge, to any person obtaining a copy
6+
# of this software and associated documentation files (the "Software"), to deal
7+
# in the Software without restriction, including without limitation the rights
8+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
# copies of the Software, and to permit persons to whom the Software is
10+
# furnished to do so, subject to the following conditions:
11+
#
12+
# The above copyright notice and this permission notice shall be included in all
13+
# copies or substantial portions of the Software.
14+
#
15+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
# SOFTWARE.
22+
23+
from .local_solver import run_dyna # noqa: F401
24+
from .options import MemoryUnit, MpiOption, Precision # noqa: F401
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Copyright (C) 2021 - 2024 ANSYS, Inc. and/or its affiliates.
2+
# SPDX-License-Identifier: MIT
3+
#
4+
#
5+
# Permission is hereby granted, free of charge, to any person obtaining a copy
6+
# of this software and associated documentation files (the "Software"), to deal
7+
# in the Software without restriction, including without limitation the rights
8+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
# copies of the Software, and to permit persons to whom the Software is
10+
# furnished to do so, subject to the following conditions:
11+
#
12+
# The above copyright notice and this permission notice shall be included in all
13+
# copies or substantial portions of the Software.
14+
#
15+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
# SOFTWARE.
22+
23+
"""Base runner class."""
24+
25+
from ansys.dyna.core.run.options import MemoryUnit, MpiOption, Precision
26+
27+
28+
class BaseRunner:
29+
def __init__(self, **kwargs):
30+
# TODO - split mpi option into precision?
31+
self.mpi_option = kwargs.get("mpi_option", MpiOption.SMP)
32+
self.ncpu = kwargs.get("ncpu", 1)
33+
self.memory = kwargs.get("memory", 20)
34+
self.memory_unit = kwargs.get("memory_unit", MemoryUnit.MB)
35+
self.precision = kwargs.get("precision", Precision.DOUBLE)
36+
37+
def get_memory_string(self) -> str:
38+
unit = {MemoryUnit.MB: "m", MemoryUnit.GB: "G"}[self.memory_unit]
39+
return f"{self.memory}{unit}"

0 commit comments

Comments
 (0)