ansys / pymapdl

Pythonic interface to MAPDL
https://mapdl.docs.pyansys.com
MIT License
423 stars 119 forks source link

Issue with pulling nodal stress from rst file #11

Closed PSutkowski closed 6 years ago

PSutkowski commented 6 years ago

Before I'd actually start describing issue I'd like to compliment author's work - pyAnsys is truly amazing tool, great job ! I have some experience in APDL and I'm relatively new to python, but still setting up pyansys took me significantly less time than developing APDL script.

Anyway, there are two things I'd like to comment:

  1. is there a plan to include other result components ? At this moment I'm looking for nodal principal stress - I know I can achieve that by applying laws of mechanics to stress components in python (and I might end up doing that), but it would nice have them directly from ansys.

  2. I'm trying to read whole RST and rewrite it to text file with 10 columns (node ID, XYZcoord, stress components). I've executed following code: ` import pyansys import numpy result=pyansys.ResultReader('myRstfile.rst') nnum = result.nnum
    disp = result.GetNodalResult(0) stress = result.NodalStress(0)
    print ("Nodes size: " + str(numpy.shape(nnum))) print ("Displ size: " + str(numpy.shape(disp))) print ("Stress size: " + str(numpy.shape(stress))) '

and as a result I've received: Nodes size: (727562,) Displ size: (727562, 3) Stress size: (554638, 6). First two look as I expected, third is surprising: how come row count is different ?

Thank you in advance, Kind Regards, Pawel.

akaszynski commented 6 years ago

Thanks for the kind comments about the code! We used to use MATLAB and python to read in results from text results outputted from ANSYS and found it was much easier to directly read them from the binary file, especially when visualizing.

To answer your questions:

  1. ANSYS doesn't store principle stresses in the result file. These are computed in ANSYS upon request. Only a few results are actually stored in the result file and many results, such as principle stress, are computed from data stored in the result file as this keeps the result file size down. I'l add in code that computes these quickly for the next version in a week or two. If you need it right now, follow the code in the website below: https://robsiegwart.com/principal-stresses-in-3d/

  2. Nodal stress is computed by evaluating stress at the elements and averaging those strains in the same manner as ANSYS for the edge nodes. What you're seeing is the stress only at the edge nodes and not at mid-side nodes. ANSYS computes displacement at mid-side nodes (based on the solution of the eigensolution), but stress is only evaluated at the edge nodes (which is what you'd get from ANSYS as well).

Here's the documentation explaining this: http://pyansys.readthedocs.io/en/latest/loading_results.html#accessing-solution-results http://pyansys.readthedocs.io/en/latest/loading_results.html#pyansys.ResultReader.NodalStress

PSutkowski commented 6 years ago

Thanks a lot for the prompt reply. So regarding point 2: let's say I want to export nodes and corresponding stress components for edge nodes only. How do I do that ? I don't see a way to tell which row in nodeIDs array correspond to which row in stress array.

PSutkowski commented 6 years ago

Oops, I've just read documantation again and found answer. Thanks a lot!

akaszynski commented 6 years ago

Turns out that I've commented out a piece of code that makes that easy to generate. I'll add it in for the next release. Here's how you can get the edge node numbers:

edge_node_num = result.geometry['nnum'][result.edge_node_num_idx]

In the future this will be accessible from:

self.edge_node_num
akaszynski commented 6 years ago

Added principal stress computation. See the latest release 0.21.0