|
[Sponsors] |
[Tutorials] Coupling Dakota and OpenFOAM - Tutorial |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
April 20, 2016, 20:03 |
Coupling Dakota and OpenFOAM - Tutorial
|
#1 |
Super Moderator
Tobias Holzmann
Join Date: Oct 2010
Location: Bad Wörishofen
Posts: 2,711
Blog Entries: 6
Rep Power: 52 |
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.
__________________
Keep foaming, Tobias Holzmann Last edited by Tobi; June 16, 2020 at 07:43. |
|
April 30, 2016, 09:57 |
|
#2 |
Senior Member
Nicolas Edh
Join Date: Mar 2010
Location: Uppsala, Sweden
Posts: 123
Rep Power: 18 |
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* Code:
rm -rf [0-9]* Code:
rm -rf 0.[0-9]* [1-9]* 0 Nicolas |
|
May 1, 2016, 16:06 |
|
#3 |
Super Moderator
Tobias Holzmann
Join Date: Oct 2010
Location: Bad Wörishofen
Posts: 2,711
Blog Entries: 6
Rep Power: 52 |
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.
__________________
Keep foaming, Tobias Holzmann |
|
May 2, 2016, 16:06 |
|
#4 | |
Senior Member
Nicolas Edh
Join Date: Mar 2010
Location: Uppsala, Sweden
Posts: 123
Rep Power: 18 |
Quote:
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 Last edited by nsf; May 2, 2016 at 16:07. Reason: Readding attachment |
||
May 2, 2016, 16:19 |
|
#5 | |
Super Moderator
Tobias Holzmann
Join Date: Oct 2010
Location: Bad Wörishofen
Posts: 2,711
Blog Entries: 6
Rep Power: 52 |
Quote:
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!
__________________
Keep foaming, Tobias Holzmann |
||
May 3, 2016, 15:27 |
|
#6 |
Senior Member
Nicolas Edh
Join Date: Mar 2010
Location: Uppsala, Sweden
Posts: 123
Rep Power: 18 |
That's sounds great!
Let me know if I should change anything. Best Regards Nicolas |
|
May 9, 2016, 16:08 |
|
#7 |
Super Moderator
Tobias Holzmann
Join Date: Oct 2010
Location: Bad Wörishofen
Posts: 2,711
Blog Entries: 6
Rep Power: 52 |
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 |
|
May 9, 2016, 17:44 |
|
#8 |
Senior Member
Nicolas Edh
Join Date: Mar 2010
Location: Uppsala, Sweden
Posts: 123
Rep Power: 18 |
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 |
|
October 17, 2016, 12:13 |
|
#9 | |
New Member
Yue Wang
Join Date: Sep 2009
Posts: 14
Rep Power: 17 |
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:
|
||
October 17, 2016, 16:49 |
|
#10 | |
Senior Member
Nicolas Edh
Join Date: Mar 2010
Location: Uppsala, Sweden
Posts: 123
Rep Power: 18 |
Quote:
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 |
||
August 31, 2017, 17:36 |
|
#11 | |
Member
Luis Eduardo
Join Date: Jan 2011
Posts: 85
Rep Power: 15 |
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:
I have already checked lots of documentations from Dakota, but didn't find it. Best Regards, Luis |
||
September 1, 2017, 04:54 |
|
#12 | |
Senior Member
Nicolas Edh
Join Date: Mar 2010
Location: Uppsala, Sweden
Posts: 123
Rep Power: 18 |
Quote:
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 |
||
September 1, 2017, 11:08 |
|
#13 |
Member
Luis Eduardo
Join Date: Jan 2011
Posts: 85
Rep Power: 15 |
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 |
|
September 17, 2017, 22:45 |
|
#14 |
Member
Luis Eduardo
Join Date: Jan 2011
Posts: 85
Rep Power: 15 |
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 |
|
Tags |
coupling, dakota, holzmann-cfd, openfoam |
Thread Tools | Search this Thread |
Display Modes | |
|
|
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 09:57 |
Coupling Dakota with OpenFoam! | CFD-Lover | OpenFOAM | 16 | March 29, 2017 15:12 |
[Tutorials] New Dakota - OpenFOAM Coupling Tutorial | Tobi | OpenFOAM Community Contributions | 0 | October 9, 2016 18:19 |
UNIGE February 13th-17th - 2107. OpenFOAM advaced training days | joegi.geo | OpenFOAM Announcements from Other Sources | 0 | October 1, 2016 20:20 |
Suggestion for a new sub-forum at OpenFOAM's Forum | wyldckat | Site Help, Feedback & Discussions | 20 | October 28, 2014 10:04 |