GithubHelp home page GithubHelp logo

ansys / pymapdl-reader Goto Github PK

View Code? Open in Web Editor NEW
42.0 9.0 18.0 65.19 MB

Legacy binary interface to MAPDL binary files.

Home Page: https://reader.docs.pyansys.com

License: MIT License

Python 63.67% Makefile 0.14% C++ 2.29% C 5.77% Shell 0.05% Cython 28.08%

pymapdl-reader's Introduction

PyMAPDL Reader - Legacy Binary and Archive File Reader

PyAnsys pypi PyPIact GH-CI codecov MIT black pre-commit.ci status

This is the legacy module for reading in binary and ASCII files generated from MAPDL.

This Python module allows you to extract data directly from binary ANSYS v14.5+ files and to display or animate them rapidly using a straightforward API coupled with C libraries based on header files provided by ANSYS.

The ansys-mapdl-reader module supports the following formats:

  • *.rst - Structural analysis result file
  • *.rth - Thermal analysis result file
  • *.emat - Element matrix data file
  • *.full - Full stiffness-mass matrix file
  • *.cdb or *.dat - MAPDL ASCII block archive and Mechanical Workbench input files

Please see the PyMAPDL-Reader Documentation for the full documentation.

Note

This module may be depreciated in the future.

You are encouraged to use the new Data Processing Framework (DPF) modules at PyDPF-Core and PyDPF-Post as they provide a modern interface to Ansys result files using a client/server interface using the same software used within Ansys Mechanical, but via a Python client.

Note

Result file compatibility will be greatly improved by disabling result file compression by setting /FCOMP,RST,0.

DPF does not have this restriction.

Installation

Installation through pip:

pip install ansys-mapdl-reader

You can also visit pymapdl-reader to download the source or releases from GitHub.

Examples

Loading and Plotting a MAPDL Archive File

ANSYS archive files containing solid elements (both legacy and modern), can be loaded using Archive and then converted to a vtk object.

from ansys.mapdl import reader as pymapdl_reader
from ansys.mapdl.reader import examples

# Sample *.cdb
filename = examples.hexarchivefile

# Read ansys archive file
archive = pymapdl_reader.Archive(filename)

# Print raw data from cdb
for key in archive.raw:
   print("%s : %s" % (key, archive.raw[key]))

# Create a vtk unstructured grid from the raw data and plot it
grid = archive.parse_vtk(force_linear=True)
grid.plot(color='w', show_edges=True)

# write this as a vtk xml file 
grid.save('hex.vtu')

# or as a vtk binary
grid.save('hex.vtk')

You can then load this vtk file using pyvista or another program that uses VTK.

# Load this from vtk
import pyvista as pv
grid = pv.UnstructuredGrid('hex.vtu')
grid.plot()

Loading the Result File

This example reads in binary results from a modal analysis of a beam from ANSYS.

# Load the reader from pyansys
from ansys.mapdl import reader as pymapdl_reader
from ansys.mapdl.reader import examples

# Sample result file
rstfile = examples.rstfile

# Create result object by loading the result file
result = pymapdl_reader.read_binary(rstfile)

# Beam natural frequencies
freqs = result.time_values
>>> print(freq)
[ 7366.49503969  7366.49503969 11504.89523664 17285.70459456
  17285.70459457 20137.19299035]

Get the 1st bending mode shape. Results are ordered based on the sorted node numbering. Note that results are zero indexed

