Skip to content

Commit a88765e

Browse files
kanthadyaRobPasMue
andauthored
updated docs for getting started and landing page (#271)
Co-authored-by: Roberto Pastor Muela <[email protected]>
1 parent df27132 commit a88765e

File tree

7 files changed

+5546
-233
lines changed

7 files changed

+5546
-233
lines changed

README.rst

Lines changed: 19 additions & 163 deletions
Original file line numberDiff line numberDiff line change
@@ -36,29 +36,26 @@ PyDYNA is a Pythonic package for providing a more convenient and complete way to
3636
build an Ansys DYNA input deck, submit it to the Ansys LS-DYNA solver, and
3737
finally postprocess the results.
3838

39-
In the PyDYNA installation, the ``docker`` directory has two child
40-
directories:
41-
42-
- ``pre``: Contains the package with the ``ls-pre`` Docker image for the
43-
``pre`` service. This service provides highly abstracted APIs for creating and
44-
setting up DYNA input decks for DynaMech, DynaIGA, DynaICFD, DynaSALE, DynaEM,
45-
and DynaAirbag.
46-
- ``solver``: Contains the package with the ``dynasolver`` Docker image
47-
for the ``solver`` service. This service provides highly abstracted
48-
APIs for interacting directly with the Ansys LS-DYNA solver. Because LS-DYNA
49-
is primarily a batch solver with very limited interactive capabilities, the
50-
``solver`` service is similarly limited. The target use case is that LS-DYNA is
51-
running in a container environment such as Docker or Kubernetes. Using this
52-
service, you can push input files to the container, start LS-DYNA
53-
and monitor its progress, and then retrieve Ansys solver results (RST)
54-
files.
39+
PyDYNA contains two submodules, ``ansys.dyna.core.pre`` and ``ansys.dyna.core.solver``
40+
41+
- ``pre``: This module provides highly abstracted APIs for creating and
42+
setting up DYNA input decks. There are many classes supported, namely,
43+
DynaMech, DynaIGA, DynaICFD, DynaSALE, DynaEM,DynaNVH, DynaMaterial,
44+
DynaISPH, DynaICFD and DynaAirbag. Each of these classes can be used to generate
45+
LS-DYNA keywords. Since these classes have high-level abstraction, each function call
46+
generates groups of keywords needed to define an input in LS-DYNA.
47+
- ``solver``: This API provides features to interact directly with the Ansys LS-DYNA solver.
48+
LS-DYNA is primarily a batch solver with very limited interactive capabilities, the
49+
``solver`` service provides a way to push input files to the LS-DYNA solver, monitor the state
50+
of the running job, change the value of a load curve and finally retrieve result files back from
51+
the server
5552

5653
Once you have results, you can use the Ansys Data Processing Framework (DPF),
5754
which is designed to provide numerical simulation users and engineers
5855
with a toolbox for accessing and transforming simulation data. DPF
59-
can access data from Ansys solver RST files and from several
60-
files with neutral formats, including CSV, HDF5, and VTK. Using DPF's
61-
various operators, you can manipulate and transform this data.
56+
can access data from Ansys solver files and from several files with neutral formats,
57+
including CSV, HDF5, and VTK. Using DPF's various operators,
58+
you can manipulate and transform this data.
6259

6360
The `ansys-dpf-post package <https://github.com/ansys/pydpf-post>`_ provides
6461
a simplified Python interface to DPF, thus enabling rapid postprocessing
@@ -70,6 +67,9 @@ Documentation and issues
7067
Documentation for the latest stable release of PyDyna is hosted at `PyDYNA documentation
7168
<https://dyna.docs.pyansys.com/version/stable//>`_.
7269

70+
For examples on how to use PyDYNA, see `Examples <https://dyna.docs.pyansys.com/version/stable/examples/index.html>`_
71+
in the PyDYNA documentation.
72+
7373
In the upper right corner of the documentation's title bar, there is an option for switching from
7474
viewing the documentation for the latest stable release to viewing the documentation for the
7575
development version or previously released versions.
@@ -81,150 +81,6 @@ you can post questions, share ideas, and get community feedback.
8181

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

84-
Usage
85-
=====
86-
The next few sections show how to preprocess, solve, and postprocess a ball plate example.
87-
88-
Preprocess
89-
----------
90-
The following code preprocesses a ball plate example. In the repository, you can get the
91-
input file from ``src/ansys/dyna/core/pre/examples/explicit/ball_plate/ball_plate.k`` and
92-
the Python file from ``examples/Explicit/ball_plate.py``.
93-
94-
.. code:: python
95-
96-
import os
97-
import sys
98-
from ansys.dyna.core.pre.dynasolution import DynaSolution
99-
from ansys.dyna.core.pre.dynamech import (
100-
DynaMech,
101-
Velocity,
102-
PartSet,
103-
ShellPart,
104-
SolidPart,
105-
NodeSet,
106-
Contact,
107-
ContactSurface,
108-
ShellFormulation,
109-
SolidFormulation,
110-
ContactType,
111-
AnalysisType
112-
)
113-
from ansys.dyna.core.pre.dynamaterial import (
114-
MatRigid,
115-
MatPiecewiseLinearPlasticity,
116-
)
117-
from ansys.dyna.core.pre import examples
118-
119-
hostname = "localhost"
120-
if len(sys.argv) > 1:
121-
hostname = sys.argv[1]
122-
solution = DynaSolution(hostname)
123-
124-
fns = []
125-
path = examples.ball_plate + os.sep
126-
fns.append(path+"ball_plate.k")
127-
solution.open_files(fns)
128-
129-
solution.set_termination(termination_time=10)
130-
131-
ballplate = DynaMech(AnalysisType.NONE)
132-
solution.add(ballplate)
133-
134-
matrigid = MatRigid(mass_density=7.83e-6, young_modulus=207, poisson_ratio=0.3)
135-
matplastic = MatPiecewiseLinearPlasticity(mass_density=7.83e-6, young_modulus=207, yield_stress=0.2, tangent_modulus=2)
136-
137-
plate = ShellPart(1)
138-
plate.set_element_formulation(ShellFormulation.BELYTSCHKO_TSAY)
139-
plate.set_material(matplastic)
140-
plate.set_thickness(1)
141-
plate.set_integration_points(5)
142-
ballplate.parts.add(plate)
143-
144-
ball = SolidPart(2)
145-
ball.set_material(matrigid)
146-
ball.set_element_formulation(SolidFormulation.CONSTANT_STRESS_SOLID_ELEMENT)
147-
ballplate.parts.add(ball)
148-
149-
selfcontact = Contact(type=ContactType.AUTOMATIC)
150-
surf1 = ContactSurface(PartSet([1, 2]))
151-
selfcontact.set_slave_surface(surf1)
152-
ballplate.contacts.add(selfcontact)
153-
154-
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]
155-
for i in range(1,19):
156-
spc.append(i)
157-
for i in range(272,290):
158-
spc.append(i)
159-
ballplate.boundaryconditions.create_spc(NodeSet(spc),rx=False,ry=False,rz=False)
160-
161-
for i in range(1,1652):
162-
ballplate.initialconditions.create_velocity_node(i,trans=Velocity(0, 0, -10))
163-
164-
solution.set_output_database(glstat=0.1, matsum=0.1, sleout=0.1)
165-
solution.create_database_binary(dt=1)
166-
serverpath = solution.save_file()
167-
168-
serveroutfile = '/'.join((serverpath,"ball_plate.k"))
169-
downloadpath = os.path.join(os.getcwd(), "output")
170-
if not os.path.exists(downloadpath):
171-
os.makedirs(downloadpath)
172-
downloadfile = os.path.join(downloadpath,"ball_plate.k")
173-
solution.download(serveroutfile,downloadfile)
174-
175-
Solve
176-
-----
177-
The following code solves this basic ball plate example. In the repository,
178-
you can get the Python file from ``examples/solver/ball_plate_solver.py``.
179-
180-
.. code:: python
181-
182-
import ansys.dyna.core.solver as solver
183-
184-
hostname = "localhost"
185-
port = "5000"
186-
dyna=solver.DynaSolver(hostname,port) # connect to the container
187-
dyna.push("./output/ball_plate.k") # push an input file
188-
dyna.start(4) # start 4 ranks of mppdyna
189-
dyna.run("i=ball_plate.k memory=10m ncycle=20000") # begin execution
190-
191-
192-
Postprocess
193-
-----------
194-
The following code postprocesses results from the solve of this basic ball plate example:
195-
196-
.. code:: python
197-
198-
from ansys.dpf import core as dpf
199-
import os
200-
201-
ds = dpf.DataSources()
202-
data_path = os.path.join(os.getcwd(), 'd3plot')
203-
ds.set_result_file_path(data_path, 'd3plot')
204-
205-
model = dpf.Model(ds)
206-
# Extract displacements for all time steps from d3plot
207-
D = model.results.displacement.on_all_time_freqs().eval()
208-
D.animate()
209-
210-
stress = dpf.operators.result.stress()
211-
stress.inputs.data_sources(ds)
212-
stress.inputs.time_scoping([12])
213-
stress.connect(25, [1])
214-
stress.inputs.requested_location.connect("Nodal")
215-
fields = stress.outputs.fields_container()
216-
217-
shell_layer_extract = dpf.operators.utility.change_shell_layers()
218-
shell_layer_extract.inputs.fields_container.connect(fields)
219-
print(shell_layer_extract.inputs.e_shell_layer)
220-
shell_layer_extract.inputs.e_shell_layer.connect(0)
221-
fields_top = shell_layer_extract.outputs.fields_container_as_fields_container()
222-
print(fields_top)
223-
fields_top.animate()
224-
225-
For more examples, see `Examples <https://dyna.docs.pyansys.com/version/stable/examples/index.html>`_
226-
in the PyDYNA documentation.
227-
22884
License
22985
=======
23086
PyDYNA is licensed under the MIT license.

