ansys / pymapdl

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

Windows compatibility #24

Closed csevast closed 6 years ago

csevast commented 6 years ago

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.

akaszynski commented 6 years ago

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.

akaszynski commented 6 years ago

Started working on this and discovered why it hangs when starting.

csevast commented 6 years ago

Very nice. I hope my hint notes in my issue message were helpfull. Are you testing it in Windows?

Διπλωματούχος Ηλεκτρολόγος Μηχανικός Δρ. Ηλεκτρακουστικής Εργαστηριακό Διδακτικό Προσωπικό

Τμ. Ηλεκτρολόγων Μηχανικών και Μηχανικών Υπολογιστών Αριστοτέλειο Πανεπιστήμιο Θεσσαλονίκη Πανεπιστημιούπολη Θεσσαλονίκη 541 24

κιν. 6977447820 τηλ. 2310996317

Electrical Engineering Diploma Electroacoustics PhD Laboratory Teacher

School of Electrical and Computer Engineering Aristotle University of Thessaloniki University Campus Thessaloniki, 541 24 Greece

mob. +30 6977447820 tel. +30 2310996317

On 13 June 2018 at 19:58, Alex Kaszynski notifications@github.com wrote:

Started working on this and discovered why it hangs when starting.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/akaszynski/pyansys/issues/24#issuecomment-397011092, or mute the thread https://github.com/notifications/unsubscribe-auth/AYDNpyz-ck-JU9fDJ64KVzbEW-pAm71eks5t8UTFgaJpZM4UTxpC .

akaszynski commented 6 years ago

Christos,

Your notes were helpful as I'm able to establish that the code is having the same problems in your Windows enviornment as mine.

I can boot into Windows or run it using VirtualBox when necessary for code testing.

Alex

Christos Sevastiadis writes:

Very nice. I hope my hint notes in my issue message were helpfull. Are you testing it in Windows?

Διπλωματούχος Ηλεκτρολόγος Μηχανικός Δρ. Ηλεκτρακουστικής Εργαστηριακό Διδακτικό Προσωπικό

Τμ. Ηλεκτρολόγων Μηχανικών και Μηχανικών Υπολογιστών Αριστοτέλειο Πανεπιστήμιο Θεσσαλονίκη Πανεπιστημιούπολη Θεσσαλονίκη 541 24

κιν. 6977447820 τηλ. 2310996317

Electrical Engineering Diploma Electroacoustics PhD Laboratory Teacher

School of Electrical and Computer Engineering Aristotle University of Thessaloniki University Campus Thessaloniki, 541 24 Greece

mob. +30 6977447820 tel. +30 2310996317

On 13 June 2018 at 19:58, Alex Kaszynski notifications@github.com wrote:

Started working on this and discovered why it hangs when starting.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/akaszynski/pyansys/issues/24#issuecomment-397011092, or mute the thread https://github.com/notifications/unsubscribe-auth/AYDNpyz-ck-JU9fDJ64KVzbEW-pAm71eks5t8UTFgaJpZM4UTxpC .

akaszynski commented 6 years ago

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

csevast commented 6 years ago

Dear Alex,

I had a lot of other works to do and I didn't have a lot of time. Anyway, I checked the documentation. I started already to work on CORBA, something difficult for me because of lack of any previous experience. I started with omniORBpy and I will try to do something. There is already some interest in XANSYS community list about the subject ANSYS with Python. The new version of pyansys is still problematic for my Anaconda distribution of Python on Windows 10. So, whenever I will have news I will inform you.

Sincerely Christos Sevastiadis

Electrical Engineering Diploma Electroacoustics PhD Laboratory Teacher

AVLab - Laboratory unit of Electroacoustics and Television Systems School of Electrical and Computer Engineering Aristotle University of Thessaloniki University Campus Thessaloniki, 541 24 Greece

mob. +30 6977447820 tel. +30 2310996317

akaszynski commented 6 years ago

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?

csevast commented 6 years ago

I've already prepared a windows cmd script for downloading and installing omniORBpy to the default registered Python environment. Anfortunately uses Windows Powershell for downloading and 7-zip for unziping, but it sets the environment variables for using omniORBpy in Python. It's working for me but the automatic PyPi approach is prefered. I'd started to work on omniORBpy examples but I had something else to finish and I left it for while.

Christos

Ηλεκτρολόγος Μηχανικός Διδάκτορας Ηλεκτρακουστικής Εργαστηριακός Διδάσκων

