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

You are not logged in.

#1 2021-02-12 14:57:11

GPSalachs
Member
Registered: 2018-03-10
Posts: 239

Yacs - Openturns - Aster_Study Connection

Hello,

i am trying to create a study that connects the geometry and meshing of the model, can then pass it through Aster Study and finish on to Openturns / Persalys  for further investigation. I am trying to do that so i can in an automated way change not only the variable defined in Aster Study but also geometrical parameters. Now, following the cases presented on by FEAFORALL on youtube i was able to connect all the cases up to Aster Study. Now what i am searching for is a way to connect also with Openturns / Persalys but leaving also the option on the Yacs schema to change and do analyses depending on geometrical variability that will be defined with the option of Design of Experiment (DOE)  with a deterministic or a probability model.


Do you have any suggestions on how to proceed?

Offline

#2 2021-02-12 17:41:45

Irvise
Member
Registered: 2019-12-07
Posts: 52

Re: Yacs - Openturns - Aster_Study Connection

Hi GPSalachs,

Fernando here (the guy that did the OT videos). My suggestion would be to create the geometry that you want to parametrize and mesh it. Then tell Salome to dump the study. That basically creates a Python script that does what you want. If I remember correctly, this was explained in the YACS series. With that Python script now available, change the values that you want to turn into variables modified by YACS/OT. Then set up your CA case with the variables that you want, if any.

Then, you can do a couple of things.

1) Use OT the way I explain it in the video. However, I would recommend to use the "Python Script" case instead of the "YACS schema" one. Since that is simpler (and faster). Then just copypaste the modified Python script that Salome generated in the script editor of OT. The Python code that you copy should be copied inside a Python function known as _exec(). That function is the one being called by OT. In the function declaration include the variables that are going to be used in you design. And that should be more or less it! Just run the case.

2) All YACS. Same as above, but you create a YACS schema that ends in a Python script that does what OT would do. This gives you a lot more flexibility, but it requires more work and knowledge of OT.

Regards,

Fernando

Offline

#3 2021-02-15 10:17:29

GPSalachs
Member
Registered: 2018-03-10
Posts: 239

Re: Yacs - Openturns - Aster_Study Connection

Irvise wrote:

Hi GPSalachs,

Fernando here (the guy that did the OT videos). My suggestion would be to create the geometry that you want to parametrize and mesh it. Then tell Salome to dump the study. That basically creates a Python script that does what you want. If I remember correctly, this was explained in the YACS series. With that Python script now available, change the values that you want to turn into variables modified by YACS/OT. Then set up your CA case with the variables that you want, if any.

Then, you can do a couple of things.

1) Use OT the way I explain it in the video. However, I would recommend to use the "Python Script" case instead of the "YACS schema" one. Since that is simpler (and faster). Then just copypaste the modified Python script that Salome generated in the script editor of OT. The Python code that you copy should be copied inside a Python function known as _exec(). That function is the one being called by OT. In the function declaration include the variables that are going to be used in you design. And that should be more or less it! Just run the case.

2) All YACS. Same as above, but you create a YACS schema that ends in a Python script that does what OT would do. This gives you a lot more flexibility, but it requires more work and knowledge of OT.

Regards,

Fernando

Hello Irvise (Fernando),

i did exactly as you suggested in the post. Did the geometry, parametrized it and dumped the study. I took then the python script and attached it to the parametric.comm file so to be able to make variables of the geometry for OT/Persalys . I was not able to pass the complete study with a Python Model due to me not understanding how to give correctly the paths to read the ".comm" and ".export" files, so i preferred to do it with a YACS Model even if it is slower.

Offline

#4 2021-02-15 10:45:45

Irvise
Member
Registered: 2019-12-07
Posts: 52

Re: Yacs - Openturns - Aster_Study Connection

Hi GPSalachs,

you are right. I am sorry I did not write about the path issue with the OT->Python Script! I am aware of the issue, I wanted to make an update video to show how it is made, but for the time being, I have no time smile

The YACS Schema option in OT sets the path with other variables. However, in the case of a Python Script the path has to be hardcoded in the script, and the Path needs to be the one that points to where the .comm file resides (if I remember correctly). There was also the issue that temporary simulations would pollute the directory.

Nevertheless, I am happy that it worked. Hopefully you will get what you want.

Regards,

Fer

Offline

#5 2021-04-08 10:41:32

samprit
Member
Registered: 2021-04-08
Posts: 2

Re: Yacs - Openturns - Aster_Study Connection

GPSalachs wrote:

I took then the python script and attached it to the parametric.comm file so to be able to make variables of the geometry for OT/Persalys .

Hi GPSalachs,

Can you please explain the python script attachment-method to parametric.comm file ?
Did you paste the script inside a function {and outside DEBUT() and FIN() and called it from within} or did you paste it after DEBUT() {or before it maybe} ?

I tried these methods but I cannot get it to work, it says:
"No results are available. An error has occurred during the execution of the analysis.
The evaluation of the point number 0 is in error:No such file: '/tmp/salome_localres_workdir_sam/mesh.med'. Please check the Case View/DataFiles tab."

How do you get the mesh out and what did you write in the export file for the mesh {I use F libr mesh.med D 20}?

In my case there is no mesh.med in /tmp/ .

I have exported the geometry as below in the geometry file.
  try:
    Mids.ExportMED(r'mesh.med',auto_groups=0,minor=-1,overwrite=1,meshPart=None,autoDimension=1)
    pass
  except:
    print('ExportMED() failed. Invalid file name?')

Regards,
Samprit

[UPDATE]

I can do it now. I put the python code between DEBUT() and FIN() and also put a dummy{previously generated mesh file with the groups that are used in comm file} mesh.med in that location {/tmp/salome_localres_workdir_sam/mesh.med}. I did not add mesh.med in files tab of OT. But, it is early for me to say that it is a correct method. However the mesh.med file gets regenerated at the time of every new run folder creation, as indicated by{>> ll | grep mesh.med}.

Last edited by samprit (2021-04-09 08:36:01)

Offline

#6 2021-04-11 09:21:11

GPSalachs
Member
Registered: 2018-03-10
Posts: 239

Re: Yacs - Openturns - Aster_Study Connection

Hello samprit,

in the attachment you will find a parametric.py file that i have created to study different geometries and parameters. As you will see the initial geometry is made with shaper where i have given parameters to thickness, height, length and width. Then the file gets "transported" to the geometry module and in the end to the mesh module.  I have created this parametric file with help of the python dump function found in Salome.

For the variables definition it is needed to add them in the VARIABLE(NOM_PARA = , VALE = ) for openturns to read and declare them in the python script so it can understand what to read, otherwise you will not get a correct response and it will indicate an error message.
This is a .py file for easier visualization of the variables but you can change it in .comm and add it in place of the already generated parametric file.


Attachments:
parametric_v2.py, Size: 7.42 KiB, Downloads: 12

Offline