Embedding python in ANSYS: Anyone tried it?

Berthold Höllmann bhoel at web.de
Thu Apr 8 14:36:39 EDT 2004


Hello,

"Satish Chimakurthi" <skchim0 at engr.uky.edu> writes:

> Hello Mr. Berthold,
>
> A few months ago, I contemplated interfacing/wrapping ANSYS to
> Python. I looked at SWIG, BABEL, Boost.Python for this purpose at
> that time, only to realise that such direct wrapping is not possible
> since ANSYS libraries are basically Fortran based. I thought of the
> following work-around to the problem.
>
> ANSYS allows users to compile their own customized version. It gives
> the user access to its vast libraries with the help of some UPF
> routines ( look at ANSYS-UPF documentation here
> http://www.cesup.ufrgs.br/ansys/prog_55/g-upf/UPS1.htm ). You may be
> knowing this. There is a file called ANSCUSTOM in
> "/usr/local/ansys/v71/ansys/customize/user" directory. First, I
> wrote a "Makefile" and a "make.inc" file based on the information in
> ANSCUSTOM. I then wrote a Fortran code in which I used all the UPF
> routines I needed to be used with ANSYS. I compiled the Fortran code
> with "make.inc" simultaneously to get a binary executable. And
> that's it, I was ready to go. The binary executable could be
> executed using a specific command which could be found in ANSYS
> Installation and Configuration manual, I think. In my case, I was
> using ANSYS 7.1, so, I had to execute it as: "anscust71 -custom
> ./executable -p ANSYSRF".
>
> Now, with all that I described above, link between Fortran and ANSYS
> has become possible. You can look at F2PY (Fortran to Python
> Interface Generator) here http://cens.ioc.ee/projects/f2py2e/ to
> have an interface between your Python script and Fortran code that
> you would be writing for the purpose. At the moment, my
> Python-Fortran interface is very loose. I use Fortran to ANSYS
> mostly and do postprocessing work in Python.

This is what I am thinking about. Our final aim is to wrap as much
functionality of ANSYS to be abble to pre- and postprocess our
calculations with the help of Python modules. I have basic knowledge
about writing UPF in ANSYS and some experience in writing Python
extension modules. I now started wrapping ANSYS UPF routines using
f2py and am already able to call some basic python examples from
ANSYS. I mainly asked because wrapping a sufficiant amout of the ANSYS
interface routines is a lot of stupid typing work, and if sombody else
did it before, it would be nice to share the work :-)

I won't link my own ANSYS executable, but save time, space and efforts
by building a dynamic load shared library for ansys which is available
since about ANSYS 6.0 or 6.1. I will do my work using ANSYS 8.1.

> Please let me know if you think of any other ideas about wrapping
> Python and ANSYS directly. I would appreciate your assistance.

A nice thing to try when the basics run is to provide a python
interface for generating user elements etc. in Python. But I'm afraid
that would require some naugthy magic, is error prone and too much for
the first step.

Kind regards
Berthold Höllmann
-- 
bhoel at web.de / http://starship.python.net/crew/bhoel/



More information about the Python-list mailing list