CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Community Contributions

[Tutorials] Coupling Dakota and OpenFOAM - Tutorial

Register Blogs Community New Posts Updated Threads Search

Like Tree14Likes
  • 9 Post By Tobi
  • 1 Post By nsf
  • 1 Post By Tobi
  • 1 Post By nsf
  • 1 Post By Tobi
  • 1 Post By nsf

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 20, 2016, 19:03
Lightbulb Coupling Dakota and OpenFOAM - Tutorial
  #1
Super Moderator
 
Tobi's Avatar
 
Tobias Holzmann
Join Date: Oct 2010
Location: Tussenhausen
Posts: 2,708
Blog Entries: 6
Rep Power: 51
Tobi has a spectacular aura aboutTobi has a spectacular aura aboutTobi has a spectacular aura about
Send a message via ICQ to Tobi Send a message via Skype™ to Tobi
Dear all,

today I published a tutorial that couples OpenFOAM and Dakota based on the Tesla's One-Way-Valve case that I published last week. The tutorial has a run script that will guide you through each step that is necessary to couple dakota and openfoam.

The target or object function is the ratio between the flux in working and reverse direction of the one-way-valve. Therefore we need a respond function that could be minimized. In that case it is simple (( | 3 - ratio | )). The flux is dependend on the pressure drop that is applied between inlet and outlet and therefore the variable parameter is the pressure at the inlet. The case is working with the gradient based method mentioned by Fletcher & Reeves.