AVLab - Εργαστηριακή μονάδα Ηλεκτρακουστικής και Τηλεοπτικών Συστημάτων Τμ. Ηλεκτρολόγων Μηχανικών και Μηχανικών Υπολογιστών Αριστοτέλειο Πανεπιστήμιο Θεσσαλονίκη Πανεπιστημιούπολη Θεσσαλονίκη 541 24

κιν. 6977447820 τηλ. 2310996317

Electrical Engineering Diploma Electroacoustics PhD Laboratory Teacher

AVLab - Laboratory unit of Electroacoustics and Television Systems School of Electrical and Computer Engineering Aristotle University of Thessaloniki University Campus Thessaloniki, 541 24 Greece

mob. +30 6977447820 tel. +30 2310996317

On 17 July 2018 at 08:58, Alex Kaszynski notifications@github.com wrote:

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?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/akaszynski/pyansys/issues/24#issuecomment-405468511, or mute the thread https://github.com/notifications/unsubscribe-auth/AYDNp35WmrdGdxJYjEjQqzZbHeMTdpqCks5uHXzugaJpZM4UTxpC .

akaszynski commented 6 years ago

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.

akaszynski commented 6 years ago

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.

germa89 commented 6 years ago

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,

akaszynski commented 6 years ago

Hold off for a moment getting omniORB installed. I'm working on my own solution to package the essentials with pyansys.

germa89 commented 6 years ago

Perfect!

Let me know if you need some windows testing.

Kind regards

csevast commented 6 years ago

Unfortunately these conda installs are not from the official Continuum Anaconda channel. Also, they are available either for Pyton 2.7 or Linux only. The best solution is pip, and conda will follow.

Alex, you are going pretty fast in the subject and I can't follow you :).

Christos

Electrical Engineering Diploma Electroacoustics PhD Laboratory Teacher

AVLab - Laboratory unit of Electroacoustics and Television Systems School of Electrical and Computer Engineering Aristotle University of Thessaloniki University Campus Thessaloniki, 541 24 Greece

mob. +30 6977447820 tel. +30 2310996317

csevast commented 6 years ago

Well done!

I adapted a little bit what Alex did to run it in Windows and ANSYS 18.1. I had great results. The best should be to make some plots and return them. I don't know if CORB with this IDL can make it. Anyway, I was a little bit lost with the omniORB and omniORBpy. I installed it but I was trying to follow the tutorial with all the case studies. As I see, the colocation is enough and the IOP string is working perfect.

I was trying to do somehtin with 'ansys-mode' package in 'emacs' editor. It was supporting interactive mode with ANSYS only in Linux (UNIX). This specific solution had nothing to do with Python, but the idea of coding in an code editor and running the code in ANSYS Mechanical is missing from ANSYS Mechanical. The Workbench solution with ACT and IronPython is looking little bit strange to me and I didn't make it till now.

Anyway, Alex, you made great job. I hope that omniORBpy will become available to PyPi -realy, why it is not already there. After all, 'pyansys' can make the breakthrough in APDL coding.

I've already installed omniORBpy in my Miniconda Python installation in Windows with the attached install_omniORBpy.bat command code.

I copied the ICoMapdlUnit.idl file from C:\Program Files\ANSYS Inc\v181\ansys\customize\user to my project path.

I compiled the ICoMapdlUnit.idl file as Alex did.

omniidl -I C:\dev\Miniconda3\Lib\site-pacages\omniORB-4.2.2\idl -bpython ICoMapdlUnit.idl

I started Server Mode of ANSYS Mechanical in command line with

"%ANSYS181_DIR%\bin\%ANSYS_SYSDIR%\ansys181.exe" -aas

And I run the python code.

####################

test_code.py

######################## from omniORB import CORBA import AAS_CORBA

import os

up_path = os.getenv('USERPROFILE') orb = CORBA.ORB_init()

with open(up_path+r'\aaS_MapdlId.txt') as f: key = f.read()

mapdl = orb.string_to_object(key)

