Comments (23)
The ansys_cobra
module is able to load given that none are the errors __init__.py
file. The problem is likely due to not finding the logfile mapdl_broadcasts.txt
as the error was there and the script was locked in the while loop looking for it. All I do is have to adjust the paths.
I'm going to go ahead and implement this in pyansys
as the part I was worried out, importing the ansys_corba
module, seems to be working. Thanks for your help @germa89.
from pymapdl.
Windows compatibility is on the todo list. I should have some time to work on it over the weekend sometime in June.
Glad to hear that the post-processing module works well with Windows. I'm mainly a Linux user and have only done basic functional testing with Windows.
from pymapdl.
Started working on this and discovered why it hangs when starting.
from pymapdl.
from pymapdl.
from pymapdl.
Just to give you an update, it's actually going to be quite difficult to get it to work under windows based on the way the programmers launched ANSYS.exe. The ANSYS170.exe sets up paths and environmental variables and then launches ANSYS.exe, meaning that I'd have to hook into the new executable.
ANSYS and MATLAB get around this by launching a aaS server, but that's only available for ANSYS 17+ and only useful for Windows. I'll keep working on this, but it might take a bit as this isn't a high priority for us at the moment.
For more details, see:
https://www.sharcnet.ca/Software/Ansys/17.0/en-us/help/ans_aas/ans_aas.html
If you wish to help, feel free to contribute or suggest code to initiate a COBRA interface based on the IOR string provided by APDL.
https://www.sharcnet.ca/Software/Ansys/17.0/en-us/help/ans_aas/aas_mgmt_connecting.html
from pymapdl.
from pymapdl.
Just looked into omniORBpy
and it seems like it's the best solution. I don't like how they don't have a wheel on PyPi, so it would be a complex dependency to install for pyansys
. I've contacted the package maintainer to see if they could get a version of it on PyPi.
Do you have a traceback of the errors you encountered with pyansys on Windows?
from pymapdl.
from pymapdl.
I'm going to attack this on the Linux side as well. I want to use COBRA as well for Linux since there are some limitations to using pexpect (and it's a bit of hack and I'm a purist).
After looking around for a bit, I found some resources directly from ANSYS:
https://www.youtube.com/watch?v=bSP9pi-4QW0
If this ends up working out, I'll have to find a way to get omniORBpy installed in a pythonic manner through pip as it will be a dependency of pyansys.
from pymapdl.
Got it working on Linux.
"""
set me up with
spath=/home/alex/Documents/AFRL/Python/pyansys/Testing/corba/python-corba/omniORB-4.2.2/idl/
omniidl -I $spath -bpython ICoMapdlUnit.idl
"""
from omniORB import CORBA
import AAS_CORBA
orb = CORBA.ORB_init()
with open('./aaS_MapdlId.txt') as f:
key = f.read()
mapdl = orb.string_to_object(key)
out = mapdl.executeCommandToString('/PREP7')
print(out)
*** ANSYS - ENGINEERING ANALYSIS SYSTEM RELEASE Release 18.2.2 18.2.2 ***
ANSYS Mechanical Enterprise
00000000 VERSION=LINUX x64 23:03:03 JUL 18, 2018 CP= 0.502
***** ANSYS ANALYSIS DEFINITION (PREP7) *****
ENTER /SHOW,DEVICE-NAME TO ENABLE GRAPHIC DISPLAY
ENTER FINISH TO LEAVE PREP7
PRINTOUT KEY SET TO /GOPR (USE /NOPR TO SUPPRESS)
You can install omniORBpy using anaconda, but there's got to be an easier way. It wasn't easy to figure out that you had to use omniidl
to compile ANSYS's ICoMapdlUnit.idl
file to create an AAS_CORBA
directory which is used by CORBA.
Ideally this would all be self-contained within a wheel file within pyansys and installed without the user noticing. I'll work on incorporating this into pyansys for the next release.
from pymapdl.
Hi there,
I'm trying to replicate your post in Windows 10. I installed omniORB using conda (https://anaconda.org/mutirri/omniorb):
conda install -c mutirri/label/anaconda omniorb
But when I go into python (2.7.14) to run
from omniORB import CORBA
it says there is no omniORB module.
Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: No module named omniorb
Any idea? Kind regards,
from pymapdl.
Hold off for a moment getting omniORB installed. I'm working on my own solution to package the essentials with pyansys.
from pymapdl.
Perfect!
Let me know if you need some windows testing.
Kind regards
from pymapdl.
from pymapdl.
from pymapdl.
Great work csevast! I'm going to adapt your code and use it for building omniORB for Windows for a potential pip solution. I've got a standalone whl built for Linux and with this I'll build it for windows as well.
I've talked with the maintainer of omniORB and he's hesitant about having omniORB on pypi due to some issues he's had in the past with debian packages. I've assured him that it would be different, but we'll see what he says. It's been a bit of work adding to omniORBpy to make it pip install-able and hopefully the general open source community can benefit from this.
The other idea is to include the key parts of omniORB within pyansys and ship it, but I'd have to include multiple copies for omniORB (one for each platform) and I'd rather not do this. Having it as a separate dependency would be ideal.
Ideas?
from pymapdl.
For those interested in Windows testing:
I've been able to kluge together windows wheels to with parts of omniORBpy that are necessary for running ANSYS through a python script. Wheels are here on the test server:
https://test.pypi.org/project/ansys-corba/
These can be installed using pip with:
pip install --index-url https://test.pypi.org/simple/ ansys_corba
For those interested, I'd like you to install these wheels on Python 2.7, Python 3.5, and Python 3.6 and let me know if the script run without error. Here's the script:
"""
Simple script to test running ANSYS using ansys_corba
Install ansys_corba with:
pip install --index-url https://test.pypi.org/simple/ ansys_corba
This functionality will be incorporated into pyansys 0.29.0
"""
import sys
import pexpect
import time
import os
from ansys_corba import CORBA
import subprocess
# edit this to match your ansys exe
ansys_loc = 'C:\\Program Files\\ANSYS Inc\\v170\\ansys\\bin\winx64\\ANSYS170.exe'
# ansys apdl logging here:
logfile = 'mapdl_broadcasts.txt'
if os.path.isfile(logfile):
os.remove(logfile)
# start ANSYS
command = '"%s" -aas -i tmp.inp -o out.txt -b' % ansys_loc
proc = subprocess.Popen(command, stdout=subprocess.PIPE)
# monitor log file and wait for connection
print('Starting ANSYS...')
while True:
try:
if os.path.isfile(logfile):
with open(logfile, 'r') as f:
text = f.read()
if 'visited:collaborativecosolverunitior' in text:
break
time.sleep(0.1)
except KeyboardInterrupt:
break
print('ANSYS started')
with open('./aaS_MapdlId.txt') as f:
key = f.read()
# create server
orb = CORBA.ORB_init()
mapdl = orb.string_to_object(key)
# run simple commands to demonstrate this works
mapdl.executeCommand('/prep7')
out = mapdl.executeCommandToString('cylind, 2, , , 2, 0, 90')
print(out.replace('\\n', '\n'))
mapdl.executeCommand('FINISH')
mapdl.terminate() # could use exit, but it returns an error
If this works out, I'll build wheels for Linux, upload to PyPi, add it as a dependency to pyansys, and then update pyansys to use ansys_corba instead of pexpect for Linux. Please let me know if you encounter any problems.
from pymapdl.
Hi @akaszynski
I just try the installation and everything works perfect!
I tried to run the code and I got an error related with "System can't find the file". Doing some debugging, the problem was Ansys wasn't started.
I fixed changing the path to Ansys:
ansys_loc = 'C:\\Program Files\\ANSYS Inc\\v180\\ansys\\bin\\winx64\\MAPDL.exe'
Also I'm using an academic research license which requires the flag aa_r
, so I had to add it to the command.
I hope it helps if someone get the same error!
Thank very much for the very nice piece of work!
from pymapdl.
from pymapdl.
Hi @csevast
I'm not sure if it will help, but can you make sure you have the python script, the ICoMapdlUnit.idl
file and the folders AAS_CORBA
and AAS_CORBA__POA
in the Ansys working folder?
I think they need to be in the same folder (I have them like that) to find every file.
Also, make sure the command you are supplying to subprocess.Popen
is appropriate. Put a print before it to see it and copy and paste it in the cmd to see if it works. If you make it work in cmd, it should be straightforward do it in python.
Kind regards,
from pymapdl.
It took a bit of work, but it's finally working for Windows and Linux. I've even been able to getting plotting to work. See the updated documentation at:
http://pyansys.readthedocs.io/
Tested on Windows 10 using ANSYS 17.0 and Linux using 18.2. Should automatically detect install location on Windows. Dependencies are all available on PyPi. Open a new issue if you encounter problems.
from pymapdl.
from pymapdl.
Related Issues (20)
- ``ansys-dpf-core`` and ``sphinx-autodoc-typehints`` failing updates
- Failed scheduled build HOT 1
- HPC command line interface
- Failed scheduled build HOT 1
- Reorg translate script section
- Failed scheduled build HOT 1
- Failed scheduled build HOT 17
- Getting an error while launching PyMAPDL using latest version 0.68.1 and Python v3.12.0. HOT 13
- `timeout` and `start_timeout` conflict
- Problems whith trying to use two different instances of mapdl in the new version of ansys-mapdl-core HOT 2
- Black MAPDL window opens when compiling a program with PyMAPDL HOT 9
- MAPDL server connection terminated when using parameters HOT 6
- RDEC and VFQUERY need updating. HOT 2
- Bug located in element_values of JT, SUM in that it changes the set of selected elements after. HOT 1
- Version/Command mismatch on doc page
- Bug located in MPCOPY and other commands which has unused field HOT 5
- Add /CYCEXPAND APDL command.
- MAPDL commands do not match API HOT 1
- Large files in the final python package HOT 1
- `sphinx-build` configuration is not being catched
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pymapdl.