Skip to content

Commit

Permalink
Merge branch 'main' into pr_metalforming
Browse files Browse the repository at this point in the history
  • Loading branch information
RobPasMue authored Oct 31, 2024
2 parents b1a4af5 + c35e1f2 commit 685f4f2
Show file tree
Hide file tree
Showing 20 changed files with 5,095 additions and 41 deletions.
67 changes: 54 additions & 13 deletions .github/workflows/ci_cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
name: "Code style"
runs-on: ubuntu-latest
steps:
- uses: ansys/actions/code-style@v7
- uses: ansys/actions/code-style@v8
with:
python-version: ${{ env.MAIN_PYTHON_VERSION }}

Expand All @@ -33,7 +33,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: PyAnsys documentation style checks
uses: ansys/actions/doc-style@v7
uses: ansys/actions/doc-style@v8
with:
token: ${{ secrets.GITHUB_TOKEN }}

Expand Down Expand Up @@ -99,7 +99,7 @@ jobs:
name: documentation-pdf
path: doc/_build/latex/*.pdf
retention-days: 7

- name: Extract the server logs
if: always()
run: |
Expand All @@ -111,7 +111,7 @@ jobs:
with:
name: server_output_docs.txt
path: server_output.txt

- name: DPF Logs (on screen)
if: always()
run: |
Expand All @@ -128,7 +128,7 @@ jobs:
os: [windows-latest, ubuntu-latest]
python-version: ['3.9', '3.10', '3.11', '3.12']
steps:
- uses: ansys/actions/build-wheelhouse@v7
- uses: ansys/actions/build-wheelhouse@v8
with:
library-name: ${{ env.PACKAGE_NAME }}
operating-system: ${{ matrix.os }}
Expand Down Expand Up @@ -188,12 +188,49 @@ jobs:
path: .cov/html
retention-days: 7

run-testing:
name: Test the "run" subpackage
runs-on: ubuntu-latest
needs: [code-style]
container:
image: ghcr.io/ansys/mechanical:24.1.0
options: --entrypoint /bin/bash

steps:
- uses: actions/checkout@v4

- name: Install dependencies
run: |
apt update
apt install --reinstall ca-certificates
apt install software-properties-common git -y
add-apt-repository ppa:deadsnakes/ppa -y
apt install python3.11 python3.11-venv -y
python3.11 -m ensurepip --default-pip
python3.11 -m pip install --upgrade pip
python3.11 -m venv /env
- name: Install library
run: |
. /env/bin/activate
pip install .[tests]
- name: Unit testing
env:
ANSYSLI_SERVERS: 2325@${{secrets.LICENSE_SERVER}}
ANSYSLMD_LICENSE_FILE: 1055@${{secrets.LICENSE_SERVER}}
LSTC_LICENSE: ansys
run: |
. /env/bin/activate
save-ansys-path --name dyna /install/ansys_inc/v241/ansys/bin/linx64/lsdyna_dp.e
pytest -m run
build-library:
name: "Build library"
needs: [doc, tests]
needs: [doc, tests, run-testing]
runs-on: ubuntu-latest
steps:
- uses: ansys/actions/build-library@v7
- uses: ansys/actions/build-library@v8
with:
library-name: ${{ env.PACKAGE_NAME }}
python-version: ${{ env.MAIN_PYTHON_VERSION }}
Expand All @@ -205,14 +242,14 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: "Release to the public PyPI repository"
uses: ansys/actions/release-pypi-public@v7
uses: ansys/actions/release-pypi-public@v8
with:
library-name: ${{ env.PACKAGE_NAME }}
twine-username: "__token__"
twine-token: ${{ secrets.PYPI_TOKEN }}

- name: "Release to GitHub"
uses: ansys/actions/release-github@v7
uses: ansys/actions/release-github@v8
with:
library-name: ${{ env.PACKAGE_NAME }}

Expand All @@ -222,18 +259,22 @@ jobs:
runs-on: ubuntu-latest
needs: [build-library]
steps:
- uses: ansys/actions/doc-deploy-dev@v7
- uses: ansys/actions/doc-deploy-dev@v8
with:
cname: ${{ env.DOCUMENTATION_CNAME }}
token: ${{ secrets.GITHUB_TOKEN }}
token: ${{ secrets.PYANSYS_CI_BOT_TOKEN }}
bot-user: ${{ secrets.PYANSYS_CI_BOT_USERNAME }}
bot-email: ${{ secrets.PYANSYS_CI_BOT_EMAIL }}

doc-deploy-stable:
name: "Deploy stable documentation"
if: github.event_name == 'push' && contains(github.ref, 'refs/tags')
runs-on: ubuntu-latest
needs: [release]
steps:
- uses: ansys/actions/doc-deploy-stable@v7
- uses: ansys/actions/doc-deploy-stable@v8
with:
cname: ${{ env.DOCUMENTATION_CNAME }}
token: ${{ secrets.GITHUB_TOKEN }}
token: ${{ secrets.PYANSYS_CI_BOT_TOKEN }}
bot-user: ${{ secrets.PYANSYS_CI_BOT_USERNAME }}
bot-email: ${{ secrets.PYANSYS_CI_BOT_EMAIL }}
4 changes: 2 additions & 2 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
# For contributions made under a Corporate CLA, the organization is
# added to this file.
#
# If you have contributed to the repository and wish to be added to this file
# please submit a request.
# If you have contributed to the repository and want to be added to this file,
# submit a request.
#
#
ANSYS, Inc.
16 changes: 13 additions & 3 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
# Contributors

## Individual contributors
## Project Lead

* [Zhanqun Zhang](https://github.com/zhangzhanqun)
* [Wenhui Yu](https://github.com/wenhuiuy)
* [Srikanth Adya](https://github.com/kanthadya)
* [Wenhui Yu](https://github.com/wenhuiuy)
* [Zhanqun Zhang](https://github.com/zhangzhanqun)

## Individual Contributors

* [Alexander Kaszynski](https://github.com/akaszynski)
* [Dominik Gresch](https://github.com/greschd)
* [Fabian de Leon](https://github.com/fdeleonm)
* [Jorge Martínez](https://github.com/jorgepiloto)
* [Maxime Rey](https://github.com/MaxJPRey)
* [Revathy Venugopal](https://github.com/Revathyvenugopal162)
* [Roberto Pastor](https://github.com/RobPasMue)
8 changes: 5 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ Overview
========
PyDYNA is a Pythonic package for providing a more convenient and complete way to
build an Ansys DYNA input deck, submit it to the Ansys LS-DYNA solver, and
finally postprocess the results.
finally postprocess the results.

PyDYNA contains two submodules, ``ansys.dyna.core.pre`` and ``ansys.dyna.core.solver``
PyDYNA contains three submodules, ``ansys.dyna.core.pre``, ``ansys.dyna.core.solver``, and ``ansys.dyna.core.run``.

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

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

To reach the project support team, email `pyansys.core@ansys.com <pyansys.core@ansys.com>`_.

Expand Down
25 changes: 25 additions & 0 deletions doc/source/getting-started/RUN_README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
Use PyDYNA to run LSDYNA locally
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Run LS-DYNA using ansys.dyna.core.run
*************************************

.. code:: python
import os
from ansys.dyna.core.run import run_dyna
dynafile = "input.k"
working_directory = os.path.getcwd()
filepath = run_dyna(dynafile, working_directory=dynadir)
......
How it works
************

``run_dyna`` attempts to find an installation of the LS-DYNA solver on your machine.
It uses the Python dependency ``ansys-tools-path`` to discover where LS-DYNA is installed.
After installing ``ansys-tools-path``, the location of LS-DYNA can be saved by running
``save-ansys-path --name dyna {path/to/dyna}`` so that subsequent usages of ``run_dyna``
look there.
14 changes: 11 additions & 3 deletions doc/source/getting-started/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@ page on the Ansys website.

Installation
============
PyDYNA consists of two modules, ``ansys.dyna.core.pre`` and ``ansys.dyna.core.solver``.
Both these modules are gRPC enabled and hence need to be run using server-client connection.
PyDYNA consists of three modules, ``ansys.dyna.core.pre``, ``ansys.dyna.core.solver``, and
``ansys.dyna.core.run``.

``ansys.dyna.core.pre`` and ``ansys.dyna.core.solver`` use gRPC and hence need to be run
using server-client connection.

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

Run PyDYNA server locally
Run PyDYNA server locally
-------------------------
Launching the servers directly on local machines.

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

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

Run DYNA using ``ansys.dyna.core.run`` on a local machine,
this does not require Docker.

.. include:: ./RUN_README.rst

Example
-------

Expand Down
25 changes: 13 additions & 12 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,48 +27,49 @@ classifiers = [

dependencies = ["ansys-dpf-core>=0.7.2",
"ansys-api-dyna==0.4.1",
"ansys-platform-instancemanagement~=1.0",
"ansys-tools-path>=0.6.0",
"ansys-platform-instancemanagement~=1.0",
"pyvista>=0.43.4",
]

[project.optional-dependencies]
tests = [
"matplotlib==3.9.2",
"numpy==2.1.1",
"numpy==2.1.2",
"pytest==8.3.3",
"pytest-cov==5.0.0",
"joblib==1.4.2",
"pandas==2.2.3",
"openpyxl==3.1.5",
"scikit-learn==1.5.2",
"pytest-xdist==3.6.1",
"ipython==8.27.0",
"ipython==8.29.0",
"pyvista==0.44.1",
]
doc = [
"recommonmark==0.7.1",
"matplotlib==3.9.2",
"imageio==2.35.1",
"imageio==2.36.0",
"imageio-ffmpeg==0.5.1",
"numpydoc==1.8.0",
"Sphinx==8.0.2",
"sphinx-autobuild==2024.9.19",
"Sphinx==8.1.3",
"sphinx-autobuild==2024.10.3",
"sphinxcontrib-websupport==2.0.0",
"pytest-sphinx==0.6.3",
"sphinx-notfound-page==1.0.4",
"sphinx-copybutton==0.5.2",
"sphinx-gallery==0.17.1",
"sphinx-autodoc-typehints==2.4.4",
"ansys-sphinx-theme==1.0.11",
"pypandoc==1.13",
"sphinx-gallery==0.18.0",
"sphinx-autodoc-typehints==2.5.0",
"ansys-sphinx-theme==1.1.7",
"pypandoc==1.14",
"nbsphinx==0.9.5",
"ipywidgets==8.1.5",
"joblib==1.4.2",
"scikit-learn==1.5.2",
"ipython==8.27.0",
"ipython==8.29.0",
"jupyterlab==4.2.5",
"sphinx-jinja==2.0.2",
"sphinx-autoapi==3.3.1",
"sphinx-autoapi==3.3.3",
"pyvista==0.44.1",
]

Expand Down
3 changes: 3 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[pytest]
markers =
run: tests that exercise the `run` subpackage
24 changes: 24 additions & 0 deletions src/ansys/dyna/core/run/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Copyright (C) 2021 - 2024 ANSYS, Inc. and/or its affiliates.
# SPDX-License-Identifier: MIT
#
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

from .local_solver import run_dyna # noqa: F401
from .options import MemoryUnit, MpiOption, Precision # noqa: F401
39 changes: 39 additions & 0 deletions src/ansys/dyna/core/run/base_runner.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Copyright (C) 2021 - 2024 ANSYS, Inc. and/or its affiliates.
# SPDX-License-Identifier: MIT
#
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

"""Base runner class."""

from ansys.dyna.core.run.options import MemoryUnit, MpiOption, Precision


class BaseRunner:
def __init__(self, **kwargs):
# TODO - split mpi option into precision?
self.mpi_option = kwargs.get("mpi_option", MpiOption.SMP)
self.ncpu = kwargs.get("ncpu", 1)
self.memory = kwargs.get("memory", 20)
self.memory_unit = kwargs.get("memory_unit", MemoryUnit.MB)
self.precision = kwargs.get("precision", Precision.DOUBLE)

def get_memory_string(self) -> str:
unit = {MemoryUnit.MB: "m", MemoryUnit.GB: "G"}[self.memory_unit]
return f"{self.memory}{unit}"
Loading

0 comments on commit 685f4f2

Please sign in to comment.