commands = ['/title, Transmission Loss of Muffle', '/show,png', '/nopr', '/PREP7', 'rho=1.2041 ! air mass density', 'c0=343.24 ! air sound speed', 'z0=rhoc0', 'freqE=3000 ! highest working frequency', 'wave=c0/freqE ! wavelength at the highest frequency', 'p=1', 'vn=-p/(rhoc0) ! normal velocity excitation', ' ! define element and materials', 'et,1,221,,1 ! tet uncoupled element', 'mp,dens,1,rho ! material ', 'mp,sonc,1,c0', ' ! create the model', 'rapipe=0.0174625', 'lpipe=0.104775', 'rchamb=0.0766445', 'lchamb=0.2032', 'cylind,0,rapipe,0,lpipe,0,180', 'cylind,0,rchamb,lpipe,lpipe+lchamb,0,180', 'cylind,0,rapipe,lpipe+lchamb,2lpipe+lchamb,0,180', 'vsel,all', 'vglue,all', ' ! mesh the geometry', 'h=wave/10 ! 10 elements/per wavelength', 'esize,h', 'type,1', 'mat,1', 'vmesh,all', 'nummrg,all', ' ! define excitation and boundary conditions on inlet and outlet port', 'nsel,s,loc,z,0 ! nodes on inlet', 'sf,all,port,1 ! inlet port', 'sf,all,shld,vn ! normal velocity', 'sf,all,impd,z0 ! impedance boundary on inlet ', 'nsel,s,loc,z,2lpipe+lchamb ! nodes on outlet', 'sf,all,port,2 ! outlet port', 'sf,all,inf ! radiation boundary on outlet ', 'alls', 'fini', ' ! perform solutions', '/solu', 'antype,harmic', 'hropt,auto', 'kbc,1', 'harf,0,freqE', 'nsub,60 ! 50 Hz interval with 60 steps ', 'solve', 'finish', '! post-processing', '/post1', 'spower,1,2 ! calculate sound power data', 'plst,file0102,a2p,tl ! plot transmission loss', 'fini']

for cmd in commands: print(mapdl.executeCommandToString(cmd))

############################ OUTPUT ############################ Python 3.6.6 |Anaconda, Inc.| (default, Jun 28 2018, 11:27:44) [MSC v.1900 64 bit (AMD64)] on Hades, Standard

TITLE=\n Transmission Loss of Muffle\n /SHOW SWITCH PLOTS TO PNG - RASTER MODE.

ANSYS - ENGINEERING ANALYSIS SYSTEM RELEASE Release 18.1 18.1 \n ANSYS Academic Teaching Advanced\n 01039803 VERSION=WINDOWS x64 15:52:33 JUL 19, 2018 CP= 0.391\n\n Transmission Loss of Muffle\n\n\n\n ANSYS ANALYSIS DEFINITION (PREP7) \n\n ENTER /SHOW,DEVICE-NAME TO ENABLE GRAPHIC DISPLAY\n ENTER FINISH TO LEAVE PREP7\n PRINTOUT KEY SET TO /GOPR (USE /NOPR TO SUPPRESS) PARAMETER RHO = 1.204100000 PARAMETER C0 = 343.2400000 PARAMETER Z0 = 413.2952840 PARAMETER FREQE = 3000.000000 PARAMETER WAVE = 0.1144133333 PARAMETER P = 1.000000000 PARAMETER VN = -0.2419577573E-02

ELEMENT TYPE 1 IS FLUID221 3-D ACOUSTIC FLUID\n KEYOPT( 1- 6)= 0 1 0 0 0 0\n KEYOPT( 7-12)= 0 0 0 0 0 0\n KEYOPT(13-18)= 0 0 0 0 0 0\n\n CURRENT NODAL DOF SET IS PRES\n THREE-DIMENSIONAL MODEL MATERIAL 1 DENS = 1.204100 MATERIAL 1 SONC = 343.2400

PARAMETER RAPIPE = 0.1746250000E-01 PARAMETER LPIPE = 0.1047750000 PARAMETER RCHAMB = 0.7664450000E-01 PARAMETER LCHAMB = 0.2032000000 CREATE A CYLINDRICAL VOLUME WITH\n INNER RADIUS = 0.000000000\n OUTER RADIUS = 0.1746250000E-01\n STARTING THETA ANGLE = 0.000000000\n ENDING THETA ANGLE = 180.0000000\n END Z-DISTANCES FROM 0.000000000 TO 0.1047750000\n\n OUTPUT VOLUME = 1 CREATE A CYLINDRICAL VOLUME WITH\n INNER RADIUS = 0.000000000\n OUTER RADIUS = 0.7664450000E-01\n STARTING THETA ANGLE = 0.000000000\n ENDING THETA ANGLE = 180.0000000\n END Z-DISTANCES FROM 0.1047750000 TO 0.3079750000\n\n OUTPUT VOLUME = 2 CREATE A CYLINDRICAL VOLUME WITH\n INNER RADIUS = 0.000000000\n OUTER RADIUS = 0.1746250000E-01\n STARTING THETA ANGLE = 0.000000000\n ENDING THETA ANGLE = 180.0000000\n END Z-DISTANCES FROM 0.3079750000 TO 0.4127500000\n\n OUTPUT VOLUME = 3 ALL SELECT FOR ITEM=VOLU COMPONENT=\n IN RANGE 1 TO 3 STEP 1\n\n 3 VOLUMES (OF 3 DEFINED) SELECTED BY VSEL COMMAND. GLUE VOLUMES\n INPUT VOLUMES = 1 2 3\n INPUT VOLUMES WILL BE DELETED IF POSSIBLE\n OUTPUT VOLUMES = 1 4 5

