Skip to main content

This python module provides minimum support for connecting to an ANSYS APDL server using Python. While it is designed to be used as a support module to support pyansys, it can be used individually to send text commands to an APDL instance, but with none of the syntax checking or error handling pyansys uses. In short, if you find yourself here, install pyansys unless you really want a quick and dirty solution to driving ANSYS APDL from Python.

This module relies on documentation provided by ANSYS APDL and uses compiled libraries using both source file from omniORB. See the shell files on the GitHub repository for Linux build instructions. Building for Windows was a nightmare.

Installation

Pre-compiled binary files are available for Python 2.7, 3.5, and 3.6 for Linux and Windows. Open an issue if you need another version. Python 3.7 is unavailable as the source isn’t compiling. Wait until 4.2.3 or greater is released. Contact the maintainer at omniORB.

Installation is simply:

pip install ansys_corba

Usage

Once again, you really should be using pyansys. It handles figuring out where the mapdl_broadcasts.txt file is and when to open a connection with the server. If you’d rather live on the wild side, here’s how you’d open ANSYS, connect to a CORBA server, and send over a few commands:

import sys
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)

# make temporary input file to stop ansys from prompting the user
with open('tmp.inp', 'w') as f:
    f.write('FINISH')

# start ANSYS
command = '"%s" -aas -i tmp.inp -o out.txt -b' % ansys_loc
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:
                    print('ANSYS started')
                    break
                time.sleep(0.1)
    except KeyboardInterrupt:
        sys.exit()

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

There’s several things that could break here, for example, your path to ANSYS, or finding the mapdl_broadcasts.txt file. If this python script isn’t running in the same directory as ANSYS, it will hang until you kill the process or exit it with a keyboard interrupt.

Further Documentation

Once you’ve opened a connection to ANSYS, there’s really only three commands that you need to use. This documentation was shamelessly taken from sharcnet.

  • executeCommand:

    Issues a command to the connected Mechanical APDL session. Output from the command is not returned.

  • executeCommandToString

    Issues a command to the connected Mechanical APDL session and returns the output as a string.

  • terminate

    Terminates the connected Mechanical APDL as a Server session.

See the sharcnet documentation for more details

Notes

Installing from source is not possible using PyPi as the shared libraries need to be compiled outside of Python. I’ve included docker_buildlinux.sh and docker.sh which can be used to build the source code for Linux. Building for Windows is more complicated and requires following the readme within the omniorb source along with some trial and error.

License and Acknowledgments

This code is licensed under the MIT license.

This module, ansys_corba makes no commercial claim over ANSYS whatsoever. This tool extends the functionality of ANSYS by adding a python interface in both file interface as well as interactive scripting without changing the core behavior or license of the original software. The use of the interactive APDL control of ansys_corba requires a legally licensed local copy of ANSYS.

Also, this module wouldn’t be possible without omniORB as most of the source code is directly take from omniORBpy with only minor modifications to the file structure and the addition of documentation specific to ANSYS.

Metadata

Release files for ansys-corba 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for ansys-corba 0.1.1
File
ansys_corba-0.1.1-cp38-none-win_amd64.whl CPython 3.8 none Windows x86-64 Details
ansys_corba-0.1.1-cp38-cp38-manylinux2010_x86_64.whl CPython 3.8 CPython 3.8 Linux glibc 2.12+ x86-64 Details
ansys_corba-0.1.1-cp37-cp37m-manylinux2010_x86_64.whl CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.12+ x86-64 Details
ansys_corba-0.1.1-cp36-cp36m-manylinux2010_x86_64.whl CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.12+ x86-64 Details
ansys_corba-0.1.1-cp35-cp35m-manylinux2010_x86_64.whl CPython 3.5 CPython 3.5 pymalloc Linux glibc 2.12+ x86-64 Details
ansys_corba-0.1.1-cp27-cp27mu-manylinux2010_x86_64.whl CPython 2.7 CPython 2.7 pymalloc wide-unicode Linux glibc 2.12+ x86-64 Details
ansys_corba-0.1.1-cp27-cp27m-manylinux2010_x86_64.whl CPython 2.7 CPython 2.7 pymalloc Linux glibc 2.12+ x86-64 Details

Total release size: 34.8 MB

Release files / ansys_corba-0.1.1-cp38-none-win_amd64.whl

