Skip to content

Commit d3daeb8

Browse files
committed
Merge branch 'main' into release/0.4
2 parents d35d205 + 6978b4a commit d3daeb8

File tree

9 files changed

+307
-115
lines changed

9 files changed

+307
-115
lines changed
Lines changed: 4 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,9 @@
11
Start PyDYNA preprocessing server locally
2-
=========================================
3-
4-
There are two ways to start the PyDYNA preprocessing server
5-
6-
1.Start server manually
7-
-----------------------
8-
9-
* Run this command in the current folder:
10-
11-
.. code:: console
12-
13-
python kwserver.py
14-
15-
2.Start server automatically
16-
----------------------------
17-
18-
Start server on Windows
19-
~~~~~~~~~~~~~~~~~~~~~~~
20-
21-
#. Set environment variable:
22-
23-
.. code:: bash
24-
25-
Variable name: ANSYS_PYDYNA_PRE_SERVER_PATH
26-
variable value: <The file path of this package>
27-
28-
example of variable value: C:\pydyna\ansys-pydyna-pre-server
29-
30-
Start server on Linux
31-
~~~~~~~~~~~~~~~~~~~~~
32-
33-
#. Set environment variable:
34-
35-
.. code:: bash
36-
37-
ANSYS_PYDYNA_PRE_SERVER_PATH=<The file path of this package>
38-
39-
example of variable value: /home/lstc/ansys-pydyna-pre-server
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
403

414
Run an example on the client side
42-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
43-
5+
*********************************
6+
447
.. code:: bash
458
469
hostname = "localhost"
@@ -49,4 +12,4 @@ Run an example on the client side
4912
solution = DynaSolution(hostname)
5013
......
5114
52-
#. The function of DynaSolution() can start the preprocessing server automatically.
15+
#. The function of DynaSolution() can download and start the preprocessing server automatically.
Lines changed: 6 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
Start PyDYNA solver server locally
2-
==================================
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
33

44
Prerequisites
5-
-------------
5+
*************
66

77
Start server on Windows
8-
~~~~~~~~~~~~~~~~~~~~~~~
8+
+++++++++++++++++++++++
99

1010
#. If you want to start the server on Windows,please ensure that you have installed the ANSYS locally.
1111

1212
Start server on Linux(Centos7)
13-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
13+
++++++++++++++++++++++++++++++
1414

1515
#. If you want to start the server on Linux,please ensure that you have installed the Open MPI package.
1616

@@ -25,47 +25,8 @@ Start server on Linux(Centos7)
2525
export LD_LIBRARY_PATH=/usr/lib64/openmpi3/lib:$LD_LIBRARY_PATH
2626
export PATH=/usr/lib64/openmpi3/bin:$PATH
2727
28-
29-
There are two ways to start the PyDYNA solver server
30-
====================================================
31-
32-
1.Start server manually
33-
-----------------------
34-
35-
* Run this command in the current folder:
36-
37-
.. code:: console
38-
39-
python server.py
40-
41-
2.Start Server Automatically
42-
----------------------------
43-
44-
Start Server On Windows
45-
~~~~~~~~~~~~~~~~~~~~~~~
46-
47-
#. Set environment variable:
48-
49-
.. code:: bash
50-
51-
Variable name: ANSYS_PYDYNA_SOLVER_SERVER_PATH
52-
variable value: <The file path of this package>
53-
54-
example of variable value: C:\pydyna\ansys-pydyna-solver-server
55-
56-
Start Server on Linux(Centos7)
57-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
58-
59-
#. Set environment variable:
60-
61-
.. code:: bash
62-
63-
ANSYS_PYDYNA_SOLVER_SERVER_PATH=<The file path of this package>
64-
65-
example of variable value: /home/lstc/ansys-pydyna-solver-server
66-
6728
Run an example on the client side
68-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
29+
*********************************
6930

