generated from ansys/template
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
5,569 additions
and
268 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
PyDYNA | ||
======== | ||
====== | ||
|
||
.. readme_start | ||
|pyansys| |python| |pypi| |GH-CI| |codecov| |MIT| |black| | ||
|
||
.. |pyansys| image:: https://img.shields.io/badge/Py-Ansys-ffc107.svg?logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkWg2AAABDklEQVQ4jWNgoDfg5mD8vE7q/3bpVyskbW0sMRUwofHD7Dh5OBkZGBgW7/3W2tZpa2tLQEOyOzeEsfumlK2tbVpaGj4N6jIs1lpsDAwMJ278sveMY2BgCA0NFRISwqkhyQ1q/Nyd3zg4OBgYGNjZ2ePi4rB5loGBhZnhxTLJ/9ulv26Q4uVk1NXV/f///////69du4Zdg78lx//t0v+3S88rFISInD59GqIH2esIJ8G9O2/XVwhjzpw5EAam1xkkBJn/bJX+v1365hxxuCAfH9+3b9/+////48cPuNehNsS7cDEzMTAwMMzb+Q2u4dOnT2vWrMHu9ZtzxP9vl/69RVpCkBlZ3N7enoDXBwEAAA+YYitOilMVAAAAAElFTkSuQmCC | ||
|
@@ -36,29 +39,26 @@ 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. | ||
|
||
In the PyDYNA installation, the ``docker`` directory has two child | ||
directories: | ||
|
||
- ``pre``: Contains the package with the ``ls-pre`` Docker image for the | ||
``pre`` service. This service provides highly abstracted APIs for creating and | ||
setting up DYNA input decks for DynaMech, DynaIGA, DynaICFD, DynaSALE, DynaEM, | ||
and DynaAirbag. | ||
- ``solver``: Contains the package with the ``dynasolver`` Docker image | ||
for the ``solver`` service. This service provides highly abstracted | ||
APIs for interacting directly with the Ansys LS-DYNA solver. Because LS-DYNA | ||
is primarily a batch solver with very limited interactive capabilities, the | ||
``solver`` service is similarly limited. The target use case is that LS-DYNA is | ||
running in a container environment such as Docker or Kubernetes. Using this | ||
service, you can push input files to the container, start LS-DYNA | ||
and monitor its progress, and then retrieve Ansys solver results (RST) | ||
files. | ||
PyDYNA contains two submodules, ``ansys.dyna.core.pre`` and ``ansys.dyna.core.solver`` | ||
|
||
- ``pre``: This module provides highly abstracted APIs for creating and | ||
setting up DYNA input decks. There are many classes supported, namely, | ||
DynaMech, DynaIGA, DynaICFD, DynaSALE, DynaEM,DynaNVH, DynaMaterial, | ||
DynaISPH, DynaICFD and DynaAirbag. Each of these classes can be used to generate | ||
LS-DYNA keywords. Since these classes have high-level abstraction, each function call | ||
generates groups of keywords needed to define an input in LS-DYNA. | ||
- ``solver``: This API provides features to interact directly with the Ansys LS-DYNA solver. | ||
LS-DYNA is primarily a batch solver with very limited interactive capabilities, the | ||
``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 | ||
|
||
Once you have results, you can use the Ansys Data Processing Framework (DPF), | ||
which is designed to provide numerical simulation users and engineers | ||
with a toolbox for accessing and transforming simulation data. DPF | ||
can access data from Ansys solver RST files and from several | ||
files with neutral formats, including CSV, HDF5, and VTK. Using DPF's | ||
various operators, you can manipulate and transform this data. | ||
can access data from Ansys solver files and from several files with neutral formats, | ||
including CSV, HDF5, and VTK. Using DPF's various operators, | ||
you can manipulate and transform this data. | ||
|
||
The `ansys-dpf-post package <https://github.com/ansys/pydpf-post>`_ provides | ||
a simplified Python interface to DPF, thus enabling rapid postprocessing | ||
|
@@ -70,6 +70,9 @@ Documentation and issues | |
Documentation for the latest stable release of PyDyna is hosted at `PyDYNA documentation | ||
<https://dyna.docs.pyansys.com/version/stable//>`_. | ||
|
||
For examples on how to use PyDYNA, see `Examples <https://dyna.docs.pyansys.com/version/stable/examples/index.html>`_ | ||
in the PyDYNA documentation. | ||
|
||
In the upper right corner of the documentation's title bar, there is an option for switching from | ||
viewing the documentation for the latest stable release to viewing the documentation for the | ||
development version or previously released versions. | ||
|
@@ -81,150 +84,6 @@ you can post questions, share ideas, and get community feedback. | |
|
||
To reach the project support team, email `[email protected] <[email protected]>`_. | ||
|
||
Usage | ||
===== | ||
The next few sections show how to preprocess, solve, and postprocess a ball plate example. | ||
|
||
Preprocess | ||
---------- | ||
The following code preprocesses a ball plate example. In the repository, you can get the | ||
input file from ``src/ansys/dyna/core/pre/examples/explicit/ball_plate/ball_plate.k`` and | ||
the Python file from ``examples/Explicit/ball_plate.py``. | ||
|
||
.. code:: python | ||
import os | ||
import sys | ||
from ansys.dyna.core.pre.dynasolution import DynaSolution | ||
from ansys.dyna.core.pre.dynamech import ( | ||
DynaMech, | ||
Velocity, | ||
PartSet, | ||
ShellPart, | ||
SolidPart, | ||
NodeSet, | ||
Contact, | ||
ContactSurface, | ||
ShellFormulation, | ||
SolidFormulation, | ||
ContactType, | ||
AnalysisType | ||
) | ||
from ansys.dyna.core.pre.dynamaterial import ( | ||
MatRigid, | ||
MatPiecewiseLinearPlasticity, | ||
) | ||
from ansys.dyna.core.pre import examples | ||
hostname = "localhost" | ||
if len(sys.argv) > 1: | ||
hostname = sys.argv[1] | ||
solution = DynaSolution(hostname) | ||
fns = [] | ||
path = examples.ball_plate + os.sep | ||
fns.append(path+"ball_plate.k") | ||
solution.open_files(fns) | ||
solution.set_termination(termination_time=10) | ||
ballplate = DynaMech(AnalysisType.NONE) | ||
solution.add(ballplate) | ||
matrigid = MatRigid(mass_density=7.83e-6, young_modulus=207, poisson_ratio=0.3) | ||
matplastic = MatPiecewiseLinearPlasticity(mass_density=7.83e-6, young_modulus=207, yield_stress=0.2, tangent_modulus=2) | ||
plate = ShellPart(1) | ||
plate.set_element_formulation(ShellFormulation.BELYTSCHKO_TSAY) | ||
plate.set_material(matplastic) | ||
plate.set_thickness(1) | ||
plate.set_integration_points(5) | ||
ballplate.parts.add(plate) | ||
ball = SolidPart(2) | ||
ball.set_material(matrigid) | ||
ball.set_element_formulation(SolidFormulation.CONSTANT_STRESS_SOLID_ELEMENT) | ||
ballplate.parts.add(ball) | ||
selfcontact = Contact(type=ContactType.AUTOMATIC) | ||
surf1 = ContactSurface(PartSet([1, 2])) | ||
selfcontact.set_slave_surface(surf1) | ||
ballplate.contacts.add(selfcontact) | ||
spc = [34,35,51,52,68,69,85,86,102,103,119,120,136,137,153,154,170,171,187,188,204,205,221,222,238,239,255,256] | ||
for i in range(1,19): | ||
spc.append(i) | ||
for i in range(272,290): | ||
spc.append(i) | ||
ballplate.boundaryconditions.create_spc(NodeSet(spc),rx=False,ry=False,rz=False) | ||
for i in range(1,1652): | ||
ballplate.initialconditions.create_velocity_node(i,trans=Velocity(0, 0, -10)) | ||
solution.set_output_database(glstat=0.1, matsum=0.1, sleout=0.1) | ||
solution.create_database_binary(dt=1) | ||
serverpath = solution.save_file() | ||
serveroutfile = '/'.join((serverpath,"ball_plate.k")) | ||
downloadpath = os.path.join(os.getcwd(), "output") | ||
if not os.path.exists(downloadpath): | ||
os.makedirs(downloadpath) | ||
downloadfile = os.path.join(downloadpath,"ball_plate.k") | ||
solution.download(serveroutfile,downloadfile) | ||
Solve | ||
----- | ||
The following code solves this basic ball plate example. In the repository, | ||
you can get the Python file from ``examples/solver/ball_plate_solver.py``. | ||
|
||
.. code:: python | ||
import ansys.dyna.core.solver as solver | ||
hostname = "localhost" | ||
port = "5000" | ||
dyna=solver.DynaSolver(hostname,port) # connect to the container | ||
dyna.push("./output/ball_plate.k") # push an input file | ||
dyna.start(4) # start 4 ranks of mppdyna | ||
dyna.run("i=ball_plate.k memory=10m ncycle=20000") # begin execution | ||
Postprocess | ||
----------- | ||
The following code postprocesses results from the solve of this basic ball plate example: | ||
|
||
.. code:: python | ||
from ansys.dpf import core as dpf | ||
import os | ||
ds = dpf.DataSources() | ||
data_path = os.path.join(os.getcwd(), 'd3plot') | ||
ds.set_result_file_path(data_path, 'd3plot') | ||
model = dpf.Model(ds) | ||
# Extract displacements for all time steps from d3plot | ||
D = model.results.displacement.on_all_time_freqs().eval() | ||
D.animate() | ||
stress = dpf.operators.result.stress() | ||
stress.inputs.data_sources(ds) | ||
stress.inputs.time_scoping([12]) | ||
stress.connect(25, [1]) | ||
stress.inputs.requested_location.connect("Nodal") | ||
fields = stress.outputs.fields_container() | ||
shell_layer_extract = dpf.operators.utility.change_shell_layers() | ||
shell_layer_extract.inputs.fields_container.connect(fields) | ||
print(shell_layer_extract.inputs.e_shell_layer) | ||
shell_layer_extract.inputs.e_shell_layer.connect(0) | ||
fields_top = shell_layer_extract.outputs.fields_container_as_fields_container() | ||
print(fields_top) | ||
fields_top.animate() | ||
For more examples, see `Examples <https://dyna.docs.pyansys.com/version/stable/examples/index.html>`_ | ||
in the PyDYNA documentation. | ||
|
||
License | ||
======= | ||
PyDYNA is licensed under the MIT license. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,19 @@ | ||
Getting started | ||
=============== | ||
To run PyDYNA, you must have an installation of Ansys LS-DYNA. | ||
PyDYNA supports LS-DYNA 2023 R2 and later. | ||
|
||
To use the solver features of PyDYNA, you must have a valid LS-DYNA license. | ||
|
||
For information on getting a licensed copy of LS-DYNA, see | ||
the `Ansys LS-DYNA <https://www.ansys.com/products/structures/ansys-ls-dyna>`_ | ||
page on the Ansys website. | ||
|
||
Installation | ||
============ | ||
To use PyDYNA, you must install Docker images for the ``pre`` and ``solver`` | ||
services and the ``ansys.dyna.core`` package itself. | ||
|
||
|
||
Install Docker image for the ``pre`` service | ||
-------------------------------------------- | ||
To launch the ``pre`` service locally, you must have Docker installed | ||
on your machine. | ||
|
||
.. caution:: | ||
|
||
The ``pre`` service is available only as a Linux Docker image. | ||
Make sure that your Docker engine is configured to run Linux Docker images. | ||
|
||
For information on installing the Docker container for the ``pre`` service, | ||
see the ``README.rst`` file in the repository's ``docker/pre`` directory. | ||
|
||
Install Docker image for the ``solver`` service | ||
----------------------------------------------- | ||
For information on installing the Docker container for the ``solver`` service, | ||
see the ``README.rst`` file in the repository's ``docker/solver`` directory. | ||
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. | ||
|
||
Install the package | ||
------------------- | ||
Install the client | ||
------------------ | ||
The ``ansys.dyna.core`` package supports Python 3.8 through | ||
Python 3.11 on Windows, Linux, and MacOS. | ||
|
||
|
@@ -46,7 +27,7 @@ Install in user mode | |
~~~~~~~~~~~~~~~~~~~~ | ||
|
||
Before installing PyDYNA in user mode, make sure you have the latest version of | ||
`pip`_ with this command: | ||
`pip <https://pip.pypa.io/en/stable/installation/>`_ with this command: | ||
|
||
.. code:: bash | ||
|
@@ -58,30 +39,16 @@ Then, install PyDYNA with this command: | |
python -m pip install ansys-dyna-core | ||
.. caution:: | ||
|
||
PyDYNA is currently hosted in a private PyPI repository. You must provide the index | ||
URL to the private PyPI repository: ``https://pkgs.dev.azure.com/pyansys/_packaging/pyansys/pypi/simple/``. | ||
|
||
If access to this package registry is needed, email `[email protected] <mailto:[email protected]>`_ | ||
to request access. The PyAnsys team can provide you with a read-only token. | ||
|
||
Once you have the token, run this command, replacing ``${PRIVATE_PYPI_ACCESS_TOKEN}`` with the | ||
read-only token: | ||
|
||
.. code:: bash | ||
pip install ansys-dyna-core --index-url=https://${PRIVATE_PYPI_ACCESS_TOKEN}@pkgs.dev.azure.com/pyansys/_packaging/pyansys/pypi/simple/ | ||
Install in developer mode | ||
~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
Installing PyDYNA in developer mode allows you to modify the source and enhance it. | ||
|
||
.. note:: | ||
|
||
Before contributing to the project, ensure that you are thoroughly familiar | ||
with the `PyAnsys Developer's Guide`_. | ||
with the `PyAnsys Developer's Guide <https://dev.docs.pyansys.com/index.html>`_. | ||
|
||
Start by cloning and installing the repository with these commands: | ||
|
||
|
@@ -94,10 +61,9 @@ Start by cloning and installing the repository with these commands: | |
Install in offline mode | ||
~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
If you lack an internet connection on your installation machine (or you do not have access | ||
to the private Ansys PyPI packages repository), you should install PyDYNA by downloading | ||
the wheelhouse archive for your corresponding machine architecture from the | ||
`Releases Page <https://github.com/pyansys/pydyna/releases>`_. | ||
If you lack an internet connection on your installation machine, you should install | ||
PyDYNA by downloading the wheelhouse archive for your corresponding machine | ||
architecture from the `Releases Page <https://github.com/pyansys/pydyna/releases>`_. | ||
|
||
Each wheelhouse archive contains all the Python wheels necessary to install | ||
PyDYNA from scratch on Windows and Linux for Python 3.8 through 3.11. You can install | ||
|
@@ -114,6 +80,14 @@ with these commands: | |
If you're on Windows with Python 3.8, unzip the wheelhouse archive to a ``wheelhouse`` | ||
directory and install PyDYNA using the preceding command. | ||
|
||
Install the server | ||
------------------ | ||
Currently, PyDYNA server is only supported withing a Docker container. | ||
Future releases support launching the servers directly on local machines as well. | ||
|
||
.. include:: ../../../docker/pre/README.rst | ||
|
||
.. include:: ../../../docker/solver/README.rst | ||
|
||
.. LINKS | ||
.. _pydyna_pypi: https://pypi.org/projects/ansys-dyna-core/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.