CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM (http://www.cfd-online.com/Forums/openfoam/)
-   -   When should i stop simulation!? (http://www.cfd-online.com/Forums/openfoam/86608-when-should-i-stop-simulation.html)

davidmd March 28, 2011 08:33

When should i stop simulation!?
 
Good day, All!

I use MRFSimpleFoam based solver, and I have a questions: When do I need to stop the simulation?

How do I know that the solution persisted?

How to write a condition in the solver, so that when it reach a certain level of accuracy a decision to stop. (of course if it's possible :) )

I would be very grateful to all who answer me!!!

sixwp March 28, 2011 08:51

Hi David,

use:
Code:

pyFoamPlotRunner.py MRFSimpleFoam
you'll have residuals and continuity graphs.

Regards

davidmd March 28, 2011 09:26

Quote:

Originally Posted by sixwp (Post 301220)
Hi David,

use:
Code:

pyFoamPlotRunner.py MRFSimpleFoam
you'll have residuals and continuity graphs.

Regards

sixwp, thanks for responding!

But I do not know what is pyFoamPlotRunner.py :-( Where can I find itself, and manual for it? And what is the functionality of pyFoamPlotRunner.py?
will this help me to stop the solver on the condition of achievement a given accuracy?

I would really appreciate if you answer!

grjmell March 28, 2011 10:55

http://openfoamwiki.net/index.php/Contrib_PyFoam

davidmd March 28, 2011 16:05

So I install it, and now try to start solving my case with this:

Code:

python '/home/davidmd/src/PyFoam-0.5.4/bin/pyFoamPlotRunner.py' ReMRFSimpleFoam '/home/davidmd/OpenFOAM/davidmd-1.7.0/work/' NF2
"ReMRFSimpleFoam" - is my solver "NF2" - is my case

and got this:
Code:

Traceback (most recent call last):
  File "/home/davidmd/src/PyFoam-0.5.4/bin/pyFoamPlotRunner.py", line 3, in <module>
    from PyFoam.Applications.PlotRunner import PlotRunner
  File "/usr/local/lib/python2.6/dist-packages/PyFoam/Applications/PlotRunner.py", line 7, in <module>
    from PyFoam.Execution.GnuplotRunner import GnuplotRunner
  File "/usr/local/lib/python2.6/dist-packages/PyFoam/Execution/GnuplotRunner.py", line 49
    self.plotIter=GnuplotTimelines(self.getAnalyzer("PlotIterations").lines,persist=persist,with="steps")
                                                                                              ^
SyntaxError: invalid syntax

Where is my mistake?


Now I try to rename variable "with" in GnuplotRunnr.py and now i have this:


Code:

davidmd@rootpc ~/OpenFOAM/davidmd-1.7.0/work/NF2 $ python '/home/davidmd/src/PyFoam-0.5.4/bin/pyFoamPlotRunner.py' 'ReMRFSimpleFoam' '/home/davidmd/OpenFOAM/davidmd-1.7.0/work/' 'NF2'
/usr/local/lib/python2.6/dist-packages/PyFoam/Execution/FoamThread.py:3: DeprecationWarning: The popen2 module is deprecated.  Use the subprocess module.
  from popen2 import Popen4

Usage: ReMRFSimpleFoam [-parallel] [-case dir]  [-help] [-doc] [-srcDoc]



--> FOAM FATAL ERROR:
Wrong number of arguments, expected 0 found 2


FOAM exiting

What am I doing wrong?

grjmell March 29, 2011 03:32

Make sure you have done the required under points 3.2 adn 3.5 of the above link. Copy paste the PATHs into your ~/.bashrc file. then test the installation (point 3.5), then you dont have to give the entire path to the py-utility you are using.
if your installation test is negative, then it wont work...

the correct syntax to run a case is (from inside your case directory)

pyFoamPlotRunner.py nameOfSolver, e.g. pyFoamPlotRunner.py pisoFoam

val46 March 29, 2011 04:29

Hi David,

there are different (and easier) ways...
1. You can use gnuplot to plot the residuals (look here)
2. You should monitor important points in your modell. (easily done in controlDict --> you will find an example in the pimpleFoam/t-junction tutorial)
3. You can also monitor the pressure force on specific patches/walls --> also done in controlDict --> example in tutorials/incompressible/pimpleDyMFoam/wingMotion/wingMotion2D_simpleFoam)


I for myself use all 3 of them to make sure my solution is converged

Regards,
Toni

davidmd March 29, 2011 05:48

Thank you, grjmell! I really found PyFoam was setup wrong. Now I got the graphics! Something like these:
http://davidmd.narod.ru/pic01.png
But how can I now determine when to stop the calculation? I see that it is converges.
I should just independently decide when I'm quitting?
Oh, and can someone tell me what I have to deal with pressure? Why is it jumping?

val46, thank you very much for your reply! However, I have tried so far only the first way and I have something wrong in the chart with the pressure. Perhaps the fact that I use 3 nonOrthogonalCorrectors and I get something like this
http://davidmd.narod.ru/pic02.png

And once again thank you, that you answered!

davidmd March 29, 2011 07:14

Quote:

Originally Posted by davidmd (Post 301348)
val46, thank you very much for your reply! However, I have tried so far only the first way and I have something wrong in the chart with the pressure.


I figured, just a little rewrote solver! Thank you!

But how to make the solver stopped himself when a certain accuracy reached? Which is the best parameter to determine the convergence of the solution inside of the solver?

val46 March 30, 2011 04:52

Quote:

But how to make the solver stopped himself when a certain accuracy reached? Which is the best parameter to determine the convergence of the solution inside of the solver?
Hi David,

as I said, I would recommend you to monitor points. The reason is sometimes you have a good solution when all residuals reach 10^-3 and sometimes its not even converged when you reach 10^-6.

So to answer your question:
The best parameter to determine the convergence of the solution is NOT the residual, its the velocity, pressure or temperature of certain points within your domain.

Regards,
Toni

longamon March 30, 2011 07:56

My opinion in this subject, hope it helps:

If its a laminar case with a steady state solution, then residual is a good way to know when to stop. You could also check that stady state has been reached by checking that velocity isn't changing in time.

There's also laminar cases that don't reach a stady state (such as flow over bodies past a critical Re), instead they reach a periodic state. For this its usefull to use averages and check to see if the averaged solution reach a steady state.

Turbulent cases are a bit different, if you're using RANS models, then the average steady state may be reached. Usually you have to check several conditions, for this what val46 is very usefull. Plot a map of velocity over time at certain points, then, you'll see the behaviour of the velocity. There'll be a first transition period and a statistically stationary period. When you're in the statistically stationary period you should choose an integration time long enough so that your parameters are satisfactory.

If your case is turbulent I recomend you check a turbulent flow book. Turbulent Flows by Stephen B. Pope is quite good.

I have used 2 tools in OF to check the behaviour of my case, probes and fieldAverages. They are configured in the controlDict:

functions
{
probes
{
type probes;
functionObjectLibs ("libsampling.so");
enabled true;
outputControl timeStep;
outputInterval 10;
probeLocations
(
( 8.55 0.5 3 )
);

fields
(
U
);
}
fieldAverage1
{
type fieldAverage;
functionObjectLibs ( "libfieldFunctionObjects.so" );
enabled true;
outputControl outputTime;
outputInterval 100;
fields
(
U
{
mean on;
prime2Mean on;
base time;
}

p
{
mean on;
prime2Mean off;
base time;
}
);
}
}

Remember that averages should be enabled (for turbulent flows) once a statistically stationary state has been reached.

davidmd April 2, 2011 05:22

Many thanks to all who replied. I have no more questions! :):):)


All times are GMT -4. The time now is 10:30.