7031
.. code:: bash
7132
@@ -77,4 +38,4 @@ Run an example on the client side
7738
dyna.push("./output/ball_plate.k") # push an input file
7839
dyna.start_locally(input = "ball_plate.k",nproc=1)
7940
80-
#. The function of DynaSolver() can start the solver server automatically.
41+
#. The function of DynaSolver() can download and start the solver server automatically.
Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
The next few sections show how to preprocessing, solve, and postprocessing a ball plate example.
2+
3+
Preprocessing
4+
~~~~~~~~~~~~~
5+
The following code processes a ball plate example. In the repository, you can get the
6+
input file from ``src/ansys/dyna/core/pre/examples/explicit/ball_plate/ball_plate.k`` and
7+
the Python file from ``examples/Explicit/ball_plate.py``.
8+
9+
.. code:: python
10+
11+
import os
12+
import sys
13+
from ansys.dyna.core.pre.dynasolution import DynaSolution
14+
from ansys.dyna.core.pre.dynamech import (
15+
DynaMech,
16+
Velocity,
17+
PartSet,
18+
ShellPart,
19+
SolidPart,
20+
NodeSet,
21+
Contact,
22+
ContactSurface,
23+
ShellFormulation,
24+
SolidFormulation,
25+
ContactType,
26+
AnalysisType
27+
)
28+
from ansys.dyna.core.pre.dynamaterial import (
29+
MatRigid,
30+
MatPiecewiseLinearPlasticity,
31+
)
32+
from ansys.dyna.core.pre import examples
33+
34+
hostname = "localhost"
35+
if len(sys.argv) > 1:
36+
hostname = sys.argv[1]
37+
solution = DynaSolution(hostname)
38+
39+
fns = []
40+
path = examples.ball_plate + os.sep
41+
fns.append(path+"ball_plate.k")
42+
solution.open_files(fns)
43+
44+
solution.set_termination(termination_time=10)
45+
46+
ballplate = DynaMech(AnalysisType.NONE)
47+
solution.add(ballplate)
48+
49+
matrigid = MatRigid(mass_density=7.83e-6, young_modulus=207, poisson_ratio=0.3)
50+
matplastic = MatPiecewiseLinearPlasticity(mass_density=7.83e-6, young_modulus=207, yield_stress=0.2, tangent_modulus=2)
51+
52+
plate = ShellPart(1)
53+
plate.set_element_formulation(ShellFormulation.BELYTSCHKO_TSAY)
54+
plate.set_material(matplastic)
55+
plate.set_thickness(1)
56+
plate.set_integration_points(5)
57+
ballplate.parts.add(plate)
58+
59+
ball = SolidPart(2)
60+
ball.set_material(matrigid)
61+
ball.set_element_formulation(SolidFormulation.CONSTANT_STRESS_SOLID_ELEMENT)
62+
ballplate.parts.add(ball)
63+
64+
selfcontact = Contact(type=ContactType.AUTOMATIC)
65+
surf1 = ContactSurface(PartSet([1, 2]))
66+
selfcontact.set_slave_surface(surf1)
67+
ballplate.contacts.add(selfcontact)
68+
69+
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]
70+
for i in range(1,19):
71+
spc.append(i)
72+
for i in range(272,290):
73+
spc.append(i)
74+
ballplate.boundaryconditions.create_spc(NodeSet(spc),rx=False,ry=False,rz=False)
75+
76+
for i in range(1,1652):
77+
ballplate.initialconditions.create_velocity_node(i,trans=Velocity(0, 0, -10))
78+
79+
solution.set_output_database(glstat=0.1, matsum=0.1, sleout=0.1)
80+
solution.create_database_binary(dt=1)
81+
serverpath = solution.save_file()
82+
83+
serveroutfile = '/'.join((serverpath,"ball_plate.k"))
84+
downloadpath = os.path.join(os.getcwd(), "output")
85+
if not os.path.exists(downloadpath):
86+
os.makedirs(downloadpath)
87+
downloadfile = os.path.join(downloadpath,"ball_plate.k")
88+
solution.download(serveroutfile,downloadfile)
89+
90+
Solve
91+
~~~~~
92+
The following code solves this basic ball plate example. In the repository,
93+
you can get the Python file from ``examples/solver/ball_plate_solver.py``.
94+
95+
.. code:: python
96+
97+
import ansys.dyna.core.solver as solver
98+
99+
hostname = "localhost"
100+
port = "5000"
101+
dyna=solver.DynaSolver(hostname,port) # connect to the container
102+
dyna.push("./output/ball_plate.k") # push an input file
103+
dyna.start(4) # start 4 ranks of mppdyna
104+
dyna.run("i=ball_plate.k memory=10m ncycle=20000") # begin execution
105+
106+
107+
Post processing
108+
~~~~~~~~~~~~~~~
109+
The following code processes results from the solve of this basic ball plate example:
110+
111+
.. code:: python
112+
113+
from ansys.dpf import core as dpf
114+
import os
115+
116+
ds = dpf.DataSources()
117+
data_path = os.path.join(os.getcwd(), 'd3plot')
118+
ds.set_result_file_path(data_path, 'd3plot')
119+
120+
model = dpf.Model(ds)
121+
# Extract displacements for all time steps from d3plot
122+
D = model.results.displacement.on_all_time_freqs().eval()
123+
D.animate()
124+
125+
stress = dpf.operators.result.stress()
126+
stress.inputs.data_sources(ds)
127+
stress.inputs.time_scoping([12])
128+
stress.connect(25, [1])
129+
stress.inputs.requested_location.connect("Nodal")
130+
fields = stress.outputs.fields_container()
131+
132+
shell_layer_extract = dpf.operators.utility.change_shell_layers()
133+
shell_layer_extract.inputs.fields_container.connect(fields)
134+
print(shell_layer_extract.inputs.e_shell_layer)
135+
shell_layer_extract.inputs.e_shell_layer.connect(0)
136+
fields_top = shell_layer_extract.outputs.fields_container_as_fields_container()
137+
print(fields_top)
138+
fields_top.animate()
139+
140+
For more examples, see `Examples <https://dyna.docs.pyansys.com/version/stable/examples/index.html>`_
141+
in the PyDYNA documentation.

