This Website is not fully compatible with Internet Explorer.
For a more complete and secure browsing experience please consider using Microsoft Edge, Firefox, or Chrome

Q&A

Q&A

Q: Is there a manual/docu available for python commands that can be used in Ansys? Or do you work predominantly with the journal recorder?

A: You can use Ansys documentation, since it contains very useful code recipes and snippets, however it does not explain in detail all the Python objects and the data structure. For that reason, the most convenient is to combine it as well with the recording capability.

 

Q: Do you define the name of each domain in the geometry script?

A: Yes, the names of sets, named selections, groups… are specified in the script.

 

Q: Which type of contact have you used between the fibre and matrix?

A: It is a contact debonding type for each fiber-matrix interface including a material with the interfacial properties (strength, fracture energy…). The contact region (fiber-matrix) needs to be defined previously.

 

Q: Your scripts, do you just save them under different extension rather than *.py without extra command lines in them or there are some extra steps required to make Ansys understand what you want?

A: Some Ansys scripts are saved with a different extension automatically (Spaceclaim and Workbench), rather than “.py”.

In Spaceclaim (SC) scripts can only be read and edited within SC because they are saved in a compiled fashion (extension “.scscript”). Whereas Workbench scripts are saved with a different extension (“.wbpj”), but they have Python syntax. And finally, Ansys Mechanical scripts are plain text Python files (“.py”).

 

Q: How much time is spent in creating the scripts, for the the first time?

A: This really depends on the complexity of the script (or model) and the experience of the user. It could go from a few minutes, for a simple case, up to several hours for very complex cases.

This is like answering: how long does it take to create an FE model? It depends…

 

Q: How can one make Python scripts the exact replica of complex models?

A: The easiest approach at the beginning is to record the fundamental operations that are required to generate a basic version of the FE model. Then, take a functions and adapt the code to fit your needs taking advantage of variables, loops, etc.

 

Q: Though this would be reproducible, won't it be very difficult to code all the intricate parts?

A: Absolutely, certain operations are more convenient to automate than others.

Scripting the whole design of an intricate part will not be practical. It would take longer to figure out how to put it into a script rather than doing it by hand. Scripts are intended to repeat operations, to perform intensive tasks that are “easy” to describe. More intricacy means more exceptions which turns into more coding complexity.

 

Q: What is the difference with writing a complete APDL file that creates a model? That’s what I do with Mechanical APDL. Also, post-processing can be carried out with APDL files

A: The main advantage over APDL is the interoperability. APDL files are intended to communicate with Ansys: describing the numerical model, launching the simulation and finally postprocessing it. Therefore, Python scripts do not add a remarkable improvement on these topics, however Python enables other tasks (e.g. many more plotting and visualization options) and communication with other programs or even the operative system (e.g. export data to Excel, interact with Matlab, complex postprocessing…).

There is a recent effort by Ansys to provide easy interaction through Python libraries: PyAnsys, which includes, for instance, pyMAPDL to generate and interact with APDL files.

 

Q: Do you use some dedicated module/library (e.g. pandas, scipy) with predefined functions to communicate?

A: In these examples there are no additional/external modules. Nevertheless, you can use additional libraries in case you communicate with the software from the outside, which can be done through APIs or through the command line.

 

Q: Is it possible to have the script used in these examples?

A: You can find an example of Python script in Abaqus for a ballistic impact by subscribing to https://tecnodigitalschool.com/

 

Q: Learning from examples seem to be effective for the scripting. If any of the shown scripts are available or any other good examples we can refer to (particularly interested on the Salome_Meca & Abaqus), could you please let us know.

A: You can find an example of Python script in Abaqus for a ballistic impact by subscribing to https://tecnodigitalschool.com/

 

Q: Can we see how the scripts are built and how the API is set up?

A: The scripts are single text files and there is not any API to set up. The only case in which we need additional files is for Salome-Meca: export and comm files.

 

Q: Where could I start getting to know with Python for someone who has never worked with it? What would you recommend?

