ansys / pymapdl Goto Github PK
View Code? Open in Web Editor NEWPythonic interface to MAPDL
Home Page: https://mapdl.docs.pyansys.com
License: MIT License
Pythonic interface to MAPDL
Home Page: https://mapdl.docs.pyansys.com
License: MIT License
Hello,
for the example file.rst I get a different number of stress results than the number of nodes.
for:
print "number nodes: ", len(result.nnum)
print "number elements: ", len(result.enum)
print "number nodal stress results: ", len(result.NodalStress(0))
I get:
number nodes: 321
number elements: 40
number nodal stress results: 99 (Stress Tensors)
Shouldn't the number of stress tensors be equal to the number of nodes?
Best regards,
I loaded the result file 'rotor.rst' in #22, but IndexError Exception is raised when call the NodalSolution method.
import pyansys
result = pyansys.ResultReader('rotor.rst')
nnum, ms = result.NodalSolution(10) # <----- Exception arised here
The detailed exception message is,
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Anaconda3\lib\site-packages\pyansys-0.27.2-py3.6-win-amd64.egg\pyansys\binary_reader.py", line 1473, in NodalSolution
nnum = nnum[self.mas_ind] # only concerned with the master sector
IndexError: index 460 is out of bounds for axis 1 with size 460
Hello there,
I am trying to use pyansys to convert a .rst file into a vtk readable file.
This is needed because I'd like to use the .rst in Paraview (if there are other options please let me know).
The file is loaded fine as
import pyansys
rst_file = pyansys.ResultReader("my_file.rst")
but when I try to save it (rst_file.SaveAsVTK("my_new_file.vtu")
), I get the following error
AttributeError: 'ResultReader' object has no attribute 'uGrid'
I do not have the VTK python bindings installed. Is that the reason why I get the error?
Thank you!
Hi,
first of all I really enjoy the work you put into this library!
My question regards possibility of extracting nodal temperatures (plnsol,bfe,temp) from structural result file ? In a top level manner I would like to have time vs nodal temp and stress for each node to perform LCF calculation.
Thanks for your great work!
Kris
Hi there,
After installing and setting the exe path using:
import pyansys
ansys = pyansys.ANSYS(exec_file="C:\\Program Files\\ANSYS Inc\\v180\\ansys\\bin\\winx64\\ANSYS.exe", run_location=None, jobname='file', nproc=None, override=False, wait=True, loglevel='INFO')
I get two windows pup up which say:
The code execution cannot proceed because AnsMPI.dll was not found. Reinstalling the program may fix this problem.
and
The code execution cannot proceed because AnsGPU.dll was not found. Reinstalling the program may fix this problem.
Any idea how to fix it?
A question related to #19
Is it possible to get variables from *GET into the Python workspace?
Hi,
when I try to run the "Loading and Plotting an ANSYS Result File" example, I get the following error
raise Exception('Unsupported type {:s} for vtk copy'.format(typestring))
Exception: Unsupported type <type 'vtkobject for vtk copy
The 0.13 version example with LoadCDB works perfectly. Must have been due to some changes in the new version.
Thank you for your support.
Btw I am still struggling to find a way to plot element solutions (stresses, plastic strains etc.). Would be great if the functionality was available as well.
Hi,
Thank you for your work so far! Your library is really useful!
As I wrote in the title beside of the extraction of the binary in certain cases I would like to modify it.
What do you think, is it possible?
Best regards,
Bela
Dear Alex,
I tried the new version of pyansys on a rather old laptop -core2duo- in which the first run of ANSYS server is slow. The pyansys aborts the ANSYS starting procedure due to the short -20.0 seconds- waiting time and the delayed ANSYS server is becoming unreachable from python shell. The started ANSYS server has to be killed and its lock file to be cleaned up manually. After the first startup and cleanup attempt the ansys object can be instantiated.
"""
In [4]: path = os.getcwd()
TimeoutError Traceback (most recent call last)
in ()
----> 1 ansys = pyansys.ANSYS(run_location=path, interactive_plotting=True)
C:\dev\Miniconda3\lib\site-packages\pyansys\ansys.py in init(self, exec_file, run_location, jobname, nproc, overr
ide, loglevel, additional_switches, start_timeout, interactive_plotting, log_broadcast, check_version, prefer_pexpect
)
405 self.OpenProcess(nproc, start_timeout)
406 else: # use corba
--> 407 self.OpenCorba(nproc, start_timeout)
408
409 # separate logger for broadcast file
C:\dev\Miniconda3\lib\site-packages\pyansys\ansys.py in OpenCorba(self, nproc, timeout)
831 err_msg = 'Unable to start ANSYS within %.1f seconds' % timeout
832 self.log.error(err_msg)
--> 833 raise TimeoutError(err_msg)
834
835 # open server
TimeoutError: Unable to start ANSYS within 20.0 seconds
NameError Traceback (most recent call last)
in ()
----> 1 ansys.Exit()
NameError: name 'ansys' is not defined
"""
hi, there is an error when I get nodal stress using NodalStress() method. I use the rst file in your closed issues "test_pyansys.rst".
I guess there is something wrong with numpy.int64 type.
the code is below:
stress = result.NodalStress(0)
Traceback (most recent call last):
File "<ipython-input-12-6342d70f8bcd>", line 1, in <module>
stress = result.NodalStress(0)
File "C:\Users\zxmy\Anaconda3\lib\site-packages\pyansys\binary_reader.py", line 977, in NodalStress
self.edge_idx.astype(np.int64))
File "pyansys/cython/_rstHelper.pyx", line 158, in pyansys._rstHelper.LoadStress
ValueError: Buffer dtype mismatch, expected 'long' but got 'long long'
Dear Alex!
I tried to use pyansys to get stiffness matrix from a fullfile. When I ran the code with my fullfile, it showed the following error message: negative dimensions are not allowed
The code run very well with the example (which contain the pyansys), but with mine its not work!
Do you have any idea, what can I do to solve the problem?
My model contains only one element without boundary conditions.
I used the next code:
import pyansys
from pyansys import examples
file=examples.fullfile
ans=pyansys.FullReader('elem.full')
dof_ref, k, m = ans.LoadKM()
If you want, I can send you the fullfile.
Thanks,
Daniel
Hi.
I try to call "from pyansys import Reader" and receive ImportEror "Cannot import name "_parsefull""
I can not understand why. Could you help me?
Hi, attached a zipped debug_pyansys.rst
,
import pyansys
result = pyansys.ResultReader("debug_pyansys.rst")
result.edge_node_num[0:10]
result.NodalStress(0)[0:3]
I get from pyansys
>>> result.edge_node_num[0:10]
array([ 1, 2, 4, 6, 8, 10, 12, 15, 34, 35])
>>> result.NodalStress(0)[0:3]
array([[-1.2874937e-06, 1.2874934e-06, 5.6843419e-14, 0.0000000e+00, 8.1756007e-06, -8.1756007e-06],
[-1.1674185e-04, -1.1674478e-04, -3.0856981e-04, -1.7892545e-06, -2.5823609e-05, 2.5835518e-05],
[-5.7354209e-05, -5.5398770e-05, -1.4944717e-04, -1.0580692e-06, -1.7659733e-05, -3.5462126e-06]], dtype=float32)
From ANSYS with
set,1,1
*get,foo,node,1,s,x
*get,foo,node,1,s,y
*get,foo,node,1,s,z
...
*GET FOO FROM NODE 1 ITEM=S X VALUE=-0.128749366E-05
*GET FOO FROM NODE 1 ITEM=S Y VALUE= 0.128749343E-05
*GET FOO FROM NODE 1 ITEM=S Z VALUE= 0.568434189E-13
*GET FOO FROM NODE 2 ITEM=S X VALUE=-0.116741852E-03
*GET FOO FROM NODE 2 ITEM=S Y VALUE=-0.116744777E-03
*GET FOO FROM NODE 2 ITEM=S Z VALUE=-0.308569797E-03
*GET FOO FROM NODE 4 ITEM=S X VALUE=-0.553783551E-04
*GET FOO FROM NODE 4 ITEM=S Y VALUE=-0.536294307E-04
*GET FOO FROM NODE 4 ITEM=S Z VALUE=-0.148084539E-03
Values on nodes 1 and 2 seem to be ok, but on node 4 the values differ.
The mesh is done using solid186 (20 node) element, but the shape of the elements in this mesh is prism. When ANSYS calculates the stress averages, at each location each element is counted only once (and not twice when the nodes of the element are coincident in case of prisms).
Is is possible to make the nodes selectable in the VTK and to know the result and node number at a particular node?
Dear Alex,
I tried to start the interactive_plotting mode of pyansys in my old laptop with Windows 7 and the following error raised.
Exception Traceback (most recent call last)
in ()
----> 1 ansys = pyansys.ANSYS(run_location=path, interactive_plotting=True)
C:\dev\Miniconda3\lib\site-packages\pyansys\ansys.py in init(self, exec_file, run_location, jobname, nproc, override, loglevel, additional_switches, start_timeout, interactive_plotting, log_broadcast, check_version, prefer_pexpect)
387 raise Exception('Lock file exists for jobname %s \n' % self.jobname +
388 ' at %s' % self.lockfile +
--> 389 'Set override=True to delete lock and start ANSYS')
390 else:
391 os.remove(self.lockfile)
Exception: Lock file exists for jobname file
at C:\Users\csevast\Documents\file.lockSet override=True to delete lock and start ANSYS
In [8]: ansys = pyansys.ANSYS(run_location=path, interactive_plotting=True)
Cached ANSYS executable not found
Found ANSYS at C:\Program Files\ANSYS Inc\v181\ANSYS\bin\winx64\ansys181.exe
Use this location? [Y/n]y
2018-08-06 19:20:19,103 [INFO] pyansys.ansys: Connecting to ANSYS via CORBA
2018-08-06 19:20:25,386 [INFO] pyansys.ansys: /SHOW SWITCH PLOTS TO PNG - RASTER MODE.
In [9]: ansys.Prep7()
2018-08-06 19:20:43,127 [INFO] pyansys.ansys: *** ANSYS - ENGINEERING ANALYSIS SYSTEM RELEASE Release 18.1 18.1
***
ANSYS Academic Teaching Advanced
01039803 VERSION=WINDOWS x64 19:20:43 AUG 06, 2018 CP= 0.593
***** ANSYS ANALYSIS DEFINITION (PREP7) *****
TypeError Traceback (most recent call last)
in ()
----> 1 ansys.Prep7()
C:\dev\Miniconda3\lib\site-packages\pyansys\ansys_functions.py in Prep7(self, **kwargs)
26206 """
26207 command = "/PREP7," % ()
26208 return self.Run(command, **kwargs)
26209
26210 def Force(self, lab="", **kwargs):
C:\dev\Miniconda3\lib\site-packages\pyansys\ansys.py in Run(self, command)
486 def Run(self, command):
487 if self.using_corba:
--> 488 return self.RunCorbaCommand(command)
489 else:
490 return self.RunProcessCommand(command)
C:\dev\Miniconda3\lib\site-packages\pyansys\ansys.py in RunCorbaCommand(self, command)
679
680 if self._interactive_plotting:
--> 681 self.DisplayPlot()
682
683 return text, additional_text
TypeError: DisplayPlot() missing 1 required positional argument: 'text'
In [10]:
"""
Ansys functions not showing up in docs
In the document, an Ansys result file named 'rotor.rst' is used. Where can I find it to run the examples?
Thank you!
From a developer perspective it's extremely nice to be able to run APDL commands interactively on a running ANSYS instance. However, sometimes it's better to generate the APDL code as a file and run it in ANSYS later.
Would it be a big deal to make it possible to starte a 'fake' ANSYS that simply writes all commands to a file?
Maybe this is what the /OUTPUT flag already does?
I am in the process of adding the functionality to write results to a VTK unstructured grid (.vtu) format using vtk.vtkXMLPUnstructuredGridWriter(). So that I may view results in Paraview and do further post processing.
So far I have made small changes to the reader file to return the uGrid object and then write this to a file. However in paraview the only available data set are the node number. Indicating that I am unsuccessfully associating the data set with the uGrid object when writing to file.
Is this a functionality you are considering? Or something you be able to assist with?
Not specifying a colormap in mode shape plotting results in a white mesh.
Thank you very much for providing this functionality.
Is there an easy way to visualize stresses or other results other than displacements with pyansys?
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/jeff/.local/lib/python3.5/site-packages/pyansys/examples/examples.py", line 34, in RunAll
any(f() for f in testfunctions)
File "/home/jeff/.local/lib/python3.5/site-packages/pyansys/examples/examples.py", line 34, in <genexpr>
any(f() for f in testfunctions)
File "/home/jeff/.local/lib/python3.5/site-packages/pyansys/examples/examples.py", line 308, in CylinderANSYS
result.PlotNodalResult(0, colormap='bwr')
AttributeError: 'Result' object has no attribute 'PlotNodalResult'
Hello,
I am currently promoting Pyansys in our company for fast screening of large structures to perform fatigue analysis. However I have two issues to resolve:
(1) I have not been able to extract the element stress (non-average) at top and bottom planes of shell elements. What "result.ElementStress(0)" provides is only the element stress at Mid-plane of shell elements through an array with 4 rows, which cannot be used for fatigue analysis. Is there any way to get the element stress through an array with 8 rows including 4 nodes at the top layer and 4 nodes at the bottom layer ?
(Note: Mid-plane results is indeed the average of top and bottom planes of shell elements. For a rectangular shell elements we have 4 top nodes and 4 bottom nodes, so the stress array should have 8 rows to capture the bending effect. This is how we traditionally extracted the results from ANSYS binary rst file.)
(2) We need to extract the component stresses for shell elements in the Element Coordinate System instead of the Global Coordinate System. Any suggestion?
Thanks in advance.
-Shobeir
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:
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.
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.
Hi
When reading in my own rst-file (from Ansys 17.2), I get this error when issuing the PlotNodalStress() command. I can see from the result object that the "edge_idx" and the "edge_node_num_idx" arrays both have a "-1" number in them, which I guess is causing the problem. Can something be done to prevent this?
Thanks in advance!
Working with the rst file in the default example, I see the size of Nodal stress as 99x6 where as the number of nodes, obtained from the geometry attribute, in this example is 321. I guess the 6 corresponds to the stress components, but shouldn't I see 321x6 values of stresses i.e. number of node x DoF?
It is great job for ANSYS, APDL and Python users.
Unfortunately the interactive mode is not usable in Windows. In the pyansys code there are a lot of method calls for the ANSYS process (isalive) which are not available for Windows. The ANSYS output window is black โ I don't know how it should be; in ANSYS CLI mode there is the BEGIN: prompt, line 253 self.process.expect('CONTINUE') has to be commented, for every command sent to ANSYS return/enter has to be pressed in ANSYS output window, and many other issues, like plotting, are unsolved. I'm using ANSYS Mechanical v18.1.
Anyway, the postprocessing part of the module shows no problems in Windows. ANSYS surface output files processing should be nice to be added. The VTK display is looking even better than ANSYS's display drivers.
Thank you for your attention.
How to read .cas and .dat files obtained from ansys fluent?
Hello,
I am having trouble with reading layer data for shell elements - SHELL181 in particular. The method Reader.ElementStress returns the data for one layer only. Also I am having concerns about the coordinates in which the stress tensor is read. I would like the stress tensor to be in global coordinates but I can't quite figure it out. I attached the .rst file and the .lis files with results I was expecting to get with both ElementStress(0) and NodalStress(0) method calls.
Nevertheless, pyansys works great and saves a lot of time. Keep up the good work :)
when I follow the instruction and read my rst file, the assert sentence appears.
Could you tell me what happen when it read my .rst file using pyansys.ResultReader() command?
How can I correct the file so that I can get results?
I'm attempting to develop state-space models of a finite element model and while I can get the mass and stiffness matrices through pyansys, I am unable to get the RHS/load vector which is needed to develop a full state-space model. Would it be possible to define a method that would perform this action?
Hi.
I use Python 3.6.5 on Windows 7 x64. when I import the pyansys and got Import error "cannot import name '_reader'
Could you help me to solve this error?
Hi there,
I was trying to use your app in windows and as you mentioned in another issue. It does not work, basically because the command output window is not very responsive in windows. (I hope I got the concept properly).
So I was checking the web, and I found out the WSL which allows installing Linux kernel in Windows. So I wonder if it could be possible from that, lunch Ansys from that command line as it was launched from Linux. Maybe you can get all the required flexibility.
It's a crazy idea, but I have no knowledge to check for myself. I can install the WSL and Ubuntu but I can't go from the command line.
I hope it helps! Kind regards,
Hi,
I tried to upgrade pyansys and than reinstall it but non of these worked. I got the following error:
cl : Command line warning D9025 : overriding '/W3' with '/w'
_parsefull.c
c1: fatal error C1083: Cannot open source file: 'pyansys/cython/_parsefull.c': No such file or directory
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\x86_amd64\\cl.exe' failed with exit status 2
Am I missing something? (0.32.4 working fine for me)
Thanks!!
Hi Alex,
I am trying to read some ansys RST files containing SHELL 281 and SOLID 186 Elements. PyAnsys seems to plot the solid elements with no issue; however, it does not show any of the shell elements.
In addition, looking at the numerical data, when using the elem command to see the nodes in the element, it looks as though only the first 4 nodes are listed for any element.
Does PyAnsys not support 8 node shell elements yet?
If this is the case, I'm fairly new to python coding, but would be willing to help implement it if you plan on doing it.
Keep up the amazing work!
Cheers,
Jakub
When installing in a fresh conda created python 3.7 environment, I get the following error:
(base) C:>conda create -n py37 python=3.7 numpy cython
...
(base) C:>conda activate py37
(py37) C:>pip install pyansys
Collecting pyansys
... (removed the other dependency lines that were successful)
Collecting vtk (from vtkInterface>=0.11.0->pyansys)
Could not find a version that satisfies the requirement vtk (from vtkInterface>=0.11.0->pyansys) (from versions: )
No matching distribution found for vtk (from vtkInterface>=0.11.0->pyansys)
Note: the same procedure for python 3.6 works fine.
Hi Alex,
Pyansys currently ignores SHELL elements from the .RST file.
Regards,
Abhi
Hi Alex,
a nice and very fast software you have developed here. Thank you.
For our purpose, we also would be interested to read the section and material properties as given in the EBLOCK statement (element 1 of statement = material, element 4 = section id). Any chance to have this implemented in the reader.c file and then return it as an additional vector?
The actual parsing of the material and section statements I might be able to implement myself in the relevant python code. Or let me know if you need some examples.
Thank you,
Michael
I experience that ANSYS suddenly shuts down prematurely with this message in the error log:
It might be due to a license issue. In fact I have the licenses I need, though I'm not able to specify the license to PyAnsys. When using ANSYS from the command line I would use the -p option to specify a product name. I have tried to use the additional_swithes option for this, but without success. It look like the additional_switches setting is ignored.
vtk does not seem to be a very hard dependency. Maybe make it optional and remove it from requirements?
After upgrading PyAnsys from version 0.29.0 to 0.31.2, certain APDL commands now fails; f. ex. SECBLOCK.
Error message says 'APDL command not supported in aaS'
It would be really nice if plane42/82 (legacy) and plane182/183 element types were added .
If you don't have the time for it, i think i will try to contribute to the project.
I am trying to get the stresses from an analysis with beam 188 into my Python workspace. In APDL, I do this via etables. Does pyANSYS allow for this?
Thanks in advance!
Hi Alex,
Sorry if this is the wrong platform to ask this, is it possible to get the nodal solutions to export with the node locations from the pyansys.ResultReader object? Or get the node numbers with node locations from the result file?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.