PARAMETER H = 0.1144133333E-01 DEFAULT ELEMENT DIVISIONS PER LINE BASED ON ELEMENT SIZE = 0.114E-01 ELEMENT TYPE SET TO 1 MATERIAL NUMBER SET TO 1 GENERATE NODES AND ELEMENTS IN ALL SELECTED VOLUMES\n\n Initiating meshing of volume 1 exterior.\n\n Meshing of volume 1 exterior is complete. Facet count = 198.\n\n Initiating meshing of volume 1 interior.\n Estimated number of elements to fill this volume = 290.\n Estimated number of nodes = 400.\n\n Begin meshing of volume 1\n Completed pre-check of triangle facets\n\n Meshing of volume 1 is complete.\n Now storing 124 nodes and 220 elements.\n\n Initiating meshing of volume 4 exterior.\n\n Meshing of volume 4 exterior is complete. Facet count = 198.\n\n Initiating meshing of volume 4 interior.\n Estimated number of elements to fill this volume = 290.\n Estimated number of nodes = 400.\n\n Begin meshing of volume 4\n Completed pre-check of triangle facets\n\n Meshing of volume 4 is complete.\n Now storing 126 nodes and 222 elements.\n\n Initiating meshing of volume 5 exterior.\n\n Meshing of volume 5 exterior is complete. Facet count = 1518.\n\n Initiating meshing of volume 5 interior.\n Estimated number of elements to fill this volume = 8600.\n Estimated number of nodes = 10800.\n\n Begin meshing of volume 5\n Completed pre-check of triangle facets\n\n Meshing of volume 5 is complete.\n Now storing 8278 nodes and 7308 elements.\n\n NUMBER OF VOLUMES MESHED = 3\n MAXIMUM NODE NUMBER = 12298\n MAXIMUM ELEMENT NUMBER = 7750

MERGE COINCIDENT NODES WITHIN TOLERANCE OF 0.10000E-03\n\n NOTE CP = 0.750 TIME= 15:52:34\n Zero nodes were merged.\n\n MERGE IDENTICAL MATERIALS WITHIN TOLERANCE OF 0.10000E-06\n\n MERGE IDENTICAL ELEMENT TYPES\n\n MERGE IDENTICAL REAL CONSTANT SETS WITHIN TOLERANCE OF 0.10000E-06\n\n MERGE IDENTICAL SECTION ID SET WITHIN TOLERANCE OF 0.10000E-06\n\n MERGE IDENTICAL ELEMENTS\n\n ZERO ELEMENTS WERE MERGED\n\n MERGE IDENTICAL COUPLED DOF SETS\n\n MERGE IDENTICAL CONSTRAINT EQUATIONS WITHIN TOLERANCE OF 0.10000E-06\n\n MERGE COINCIDENT KEYPOINTS WITHIN TOLERANCE OF 0.10000E-03\n\n NO KEYPOINTS WERE MERGED SELECT FOR ITEM=LOC COMPONENT=Z BETWEEN 0.0000 AND 0.0000\n KABS= 0. TOLERANCE= 0.100000E-05\n\n 32 NODES (OF 12298 DEFINED) SELECTED BY NSEL COMMAND. GENERATE SURFACE LOAD PORT ON SURFACE DEFINED BY ALL SELECTED NODES\n PORT NUMBER = 1.\n\n NUMBER OF PORT ELEMENT FACE LOADS STORED = 11 GENERATE SURFACE LOAD SHLD ON SURFACE DEFINED BY ALL SELECTED NODES\n VALUES = -2.419577573E-03 0.00000000\n\n NUMBER OF SHLD ELEMENT FACE LOADS STORED = 11 GENERATE SURFACE LOAD IMPD ON SURFACE DEFINED BY ALL SELECTED NODES\n VALUES = 413.295284 0.00000000\n\n NUMBER OF IMPD ELEMENT FACE LOADS STORED = 11 SELECT FOR ITEM=LOC COMPONENT=Z BETWEEN 0.41275 AND 0.41275\n KABS= 0. TOLERANCE= 0.206375E-02\n\n 32 NODES (OF 12298 DEFINED) SELECTED BY NSEL COMMAND. GENERATE SURFACE LOAD PORT ON SURFACE DEFINED BY ALL SELECTED NODES\n PORT NUMBER = 2.\n\n NUMBER OF PORT ELEMENT FACE LOADS STORED = 11 SET SURFACE FLAG INF ON SURFACE DEFINED BY ALL SELECTED NODES\n\n NUMBER OF INF ELEMENT FACE FLAGS SET = 11 SELECT ALL ENTITIES OF TYPE= ALL AND BELOW ROUTINE COMPLETED CP = 0.984\n\n