The tutorial should only demonstrate how to combine both software packages, so please do not ask about the meaning of the case (: anyway I think its very clear and understandable.

The case can be found on my homepage www.holzmann-cfd.com



I hope it could help someone. Feedback is always welcomed.
Attached Images
File Type: png 11220903_588802291279807_6074924078124389805_n.png (48.3 KB, 1056 views)
__________________
Keep foaming,
Tobias Holzmann

Last edited by Tobi; June 16, 2020 at 06:43.
Tobi is offline   Reply With Quote

Old   April 30, 2016, 08:57
Default
  #2
nsf
Senior Member
 
Nicolas Edh
Join Date: Mar 2010
Location: Uppsala, Sweden
Posts: 123
Rep Power: 18
nsf is on a distinguished road
Hi,

Really nice tutorial. Just a week before you posted this I showed OpenFOAM for a group of colleagues and had prepared something similar. If you are interested I can clean up the case and post it here.

I did multidimensional parameter study and set dakota up so it store each run i a separate directory.

I saw this in your your dakota.sh
Code:
    # Remove time directorys (reg expression would be nicer)
    #---------------------------------------------------------------------------
    rm -rf 1* 2* 3* 4* 5* 6* 7* 8* 9*
So I thought I'd show post back and let you know how I would set up the regular expression:

Code:
rm -rf [0-9]*
Now for that to work you would first have to rename the 0.org folder to org0. Other wise one could do this

Code:
rm -rf 0.[0-9]* [1-9]* 0
Best Regards
Nicolas
Tobi likes this.
nsf is offline   Reply With Quote

Old   May 1, 2016, 15:06
Default
  #3
Super Moderator
 
Tobi's Avatar
 
Tobias Holzmann
Join Date: Oct 2010
Location: Tussenhausen
Posts: 2,708
Blog Entries: 6
Rep Power: 51
Tobi has a spectacular aura aboutTobi has a spectacular aura aboutTobi has a spectacular aura about
Send a message via ICQ to Tobi Send a message via Skype™ to Tobi
Hey Nikolas,

thanks for the replay. The regular expressions are familiar for me but I did not want to do it here due to the fact that (maybe) non-familiar people are using this

I will change it in the new tutorials (:

If you want, you can change your case and I will upload it too (of course within your name). For my Ph.D. I also do multidimension analysis, but the main focus is only in coupling.

Anyway Dakota is very powerful and could be changed to a lot of studies.
nsf likes this.
__________________
Keep foaming,
Tobias Holzmann
Tobi is offline   Reply With Quote

Old   May 2, 2016, 15:06
Default
  #4
nsf
Senior Member
 
Nicolas Edh
Join Date: Mar 2010
Location: Uppsala, Sweden
Posts: 123
Rep Power: 18
nsf is on a distinguished road
Quote:
Originally Posted by Tobi View Post
Hey Nikolas,

thanks for the replay. The regular expressions are familiar for me but I did not want to do it here due to the fact that (maybe) non-familiar people are using this

I will change it in the new tutorials (:

If you want, you can change your case and I will upload it too (of course within your name). For my Ph.D. I also do multidimension analysis, but the main focus is only in coupling.

Anyway Dakota is very powerful and could be changed to a lot of studies.
Hi,

I've made some preliminary clean up. In my mind running the case is crystal clear but I've realized that my mind is not the real world so it might not "just work". The case should be attached. You are very welcome to publish it (or throw it in the trash if you don't like it).

Yes, I agree dakota is really powerful. I've seen that it already has a method for Richardson extrapolation. I haven't tried it but perhaps really should.

What I find lacking in dakota though, is a good way to postprocess the results. For an optimization this might not be very important but for a sensitivity study it would be. I'm very new to dakota so if I missed something obvious don't shoot me. The first tool that comes to mind is Excels pivot table.

Best Regards
Nicolas
Attached Files
File Type: gz dakota-mulitparamstudy.tar.gz (63.0 KB, 147 views)
Tobi likes this.

Last edited by nsf; May 2, 2016 at 15:07. Reason: Readding attachment
nsf is offline   Reply With Quote

Old   May 2, 2016, 15:19
Default
  #5
Super Moderator
 
Tobi's Avatar
 
Tobias Holzmann
Join Date: Oct 2010
Location: Tussenhausen
Posts: 2,708
Blog Entries: 6
Rep Power: 51
Tobi has a spectacular aura aboutTobi has a spectacular aura aboutTobi has a spectacular aura about
Send a message via ICQ to Tobi Send a message via Skype™ to Tobi
Quote:
Originally Posted by nsf View Post
Hi,

I've made some preliminary clean up. In my mind running the case is crystal clear but I've realized that my mind is not the real world so it might not "just work". The case should be attached. You are very welcome to publish it (or throw it in the trash if you don't like it).

Yes, I agree dakota is really powerful. I've seen that it already has a method for Richardson extrapolation. I haven't tried it but perhaps really should.

What I find lacking in dakota though, is a good way to postprocess the results. For an optimization this might not be very important but for a sensitivity study it would be. I'm very new to dakota so if I missed something obvious don't shoot me. The first tool that comes to mind is Excels pivot table.

Best Regards
Nicolas
Hi Nicolas,

I think each tutorial that can be published in one close place is worth to publish (:
I will definitely upload it with the remark that this is from you and add this to the dakota site of the openfoamwiki.

But it will take a few time. I think the weekend in two weeks is reserved for doing that

Many thanks for your share and the open-source thought!
nsf likes this.
__________________
Keep foaming,
Tobias Holzmann
Tobi is offline   Reply With Quote

Old   May 3, 2016, 14:27
Default
  #6
nsf
Senior Member
 
Nicolas Edh
Join Date: Mar 2010
Location: Uppsala, Sweden
Posts: 123
Rep Power: 18
nsf is on a distinguished road
That's sounds great!

Let me know if I should change anything.

Best Regards
Nicolas
nsf is offline   Reply With Quote

Old   May 9, 2016, 15:08
Default
  #7
Super Moderator
 
Tobi's Avatar
 
Tobias Holzmann
Join Date: Oct 2010
Location: Tussenhausen
Posts: 2,708
Blog Entries: 6
Rep Power: 51
Tobi has a spectacular aura aboutTobi has a spectacular aura aboutTobi has a spectacular aura about
Send a message via ICQ to Tobi Send a message via Skype™ to Tobi
Dear Nicolas,

nice Dakota tutorial but for a beginner a bit hard with all the scripts. Just one question: can you simplify it in a way like I did it? Otherwise I will do it if I find time (:

Thanks for sharing // which FOAM version should be used?
__________________
Keep foaming,
Tobias Holzmann
Tobi is offline   Reply With Quote

Old   May 9, 2016, 16:44
Default
  #8
nsf
Senior Member
 
Nicolas Edh
Join Date: Mar 2010
Location: Uppsala, Sweden
Posts: 123
Rep Power: 18
nsf is on a distinguished road
Hi,

You have a fair point! I had a pre script which only ran once in the templatedir because I thought it more efficient but come to think of it; meshing takes about 1s and running the case takes about 20 s...

I've combined most of the scripts. I now use two, Allrun (for running dakota) and templatecase/runcase which creates the mesh, runs deprepro, runs interFoam and postprocesses. Then there are clean scripts as well.

I've attached the new case dakota-multiparamstudy2.tar.gz. I've used OpenFOAM-3.0.x. You are more than welcome to add comments of your own.

Best Regards
Nicolas
nsf is offline   Reply With Quote

Old   October 17, 2016, 11:13
Default
  #9
New Member
 
Yue Wang
Join Date: Sep 2009
Posts: 14
Rep Power: 16
popstar0426 is on a distinguished road
Dear Nicolas:

Thank you for sharing your case dakota-mulitparamstudy.tar.gz.
I am runing it. However, it is quit slow.
May I run it in parallel?
How do I run it parallel?

I tried to compile dakota in parallel with MPICH2.
I selected "DAKOTA_HAVE_MPI" option in ccmake step.
However, there was an error on the step of "make install".
It seems "DAKOTA_HAVE_MPI" conflicts with "DAKOTA_ENABLE_TESTS".
Because I deselected "DAKOTA_ENABLE_TESTS" and selected "DAKOTA_HAVE_MPI" ON, "make install" step is OK.

Best regards!


Quote:
Originally Posted by nsf View Post
Hi,

I've made some preliminary clean up. In my mind running the case is crystal clear but I've realized that my mind is not the real world so it might not "just work". The case should be attached. You are very welcome to publish it (or throw it in the trash if you don't like it).

Yes, I agree dakota is really powerful. I've seen that it already has a method for Richardson extrapolation. I haven't tried it but perhaps really should.

What I find lacking in dakota though, is a good way to postprocess the results. For an optimization this might not be very important but for a sensitivity study it would be. I'm very new to dakota so if I missed something obvious don't shoot me. The first tool that comes to mind is Excels pivot table.

Best Regards
Nicolas
popstar0426 is offline   Reply With Quote

Old   October 17, 2016, 15:49
Default
  #10
nsf
Senior Member
 
Nicolas Edh
Join Date: Mar 2010
Location: Uppsala, Sweden
Posts: 123
Rep Power: 18
nsf is on a distinguished road
Quote:
Originally Posted by popstar0426 View Post
Dear Nicolas:

Thank you for sharing your case dakota-mulitparamstudy.tar.gz.
I am runing it. However, it is quit slow.
May I run it in parallel?
How do I run it parallel?

I tried to compile dakota in parallel with MPICH2.
I selected "DAKOTA_HAVE_MPI" option in ccmake step.
However, there was an error on the step of "make install".
It seems "DAKOTA_HAVE_MPI" conflicts with "DAKOTA_ENABLE_TESTS".
Because I deselected "DAKOTA_ENABLE_TESTS" and selected "DAKOTA_HAVE_MPI" ON, "make install" step is OK.

Best regards!
Hi,

I've actually only setup dakota and openfoam once as a proof of concept for colleagues. I've never actually ran it in parallel but here are my guesses.

I don't think you need to compile dakota with mpi for it to run parallel openfoam simulations. You do need mpi support for dakota to run in parallel. Does that make sense?

There are different modes of using dakota. The way I set it up was the simplest way, just have dakota run a script which fires of your simulation and waits for the simulation to finish. It expects the result in a text file on disk. This way dakota has no clue if the script actually ran in serial, parallel or submitted the job to a queue system on a super computer. For this you would have to change the script "dakota-multiparamstudy/templatecase/runcase" accordingly.

The next way is to have dakota fire of the varies permutations of your simulation asynchronously. For a parameter study there is no real need to wait for simulation A to finish before starting simulation B we can just start them simultaneously. I don't think this requires mpi support either. For this case you would have to uncomment line 26 in file "dakota.in".

The only reason, as I understand, to use dakota with mpi is if you couple it with you're own software on code level, i.e. using dakota as a library. You would have to check the manual for this as I have no clue on how to do this.

I haven't tried either of above methods. Please let me know if you give it a try.

Best Regards
Nicolas
anon_q likes this.
nsf is offline   Reply With Quote

Old   August 31, 2017, 16:36
Default
  #11
Member
 
Luis Eduardo
Join Date: Jan 2011
Posts: 85
Rep Power: 15
lebc is on a distinguished road
Hi guys,

This will probably be out of topic, but as we don't have a Dakota topic, there it goes!

I have already coupled OF4.1 with Dakota 6.5, it is running ok. My problem is: I have to optimize the distribution of source terms over a 2D domain, but Dakota suggests more than one source term located on the same point (by doing this, the source term bugs and duplicates its effects).

One of the restrictions of my problem is the distance between every source term, it has a minimum value, but until now I was not able to implement it.

As an example, for 2 source terms (4 variables)

Quote:
variables
continuous_design = 4
cdv_initial_point 200 200 200 800
cdv_lower_bounds 200 200 200 200
cdv_upper_bounds 800 800 800 800
cdv_descriptor 'x1' 'y1' 'x2' 'y2'
the restriction should be (x1-x2)² + (y1-y2)² > Some value

I have already checked lots of documentations from Dakota, but didn't find it.

Best Regards,
Luis
lebc is offline   Reply With Quote

Old   September 1, 2017, 03:54
Default
  #12
nsf
Senior Member
 
Nicolas Edh
Join Date: Mar 2010
Location: Uppsala, Sweden
Posts: 123
Rep Power: 18
nsf is on a distinguished road
Quote:
Originally Posted by lebc View Post
Hi guys,

This will probably be out of topic, but as we don't have a Dakota topic, there it goes!

I have already coupled OF4.1 with Dakota 6.5, it is running ok. My problem is: I have to optimize the distribution of source terms over a 2D domain, but Dakota suggests more than one source term located on the same point (by doing this, the source term bugs and duplicates its effects).

One of the restrictions of my problem is the distance between every source term, it has a minimum value, but until now I was not able to implement it.

As an example, for 2 source terms (4 variables)

the restriction should be (x1-x2)² + (y1-y2)² > Some value

I have already checked lots of documentations from Dakota, but didn't find it.

Best Regards,
Luis
Hi Luis,

I'm glad to hear that someone is using Dakota with OpenFoam. I haven't worked more with Dakota so I'm not really up to speed. But I do remember the Dakota manual mentioning non linear constraints. You could check that out.

There is also a workaround. Just let one of your "pre simulation" scripts check the distances. If it's to close just set whatever metric you are optimizing to a high value. You don't even have to run the simulation!

Good luck
Best regards
Nicolas
nsf is offline   Reply With Quote

Old   September 1, 2017, 10:08
Default
  #13
Member
 
Luis Eduardo
Join Date: Jan 2011
Posts: 85
Rep Power: 15
lebc is on a distinguished road
Hi Nicolas,

Thank you for the answer!

I using Dakota on my MsC, it has only one week I'm using it (it was actually a surprise that things worked so fast with OpenFoam!)

Some hours after posting this thread I thought something like you suggested, this is probably the fastest workaround, maybe I can write a python script that reads params.in and check the distance before the simulation.

I also saw about the non linear constraints, but I didn't find much information or a way to make something like what I need.

On the next week I'll be testing it, I will post the solution here in case I succeed!

Best Regards,
Luis
lebc is offline   Reply With Quote

Old   September 17, 2017, 21:45
Default
  #14
Member
 
Luis Eduardo
Join Date: Jan 2011
Posts: 85
Rep Power: 15
lebc is on a distinguished road
Hi Nicolas,

Finally I have followed your suggestion, it works, but not exactly as I wanted to...

As I'm working with a maximization problem, every time the minimum distance is not respected I put 0 for the objective function. The problem of doing this is that it takes a long time for Dakota to find a configuration that respects this outside constrain, and sometimes I end the optimization with just a few individuals on my population (I'm using genetic algorithm - SOGA).

For example, if I set the population = 30, after about 300 evaluations my population have only 3~4 individuals, and maybe I will end up on a local optimum point...

In order to overcome this I thought about using my own initial population that already respected this constraint via a python ode that creates it, but Dakota seems to mess my input file and I can't use this method.

If there is anyone that could help me on any of the mentioned problems I would be really thankful!!!

Regards,
Luis
lebc is offline   Reply With Quote

Reply

Tags
coupling, dakota, holzmann-cfd, openfoam


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
UNIGE February 5-8, 2018. OpenFOAM advanced training days - DAKOTA training joegi.geo OpenFOAM Announcements from Other Sources 0 September 6, 2017 08:57
Coupling Dakota with OpenFoam! CFD-Lover OpenFOAM 16 March 29, 2017 14:12
[Tutorials] New Dakota - OpenFOAM Coupling Tutorial Tobi OpenFOAM Community Contributions 0 October 9, 2016 17:19
UNIGE February 13th-17th - 2107. OpenFOAM advaced training days joegi.geo OpenFOAM Announcements from Other Sources 0 October 1, 2016 19:20
Suggestion for a new sub-forum at OpenFOAM's Forum wyldckat Site Help, Feedback & Discussions 20 October 28, 2014 09:04


All times are GMT -4. The time now is 21:24.