doc/source/user-guide/index.rst renamed to doc/source/.user-guide/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ directories:
77
In the PyDYNA installation, the ``docker`` directory has two child
88
directories:
99

10-
- ``pre``: Contains the package with the ``ls-pre`` Docker image for the
10+
- ``pre``: Contains the package with the ``pre`` Docker image for the
1111
``pre`` service. This service provides highly abstracted APIs for creating and
1212
setting up DYNA input decks for DynaMech, DynaIGA, DynaICFD, DynaSALE, DynaEM,
1313
and DynaAirbag.

doc/source/getting-started/index.rst

Lines changed: 17 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,19 @@
11
Getting started
22
===============
3-
To run PyDYNA, you must have an installation of Ansys LS-DYNA.
4-
PyDYNA supports LS-DYNA 2023 R2 and later.
3+
4+
To use the solver features of PyDYNA, you must have a valid LS-DYNA license.
55

66
For information on getting a licensed copy of LS-DYNA, see
77
the `Ansys LS-DYNA <https://www.ansys.com/products/structures/ansys-ls-dyna>`_
88
page on the Ansys website.
99

1010
Installation
1111
============
12-
To use PyDYNA, you must install Docker images for the ``pre`` and ``solver``
13-
services and the ``ansys.dyna.core`` package itself.
14-
15-
16-
Install Docker image for the ``pre`` service
17-
--------------------------------------------
18-
To launch the ``pre`` service locally, you must have Docker installed
19-
on your machine.
20-
21-
.. caution::
22-
23-
The ``pre`` service is available only as a Linux Docker image.
24-
Make sure that your Docker engine is configured to run Linux Docker images.
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.
2514