ANSYS SOLUTION ROUTINE PERFORM A HARMONIC ANALYSIS\n THIS WILL BE A NEW ANALYSIS PERFORM A FULL HARMONIC RESPONSE ANALYSIS STEP BOUNDARY CONDITION KEY= 1 HARMONIC FREQUENCY RANGE - END= 3000.0 BEGIN= 0.0000 USE 60 SUBSTEP(S) THIS LOAD STEP FOR ALL DEGREES OF FREEDOM No constraints have been defined using the D command.

FINISH SOLUTION PROCESSING\n\n\n ROUTINE COMPLETED CP = 160.766\n\n\n\n NOTE CP = 160.766 TIME= 15:54:05\n A total of 1 warnings and errors written to C:\Users\csevast\file.err.

LIST ANSYS Sound Power Data at Port 1 and Port 2\n\n Frequency LwIn01 (dB) LwOut01 (dB) RL (dB) Alpha TL (dB)\n 50.0000 0.576290E+02 0.564231E+02 0.120595E+01 0.242462E+00 0.615667E+01\n 100.0000 0.576290E+02 0.572833E+02 0.345737E+00 0.765226E-01 0.111722E+02\n 150.0000 0.576290E+02 0.574627E+02 0.166295E+00 0.375669E-01 0.142647E+02\n 200.0000 0.576290E+02 0.575269E+02 0.102115E+00 0.232385E-01 0.163472E+02\n 250.0000 0.576290E+02 0.575563E+02 0.727066E-01 0.166019E-01 0.177943E+02\n 300.0000 0.576290E+02 0.575715E+02 0.575099E-01 0.131549E-01 0.187835E+02\n 350.0000 0.576290E+02 0.575795E+02 0.495043E-01 0.113341E-01 0.194069E+02\n 400.0000 0.576290E+02 0.575831E+02 0.459336E-01 0.105209E-01 0.197127E+02\n 450.0000 0.576290E+02 0.575832E+02 0.457825E-01 0.104864E-01 0.197220E+02\n 500.0000 0.576290E+02 0.575800E+02 0.490449E-01 0.112295E-01 0.194339E+02\n 550.0000 0.576290E+02 0.575723E+02 0.567030E-01 0.129715E-01 0.188258E+02\n 600.0000 0.576290E+02 0.575576E+02 0.714403E-01 0.163152E-01 0.178507E+02\n 650.0000 0.576290E+02 0.575289E+02 0.100132E+00 0.227925E-01 0.164142E+02\n 700.0000 0.576290E+02 0.574660E+02 0.163032E+00 0.368437E-01 0.143347E+02\n 750.0000 0.576290E+02 0.572887E+02 0.340340E+00 0.753742E-01 0.112250E+02\n 800.0000 0.576290E+02 0.564196E+02 0.120947E+01 0.243074E+00 0.613717E+01\n 850.0000 0.576290E+02 0.304054E+02 0.272236E+02 0.998105E+00 0.359488E-02\n 900.0000 0.576290E+02 0.565265E+02 0.110255E+01 0.224209E+00 0.649056E+01\n 950.0000 0.576290E+02 0.573113E+02 0.317731E+00 0.705481E-01 0.115003E+02\n\n Frequency LwIn01 (dB) LwOut01 (dB) RL (dB) Alpha TL (dB)\n 1000.0000 0.576290E+02 0.574781E+02 0.150914E+00 0.341525E-01 0.145970E+02\n 1050.0000 0.576290E+02 0.575393E+02 0.897681E-01 0.204577E-01 0.166899E+02\n 1100.0000 0.576290E+02 0.575687E+02 0.603198E-01 0.137931E-01 0.181519E+02\n 1150.0000 0.576290E+02 0.575855E+02 0.435690E-01 0.998199E-02 0.191589E+02\n 1200.0000 0.576290E+02 0.575960E+02 0.330315E-01 0.757693E-02 0.198022E+02\n 1250.0000 0.576290E+02 0.576028E+02 0.262033E-01 0.601536E-02 0.201294E+02\n 1300.0000 0.576290E+02 0.576068E+02 0.222277E-01 0.510505E-02 0.201610E+02\n 1350.0000 0.576290E+02 0.576078E+02 0.212023E-01 0.487012E-02 0.198967E+02\n 1400.0000 0.576290E+02 0.576049E+02 0.241445E-01 0.554405E-02 0.193145E+02\n 1450.0000 0.576290E+02 0.575954E+02 0.336041E-01 0.770776E-02 0.183650E+02\n 1500.0000 0.576290E+02 0.575732E+02 0.558153E-01 0.127697E-01 0.169523E+02\n 1550.0000 0.576290E+02 0.575203E+02 0.108770E+00 0.247341E-01 0.148901E+02\n 1600.0000 0.576290E+02 0.573654E+02 0.263604E+00 0.588917E-01 0.117737E+02\n 1650.0000 0.576290E+02 0.565813E+02 0.104777E+01 0.214361E+00 0.656073E+01\n 1700.0000 0.576290E+02 0.363337E+02 0.212954E+02 0.992579E+00 0.107684E-01\n 1750.0000 0.576290E+02 0.567747E+02 0.854341E+00 0.178579E+00 0.727042E+01\n 1800.0000 0.576290E+02 0.574098E+02 0.219197E+00 0.492194E-01 0.124124E+02\n 1850.0000 0.576290E+02 0.575391E+02 0.898854E-01 0.204842E-01 0.155888E+02\n 1900.0000 0.576290E+02 0.575820E+02 0.469903E-01 0.107616E-01 0.177643E+02\n\n Frequency LwIn01 (dB) LwOut01 (dB) RL (dB) Alpha TL (dB)\n 1950.0000 0.576290E+02 0.575987E+02 0.303595E-01 0.696616E-02 0.193199E+02\n 2000.0000 0.576290E+02 0.576047E+02 0.243098E-01 0.558190E-02 0.204348E+02\n 2050.0000 0.576290E+02 0.576059E+02 0.231599E-01 0.531857E-02 0.212036E+02\n 2100.0000 0.576290E+02 0.576047E+02 0.243331E-01 0.558725E-02 0.216767E+02\n 2150.0000 0.576290E+02 0.576026E+02 0.264546E-01 0.607289E-02 0.218792E+02\n 2200.0000 0.576290E+02 0.576003E+02 0.287701E-01 0.660267E-02 0.218153E+02\n 2250.0000 0.576290E+02 0.575980E+02 0.310190E-01 0.711694E-02 0.214686E+02\n 2300.0000 0.576290E+02 0.575954E+02 0.336356E-01 0.771496E-02 0.207936E+02\n 2350.0000 0.576290E+02 0.575904E+02 0.385798E-01 0.884398E-02 0.196949E+02\n 2400.0000 0.576290E+02 0.575765E+02 0.525202E-01 0.120204E-01 0.179714E+02\n 2450.0000 0.576290E+02 0.575254E+02 0.103638E+00 0.235811E-01 0.151509E+02\n 2500.0000 0.576290E+02 0.572074E+02 0.421592E+00 0.925122E-01 0.982267E+01\n 2550.0000 0.576290E+02 0.375274E+02 0.201016E+02 0.990231E+00 0.193797E-02\n 2600.0000 0.576290E+02 0.571715E+02 0.457537E+00 0.999922E-01 0.948374E+01\n 2650.0000 0.576290E+02 0.574227E+02 0.206342E+00 0.464009E-01 0.118617E+02\n 2700.0000 0.576290E+02 0.571276E+02 0.501434E+00 0.109043E+00 0.879657E+01\n 2750.0000 0.576290E+02 0.538591E+02 0.376996E+01 0.580237E+00 0.222816E+01\n 2800.0000 0.576290E+02 0.404769E+02 0.171521E+02 0.980734E+00 0.252833E-01\n 2850.0000 0.576290E+02 0.479555E+02 0.967352E+01 0.892193E+00 0.411725E+00\n\n Frequency LwIn01 (dB) LwOut01 (dB) RL (dB) Alpha TL (dB)\n 2900.0000 0.576290E+02 0.410614E+02 0.165676E+02 0.977959E+00 0.310853E-01\n 2950.0000 0.576290E+02 0.421661E+02 0.154629E+02 0.971575E+00 0.640987E-01\n 3000.0000 0.576290E+02 0.501097E+02 0.751933E+01 0.822962E+00 0.751291E+00 CUMULATIVE DISPLAY NUMBER 1 WRITTEN TO FILE file000.png - RASTER MODE.\n DISPLAY TITLE=\n Transmission Loss of Muffle\n\n TRANSMISSION LOSS FROM PORT 1 TO 2 \n\n FREQUENCY (Hz) TRANSMISSION LOSS (dB)\n 50.000000 6.1566700\n 100.00000 11.172200\n 150.00000 14.264700\n 200.00000 16.347200\n 250.00000 17.794300\n 300.00000 18.783500\n 350.00000 19.406900\n 400.00000 19.712700\n 450.00000 19.722000\n 500.00000 19.433900\n 550.00000 18.825800\n 600.00000 17.850700\n 650.00000 16.414200\n 700.00000 14.334700\n 750.00000 11.225000\n 800.00000 6.1371700\n 850.00000 0.35948800E-02\n 900.00000 6.4905600\n 950.00000 11.500300\n 1000.0000 14.597000\n 1050.0000 16.689900\n 1100.0000 18.151900\n 1150.0000 19.158900\n 1200.0000 19.802200\n 1250.0000 20.129400\n 1300.0000 20.161000\n 1350.0000 19.896700\n 1400.0000 19.314500\n 1450.0000 18.365000\n 1500.0000 16.952300\n 1550.0000 14.890100\n 1600.0000 11.773700\n 1650.0000 6.5607300\n 1700.0000 0.10768400E-01\n 1750.0000 7.2704200\n 1800.0000 12.412400\n 1850.0000 15.588800\n 1900.0000 17.764300\n 1950.0000 19.319900\n 2000.0000 20.434800\n 2050.0000 21.203600\n 2100.0000 21.676700\n 2150.0000 21.879200\n 2200.0000 21.815300\n 2250.0000 21.468600\n 2300.0000 20.793600\n 2350.0000 19.694900\n 2400.0000 17.971400\n 2450.0000 15.150900\n 2500.0000 9.8226700\n 2550.0000 0.19379700E-02\n 2600.0000 9.4837400\n 2650.0000 11.861700\n 2700.0000 8.7965700\n 2750.0000 2.2281600\n 2800.0000 0.25283300E-01\n 2850.0000 0.41172500\n 2900.0000 0.31085300E-01\n 2950.0000 0.64098700E-01\n 3000.0000 0.75129100 ###################################

