2

I'm using PyCharm Community V2021.1.3 and I would like to integrate Abaqus CAE (2021) with PyCharm so that I can write/debug/run scripts for Abaqus.

Currently I write code in PyCharm/Sublime or some other editor and then run the script through either the command line function or within CAE. The real issue that I have is debugging the script. Abaqus comes with it's own IDE (Abaqus PDE) but lets be honest.... there's A LOT of room for improvement and it absolutely sucks for debugging. In the past I have ended up copying/pasting sections of code directly into CAE kernal commands just to try and pinpoint where issues might be. Far from ideal.

My PyCharm installation is using a Python 3.5 interpreter. I try to keep my projects segregated as I often have to switch between various packages and versions depending on what I'm working on. I would ideally like to create a new virtual environment that hosts the Abaqus version of Python (2.7.3) and packages associated with that version of Python. Generally I use Conda to create/maintain virtual environments however, in this case, Abaqus has installed the relevant version of Python and several packages as part of the Abaqus installation procedure. Is it necessary for me to create a new virtual environment if the Python version and packages I need are already installed locally? If I point the interpreter directly to the Abaqus installed Python version and then screw up later is that going to be a major fix? Normally if something goes wrong in a virtual environment (mixed up package requirements or that) I just delete the environment and set up a fresh one...

I'm fairly new to PyCharm (<6 months) and so I'm unsure of how best to integrate these two pieces of software (PyCharm and Abaqus) without completely messing up my Abaqus installation. This similar question: How integrate Abaqus python libraries into a project hosted in PyCharm suggests adding a new system path (PYTHONPATH) to system variables. Restarting PyCharm and then pointing the Pycharm interpreter to the system interpreter. That kind of makes sense to me but I'm not sure whether that will effect my existing virtual environments for Python 3.5? The whole point of having virtual environments is that you don't run into issues with package compatibility so I think it should be OK? If I set up a new virtual environment for Python 2.7.3 (same as the abaqus installation) and get a range of packages associated with that python version then I'll still be lacking some of the Abaqus specific packages required for checking types etc. That's why the previous post has probably recommended pointing the interpreter directly to the Abaqus installation. Is there a way to clone that version of Python and packages to a new conda virtual? Any help, tips, relevant posts etc. would be greatly appreciated.

  • I've solved this somewhat by using the abaqus command line method. Full answer here: https://stackoverflow.com/questions/22783866/passing-variables-to-a-python-script-file-using-abaqus-python-2-6-2/70171598#70171598 – Alison O' Connor Nov 30 '21 at 17:31

1 Answers1

0

It is impossible for us to debug the abaqus/python script since we don't have the access to the abaqus/python source code. But there is an alternative way to make things better, if type hints of the abaqus/python functions are provided, it is much more easier to debug the script. Fortunately, abaqus provides the documentation for almost all of the python functions in its website, based in the online documentation, I restructured the abaqus/python classes to provide type hints for the abaqus/python functions.

According to this consideration, I have developed a package named "pyabaqus" to provide type hints for abaqus/python scripting and submit the script file to abaqus kernel, you can check it in pyabaqus or github.com/Haiiliin/pyabaqus, hopes it helps you.

Hailin Wang
  • 11
  • 1
  • 1