Skip to content

Commit 9b48c61

Browse files
committed
add nodla boundary conditions and input force; bump to 0.42.2
1 parent 1cc14d6 commit 9b48c61

File tree

10 files changed

+489
-43
lines changed

10 files changed

+489
-43
lines changed

docs/loading_results.rst

Lines changed: 137 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,29 @@
1-
Working with a ANSYS Result File (rst)
2-
======================================
1+
Working with a ANSYS Result Files
2+
=================================
3+
The `pyansys` module supports the following result types from MAPDL:
4+
5+
- ".rfl"
6+
- ".rmg"
7+
- ".rst"
8+
- ".rth"
9+
310
The ANSYS result file is a FORTRAN formatted binary file containing
411
the results written from an ANSYS analysis. The results, at a
512
minimum, contain the geometry of the model analyzed along with the
613
nodal and element results. Depending on the analysis, these results
7-
could be anything from modal displacements to nodal temperatures. At
8-
this time, only the following results are supported by this code:
14+
could be anything from modal displacements to nodal temperatures.
15+
This includes (and is not limited to):
916

1017
- Nodal DOF results from a static analysis or modal analysis.
1118
- Nodal DOF results from a cyclic static or modal analysis.
1219
- Nodal averaged component stresses (i.e. x, y, z, xy, xz, yz)
1320
- Nodal principal stresses (i.e. S1, S2, S3, SEQV, SINT)
21+
- Nodal elastic, plastic, and thermal stress
22+
- Nodal time history
23+
- Nodal boundary conditions and force
24+
- Nodal temperatures
25+
- Nodal thermal strain
26+
- Various element results (see ``element_solution_data``)
1427

1528
We're working on adding additional plotting and retrieval functions to the code If you would like us to add an additional result type to be loaded, please open an issue in `GitHub <https://github.com/akaszynski/pyansys>`_ and include result file for the result type you wish to load.
1629

@@ -20,7 +33,7 @@ Loading the Result File
2033
As the ANSYS result files are binary files, the entire file does not
2134
need to be loaded into memory in order to retrieve results. This
2235
module accesses the results through a python object `result` which you
23-
can create with:
36+
can initialize with:
2437

2538
.. code:: python
2639
@@ -31,31 +44,85 @@ Upon initialization the ``ResultFile`` object contains several
3144
properties to include the time values from the analysis, node
3245
numbering, element numbering, etc.
3346