################## install_omniORBpy.bat ################## @ECHO OFF ECHO Install 'omniORBpy v4.2.2' into default (base) Python environment ECHO "Coded by Christos Sevastiadis csevast@auth.gr" ECHO Python 3 has to be registered for all users. ECHO Windows Powershell has to be installed. ECHO 7-zip has to be installed and set to the PATH variable. ECHO This batch command file has to be executed in an elevated Command, which has to be run as Administrator. ECHO (2018) ECHO

ECHO Initialize set _PATH=%PATH% set _DOWNLOADS_DIR=%TEMP% for /F "tokens=5 delims=\" %%A IN ('reg.exe query "HKLM\SOFTWARE\Python\PythonCore"') DO set _PYTHON_VERSION=%%A for /F "skip=2 tokens=3" %%A IN ('reg.exe query "HKLM\SOFTWARE\Python\PythonCore\%_PYTHON_VERSION%\InstallPath"') DO set "_PYTHON_DIR=%%A" set _OMNIORBPY_VERSION=4.2.2 set _OMNIORBPY_FILENAME=omniORBpy-%_OMNIORBPY_VERSION%-win64-python%_PYTHON_VERSION%.zip set _OMNIORBPY_URL= https://sourceforge.net/projects/omniorb/files/omniORBpy/omniORBpy-%_OMNIORBPY_VERSION% set _OMNIORBPY_PYTHONPATH=%_PYTHON_DIR%\Lib\site-packages\omniORBpy-%_OMNIORBPY_VERSION%\lib\python;%_PYTHON_DIR%\Lib\site-packages\omniORBpy-%_OMNIORBPY_VERSION%\lib\x86_win32;