A: There are thousands of resources on the internet. My recommendation is to start using it on a real project, so you will need to progress and to look for answers. The purpose could be: “I will generate the plots of my next project using Python”.

 

Q: Are there any examples that would be available to practice with?

A: You can find an example of Python script in Abaqus for a ballistic impact by subscribing to https://tecnodigitalschool.com/

 

Q: Can Siemens NX meshing be automatized through python?

A: I know NX provides interaction through Python scripts, but I am not sure about all the capabilities

 

Q: Do you have Python training for CAE engineer having no coding experience in French? I'm looking for such training for one of my team member.

A: I know Cyprien Rusu from “FEA for all”. He is French, but most of his trainings are in English.

 

Q: Do you construct your scripts for Abaqus using the .jnl files, ‘macro manager’, a combination of the 2 or via another method?

A: Yes, from the jnl, rpy and macro files I get the skeleton of a script and then you have to customize it or take only the commands that you need.

 

Q: Thank you for your useful information you provided. Do you have any recommendation for Python beginners? any reference for faster learning?

A: You can grasp the basics of Python in a couple of days (data types and structures), any introductory book is fine for that.

Then, it is a matter of practising. I recommend starting to apply it as soon as you want to start learning. You can also start some hobby project for fun to dive deeper into more advanced features (classes, exceptions…). Once you are familiar with Python syntax and some of the typical functions, I recommend the book “Dive into Python” which provides some more insight about the language.

 

Q: Hello! Would there be any major limitations of Python scripting methods as opposed to traditional methods (e.g. by hand)?

A: We should understand scripting as one more tool of the Finite Element Analyst (or FE user in general). Scripts are very convenient whenever we want to automate a repetitive and time-intensive task: repeating the same type of geometry (e.g. holes), exporting the same type of results (e.g. nodal displacement…), reading data…

But they are not meant for non-repetitive tasks. We also must consider that tasks that require more reasoning are also more difficult to implement into a script.

 

Q: What python packages are you mainly using?

A: In all the examples shown, I have used the built in Python packages of each software. A few times I used the math library included in all Python distributions.

 

Q: Is there a friendly way of working with non-parametric CAD bodies & systems comprised of many of these?

A: I am not sure of the definition of “friendly” in this context. Syntax and data structure are more friendly in some softwares than in other ones, but this is a very subjective topic and depends mostly on our experience.

Generally, regular patterns are easier to describe through code (to program it) than very irregular assemblies. But this also depends on the smartness of the programmer.

 

Q: From your experience, could we use python for writing a user defined material in Abaqus?

A: Python can only be used to interact with the program; however, Python cannot get into the solver. To define a V/UMAT in Abaqus, the only way is to write it using Fortran.

 

Q: Thank you for this great presentation. You presented an interface python/GMSH. Do you know for other good/easy libraries for meshing instead of GMSH?

A: You can use Salome-Meca only to mesh the geometry. I know Hypermesh is one of the most powerful meshing softwares, but scripting is limited to TCL instead of Python.

 

Q: Does Python access results directly within the FE code?

A: Yes, Python scripts are also capable of accessing results in the postprocessing. Obviously syntax and data structures change from one FE program to another.

 

Q: How to deal with the convergence/validation condition when we are using a script especially, for the perforation of the plate case?

A: Depending on the FE software you can read the log files written by the solver to deduce the status of the simulation. For instance, in Abaqus you can directly ask for the job status.

 

Q: Can we use the same scripts (created in python) into two different tools (e.g. Ansys & Abaqus)

A: No, functions and objects are different from program A to program B. So, scripts have to be translated or rewritten.

 

Q: Which one pre-processing tool is best for the meshing?

A: I am more familiar to Abaqus, but Gmsh and Hypermesh have amazing meshing capabilities. Gmsh is more low level and Hypermesh has many automated features.

 

Q: Do you have to export results in some buffer format to manipulate

A: You can access the results from the output files (e.g. odb in Abaqus, rmed in Code Aster) and extract whatever you need from there, postprocess those results, export or plot them, etc.