CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (https://www.cfd-online.com/Forums/openfoam-solving/)
-   -   Running the same simulation for many different initial conditions (https://www.cfd-online.com/Forums/openfoam-solving/140441-running-same-simulation-many-different-initial-conditions.html)

casesam August 14, 2014 17:12

Running the same simulation for many different initial conditions
 
Hello all,
I am just learning how to use OF and would like a little guidance on how to proceed.
Essentially what I want to do is calculate the mass flow rate through a pipe system (one inlet, one outlet) for many different pressures at the inlet. The flow is incompressible, and laminar, and I only care about the steady state. I would like to do this for the exact same system but possibly hundreds of different pressure values at the inlet.
My thoughts on how to do this have been to write a script that will go into the 0/p file and change the pressure at the inlet, then re-solve, write the mass flow rate to a file and repeat for a different pressure.
Another thought was to have some sort of time-dependent boundary pressure condition that would increase the pressure at the inlet every 5 seconds (or something) and write the mass flow rate every 4.9 seconds.
Ideally it would be nice to be able to specify the inlet pressure at the command line; something like
simpleFoam -inletP 5
would run the simulation with a pressure of 5 at the inlet, but I have not seen anything like this in my searches.
Its very possible I am missing some obvious tool, it seems like many people would want to do this sort of thing. I am essentially gathering the data to create a flow rate vs. pressure plot.

Thanks a bunch!

chegdan August 14, 2014 18:02

Casesam,

Welcome to the forum. Now this is one of those cases where less is more in terms of your effort on simulations. If you have no optimization that you are doing, then parameter space exploration isn't too difficult with shell scripting is finished and you can go on your way. I would just make is complicated enough to do the job but don't overdo it. Now if you were actually interested in parameter space exploration and some optimization (or just a desire to learn another tool) then you can use DAKOTA (dakota.sandia.gov). There is actually a nice set of introductory tutorials to get you started with OpenFOAM + DAKOTA located

http://www.dicat.unige.it/guerrero/dakotaof.html

And the first one is a parameter space exploration of a case. Unless you want this to be a project where you play around and create your own version of simpleFoam that does what you suggested, then I would try DAKOTA. Good luck and again welcome to the forum! :D

jherb August 24, 2014 08:22

Have a look at http://openfoamwiki.net/index.php/Contrib/PyFoam and http://openfoamwiki.net/index.php/Contrib/swak4Foam

It provides python classes to modify OpenFOAM cases by scripts.

james.conger August 24, 2014 19:04

tip on how to change boundary values for a run
 
It took me a while to realize that I could use the same initialization files every time, and change values in the files via macro substitution. The text below is for a situation where the 2D velocity vector was being changed for each run, but you can do the same type of macro substitution for any input value.

---------------

A convenient way to run parameter studies is to put your variables into a separate file and then include them at run time. For example, in the initialization file for velocity (U) you can add the line:

#include "velocityValues"

Within the velocity initialization file (U) you can reference variables such as $XvelMPS:

type fixedValue;
value uniform ($XvelMPS, $YvelMPS 0);

You then put your parameters for the case in the file "velocityValues" such as (omitting the usual OpenFOAM header)

XvelMPS 10.517
YvelMPS 7.3914
#inputMode merge

Your parameters are substituted into the U file at run time, so the U file does not need to be edited between cases. Just change the values in the velocityValues file between cases.


All times are GMT -4. The time now is 06:39.