26-
For information on installing the Docker container for the ``pre`` service,
27-
see the ``README.rst`` file in the repository's ``docker/pre`` directory.
28-
29-
Install Docker image for the ``solver`` service
30-
-----------------------------------------------
31-
For information on installing the Docker container for the ``solver`` service,
32-
see the ``README.rst`` file in the repository's ``docker/solver`` directory.
33-
34-
Install the package
35-
-------------------
15+
Install the client
16+
------------------
3617
The ``ansys.dyna.core`` package supports Python 3.8 through
3718
Python 3.11 on Windows, Linux, and MacOS.
3819

@@ -46,7 +27,7 @@ Install in user mode
4627
~~~~~~~~~~~~~~~~~~~~
4728

4829
Before installing PyDYNA in user mode, make sure you have the latest version of
49-
`pip`_ with this command:
30+
`pip <https://pip.pypa.io/en/stable/installation/>`_ with this command:
5031

5132
.. code:: bash
5233
@@ -65,9 +46,9 @@ Install in developer mode
6546
Installing PyDYNA in developer mode allows you to modify the source and enhance it.
6647

6748
.. note::
68-
49+
6950
Before contributing to the project, ensure that you are thoroughly familiar
70-
with the `PyAnsys Developer's Guide`_.
51+
with the `PyAnsys Developer's Guide <https://dev.docs.pyansys.com/index.html>`_.
7152

7253
Start by cloning and installing the repository with these commands:
7354

@@ -99,6 +80,14 @@ with these commands:
9980
If you're on Windows with Python 3.8, unzip the wheelhouse archive to a ``wheelhouse``
10081
directory and install PyDYNA using the preceding command.
10182

83+
Install the server
84+
------------------
85+
Currently, PyDYNA server is only supported withing a Docker container.
86+
Future releases support launching the servers directly on local machines as well.
87+
88+
.. include:: ../../../docker/pre/README.rst
89+
90+
.. include:: ../../../docker/solver/README.rst
10291

10392
.. LINKS
10493
.. _pydyna_pypi: https://pypi.org/projects/ansys-dyna-core/

doc/source/index.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ PyDYNA documentation |version|
22
===============================
33

44
.. include:: ../../README.rst
5-
.. include:: ../../docker/pre/README.rst
6-
.. include:: ../../docker/solver/README.rst
5+
76

87
.. jinja:: main_toctree
98

0 commit comments

Comments
 (0)