Download URL ansys_corba-0.1.1-cp38-none-win_amd64.whl
Size 1.1 MB
Tags CPython 3.8 Windows x86-64
SHA-256 checksum
How to use checksums
678fafd9ebbeb2f8f6e08a1f107d867ff84483a4b352234c5e6bc5ad3535ab2a
BLAKE2b-256 checksum
How to use checksums
f1379f482fefe1b14bcc3293b9aa28f76a1b0cd78646f5f214c97a012bc3860d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.3

Release files / ansys_corba-0.1.1-cp38-cp38-manylinux2010_x86_64.whl

Download URL ansys_corba-0.1.1-cp38-cp38-manylinux2010_x86_64.whl
Size 5.9 MB
Tags CPython 3.8 Linux glibc 2.12+ x86-64
SHA-256 checksum
How to use checksums
169a160ed8feada3e4b2e6c11b7a97adff4b923c1f125c7a47a2cc05ad015ca0
BLAKE2b-256 checksum
How to use checksums
390eab4a3f97e02f9cb81e96168aa90222680739e7d062d8c5e12598ffb5abca
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/40.6.2 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.9

Release files / ansys_corba-0.1.1-cp37-cp37m-manylinux2010_x86_64.whl

Download URL ansys_corba-0.1.1-cp37-cp37m-manylinux2010_x86_64.whl
Size 5.7 MB
Tags CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.12+ x86-64
SHA-256 checksum
How to use checksums
d69bfc4fd926b508d25fb881e98f1ae2f37981d4b4fc0968db9d5f4a276135c0
BLAKE2b-256 checksum
How to use checksums
7f3cac7ffaa546bd1d9b5223f8ee3e72bb92ee207d7c6deb71e4441929d553e4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/40.6.2 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.9

Release files / ansys_corba-0.1.1-cp36-cp36m-manylinux2010_x86_64.whl

Download URL ansys_corba-0.1.1-cp36-cp36m-manylinux2010_x86_64.whl
Size 5.6 MB
Tags CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.12+ x86-64
SHA-256 checksum
How to use checksums
0c75a1d8015d0da63578e790085bfb74088351fbef0923088e7770cca594bf91
BLAKE2b-256 checksum
How to use checksums
895f1d926792d974f07897c3f944cd642d01562c109e972cafbb07722ec503ea
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/40.6.2 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.9

Release files / ansys_corba-0.1.1-cp35-cp35m-manylinux2010_x86_64.whl

Download URL ansys_corba-0.1.1-cp35-cp35m-manylinux2010_x86_64.whl
Size 5.6 MB
Tags CPython 3.5 CPython 3.5 pymalloc Linux glibc 2.12+ x86-64
SHA-256 checksum
How to use checksums
cf1df422a37d93cae796960aabf8943f012aeec6f2635f41ed86651d1b05b267
BLAKE2b-256 checksum
How to use checksums
ec43e90b6781b7f4acddf79fdaf68f64c762b9a000aeee7b764f6c6117839bab
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/40.6.2 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.9

Release files / ansys_corba-0.1.1-cp27-cp27mu-manylinux2010_x86_64.whl

Download URL ansys_corba-0.1.1-cp27-cp27mu-manylinux2010_x86_64.whl
Size 5.5 MB
Tags CPython 2.7 CPython 2.7 pymalloc wide-unicode Linux glibc 2.12+ x86-64
SHA-256 checksum
How to use checksums
999672942bb5d8f2dbf6717e9b929e8514df010c3da16bc17f33dc892d077469
BLAKE2b-256 checksum
How to use checksums
209de6a1ddbed559ee3a0239c13162bfe48cfcdaa2b6528ccf4dc09de23ae1e2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/40.6.2 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.9

Release files / ansys_corba-0.1.1-cp27-cp27m-manylinux2010_x86_64.whl

Download URL ansys_corba-0.1.1-cp27-cp27m-manylinux2010_x86_64.whl
Size 5.5 MB
Tags CPython 2.7 CPython 2.7 pymalloc Linux glibc 2.12+ x86-64
SHA-256 checksum
How to use checksums
c416aed0df3021aaf8db94b0b589e0b694dded0f84ca6f42521aacf138b5342f
BLAKE2b-256 checksum
How to use checksums
b56a4810fec6f7da008e79eece98b731d267df88ea1f16ca2ab601c6f86d7272
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/40.6.2 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.9

Release history Release notifications | RSS feed

This release

0.1.1 This release

7 release files

0.1.0

11 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page