47+
The `pyansys` module can determine the correct result type by reading
48+
the header of the file, which means that if it is an ANSYS binary
49+
file, `pyansys` can probably read it (at least to some degree. For
50+
example, a thermal result file can be read with
51+
52+
.. code:: python
53+
54+
rth = pyansys.read_binary('file.rth')
55+
3456
3557
ResultFile Properties
3658
---------------------
37-
The properties of the ``ResultFile`` are contained in the result header.
59+
The properties of the ``ResultFile`` can be quickly shown by printing the result file with:
3860

3961
.. code:: python
4062
41-
result.resultheader
63+
>>> result = pyansys.read_binary('file.rst')
64+
>>> print(result)
65+
PyANSYS MAPDL Result file object
66+
Units : User Defined
67+
Version : 20.1
68+
Cyclic : False
69+
Result Sets : 1
70+
Nodes : 321
71+
Elements : 40
72+
73+
74+
Available Results:
75+
EMS : Miscellaneous summable items (normally includes face pressures)
76+
ENF : Nodal forces
77+
ENS : Nodal stresses
78+
ENG : Element energies and volume
79+
EEL : Nodal elastic strains
80+
ETH : Nodal thermal strains (includes swelling strains)
81+
EUL : Element euler angles
82+
EPT : Nodal temperatures
83+
NSL : Nodal displacements
84+
RF : Nodal reaction forces
85+
4286
4387
To obtain the time or frequency values of an analysis use:
4488

4589
.. code:: python
4690
47-
tval = result.time_values
48-
91+
>>> result.time_values
92+
array([1.])
93+
94+
95+
Individual results can be obtained with one of the many methods
96+
available to the result object. For example, the nodal displacement
97+
for the first result can be accessed with:
98+
99+
.. code:: python
100+
101+
>>> nnum, disp = rst.nodal_displacement(0)
102+
>>> nnum
103+
array([ 1, 2, 3, ..., 318, 319, 320, 321], dtype=int32)
104+
105+
>>> disp
106+
array([[-2.03146520e-09, -3.92491045e-03, 5.00047448e-05],
107+
[ 1.44630651e-09, 1.17747356e-02, -1.49992672e-04],
108+
[ 0.00000000e+00, 0.00000000e+00, 0.00000000e+00],
109+
...
110+
[-7.14982194e-03, 3.12495002e-03, 5.74992265e-04],
111+
[-7.04982329e-03, 2.44996706e-03, 5.74992939e-04],
112+
[-6.94982520e-03, 1.77498362e-03, 5.74992891e-04]])
113+
114+
49115
The sorted node and element numbering of a result can be obtained with:
50116

51117
.. code:: python
52118
53-
# sorted node numbering
54-
nnum = result.nnum
55-
56-
# sorted element numbering
57-
enum = result.enum
119+
>>> rst.geometry.nnum
120+
array([ 1, 2, 3, ..., 318, 319, 320, 321], dtype=int32)
58121
122+
>>> result.geometry.enum
123+
array([ 1, 3, 2, 4, 5, 7, 6, 8, 9, 11, 10, 12, 13, 15, 14, 16, 17,
124+
19, 18, 20, 21, 23, 22, 24, 25, 27, 26, 28, 29, 31, 30, 32, 33, 35,
125+
34, 36, 37, 39, 38, 40], dtype=int32)
59126
60127
Geometry
61128
--------
@@ -87,7 +154,9 @@ Which contains the following attributes:
87154

88155
Coordinate Systems
89156
~~~~~~~~~~~~~~~~~~
90-
Non default coordinate systems are always saved to an ANSYS result file. The coordinate system is zero indexed and individual coordinate systems can be accessed with:
157+
Non-default coordinate systems are always saved to an ANSYS result
158+
file. The coordinate system is zero indexed and individual coordinate
159+
systems can be accessed with:
91160

92161
.. code:: python
93162
@@ -167,7 +236,10 @@ This yields::
167236
pCnvVal 0.0
168237

169238

170-
The DOF solution for an analysis for each node in the analysis can be obtained using the code block below. These results correspond to the node numbers in the result file. This array is sized by the number of nodes by the number of degrees of freedom.
239+
The DOF solution for an analysis for each node in the analysis can be
240+
obtained using the code block below. These results correspond to the
241+
node numbers in the result file. This array is sized by the number of
242+
nodes by the number of degrees of freedom.
171243

172244
.. code:: python
173245
@@ -182,7 +254,9 @@ The DOF solution for an analysis for each node in the analysis can be obtained u
182254
# normalized displacement can be plotted by excluding the direction string
183255
result.plot_nodal_solution(0, label='Normalized')
184256
185-
Stress can be obtained as well using the below code. The nodal stress is computed in the same manner as ANSYS by averaging the stress evaluated at that node for all attached elements.
257+
Stress can be obtained as well using the below code. The nodal stress
258+
is computed in the same manner as ANSYS by averaging the stress
259+
evaluated at that node for all attached elements.
186260

187261
.. code:: python
188262
@@ -197,12 +271,15 @@ Stress can be obtained as well using the below code. The nodal stress is comput
197271
nnum, pstress = result.principal_nodal_stress(0)
198272
result.plot_principal_nodal_stress(0, 'SEQV')
199273
200-
Element stress can be obtained using the following segment of code. Ensure that the element results are expanded for a modal analysis within ANSYS with::
274+
Element stress can be obtained using the following segment of code.
275+
Ensure that the element results are expanded for a modal analysis
276+
within ANSYS with::
201277

202278
/SOLU
203279
MXPAND, ALL, , , YES
204280

205-
This block of code shows how you can access the non-averaged stresses for the first result from a modal analysis.
281+
This block of code shows how you can access the non-averaged stresses
282+
for the first result from a modal analysis.
206283

207284
.. code:: python
208285
@@ -254,7 +331,9 @@ These stresses can be verified using ANSYS using:
254331
255332
Accessing Element Solution Data
256333
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
257-
Individual element results for the entire solution can be accessed using the ``element_solution_data`` method. For example, to get the volume of each element:
334+
Individual element results for the entire solution can be accessed
335+
using the ``element_solution_data`` method. For example, to get the
336+
volume of each element:
258337

259338
.. code:: python
260339
@@ -269,12 +348,11 @@ Individual element results for the entire solution can be accessed using the ``e
269348
edata = np.asarray(edata)
270349
volume = edata[:, 0]
271350
272-
Documentation for the underlying results can be found in `Description of the Results File <https://www.sharcnet.ca/Software/Ansys/16.2.3/en-us/help/ans_prog/Hlp_P_INT1_2.html>`_.
273-
274351
275352
Animiating a Modal Solution
276353
~~~~~~~~~~~~~~~~~~~~~~~~~~~
277-
Solutions from a modal analysis can be animated using ``animate_nodal_solution``. For example:
354+
Solutions from a modal analysis can be animated using
355+
``animate_nodal_solution``. For example:
278356

279357
.. code:: python
280358
@@ -285,7 +363,6 @@ Solutions from a modal analysis can be animated using ``animate_nodal_solution``
285363
result.animate_nodal_solution(3)
286364
287365
288-
289366
Results from a Cyclic Analysis
290367
------------------------------
291368
``pyansys`` can load and display the results of a cyclic analysis:
@@ -297,7 +374,9 @@ Results from a Cyclic Analysis
297374
# load the result file
298375
result = pyansys.read_binary('rotor.rst')
299376
300-
You can reference the load step table and harmonic index tables by printing the result header dictionary keys ``'ls_table'`` and ``'hindex'``:
377+
You can reference the load step table and harmonic index tables by
378+
printing the result header dictionary keys ``'ls_table'`` and
379+
``'hindex'``:
301380

302381
.. code:: python
303382
@@ -314,7 +393,9 @@ You can reference the load step table and harmonic index tables by printing the
314393
array([0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4,
315394
4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7], dtype=int32)
316395
317-
Where each harmonic index entry corresponds a cumulative index. For example, result number 11 is the first mode for the 2nd harmonic index:
396+
Where each harmonic index entry corresponds a cumulative index. For
397+
example, result number 11 is the first mode for the 2nd harmonic
398+
index:
318399
319400
.. code:: python
320401
@@ -333,7 +414,10 @@ Alternatively, the result number can be obtained by using:
333414
>>> result.harmonic_index_to_cumulative(mode, harmonic_index)
334415
24
335416
336-
Using this indexing method, repeated modes are indexed by the same mode index. To access the other repeated mode, use a negative harmonic index. Should a result not exist, pyansys will return which modes are available:
417+
Using this indexing method, repeated modes are indexed by the same
418+
mode index. To access the other repeated mode, use a negative
419+
harmonic index. Should a result not exist, pyansys will return which
420+
modes are available:
337421
338422
.. code:: python
339423
@@ -343,7 +427,11 @@ Alternatively, the result number can be obtained by using:
343427
Exception: Invalid mode for harmonic index 1
344428
Available modes: [0 1 2 3 4 5 6 7 8 9]
345429
346-
Results from a cyclic analysis require additional post processing to be interperted correctly. Mode shapes are stored within the result file as unprocessed parts of the real and imaginary parts of a modal solution. ``pyansys`` combines these values into a single complex array and then returns the real result of that array.
430+
Results from a cyclic analysis require additional post processing to
431+
be interperted correctly. Mode shapes are stored within the result
432+
file as unprocessed parts of the real and imaginary parts of a modal
433+
solution. ``pyansys`` combines these values into a single complex
434+
array and then returns the real result of that array.
347435
348436
.. code:: python
349437
@@ -353,7 +441,8 @@ Results from a cyclic analysis require additional post processing to be interper
353441
[ 42.339, 48.516, 52.475]
354442
[ 36.000, 33.121, 39.044]]
355443
356-
Sometimes it is necessary to determine the maximum displacement of a mode. To do so, return the complex solution with:
444+
Sometimes it is necessary to determine the maximum displacement of a
445+
mode. To do so, return the complex solution with:
357446
358447
.. code:: python
359448
@@ -370,24 +459,31 @@ Sometimes it is necessary to determine the maximum displacement of a mode. To d
370459
371460
See ``help(result.nodal_solution)`` for more details.
372461
373-
The real displacement of the sector is always the real component of the mode shape ``ms``, and this can be varied by multiplying the mode shape by a complex value for a given phase. To change the phase by 90 degrees simply:
462+
The real displacement of the sector is always the real component of
463+
the mode shape ``ms``, and this can be varied by multiplying the mode
464+
shape by a complex value for a given phase.
374465
375-
The results of a single sector can be displayed as well using the ``plot_nodal_solution``
466+
The results of a single sector can be displayed as well using the
467+
``plot_nodal_solution``
376468
377469
.. code:: python
378470
379-
# Plot the result from the first mode of the 2nd harmonic index
380471
rnum = result.harmonic_index_to_cumulative(0, 2)
381472
result.plot_nodal_solution(rnum, label='Displacement', expand=False)
382473
383474
.. image:: ./images/rotor.jpg
384475
385-
The phase of the result can be changed by modifying the ``phase`` option. See ``help(result.plot_nodal_solution)`` for details on its implementation.
476+
The phase of the result can be changed by modifying the ``phase``
477+
option. See ``help(result.plot_nodal_solution)`` for details on its
478+
implementation.
386479
387480
388481
Exporting to ParaView
389482
---------------------
390-
ParaView is a visualization application that can be used for rapid generation of plots and graphs using VTK through a GUI. ``pyansys`` can translate the ANSYS result files to ParaView compatible files containing the geometry and nodal results from the analysis:
483+
ParaView is a visualization application that can be used for rapid
484+
generation of plots and graphs using VTK through a GUI. ``pyansys``
485+
can translate the ANSYS result files to ParaView compatible files
486+
containing the geometry and nodal results from the analysis:
391487
392488
.. code:: python
393489
@@ -400,7 +496,13 @@ ParaView is a visualization application that can be used for rapid generation of
400496
# save as a binary vtk xml file
401497
result.save_as_vtk('beam.vtu')
402498
403-
The vtk xml file can now be loaded using ParaView. This screenshot shows the nodal displacement of the first result from the result file plotted within `ParaView <https://www.paraview.org/>`_. Within the vtk file are two point arrays (``NodalResult`` and ``nodal_stress``) for each result in the result file. The nodal result values will depend on the analysis type, while nodal stress will always be the node average stress in the Sx, Sy Sz, Sxy, Syz, and Sxz directions.
499+
The vtk xml file can now be loaded using ParaView. This screenshot
500+
shows the nodal displacement of the first result from the result file
501+
plotted within `ParaView <https://www.paraview.org/>`_. Within the
502+
vtk file are two point arrays (``NodalResult`` and ``nodal_stress``)
503+
for each result in the result file. The nodal result values will
504+
depend on the analysis type, while nodal stress will always be the
505+
node average stress in the Sx, Sy Sz, Sxy, Syz, and Sxz directions.
404506
405507
.. image:: ./images/paraview.jpg
406508

examples/02-mapdl-examples/mapdl_3d_beam.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import pyansys
1616

1717
os.environ['I_MPI_SHM_LMT'] = 'shm' # necessary on ubuntu
18-
mapdl = pyansys.launch_mapdl(override=True)
18+
mapdl = pyansys.launch_mapdl(override=True, additional_switches='-smp')
1919

2020
mapdl.cdread('db', examples.hexarchivefile)
2121
mapdl.esel('s', 'ELEM', vmin=5, vmax=20)
@@ -44,5 +44,5 @@
4444

4545
# view the results using pyansys's result viewer
4646
result = mapdl.result
47-
result.animate_nodal_solution(0, show_edges=True, loop=False,
47+
result.animate_nodal_solution(0, show_edges=True, loop=False, displacement_factor=10,
4848
movie_filename='demo.gif')

0 commit comments

Comments
 (0)