ECHO Remove previous omniORBpy installation rmdir /S /Q %_PYTHON_DIR%\Lib\site-packages\omniORBpy-%_OMNIORBPY_VERSION% CALL SET "_PATH=%%_PATH:%_PYTHON_DIR%\Lib\site-packages\omniORBpy-%_OMNIORBPY_VERSION%\bin\x86_win32;=%%" CALL SETX /M PATH "%_PATH%" IF DEFINED PYTHONPATH ( SET _PYTHONPATH=%PYTHONPATH% CALL SET "_PYTHONPATH=%%_PYTHONPATH:%_OMNIORBPY_PYTHONPATH%=%%" CALL SETX PYTHONPATH "%_PYTHONPATH%" )

ECHO Download omniORBpy set _URL=%_OMNIORBPY_URL%/%_OMNIORBPY_FILENAME% set _OUTPUT="%_DOWNLOADS_DIR%\%_OMNIORBPY_FILENAME%" "%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\powershell.exe" -command "& { Start-BitsTransfer -Source %_URL% -Destination %_OUTPUT% }"

ECHO Unzip omniORBpy files to default (base) Python environment set PATH=%PATH%;%_PYTHON_DIR% rem "%_PYTHON_DIR%\python.exe" -m zipfile -e "%_DOWNLOADS_DIR%\%_OMNIORBPY_FILENAME%" "%_PYTHON_DIR%\Lib\site-packages\" 7z x "%_DOWNLOADS_DIR%\%_OMNIORBPY_FILENAME%" -o"%_PYTHON_DIR%\Lib\site-packages\"

