Abaqus has a feature to record almost all of one’s operations in Abaqus CAE environment into script in format of Python language. This feature is called Macro Manager, detailed in Abaqus/CAE manual (Section 9.5, a html page).
The recorded script is an executable function as one defined in a Python programme. And it can be executed in the interfaces provided by Abaqus to re-do the operations recorded. The interfaces include Run Script command from the main menu bar and PDE command window beneath the Viewport window (See Section 9.5 of Abaqus/CAE manual). This procedure can be utilized to improve operating efficiency in Abaqus for those routine operations.
To understand, modify and/or write a script, only basic knowledge of programming and several fundamental rules of Python format are required. For those who are familiar with Python language and scripts in Abaqus, they can even do a complete finite element analysis all by programming the operations required into a script file and executing it in Abaqus.
Relevant Resources:
- Abaqus/CAE User’s Guide: http://129.97.46.200:2080/v6.13/books/usi/default.htm
- Abaqus Scripting User’s Guide: http://129.97.46.200:2080/v6.13/books/cmd/default.htm
- Python Documentation: https://www.python.org/doc/
Basic Operations of Macro Manager
The following explanation is based on MS Windows 7 environment. And the version of used Abaqus is 6.13-1.
Start Macro Manager
To open the Macro Manager, one can click the File button from the main menu bar of Abaqus, and then click Macro Manager… in the dropdown list. It’s shown in above snapshot.
Operations in Macro Manager
There are several operations provided in the dialogue window of Macro Manager, including Create, Delete, Run, Reload and Dismiss, which are shown in the above figure. The names on the buttons are quite self-explanatory.
There are two columns in the dialogue. The left one named Name shows all the macro functions created by the user, and the right one shows the location of this macro script.
Normally, the macro script is named as abaqusMacros.py and saved in user’s HOME directory or in WORK directory of Abaqus on user’s computer. (This example is based on MS Windows 7 environment.) So, the path to this script here is,
C:\Users\{user-name}\abaqusMacros.py
This is a Python script. All the macros list in the above figure are shown as a definition of function in Python format, such as,
def AssignMaterial(): # code
Create a new macro
In the opened Macro Manager dialogue,
- click Create to start recording a new series of operations.
- Give it a name, e.g. createPlate, and
- click Continue…
then a new dialogue named Record Macro pops up, and a Stop Recording button is on the bottom of this dialogue.
Keep this dialogue openning in the background (you can move it to a corner by mouse left clicking on the title bar and holding your mouse button then moving), and perform the operations in the main window of Abaqus, then click the Stop Recording button after you finish.
After this, a new macro named createPlate will show up in the left column of Macro Manager dialogue.
Run a macro
Mouse left click in the left column of Macro Manager dialogue to select a macro, then click the Run button to re-play all the operations recorded to see what happens.
You may observe no change in the main window. Why?
Because it just re-do all the operations. And the results are all there already.
But if you close Abaqus without saving the changes and re-open it. Then open Macro Manager and select this marco to Run again. You may find that all the new changes occur agian. That’s what macros do, to replay the operations.
Other operations
I am not going to explain the Delete, Reload and Dismiss in detail. The brief explanations are as follows:
Delete: to remove a recorded macro by selecting this macro first and clicking the Delete button.
Reload: If you changed a macro in the script (abaqusMacros.py), you can reload it so that the Macro Manage can have a updated one.
Dismiss: to close the Macro Manage dialogue.
Afterword
Macro Manager provides a simple and direct way for user to recognise the internal commands in Python format for some specific operations. So that we do not have to look for certain commands in the manual and learn the call format through the monotonous and dull documents.
Mostly, the recorded script need further editting so as to be flexibly used in other models. This part will be detailed in another post later.©
本文发表于水景一页。永久链接:<https://cnzhx.net/fe/2015/12/12/abaqus-macro-script-introduction/>。转载请保留此信息及相应链接。