doc/source/getting-started/index.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ with these commands:
8080
If you're on Windows with Python 3.9, unzip the wheelhouse archive to a ``wheelhouse``
8181
directory and install PyDYNA using the preceding command.
8282

83-
Run PyDYNA Server locally
83+
Run PyDYNA server locally
8484
-------------------------
8585
Launching the servers directly on local machines.
8686

@@ -96,6 +96,10 @@ PyDYNA server can be run in a Docker container.
9696

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

99+
Example
100+
-------
101+
102+
.. include:: ./example.rst
99103

100104
.. LINKS
101105
.. _pydyna_pypi: https://pypi.org/projects/ansys-dyna-core/

pyproject.toml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,41 +29,41 @@ dependencies = ["ansys-dpf-core>=0.7.2", "ansys-api-dyna==0.3.5"]
2929

3030
[project.optional-dependencies]
3131
tests = [
32-
"pyvista==0.43.1",
32+
"pyvista==0.43.2",
3333
"matplotlib==3.8.2",
34-
"numpy==1.26.2",
34+
"numpy==1.26.3",
3535
"pytest==7.4.4",
3636
"pytest-cov==4.1.0",
3737
"joblib==1.3.2",
38-
"pandas==2.1.4",
38+
"pandas==2.2.0",
3939
"openpyxl==3.1.2",
40-
"scikit-learn==1.3.2",
40+
"scikit-learn==1.4.0",
4141
"pytest-xdist==3.5.0",
42-
"ipython==8.19.0",
42+
"ipython==8.20.0",
4343
]
4444
doc = [
4545
"recommonmark==0.7.1",
4646
"matplotlib==3.8.2",
4747
"imageio==2.33.1",
4848
"imageio-ffmpeg==0.4.9",
49-
"pyvista==0.43.1",
49+
"pyvista==0.43.2",
5050
"numpydoc==1.6.0",
5151
"Sphinx==7.2.6",
5252
"sphinx-autobuild==2021.3.14",
53-
"sphinxcontrib-websupport==1.2.6",
53+
"sphinxcontrib-websupport==1.2.7",
5454
"pytest-sphinx==0.5.0",
5555
"sphinx-notfound-page==1.0.0",
5656
"sphinx-copybutton==0.5.2",
5757
"sphinx-gallery==0.15.0",
5858
"sphinx-autodoc-typehints==1.25.2",
59-
"ansys-sphinx-theme==0.12.5",
59+
"ansys-sphinx-theme==0.13.1",
6060
"pypandoc==1.12",
6161
"nbsphinx==0.9.3",
6262
"ipywidgets==8.1.1",
6363
"joblib==1.3.2",
64-
"scikit-learn==1.3.2",
65-
"ipython==8.19.0",
66-
"jupyterlab==4.0.10",
64+
"scikit-learn==1.4.0",
65+
"ipython==8.20.0",
66+
"jupyterlab==4.0.11",
6767
"sphinx-jinja==2.0.2",
6868
"sphinx-autoapi==3.0.0",
6969
]

0 commit comments

Comments
 (0)