Welcome to the forums. Please post in English or French.

You are not logged in.

#1 2023-04-12 10:19:33

trilbytim
Member
Registered: 2023-03-08
Posts: 13

Scripting the solver

I'm looking at scripting some automatic structural optimisation, so I need to automate the iteration loop of create geometry (modifying key parameters), mesh, apply, material properties, loads and BC, etc, solve, read results and assess fitness, repeat.

It seems this must be possible with Salome Meca. I'm trying to learn this by starting with a simple example. I have created the geometry in GUI, meshed it, applied all the loads, BC's etc and solved it. I then used the 'Dump study' option to create a Python file that I could start to modify. I've attached the full file. The geometry and meshing all looks understandable, however none of the parameters set in Code Aster seem to be in this file, I just have this at the end of the file:

###
### ASTERSTUDY component
###

###
### PARAVIS component
###

So how do I script the Aster part of the iteration loop?


Attachments:
tube2.py, Size: 6.47 KiB, Downloads: 16

Offline

#2 2023-04-12 10:30:26

trilbytim
Member
Registered: 2023-03-08
Posts: 13

Re: Scripting the solver

I did also try checking the 'Multi file dump' and 'Save GUI state' boxes. This creates a file called ASTERSTUDY (attached) but it's effectively a blank file apart from the comments. All the materials, model, loads, etc are defined when I open the .hdf file in the GUI though.


Attachments:
tube2_ASTERSTUDY.py, Size: 144 B, Downloads: 20

Offline

#3 2023-04-13 13:59:10

hberro
Member
From: Palaiseau, France
Registered: 2011-07-05
Posts: 135

Re: Scripting the solver

Hi trilbytim,

Asterstudy does not produce a python dump, so it is normal that nothing shows up in the .py file that is produced.

However,

You can use salome_meca to

1) generate the geometry with GEOM or SHAPER.
2) generate the mesh with SMESH, then dump a MED file.
3) call code_aster using the AsterStudy calculation API with a template .comm file and the new mesh.
4) post process using the python dump of the paraview module.

Offline

#4 2023-05-24 20:06:39

trilbytim
Member
Registered: 2023-03-08
Posts: 13

Re: Scripting the solver

Thank you. Is there a way to output the .comm from the AsterStudy module of Salome GUI to use as a template?

I can then command CA to run  this .comm file from within Python can I?

Offline

#5 2023-05-25 05:30:22

scimulate
Member
Registered: 2021-04-13
Posts: 7

Re: Scripting the solver

I use code_aster exclusively now, but I seem to recall AsterStudy having the option to switch from GUI to text editor when setting up a simulation. You can set up a template model as you may desire using the GUI and then switch to the text editor to see the comm file. Alternatively, you can setup and run the simulation completely in Salome-Meca, and recover the COMM file from the directory where the simulation was conducted. It's usually a few folders down, but you can just search for COMM in the parent folder.

Offline

#6 2023-05-25 18:31:46

trilbytim
Member
Registered: 2023-03-08
Posts: 13

Re: Scripting the solver

Great, thank you!

scimulate wrote:

I use code_aster exclusively now, but I seem to recall AsterStudy having the option to switch from GUI to text editor when setting up a simulation. You can set up a template model as you may desire using the GUI and then switch to the text editor to see the comm file. Alternatively, you can setup and run the simulation completely in Salome-Meca, and recover the COMM file from the directory where the simulation was conducted. It's usually a few folders down, but you can just search for COMM in the parent folder.

Offline