ECHO Add PATH reference to omniORB folder set _PATH=%_PATH%%_PYTHON_DIR%\Lib\site-packages\omniORBpy-%_OMNIORBPY_VERSION%\bin\x86_win32; setx /M PATH "%_PATH%"

ECHO Add PYTHONPATH references to omniORBpy folders IF NOT DEFINED PYTHONPATH ( SETX PYTHONPATH "%_OMNIORBPY_PYTHONPATH%" ) ELSE ( SETX PYTHONPATH "%_PYTHONPATH%%_OMNIORBPY_PYTHONPATH%" )

ECHO Clean up temp files DEL "%_DOWNLOADS_DIR%\%_OMNIORBPY_FILENAME%"

ECHO Reset environment variables set _PATH= set _DOWNLOADS_DIR= set _PYTHON_VERSION= set _PYTHON_DIR= set _OMNIORBPY_VERSION= set _OMNIORBPY_FILENAME= set _OMNIORBPY_URL= set _OMNIORBPY_PYTHONPATH=

###################### EOL ######################

Christos Sevastiadis

Electrical Engineering Diploma Electroacoustics PhD Laboratory Teacher

AVLab - Laboratory unit of Electroacoustics and Television Systems School of Electrical and Computer Engineering Aristotle University of Thessaloniki University Campus Thessaloniki, 541 24 Greece

mob. +30 6977447820 tel. +30 2310996317

akaszynski commented 6 years ago

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?

akaszynski commented 6 years ago

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.

germa89 commented 6 years ago

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!

csevast commented 6 years ago

Dear Alex,

Unfortunately it didn't work on my system. I have to following: """ C:\dev\Miniconda3\envs\python36>python "G:\My Drive\python\python-projects\pyansys\test_CORBA.py" ansys_loc: C:\Program Files\ANSYS Inc\v181\ansys\bin\winx64\ANSYS181.exe command: "C:\Program Files\ANSYS Inc\v181\ansys\bin\winx64\ANSYS181.exe" -aas -i tmp.inp -o out.txt -b Starting ANSYS... The system cannot find the file specified. ANSYS started Traceback (most recent call last): File "G:\My Drive\python\python-projects\pyansys\test_CORBA.py", line 44, in mapdl.executeCommand('/prep7') File "C:\dev\Miniconda3\envs\python36\lib\site-packages\ansys_corba\ICoMapdlUnit_idl.py", line 203, in executeCommand return self._obj.invoke("executeCommand", _0_AAS_CORBA.MAPDL.Solvers.ICoMapdlUnit._d_executeCommand, args) omniORB.CORBA.TRANSIENT: CORBA.TRANSIENT(omniORB.TRANSIENT_ConnectFailed, CORBA.COMPLETED_NO)

C:\dev\Miniconda3\envs\python36> """

At the "The system cannot find the file specifiec." I press Control-C to continue. Before running your code I have to remove my PATH setting for my omniORBpy installation. I didn't have time to work more to find what is going on.

Christos Sevastiadis

Electrical Engineering Diploma Electroacoustics PhD Laboratory Teacher

AVLab - Laboratory unit of Electroacoustics and Television Systems School of Electrical and Computer Engineering Aristotle University of Thessaloniki University Campus Thessaloniki, 541 24 Greece

mob. +30 6977447820 tel. +30 2310996317

germa89 commented 6 years ago

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,

akaszynski commented 6 years ago

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.

akaszynski commented 6 years ago

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.

csevast commented 6 years ago

Dear Alex,

Great work. I checked it and it is working fine. I hope that soon I will test it more intensively.

Sincerely Christos Sevastiadis

Electrical Engineering Diploma Ηλεκτρολόγος Μηχανικός Διδάκτορας Ηλεκτρακουστικής Εργαστηριακός Διδάσκων

Electroacoustics PhD Laboratory Teacher

AVLab - Laboratory unit of Electroacoustics and Television Systems School of Electrical and Computer Engineering Aristotle University of Thessaloniki University Campus Thessaloniki, 541 24 Greece

mob. +30 6977447820 tel. +30 2310996317