Scripting Language/Repeat Simulations with changes to Variables

Hi All - I am doing multi-repeats of the same simulation with only a slight change. Is there any plug-ins or method of connecting to PrePoMax automatically - EG: writing a script language which will operate the GUI the same as doing it manually, please ? I am running a simulation many times until I find an optimum results, however manually it takes a long time. Any help advice please ?

Likely the easiest way in general for such cases is to export input files and operate on them directly, either manually (for simple cases) or using some basic scripts.

Can you share with us what part of the model are you changing?

Hi Matej - Yes sure - I am designing a plate with corrugated rims (curves) and applying pressure to the plate and measuring the maximum deflection and also the linearity of the movement. By changing the curves and the plate thickness and the curve height, the linearity and deflection is changed. I am looking for the best possible linearity, so I want to write a script that can talk to PrePoMax allowing me to run through a number of different height, thickness and curve radii’s to get the best linearity. I can do this with a gradient descent algorithm, however I need to be able to import a file and then run it automatically and then get the results from PrePoMax and then change the design in another software and then keep repeating until I find an optimum solution.

Ok, so you are changing the geometry and then you mesh the geometry and prepare the model inside PrePoMax.

Inside PraPoMax, there is a recording of user actions that can be activated by running the command Edit ->Regenerate or Regenerate using other files. So if you change the geometry file that was imported in the first place and run Regenerating it will recreate the model based on the new geometry.

The problem with this approach is that user selections (boundary conditions, loads) are repeated and when no geometry is found in the same place on the changed geometry the procedure fails. If you have the same positions of all important elements of the geometry this could work. First, try for a couple of geometries if this works by hand. The limitation is that running the analysis and postprocessing features are not recorded. Upgrading this functionality is possible.

The next step is running this command from the command line. This is not supported at the moment, but I can add this support pretty easily if needed.

There is probably a better way to do this. If you are willing to use Gmesh for the preparation of the geometry and mesh you can prepare Node sets and Element sets in the Gmesh. Then you can divide your model into two .inp files. One for the mesh and all the sets and one for the rest of the FEM model (CalculiX *Include keyword). Then you use the scripting capabilities of Gmes to regenerate the .inp file containing the mesh. And you set up the other .inp file to reference only the sets from the mesh .inp file.

Do you know about OptiMax. It could save you some time writing scripts. Take a look at the manual for the Calculix example.

1 Like

Hi Matej - Thankyou so much. As I am changing the pressure everytime I am not sure whether the re-generate methodogy will work? However - It feels like OptiMax is exactly what I am trying to do … I will investigate - again thank you :slight_smile:

Hi - Sorry to ask a silly question - Can you use the command line to run the simulation but with different pressure values, EG: Use commands to run simulation and then use command line to change pressure value and then re-run - that way a script can be written in the command line please ??

For that, Optimax would be perfect. The analysis model is written in ASCII (readable text) format into .inp file (take a look into the Temp folder under the PrePoMax base folder). There you can find a line of text where pressure is defined. Changing this one line is how you can change the pressure magnitude. Then you can rerun the analysis by calling the CalculiX solver using the command equal to the command shown in PrePoMax Monitor window at the top of the output.

1 Like

Hi - Thank you again … I have found the point where the pressure is defined so I can change this - however in optimax I input the file as a block but then I am not sure what to do next to get it to run ?

- sorry first time for this for me :slight_smile:

Please read the manual and follow the tutorial for material parameters optimization. Maybe do it by yourself to better understand the process.

1 Like

Hi - ok thank you :slight_smile: for quick reply … much appreciated …

1 Like