>>> nnum, disp = result.nodal_solution(0)
>>> print(disp)
[[ 2.89623914e+01 -2.82480489e+01 -3.09226692e-01]
 [ 2.89489249e+01 -2.82342416e+01  2.47536161e+01]
 [ 2.89177130e+01 -2.82745126e+01  6.05151053e+00]
 [ 2.88715048e+01 -2.82764960e+01  1.22913304e+01]
 [ 2.89221536e+01 -2.82479511e+01  1.84965333e+01]
 [ 2.89623914e+01 -2.82480489e+01  3.09226692e-01]
 ...

Plotting Nodal Results

As the geometry of the model is contained within the result file, you can plot the result without having to load any additional geometry. Below, displacement for the first mode of the modal analysis beam is plotted using VTK.

# Plot the displacement of Mode 0 in the x direction
result.plot_nodal_solution(0, 'x', label='Displacement')

Results can be plotted non-interactively and screenshots saved by setting up the camera and saving the result. This can help with the visualization and post-processing of a batch result.

First, get the camera position from an interactive plot:

>>> cpos = result.plot_nodal_solution(0)
>>> print(cpos)
[(5.2722879880979345, 4.308737919176047, 10.467694436036483),
 (0.5, 0.5, 2.5),
 (-0.2565529433509593, 0.9227952809887077, -0.28745339908049733)]

Then generate the plot:

result.plot_nodal_solution(0, 'x', label='Displacement', cpos=cpos,
                           screenshot='hexbeam_disp.png',
                           window_size=[800, 600], interactive=False)

Stress can be plotted as well using the below code. The nodal stress is computed in the same manner that ANSYS uses by to determine the stress at each node by averaging the stress evaluated at that node for all attached elements. For now, only component stresses can be displayed.

# Display node averaged stress in x direction for result 6
result.plot_nodal_stress(5, 'Sx')

Nodal stress can also be generated non-interactively with:

result.plot_nodal_stress(5, 'Sx', cpos=cpos, screenshot=beam_stress.png,
                       window_size=[800, 600], interactive=False)

Animating a Modal Solution

Mode shapes from a modal analysis can be animated using animate_nodal_solution:

result.animate_nodal_solution(0)

If you wish to save the animation to a file, specify the movie_filename and animate it with:

result.animate_nodal_solution(0, movie_filename='/tmp/movie.mp4', cpos=cpos)

Reading a Full File

This example reads in the mass and stiffness matrices associated with the above example.

# Load the reader from pyansys
from ansys.mapdl import reader as pymapdl_reader
from scipy import sparse

# load the full file
fobj = pymapdl_reader.FullReader('file.full')
dofref, k, m = fobj.load_km()  # returns upper triangle only

# make k, m full, symmetric matrices
k += sparse.triu(k, 1).T
m += sparse.triu(m, 1).T

If you have scipy installed, you can solve the eigensystem for its natural frequencies and mode shapes.

from scipy.sparse import linalg

# condition the k matrix
# to avoid getting the "Factor is exactly singular" error
k += sparse.diags(np.random.random(k.shape[0])/1E20, shape=k.shape)

# Solve
w, v = linalg.eigsh(k, k=20, M=m, sigma=10000)

# System natural frequencies
f = np.real(w)**0.5/(2*np.pi)

print('First four natural frequencies')
for i in range(4):
    print '{:.3f} Hz'.format(f[i])
First four natural frequencies
1283.200 Hz
1283.200 Hz
5781.975 Hz
6919.399 Hz

Developing on Windows

This package is designed to be developed on Linux, and if you need to develop on Windows you will need to install your own C++ compiler. We recommend:

  1. Install Visual C++
    1. See here for a list of which Python versions correspond to which Visual C++ version
  2. Install the development version of pymapdl-reader to your Python environment
    1. Navigate to the project's top level (the same directory as this README)
    2. run pip install -e .

License and Acknowledgments

The ansys-mapdl-reader library is licensed under the MIT license.

pymapdl-reader's People

Contributors

1990chs avatar akaszynski avatar beppo-dd avatar clatapie avatar dependabot[bot] avatar germa89 avatar jackguyver avatar jgd10 avatar ndfp avatar pipkat avatar pre-commit-ci[bot] avatar purubcik avatar raph-luc avatar robpasmue avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pymapdl-reader's Issues

comp_type in write_cmblock

Hey,

function write_cmblock() in archive.py isn't up to date. In the if-statement (line 626):

if comp_type.upper() not in ['ELEMENT', 'NODE']

ELEMENT has to be changed to ELEM.

Best regards
Andreas

Prevent users from editing `filename` property on classes

Whilst working on #98 I have made explicit filename and pathlib_filename properties on classes that have the filename property. I kept a setter for filename because to remove it would be a breaking change.

Additionally, whilst working on the tests for these changes I notice that if an invalid filename is provided the class constructor will throw an error, but obviously this wasn't happening with the setters then and it isn't happening with the setters I've added now. Do we want people to be able to set the filename like this? This would be on the Result class or Archive class, for example.

It would be trivial to delete the new setter methods before making my PR. Or alternatively I could add a check to the setters? However, this would still be a breaking change since this wasn't in the original behaviour. I would suggest just deleting the setters as it seems like you get undefined behaviour otherwise and the filename would still be accessible by the _filename property anyway if a user was particularly determined.

What do you think @akaszynski ?

Classes this affects:

  • EmatFile
  • FullFile
  • Archive
  • Result

Update Docs CI

Use github actions rather than azure pipelines just like DPF-Core, DPF-Post, and PyMAPDL.

Also need to fix the menu bar.

Consider creating a unified documentation module.

Pyansys can't read rst files from ansys 2021 R2

I'm using Ansys 2021 R2, student version. Pyansys is showing the following error: 'ValueError: negative dimensions are not allowed', while reading an Ansys rst file. Pyansys is interpreting the rst files generated from earlier Ansys versions accurately. Does anybody have a clue about the issue?

Determining the principal directions

Hi,

I am working on a stress analysis using SOLID185 elements and I am trying to determine the local coordinate system in which the principal stresses are. From looking at some other issues posted here before (ansys/pymapdl#283 and ansys/pymapdl#28), it seems that I will have to use the element Euler angles, which are stored in the binary file. I don't know how to access them though and I wonder if there is a method for it in mapdl.result, since Euler angles are displayed in the list of available results as shown below.

image

My understanding is that the euler angles will allow me to determine the coordinate system in which the principal stresses are. However, once I know this local coordinate system, how do I determine on which axis is each principal stress?

Additionally, I wonder if the approach can be applied to both nodal and element stresses ?

Thank you for the help !

Weird black lines when using plot_nodal_solution or animate_nodal_solution

Hi,

I've just updated my pyansys installation from 0.58.9 to 0.59.3 and with the update, it seems like both of these reader functions are not functioning as well as they did before. When plotting results, now some black lines appear, worsening the view of solids and surfaces, and even completely obscuring the view of the result along line bodies.
A couple of images of this behaviour for reference:
Surface body -
image
Line body -
image

Cyclic analysis: forward/backward mode direction is inconsistent

For a cyclic analysis, it looks like there's some inconsistency between the harmonic index of the result set, and the harmonic index as calculated from the sector boundary. Sometimes they match, and sometimes they don't.

Here's an uploaded results file (file_cyclic_test.rst) generated from Mechanical 2020R2:
http://filedropper.com/325u3Hvx
(simple model with 36 base sector nodes, 8 sectors, with results calculated at 1 ND)

And some code to calculate the harmonic index from two nodes on the sector boundary, and compare with the value from the result set:

from ansys.mapdl import reader as pymapdl_reader
import numpy as np
from math import pi

rstfile = 'D:/temp/file_cyclic_test.rst'  # replace with path to uploaded RST file

result = pymapdl_reader.read_binary(rstfile)

low_node_index = 28  # index of low side node
high_node_index = 35  # index of matching high side node

for i_result in range(0, result.n_results):
    node_deflection = result.nodal_displacement(i_result, as_complex=True)

    # only need one component to calculate phase angle
    deflection_low = node_deflection[1][low_node_index, 2]
    deflection_high = node_deflection[1][high_node_index, 2]
    angle_low = np.angle(deflection_low)
    angle_high = np.angle(deflection_high)

    # calculated nodal diameter from sector boundary phase angles
    nd_calculated = (angle_high - angle_low)*result.n_sector / (2*pi)

    # make sure this lies between -n_sector/2 and n_sector/2
    if nd_calculated > result.n_sector/2:
        nd_calculated -= result.n_sector
    if nd_calculated <= -1*result.n_sector/2:
        nd_calculated += result.n_sector

    # round to get rid of small floating point errors
    nd_calculated = round(nd_calculated, 3)

    print('\nResult set ' + str(i_result))
    print('Harmonic index from result set: ' + str(result.harmonic_indices[i_result]))
    print('Harmonic index calculated from boundary: ' + str(nd_calculated))
    if result.harmonic_indices[i_result] == int(nd_calculated):
        print('Match!')
    else:
        print('No match!')

This gives the following result:

Result set 0
Harmonic index from result set: 1
Harmonic index calculated from boundary: 1.0
Match!

Result set 1
Harmonic index from result set: -1
Harmonic index calculated from boundary: -1.0
Match!

Result set 2
Harmonic index from result set: 1
Harmonic index calculated from boundary: 1.0
Match!

Result set 3
Harmonic index from result set: -1
Harmonic index calculated from boundary: -1.0
Match!

Result set 4
Harmonic index from result set: 1
Harmonic index calculated from boundary: -1.0
No match!

Result set 5
Harmonic index from result set: -1
Harmonic index calculated from boundary: 1.0
No match!

Result set 6
Harmonic index from result set: 1
Harmonic index calculated from boundary: 1.0
Match!

Result set 7
Harmonic index from result set: -1
Harmonic index calculated from boundary: -1.0
Match!

Result set 8
Harmonic index from result set: 1
Harmonic index calculated from boundary: -1.0
No match!

Result set 9
Harmonic index from result set: -1
Harmonic index calculated from boundary: 1.0
No match!

Result set 10
Harmonic index from result set: 1
Harmonic index calculated from boundary: 1.0
Match!

Result set 11
Harmonic index from result set: -1
Harmonic index calculated from boundary: -1.0
Match!

Process finished with exit code 0

In the first two mode pairs (0,1 and 2,3), the direction matches between the result set and the boundary calculation, but for the third mode pair (4,5) the direction doesn't.

Element numbering not being assigned to grid

Opened a new issue regarding this

@akaszynski
Hello, I have a problem to read the result when I read the nodes from a txt file.
But when I set the all_nodes a few nodes,it can work.
By the way, the result.principal_nodal_stress(0) read all the nodes result and I can't assign the the specific nodes.
image

Originally posted by @1990chs in #33 (comment)

Would it be possible to post the result file?

`mapdl.eplot` fail to plot `target170` elements

Fail

from ansys.mapdl.core import examples
from ansys.mapdl.core import launch_mapdl

mapdl = launch_mapdl(port=50055)
mapdl.prep7()
mapdl.input(examples.vmfiles['vm211'])

mapdl.esel("s", "ename","", 170)
mapdl.eplot(vtk=True, background='white')  # Crashes

Error

Exception has occurred: TypeError
Could not find a suitable VTK type for object
  File "[C:\Users\gayuso\Others_pymapdls\pymapdl_0\pymapdl\src\ansys\mapdl\core\mesh_grpc.py]()", line 477, in _grid
    self._grid_cache = self._parse_vtk(force_linear=True)
  File "[C:\Users\gayuso\Others_pymapdls\pymapdl_0\pymapdl\src\ansys\mapdl\core\_commands\preproc\elements.py]()", line 1287, in eplot
    esurf = self.mesh._grid.linear_copy().extract_surface().clean()
  File "[C:\Users\gayuso\test\test_targe170.py]()", line 25, in <module>
    mapdl.eplot(vtk=True, background='white')

I haven't investigate it much. But it is very likely related with pymapd-reader.

.rst file result precision question

Hi,
Is rst result datas store in float type? I took these datas compared with ANSYS solution, I found only 6 or 7 significant digits
are correct. thanks.

Numbering issue and type conversion of a pointer

Hello,

In our usage of ANSYS APDL, we number the element type/real/section with a custom non contiguous numerotation.
In consequence I have relatively large number on element type/real/section (over 50 000).

In order to read my result file I had to modify the following files :

mesh.py line 121 :
type_ref = np.empty(2 << 16, np.int32) # 65536 -> 131072

rst.py (line 1342 to 1346):

NUM_MAX = 1000000 # <- new maximum
nodelm = np.empty(NUM_MAX, np.int32)  # n nodes for this element type
nodfor = np.empty(NUM_MAX, np.int32)  # n nodes per element having nodal forces
nodstr = np.empty(NUM_MAX, np.int32)  # n nodes per element having nodal stresses
ekey = []
keyopts = np.zeros((NUM_MAX, 11), np.int16)

During the exploration of my rst file (transient analysis of ~21Go), I encounter an OverflowError on cython (conversion of python int into C long...).
I circumvent this error by changing some type in _binary_reader.pyx (line 257 to 259)

def read_element_data(self, int64_t [::1] ele_ind_table, int table_index, int64_t ptr_off): #int -> int64_t
        cdef int64_t ind
        cdef int64_t ptr #int -> int64_t

I'm new to this library so may be my tweaks break something elsewhere.
But it is possible to "officially" add some variable to configure the maximum int on element type/real/section and correct the type of the cython pointer ?

Thank you for the work on this lib ! 👍

Get rid of Pyvista deprecation warning

Describe the bug

There is a deprecation warning every time we run one of our plotting functions:

For example: mapdl.eplot()

C:\ProgramData\Miniconda3\envs\pymapdldocs\lib\site-packages\pyvista\core\dataset.py:1192: PyvistaDeprecationWarning: Use of `point_arrays` is deprecated. Use `point_data` instead.
  warnings.warn(
C:\ProgramData\Miniconda3\envs\pymapdldocs\lib\site-packages\pyvista\core\dataset.py:1332: PyvistaDeprecationWarning: Use of `cell_arrays` is deprecated. Use `cell_data` instead.
  warnings.warn(

Build Error: gcc: error: ansys/mapdl/reader/cython/_archive.c: No such file or directory

Environment:

Python 3.9.12 (main, Apr  5 2022, 06:56:58) 
[GCC 7.5.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.

packages in environment at /home/user/.conda/envs/test:
  
  Name                    Version                   Build  Channel
  _libgcc_mutex             0.1                        main  
  _openmp_mutex             4.5                       1_gnu  
  appdirs                   1.4.4              pyh9f0ad1d_0    conda-forge
  blas                      1.0                    openblas  
  bzip2                     1.0.8                h7f98852_4    conda-forge
  c-ares                    1.18.1               h7f8727e_0  
  ca-certificates           2021.10.8            ha878542_0    conda-forge
  certifi                   2021.10.8        py39hf3d152e_2    conda-forge
  colorama                  0.4.4              pyh9f0ad1d_0    conda-forge
  curl                      7.80.0               h7f8727e_0  
  dbus                      1.13.6               he372182_0    conda-forge
  double-conversion         3.1.5                he6710b0_1  
  eigen                     3.3.9                h4bd325d_1    conda-forge
  expat                     2.2.10               h9c3ff4c_0    conda-forge
  ffmpeg                    4.2.2                h20bf706_0  
  fontconfig                2.13.1               h6c09931_0  
  freetype                  2.10.4               h0708190_1    conda-forge
  gl2ps                     1.4.2                h0708190_0    conda-forge
  glew                      2.1.0                h9c3ff4c_2    conda-forge
  glib                      2.69.1               h4ff587b_1  
  gmp                       6.2.1                h58526e2_0    conda-forge
  gnutls                    3.6.13               h85f3911_1    conda-forge
  gst-plugins-base          1.14.0               hbbd80ab_1  
  gstreamer                 1.14.0               h28cd5cc_2  
  hdf4                      4.2.13               h3ca952b_2  
  hdf5                      1.10.6          nompi_h7c3c948_1111    conda-forge
  icu                       58.2              hf484d3e_1000    conda-forge
  imageio                   2.9.0              pyhd3eb1b0_0  
  intel-openmp              2021.4.0          h06a4308_3561  
  jpeg                      9d                   h7f8727e_0  
  jsoncpp                   1.9.4                h4bd325d_3    conda-forge
  krb5                      1.19.2               hac12032_0  
  lame                      3.100             h7f98852_1001    conda-forge
  lcms2                     2.12                 hddcbb42_0    conda-forge
  ld_impl_linux-64          2.35.1               h7274673_9  
  libcurl                   7.80.0               h0b77cf5_0  
  libedit                   3.1.20210910         h7f8727e_0  
  libev                     4.33                 h516909a_1    conda-forge
  libffi                    3.3                  he6710b0_2  
  libgcc-ng                 9.3.0               h5101ec6_17  
  libgfortran-ng            7.5.0               ha8ba4b0_17  
  libgfortran4              7.5.0               ha8ba4b0_17  
  libglu                    9.0.0             he1b5a44_1001    conda-forge
  libgomp                   9.3.0               h5101ec6_17  
  libnetcdf                 4.8.1                h42ceab0_1  
  libnghttp2                1.46.0               hce63b2e_0  
  libogg                    1.3.4                h7f98852_1    conda-forge
  libopenblas               0.3.17               hf726d26_1  
  libopus                   1.3.1                h7f98852_1    conda-forge
  libpng                    1.6.37               h21135ba_2    conda-forge
  libssh2                   1.9.0                h1ba5d50_1  
  libstdcxx-ng              9.3.0               hd4cf53a_17  
  libtheora                 1.1.1             h7f98852_1005    conda-forge
  libtiff                   4.2.0                h85742a9_0  
  libuuid                   1.0.3                h7f8727e_2  
  libvorbis                 1.3.7                h9c3ff4c_0    conda-forge
  libvpx                    1.7.0                h439df22_0  
  libwebp-base              1.2.2                h7f8727e_0  
  libxcb                    1.13              h7f98852_1003    conda-forge
  libxml2                   2.9.12               h03d6c58_0  
  libzip                    1.8.0                h4de3113_0    conda-forge
  loguru                    0.6.0            py39hf3d152e_1    conda-forge
  lz4-c                     1.9.3                h9c3ff4c_1    conda-forge
  mkl                       2021.4.0           h06a4308_640  
  mkl-service               2.4.0            py39h7f8727e_0  
  ncurses                   6.3                  h7f8727e_2  
  nettle                    3.6                  he412f7d_0    conda-forge
  numpy                     1.19.2           py39h87658db_0  
  numpy-base                1.19.2           py39h0f7b65f_0  
  olefile                   0.46               pyh9f0ad1d_1    conda-forge
  openh264                  2.1.1                h780b84a_0    conda-forge
  openssl                   1.1.1n               h7f8727e_0  
  pcre                      8.45                 h9c3ff4c_0    conda-forge
  pillow                    7.2.0            py39h6f3857e_2    conda-forge
  pip                       21.2.4           py39h06a4308_0  
  proj                      6.2.1                hc80f0dc_0    conda-forge
  pthread-stubs             0.4               h36c2ea0_1001    conda-forge
  python                    3.9.12               h12debd9_0  
  python_abi                3.9                      2_cp39    conda-forge
  pyvista                   0.33.3             pyhd8ed1ab_0    conda-forge
  qt                        5.9.7                h5867ecd_1  
  readline                  8.1.2                h7f8727e_1  
  scooby                    0.5.12             pyhd8ed1ab_0    conda-forge
  setuptools                58.0.4           py39h06a4308_0  
  six                       1.16.0             pyhd3eb1b0_1  
  sqlite                    3.38.2               hc218d9a_0  
  tbb                       2021.5.0             hd09550d_0  
  tk                        8.6.11               h1ccaba5_0  
  tqdm                      4.64.0             pyhd8ed1ab_0    conda-forge
  typing_extensions         4.1.1              pyha770c72_0    conda-forge
  tzdata                    2022a                hda174b7_0  
  utfcpp                    3.2.1                ha770c72_0    conda-forge
  vtk                       9.0.3           py39h0649366_201  
  wheel                     0.37.1             pyhd3eb1b0_0  
  x264                      1!157.20191217       h7b6447c_0  
  xorg-kbproto              1.0.7             h7f98852_1002    conda-forge
  xorg-libx11               1.7.2                h7f98852_0    conda-forge
  xorg-libxau               1.0.9                h7f98852_0    conda-forge
  xorg-libxdmcp             1.1.3                h7f98852_0    conda-forge
  xorg-libxext              1.3.4                h7f98852_1    conda-forge
  xorg-xextproto            7.3.0             h7f98852_1002    conda-forge
  xorg-xproto               7.0.31            h7f98852_1007    conda-forge
  xz                        5.2.5                h7b6447c_0  
  zlib                      1.2.11               h7f8727e_4  
  zstd                      1.4.9                ha95c52a_0    conda-forge

# $ python setup.py install --single-version-externally-managed --record=record.txt
  running install
  running build
  running build_py
  creating build
  creating build/lib.linux-x86_64-3.9
  creating build/lib.linux-x86_64-3.9/ansys
  creating build/lib.linux-x86_64-3.9/ansys/mapdl
  creating build/lib.linux-x86_64-3.9/ansys/mapdl/reader
  copying ansys/mapdl/reader/emat.py -> build/lib.linux-x86_64-3.9/ansys/mapdl/reader
  copying ansys/mapdl/reader/__init__.py -> build/lib.linux-x86_64-3.9/ansys/mapdl/reader
  copying ansys/mapdl/reader/common.py -> build/lib.linux-x86_64-3.9/ansys/mapdl/reader
  copying ansys/mapdl/reader/cell_quality.py -> build/lib.linux-x86_64-3.9/ansys/mapdl/reader
  copying ansys/mapdl/reader/full.py -> build/lib.linux-x86_64-3.9/ansys/mapdl/reader
  copying ansys/mapdl/reader/elements.py -> build/lib.linux-x86_64-3.9/ansys/mapdl/reader
  copying ansys/mapdl/reader/cyclic_reader.py -> build/lib.linux-x86_64-3.9/ansys/mapdl/reader
  copying ansys/mapdl/reader/_version.py -> build/lib.linux-x86_64-3.9/ansys/mapdl/reader
  copying ansys/mapdl/reader/rst.py -> build/lib.linux-x86_64-3.9/ansys/mapdl/reader
  copying ansys/mapdl/reader/_mp_keys.py -> build/lib.linux-x86_64-3.9/ansys/mapdl/reader
  copying ansys/mapdl/reader/mesh.py -> build/lib.linux-x86_64-3.9/ansys/mapdl/reader
  copying ansys/mapdl/reader/misc.py -> build/lib.linux-x86_64-3.9/ansys/mapdl/reader
  copying ansys/mapdl/reader/rst_avail.py -> build/lib.linux-x86_64-3.9/ansys/mapdl/reader
  copying ansys/mapdl/reader/dis_result.py -> build/lib.linux-x86_64-3.9/ansys/mapdl/reader
  copying ansys/mapdl/reader/plotting.py -> build/lib.linux-x86_64-3.9/ansys/mapdl/reader
  copying ansys/mapdl/reader/archive.py -> build/lib.linux-x86_64-3.9/ansys/mapdl/reader
  copying ansys/mapdl/reader/errors.py -> build/lib.linux-x86_64-3.9/ansys/mapdl/reader
  copying ansys/mapdl/reader/_rst_keys.py -> build/lib.linux-x86_64-3.9/ansys/mapdl/reader
  creating build/lib.linux-x86_64-3.9/ansys/mapdl/reader/examples
  copying ansys/mapdl/reader/examples/__init__.py -> build/lib.linux-x86_64-3.9/ansys/mapdl/reader/examples
  copying ansys/mapdl/reader/examples/examples.py -> build/lib.linux-x86_64-3.9/ansys/mapdl/reader/examples
  copying ansys/mapdl/reader/examples/downloads.py -> build/lib.linux-x86_64-3.9/ansys/mapdl/reader/examples
  copying ansys/mapdl/reader/examples/TetBeam.cdb -> build/lib.linux-x86_64-3.9/ansys/mapdl/reader/examples
  copying ansys/mapdl/reader/examples/HexBeam.cdb -> build/lib.linux-x86_64-3.9/ansys/mapdl/reader/examples
  copying ansys/mapdl/reader/examples/file.rst -> build/lib.linux-x86_64-3.9/ansys/mapdl/reader/examples
  copying ansys/mapdl/reader/examples/file.full -> build/lib.linux-x86_64-3.9/ansys/mapdl/reader/examples
  copying ansys/mapdl/reader/examples/sector.cdb -> build/lib.linux-x86_64-3.9/ansys/mapdl/reader/examples
  running build_ext
  building 'ansys.mapdl.reader._archive' extension
  creating build/temp.linux-x86_64-3.9
  creating build/temp.linux-x86_64-3.9/ansys
  creating build/temp.linux-x86_64-3.9/ansys/mapdl
  creating build/temp.linux-x86_64-3.9/ansys/mapdl/reader
  creating build/temp.linux-x86_64-3.9/ansys/mapdl/reader/cython
  gcc -pthread -B /home/user/.conda/envs/test/compiler_compat -Wno-unused-result -Wsign-compare -DNDEBUG -O2 -Wall -fPIC -O2 -isystem /home/user/.conda/envs/test/include -I/home/user/.conda/envs/test/include -fPIC -O2 -isystem /home/user/.conda/envs/test/include -fPIC -I/home/user/.conda/envs/test/lib/python3.9/site-packages/numpy/core/include -I/home/user/.conda/envs/test/include/python3.9 -c ansys/mapdl/reader/cython/_archive.c -o build/temp.linux-x86_64-3.9/ansys/mapdl/reader/cython/_archive.o -O3 -w
  gcc: error: ansys/mapdl/reader/cython/_archive.c: No such file or directory
  gcc: fatal error: no input files
  compilation terminated.
  error: command '/usr/bin/gcc' failed with exit code 1

Deprecation issues with pyvista

While fooling around with the functions plot_nodal_solution() and animate_nodal_solution() I've gotten some small issues due to changes in pyvista:

With plot_nodal_solution() it raises an error due to the use of stitle as a keyword, instead of the suggested use of '''scalar_bar_args={'title': 'Scalar Bar Title'}'''. This is just a warning, so the function works and plots correctly.

With animate_nodal_solution() it raises a DeprecationError due to the use of use_ipyvtk instead of the ipyvtklink backend. The animation doesn't render.

From what I've gathered looking into the code, the first issue is present in various functions, while the second appears only in _plot_point_scalars() (which I was taking a look in order to add a return_plotter keyword), but I'm not comfortable enough yet with pyvista to fix and PR myself

Issues about reading results from rst file

I want to use this modulus in ANSYS act. The nodes are from ironPython and it is list(for example nodes = [1,2,3....1000]). The nodes have midside nodes. I want to get the cornor nodes stress values and temperatures. In the ANSYS classic, first use "nsle,r,corn" to remove the midside nodes and use *get to get the node value.
From issue ansys/pymapdl#50 ,we can use the following codes to read result from *.rst file

from ansys.mapdl import reader as pymapdl_reader
resultfile = os.path.join(mapdl.path, '%s.rst' % mapdl.jobname)
result = pymapdl_reader.read_binary(result file)

So is there any way to remove midside cornor of the nodes list and get the cornor nodes values in result function?

nodes num can't mach

There is a strange question as follow. when I use nodal_stress(0,all_nodes) to get nodal stress . But the len num don't match the len stress,it very strange. As follow, the length of num is 915980, it does't match the input nodes length. The length of stress is 893061, it is the same as the input nodes length. Why this happen ?
image

Material ID incorrect

Hello,
When importing the materials:
result.materials
the materials are numbered consecutively starting from 1.
In the element-material association vector:
result.mesh.material_type
the IDs differ from the ones in the material list.
When considering the unique number of IDs in material_type, the number of materials in materials is obtained.
I assume the ID in the materials list is incorrect.
Could you please check it?
Thank you
Regards
Francesco

Incorporate pathlib compatibility

This package does not yet support pathlib.Path objects, and this is causing issues in pymapdl (ansys/pymapdl#647).

Ideally we should:

  • Allow input paths to be strings or pathlib.Path objects and

  • switch over to pathlib.Path objects wherever possible.

rigid modal displacement issue

Hi,
I've put the displacements solve from ANSYS and the displacements get from pymapdl-reader into comparation,I found the rigid modal displacements are different,is that not get from result file directly?why? THANKS.

RLBLOCK read error

Hi,
Reading a .cdb file with Archive(), and there is something wrong in reading RLBLOCK lines, here is the file, Thanks.
cdb_file.zip

Temperature read from rst file seems to differ from nodal values

Hi everybody,

a colleague of mine recently set up a simulation test case where we plan to combine mechanical and thermal loads (basically forces and heatfluxes). To do so, SURF154 and SURF152 elements for the respective loads, as well as SOLID226 and SOLID227 elements for the volumes in the mesh are being created.

In principal this works as expected and when processed in the Ansys Workbench or Tecplot, the results look good. However, we did observe a deviation from the other methods when reading the nodal temperature data using pyansys.pymapdl.reader.

The image I attached shows the difference between the nodal temperature read from the rst file using Tecplot and the pyansys reader. To read the temperatures I used the following minimum example script (with the latest version 0.51.3 of the reader):

#!/usr/bin/env python                                                           
from ansys.mapdl import reader                                                  
                                                                                
rstData = reader.read_binary('structure.rst')                                   
                                                                                
resultIndex = rstData.nsets - 1                                                 
nodeIDs, nodalData = rstData.nodal_temperature(resultIndex)                     
                                                                                
for i in range(nodeIDs.shape[0]):                                               
    print(nodeIDs[i], nodalData[i])

A heat flux boundary condition is applied to the side of the cube facing us (X=Xmin). The top side (Z=Zmax) is prepared to be loaded with a force (which is zero by now).

Although the deviations are relatively small (max. is 0.89K), I wonder what causes them. From what I understand, the nodal temperature should be a state variable that is, once defined by solving the system, not depending on the connectivity or element type of the elements the node is belonging to (other than e.g. a nodal value for the heatflux). Thus, the nodal temperature should be the same when read by any of the tools at hand (Workbench, Tecplot, pyansys), right?

Do you have any idea what the cause of this deviation could be? I assume that it is not connected to the FEM model, but mainly due to how the reader parses the data. I would be very thankful for any hint or explanation.

For now I only attached the results file structure.rst.zip, but as you have probably already guessed, the shown case is a minimum working example and I could easily provide any data (e.g. input file, workbench project), if that helps somehow.

Best regards,
Sebastian

Cube_deltaT

Definition of ELEMENT_INDEX_TABLE_KEYS and ELEMENT_RESULT_NCOMP

Hello,
Would it be possible to add the definition of the variables ELEMENT_INDEX_TABLE_KEYS and ELEMENT_RESULT_NCOMP to the Result class?

class Result(AnsysBinary):
    ELEMENT_INDEX_TABLE_KEYS = ELEMENT_INDEX_TABLE_KEYS
    ELEMENT_RESULT_NCOMP = ELEMENT_RESULT_NCOMP

In this way, they can be accessed from outside the rst.py file.
Thank you
Francesco

Import of mesh including radiation fails

I recently created some thermal simulation cases that include radiation boundary conditions, exported the corresponding mesh to a CDB file and tried to read it using the Archive class:

from ansys.mapdl import reader as pymapdl_reader
arcv = pymapdl_reader.Archive("ErnoRadiation.CDB", parse_vtk=False)

For some cases the reader will then freeze. If I suppress the radiation bc, the mesh is read smoothly.
I was able to boil the effect down to a very simple testcase that I attached.

Cube.zip

Cyclic analysis: complex results always use mode pair

It looks like the results always use the paired mode (instead of the duplicate sector, if available) when a complex result is requested.

In cyclic_reader.py line 520:
result_r = self._get_complex_result(func, rnum, result)

I believe this should be:
result_r = self._get_complex_result(func, rnum, full_result)

So that the entire result is passed to _get_complex_result

And farther down the file, starting line 572:

        if self._is_repeated_mode[rnum]:  # get mode pair result
            _, result_r = func(self._repeated_index[rnum])
            if result_r.shape[0] != self._mas_ind.size:
                result_r = result_r[self._mas_ind]
        elif has_dup_result:  # use the duplicate sector
            result_r = full_result[self._dup_ind]
        else:  # otherwise, a standing wave (no complex component)            
            result_r = np.zeros((self._mas_ind.size, full_result.shape[1]),
                                dtype=full_result.dtype)

The current logic is:
If there's a paired mode, return the real part of the paired mode.
If there's a duplicate sector, use the duplicate sector
Otherwise, return zeros

I believe the duplicate sector result should be used first if available, to prevent any indexing problems since the matching mode pairs are not defined in the results file (they are determined in cyclic_reader based on frequency).

Remove optional wheels for Python 3.10

0%|          | 0.00/3.67M [00:00<?, ?B/s]
  0%|          | 8.00k/3.67M [00:00<01:51, 34.5kB/s]
  4%|▍         | 152k/3.67M [00:00<00:07, 495kB/s]  
 13%|█▎        | 472k/3.67M [00:00<00:02, 1.32MB/s]
 29%|██▉       | 1.08M/3.67M [00:00<00:00, 2.[87](https://github.com/pyansys/pymapdl-reader/runs/5301409807?check_suite_focus=true#step:5:87)MB/s]
100%|██████████| 3.67M/3.67M [00:01<00:00, 3.83MB/s]
Error during upload. Retry with the --verbose option for more details.
HTTPError: 400 Bad Request from https://upload.pypi.org/legacy/
Invalid value for requires_dist. Error: Can't have direct dependency: 'vtk @ https://github.com/pyvista/pyvista-wheels/raw/main/vtk-9.1.0.dev0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl'
Error: Process completed with exit code 1.

Missing requirement of matplotlib in setup.py

Hi @akaszynski,

excuse me to be annoying, but as a follow up to the discussion we had in pyvista, I think the requirement of matplotlib ist still missing in setup.py of ansys-mapdl-core and needs to be added as in ansys-mapdl-core.

It seems that the addition in requirements-build.txt is not enough for pip to be recognised.

Nonetheless, thank you for your excellent work.
Best regards

$ python -m pip install ansys-mapdl-reader
Collecting ansys-mapdl-reader
...
Installing collected packages: pillow, imageio, transforms3d, scooby, meshio, appdirs, vtk, pyvista, tqdm, ansys-mapdl-reader
Successfully installed ansys-mapdl-reader-0.50.15 appdirs-1.4.4 imageio-2.9.0 meshio-4.4.6 pillow-8.2.0 pyvista-0.31.0 scooby-0.5.7 tqdm-4.61.0 transforms3d-0.3.1 vtk-9.0.1

$ python
Python 3.8.6 (default, Apr 15 2021, 08:28:58) 
[GCC 9.2.1 20191120 (Red Hat 9.2.1-2)] on linux
>>> from ansys.mapdl import reader
Traceback (most recent call last):
  File "/opt/fs/linux-centos8-haswell/gcc-9.2.1/python-3.8.6-qbpjqyumg5orxexerjfldkuqaanw7roe/lib/python3.8/site-packages/pyvista/plotting/colors.py", line 396, in get_cmap_safe
    from matplotlib.cm import get_cmap
ModuleNotFoundError: No module named 'matplotlib'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/opt/fs/linux-centos8-haswell/gcc-9.2.1/python-3.8.6-qbpjqyumg5orxexerjfldkuqaanw7roe/lib/python3.8/site-packages/ansys/mapdl/reader/__init__.py", line 30, in <module>
    _configure_pyvista()
  File "/opt/fs/linux-centos8-haswell/gcc-9.2.1/python-3.8.6-qbpjqyumg5orxexerjfldkuqaanw7roe/lib/python3.8/site-packages/ansys/mapdl/reader/misc.py", line 141, in _configure_pyvista
    pv.rcParams["cmap"] = "jet"
  File "/opt/fs/linux-centos8-haswell/gcc-9.2.1/python-3.8.6-qbpjqyumg5orxexerjfldkuqaanw7roe/lib/python3.8/site-packages/pyvista/themes.py", line 58, in __setitem__
    setattr(pyvista.global_theme, key, value)
  File "/opt/fs/linux-centos8-haswell/gcc-9.2.1/python-3.8.6-qbpjqyumg5orxexerjfldkuqaanw7roe/lib/python3.8/site-packages/pyvista/themes.py", line 1474, in cmap
    get_cmap_safe(cmap)  # for validation
  File "/opt/fs/linux-centos8-haswell/gcc-9.2.1/python-3.8.6-qbpjqyumg5orxexerjfldkuqaanw7roe/lib/python3.8/site-packages/pyvista/plotting/colors.py", line 398, in get_cmap_safe
    raise ImportError('cmap requires matplotlib')
ImportError: cmap requires matplotlib

$ pipdeptree -p ansys-mapdl-reader
ansys-mapdl-reader==0.50.15
  - appdirs [required: >=1.4.0, installed: 1.4.4]
  - numpy [required: >=1.14.0, installed: 1.19.4]
  - pyvista [required: >=0.30.1, installed: 0.31.0]
    - appdirs [required: Any, installed: 1.4.4]
    - imageio [required: Any, installed: 2.9.0]
      - numpy [required: Any, installed: 1.19.4]
      - pillow [required: Any, installed: 8.2.0]
    - meshio [required: >=4.0.3,<5.0, installed: 4.4.6]
      - numpy [required: Any, installed: 1.19.4]
    - numpy [required: Any, installed: 1.19.4]
    - pillow [required: Any, installed: 8.2.0]
    - scooby [required: >=0.5.1, installed: 0.5.7]
    - transforms3d [required: ==0.3.1, installed: 0.3.1]
    - vtk [required: Any, installed: 9.0.1]
  - tqdm [required: >=4.45.0, installed: 4.61.0]

pip installation ended with error

Hi, I have some problems installing pymapdl-reader using pip.
I use a plain environment (only python, pip and numpy, cython installed) and try to install pymapdl-reader.

But that ends up with the following error:

`
ERROR: Cannot install ansys-mapdl-reader because these package versions have conflicting dependencies.

The conflict is caused by:
pyvista 0.29.0 depends on vtk
pyvista 0.28.1 depends on vtk
pyvista 0.28.0 depends on vtk
pyvista 0.27.4 depends on vtk
pyvista 0.27.3 depends on vtk
pyvista 0.27.2 depends on vtk
`

I tried several ways of installing the pymapdl-reader (installing pyvista before and so on), but no chance to get it.
It would be great to have a pip-ready version that handles this problems.

decouple the testing requirements of ansys-mapdl-core

The test suite relies on the installation of ansys-mapdl-core to operate properly. However, this also relies on an installation of this package, which results in a circular requirement and you end up installing the latest version of the package into your venv alongside the development version which is a recipe for confusion.

We should decouple these as suggested by Alex in #99

"by caching the expected results to *.npy arrays within testfiles."

How to close file

Hi,
I found that after read .rst file by read_binary, the file did not close automatically. Is there any method or way to close it? Thank you.

Plotting beam elements

I have a model with different element types and I want to plot just the vMises stresses for the beams with pyvista.Plotter(). I'm thinking about creating a mask vector like this,

result = pymapdl_reader.read_binary(str(rstFilePath))
typeList = result.mesh.etype
nnum, stress = result.principal_nodal_stress(-1)
beamMask = typeList == 188
beamStresses = list(compress(element_stress, beamMask))
enumBeam = list(compress(enum, beamMask))

but now I'm stuck.

How can I plot these?

write_cmblock doesn't work by up_to = 0

Hey,

the command write_cmblock isn't working, when the variable up_to = 0.
In the cdb-file, the elements are written in one line.

I think the problem is that cmblock_items[:-0] returns an empty array.

Import material stress limits

Hello,
I would like to import from a .rst file the stress limits associated with a material.
This information should be included in the .rst file.
In pyansys I have found the mesh.materials property but it does not include the stress limits.
Is there a function implemented for reading these data?

Cannot get complex values

Hello, thank you very much for the very good work. I have tried the interface, but so far I have not been able to read the complex values (stress, force, displacement) from the result-file of a harmonic analysis.

I have tried it with both nodal_stress and element_stress, both functions only return the real values.

result.animate_nodal_displacement() crashes

I've run a modal analysis, which I'd like to postprocess.

result = mapdl.result
result.animate_nodal_displacement(1)

does create an animation of the first mode
image
but when closing the plot window, the following error is returned:
image

I'll paste the complete error message in comment, but I don't know how to address this.

Displacement reading issue with nodal_displacement

Hi,
I am using pymapdl-reader to read an rst file from a simulation to analyse the displacement of a modal analysis.
There is no probleme when I take directly from the displacement list of the APDL gui, but when I am trying to read it with the method : result.nodal_displacement(mode), I have the following problem : all my displacement or either huge, either null :
[-1.00111706e+172 0.00000000e+000 0.00000000e+000]
[0. 0. 0.]
[0. 0. 0.]
[0. 0. 0.]
[0. 0. 0.]
...
[0. 0. 0.]
[0.00000000e+00 0.00000000e+00 5.78486458e+15]
[0. 0. 0.]
[0. 0. 0.]
[0. 0. 0.]
[0. 0. 0.]

Also, I work on plane element so I should not have any displacement in the Z-axis. It seems to not be the case.

The link to the files used for the analysis : link

Thank you,
Raphaël

Make default colormap consistent with matplotlib (jet -> viridis/coolwarm)

Several years ago matplotlib shifted from using the colormap jet as its default, which was a legacy from when it imitated MATLAB.

jet is an extremely flawed and problematic colormap that should be avoided if possible (see below for details).

Matplotlib's change was precipitated by MATLAB shifting their default to parula, a more perceptually uniform colormap, for the above reasons. MATLAB copyrighted this colormap so matplotlib couldn't use it, as such they devised their own default and made it freely available to anyone, and everyone, who wishes to use it, viridis.

Matplotlib have detailed their logic in changing away from jet and choosing viridis in a great talk I would recommend watching, which can be found here. There is also a blog post to go along with it, which can be read here.

The issue

jet is not perceptually uniform; the rate of change of data is not proportional to the rate of change of lightness of color, in fact it is quite non-linear. In addition it is not color-blind friendly. jet distorts data.

We should stop using jet as our default and shift to either viridis, (because viridis is the chosen default of matplotlib, bringing us in line with them), or to coolwarm. coolwarm should be considered because there has been research into which colormap looks best in 3D space, and divergent colormaps are generally considered superior. coolwarm is considered the best of the divergent colormaps (see here for details).

coolwarm is the default in Paraview for comparison.

Online resources

Literature

  • Rainbow Color Map (Still) Considered Harmful’ in IEEE Computer Graphics and Applications, vol. 27, no. 2, pp. 14-17, March-April 2007.

  • "Evaluation of Artery Visualizations for Heart Disease Diagnosis", Frank Rybicki, Simone Melchionna, Michelle Borkin, Hanspeter Pfister, Charles Feldman, Dimitrios Mitsouras, Krzysztof Gajos, Amanda Peters, IEEE Transactions on Visualization & Computer Graphics vol. 17 no. undefined, p. 2479-2488, Dec., 2011

  • ‘Using color to code quantity in spatial displays.’ Spence, Ian; Kutlesa, Natasha; Rose, David L. Journal of Experimental Psychology: Applied, Vol 5(4), Dec 1999, 393-412

  • Rainbow Color Map Critiques: An Overview and Annotated Bibliography By Steve Eddins, MathWorks *

  • "Data visualization: the end of the rainbow," B. E. Rogowitz and L. A. Treinish, in IEEE Spectrum, vol. 35, no. 12, pp. 52-59, Dec 1998.

  • Diverging color maps for scientific visualization - K. Moreland 2009, pp 92-103

  • ColorBrewer.org: An Online Tool for Selecting Colour Schemes for Maps, The Cartographic Journal, 2003, pp 21-37

principal_nodal_stress(rnum) etc API suggestion

principal_nodal_stress(rnum) this API can't assign the nodes numbers. It needs update.
I have check the API document and I found some API can't assign nodes numbers or component.
The list is follow.

principal_nodal_stress(rnum)
element_stress(rnum, principal=False, in_element_coord_sys=False, **kwargs)
nodal_acceleration(rnum, in_nodal_coord_sys=False)
nodal_boundary_conditions(rnum)
nodal_input_force(rnum)
nodal_reaction_forces(rnum)
nodal_time_history(solution_type='NSL', in_nodal_coord_sys=False)
nodal_velocity(rnum, in_nodal_coord_sys=False)

class ansys.mapdl.reader.cyclic_reader.CyclicResult(filename)
nodal_displacement(rnum, phase=0, full_rotor=False, as_complex=False)
nodal_elastic_strain(rnum, phase=0, as_complex=False, full_rotor=False)
nodal_plastic_strain(rnum, phase=0, as_complex=False, full_rotor=False)
nodal_solution(rnum, phase=0, full_rotor=False, as_complex=False)
nodal_stress(rnum, phase=0, as_complex=False, full_rotor=False)
nodal_thermal_strain(rnum, phase=0, as_complex=False, full_rotor=False)
nodal_temperature(rnum, full_rotor=False)```

`fps` is not carried over to the saved video file in `animate_nodal_solution_set`

when calling animate_nodal_solution_set, there is an optional argument fps that defaults to 20. If you subsequently choose to save the animation to a movie (NOT a gif), the command has a framerate parameter, but the value of fps is not passed along.

I.e. if you call the mapdl-reader command with an fps of 1 (for example) and save the animation as a movie file, the movie file is saved at the default fps, which is 24, and NOT 1.

in rst.py, around line 2820.

if movie_filename:
    if movie_filename.strip()[-3:] == 'gif':
        plotter.open_gif(movie_filename)
    else:
        plotter.open_movie(movie_filename)

The open_movie method has an optional paramter framerate that could be set, but isn't. A solution should be straightforward as this argument just needs to be passed on as well as some clarification of the behaviour in the docstring.

This issue was originally spotted by @RPATCHI

Warning when using `animate_nodal_displacement`

C:\Users\USER\.conda\envs\pymapdl\lib\site-packages\ansys\mapdl\reader\rst.py:906: UserWarning: The ``nangles`` kwarg is depreciated and ``n_frames`` should be used instead.
  warnings.warn('The ``nangles`` kwarg is depreciated and ``n_frames`` '

Related to #112

Reading nodal velocity data from RST file fails

Hello everybody,

I encounter another problem when reading solution data from an rst file that might be related to the already solver issue #59.

I have created and uploaded the minimum example results file cube.rst.zip. My original script uses the pymapdl-reader to obtain various nodal data from the results file.
For displacements (using nodal_time_history(solution_type='NSL')) and other data this works as expected. However, using the following basic example script:

from ansys.mapdl import reader
rstData = reader.read_binary('cube.rst')
nodeIDs, nodalDataAll = rstData.nodal_time_history(solution_type='VEL')

raises the following error message:

raceback (most recent call last):
  File "./reader_mwe.py", line 10, in <module>
    nodeIDs, nodalDataAll = rstData.nodal_time_history(solution_type='VEL')
  File "TRUNCATED_PATH/ansys-mapdl-reader/0.51.4/python3.8/ansys/mapdl/reader/rst.py", line 1089, in nodal_time_history
    nnum, sol = func(0)
  File "TRUNCATED_PATH/ansys-mapdl-reader/0.51.4/python3.8/ansys/mapdl/reader/rst.py", line 1194, in nodal_velocity
    return self._nodal_solution_result(rnum, 'VSL', in_nodal_coord_sys)
  File "TRUNCATED_PATH/ansys-mapdl-reader/0.51.4/python3.8/ansys/mapdl/reader/rst.py", line 1302, in _nodal_solution_result
    result = result.reshape(-1, sumdof)
ValueError: cannot reshape array of size 243 into shape (4)

I have used the latest version 0.51.4 of the reader.

As far as I can tell the velocity values read from the file are not available on all nodes and cartesian components even seem to be partially missing on some nodes (thus the shape that is not a multiple of four).

As mentioned earlier in #59, this result file is the output of a quite uncommon setup, where we try to combine different groups of elements (currently SURF152, SURF154 and SOLID226) to perform a simulation of a force and heatflux/temperature loaded structure within a single FEM model.

Is it possible that there is a general problem with this approach?
Since the solver is well capable to handle the model itself and results look reasonable, I assume there is not, but we probably 'simply' cause a lot of trouble by acting outside of the box of intentional use.

Best regards,
Sebastian

Error while running self._resultheader['ptrGEO']

Hello,
I am trying to import some data from an .rst file.
Unfortunately, when running:
result = Result('file.rst', read_mesh=False)
I get the following error:

Traceback (most recent call last):
[...]
  File "C:\Users\xxx\.conda\envs\fattool_dev\lib\site-packages\ansys\mapdl\reader\rst.py", line 120, in __init__
    table = self.read_record(self._resultheader['ptrGEO'])
  File "C:\Users\xxx\.conda\envs\fattool_dev\lib\site-packages\ansys\mapdl\reader\common.py", line 107, in read_record
    record = self._cfile.read_record(pointer, return_bufsize)
  File "ansys\mapdl\reader\cython\_binary_reader.pyx", line 245, in ansys.mapdl.reader._binary_reader.AnsysFile.read_record
  File "ansys\mapdl\reader\cython\_binary_reader.pyx", line 364, in ansys.mapdl.reader._binary_reader.wrap_array
  File "ansys\mapdl\reader\cython\_binary_reader.pyx", line 155, in ansys.mapdl.reader._binary_reader.ArrayWrapper.__array__
ValueError: negative dimensions are not allowed

Do you have any suggestions concerning the possible cause?
Might the problem be related to the .rst being generated with an older Ansys version (19.2)?

Thank you
Francesco

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.