CFD Online Logo CFD Online URL
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Running, Solving & CFD

Running the same simulation for many different initial conditions

Register Blogs Members List Search Today's Posts Mark Forums Read

LinkBack Thread Tools Display Modes
Old   August 14, 2014, 17:12
Default Running the same simulation for many different initial conditions
New Member
Join Date: Aug 2014
Posts: 7
Rep Power: 5
casesam is on a distinguished road
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!
casesam is offline   Reply With Quote

Old   August 14, 2014, 18:02
Senior Member
chegdan's Avatar
Daniel P. Combest
Join Date: Mar 2009
Location: St. Louis, USA
Posts: 614
Rep Power: 22
chegdan will become famous soon enoughchegdan will become famous soon enough

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 ( There is actually a nice set of introductory tutorials to get you started with OpenFOAM + DAKOTA located

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!

Find me on
Twitter @dancombest

Last edited by chegdan; August 15, 2014 at 15:39. Reason: simplification
chegdan is offline   Reply With Quote

Old   August 24, 2014, 08:22
Senior Member
Joachim Herb
Join Date: Sep 2010
Posts: 428
Rep Power: 13
jherb is on a distinguished road
Have a look at and

It provides python classes to modify OpenFOAM cases by scripts.
jherb is offline   Reply With Quote

Old   August 24, 2014, 19:04
Default tip on how to change boundary values for a run
New Member
Jim Conger
Join Date: Jan 2014
Location: California, USA
Posts: 21
Rep Power: 6
james.conger is on a distinguished road
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.
james.conger is offline   Reply With Quote


Thread Tools
Display Modes

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 On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
a problem with convergence in buoyantSimpleFoam skuznet OpenFOAM Running, Solving & CFD 6 November 15, 2017 13:12
buoyantSimpleFoam and watertank Tobi OpenFOAM Running, Solving & CFD 54 July 17, 2017 14:07
SLTS+rhoPisoFoam: what is rDeltaT??? nileshjrane OpenFOAM Running, Solving & CFD 4 February 25, 2013 05:13
problem with Min/max rho tH3f0rC3 OpenFOAM 7 February 23, 2013 06:37
Negative value of k causing simulation to stop velan OpenFOAM Running, Solving & CFD 1 October 17, 2008 05:36

All times are GMT -4. The time now is 04:16.