|
[Sponsors] |
[Tutorials] Tutorial of how to plot residuals ! |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
April 30, 2009, 10:07 |
Tutorial of how to plot residuals !
|
#1 |
Senior Member
Wolfgang Heydlauff
Join Date: Mar 2009
Location: Germany
Posts: 136
Rep Power: 21 |
Hi all,
since apearantly noone has an idea of how to plot the residuals of a calculation on-the-fly, I will give a small manual on that: Tutorial on "How to plot the residuals (and forces) graphically on screen on-the-fly" Step 1: Start the calculation and make it write out a log-file. for example turbFoam >log"log" is the name of the log-file to be output. It is written into the main-case-folder. Step 2: If desired you can open a new console-window of the main-case-folder and follow the text-output by the command tail -f log"log" is the name of the log-file to be read in. To stop reading the file constantly just use Crtl+C Step 3: To plot the residuals graphically on the screen you can use gnuplot that is delivered with linux already. Within the main-case-folder you have to put a text file with a name e.g. "Residuals" (also see attachments). The file should contain the following gnuplot properties: set logscale yThe pause-command sets the seconds till reload. Deletion makes it faster in some cases. Execute the command gnuplot Residuals -in the main-case-folder. Step 4: Another good indicator for the calculations convergence is the forces-plot. Therefore you have to set the function in the controlDict that calculates the forces and forceCoeffs. See thread http://www.cfd-online.com/Forums/ope...es-of15-3.html or attachments. Be sure to have the properties for gnuplot in the main-case-folder (see attachments). You have the adapt the folder-name where the forceCoeffs.dat is inside before. While the calculation runs you also can use the gnuplot command gnuplot forceCoeffs -in the main-case-folder. When the forces seem to not change any more, the pressure allocation must be constantly what makes the convergent case proofed. Step5: Plotting the real forces is also easy. Proceed identically like in "Step 4" but be sure to set magUInf 1.0; //free stream velocity magnitudein the controlDict. Using the attached text-files, remove the ".txt" first. Hope that helps somebody. Greetings, Wolfgang |
|
May 7, 2009, 09:23 |
|
#2 |
Member
Marco Müller
Join Date: Mar 2009
Location: Germany
Posts: 94
Rep Power: 17 |
thanks ....................
|
|
May 7, 2009, 09:32 |
|
#3 |
Member
Marco Müller
Join Date: Mar 2009
Location: Germany
Posts: 94
Rep Power: 17 |
what about having pressure iterations. If I have say 5 pressure loops, the pressure graph "runs" away and plots over 5x instead of x....
|
|
May 8, 2009, 09:46 |
|
#4 |
Member
Flavio Galeazzo
Join Date: Mar 2009
Location: Karlsruhe, Germany
Posts: 34
Rep Power: 18 |
Thanks, Wolfgang! Really very useful.
|
|
May 9, 2009, 11:28 |
|
#5 |
New Member
Ashish Nedungadi
Join Date: Mar 2009
Location: Laurel, Maryland, USA
Posts: 13
Rep Power: 17 |
Wolfgang,
Vielen dank! As a newby to OF, I needed this tutorial. Regards Ashish |
|
May 18, 2009, 07:48 |
|
#6 |
New Member
Antonin
Join Date: Apr 2009
Location: France
Posts: 7
Rep Power: 17 |
Thanks, this tool is very useful.
|
|
June 3, 2009, 05:16 |
|
#7 |
Member
Leonardo Giampani Morita
Join Date: Apr 2009
Location: Paris, France
Posts: 58
Rep Power: 17 |
Hello,
What should I add if I wanted to plot the final residuals, not the initial ones? Thanks! |
|
June 4, 2009, 06:50 |
|
#8 | |
Member
Thomas Wolfanger
Join Date: Mar 2009
Location: South West Germany
Posts: 62
Rep Power: 17 |
Quote:
you could change the line extracting the pressure to read: cat log | grep 'Solving for p' | cut -d' ' -f9 | sed -n 'p;N;N;N;N' | tr -d ','" title 'p' with lines If you had two pressure iterations, you would change the argument to sed to read 'p;N'. If the final residual should be plottet, replace f9 at the cut command with f13. Best, -Thomas |
||
June 4, 2009, 07:46 |
|
#9 |
Member
Leonardo Giampani Morita
Join Date: Apr 2009
Location: Paris, France
Posts: 58
Rep Power: 17 |
It works perfectly, thank you very much, Thomas!
By the way, what does f13 mean? Something related to characters? Regards, Leonardo |
|
June 4, 2009, 08:03 |
|
#10 | |
Member
Thomas Wolfanger
Join Date: Mar 2009
Location: South West Germany
Posts: 62
Rep Power: 17 |
Quote:
"man cut" is your friend. Best, -Thomas |
||
July 8, 2009, 05:36 |
|
#11 |
Member
Bernard Esterhuyse
Join Date: Mar 2009
Location: Pretoria, South Africa
Posts: 50
Rep Power: 17 |
Thanks for this tool Wolfgang - a very useful and important tool.
|
|
August 14, 2009, 06:28 |
force.txt??
|
#12 |
Senior Member
Sandy Lee
Join Date: Mar 2009
Posts: 213
Rep Power: 18 |
Hi Wolfgang, thanks a lot. However, I guess, maybe you forget to give a attachment about "force.txt" ?
|
|
August 15, 2009, 14:32 |
Thank You
|
#13 |
Senior Member
Ahmed
Join Date: Mar 2009
Location: NY
Posts: 251
Rep Power: 18 |
That is a real brilliant addition to OpenFOAM
Thanks and Good Luck |
|
September 1, 2009, 11:36 |
|
#14 | |
New Member
Patrick Mueller
Join Date: Jun 2009
Location: Kaiserslautern
Posts: 8
Rep Power: 17 |
Quote:
But I have a little problem of undestanding why in Thomases addittion the first iteration gets plottet and the other four are ignored. Isn't the last of these iterations the most accurate? Or did I just misunderstand the code and it ignores the first iterations and plots the last one? Greetings, Patrick PS: I just plotted the residuals for both versions (p;N;N vs N;N;p), here are my solutions: p;N;N; - N;N;p: To me, the N;N;p version looks much more wishable and plausible. Btw I know that the residuals look a little bit suspicious after ~30 iterations, it's a problem I'm currently working on |
||
September 1, 2009, 16:54 |
|
#15 |
Member
Thomas Wolfanger
Join Date: Mar 2009
Location: South West Germany
Posts: 62
Rep Power: 17 |
Hello Patrick,
the place where the p lives is the line which is taken into account for further processing; when you have three lines and pipe them through sed with p;N;N only the first one is kept (as far as I remember); if in doubt, just consult the manpages. As for the residuals, I'm judging convergence only with respect to the initial value of the pressure (or velocity or whatever) residual because the second number gives you the residual after running the inner linear solver; the values calculated there will be changed again and are in no way related to the state of convergence of the whole flow under consideration. Best regards, -Thomas |
|
September 1, 2009, 22:30 |
|
#16 |
Member
Andrew King
Join Date: Mar 2009
Location: Perth, Western Australia, Australia
Posts: 82
Rep Power: 17 |
Another way to do this is to use pyFoam, http://openfoamwiki.net/index.php/Contrib_PyFoam, in particular
Code:
turbFoam > log & pyFoamPlotWatcher.py log Cheers, Andrew
__________________
Dr Andrew King Fluid Dynamics Research Group Curtin University |
|
September 2, 2009, 01:39 |
|
#17 |
Senior Member
Sandy Lee
Join Date: Mar 2009
Posts: 213
Rep Power: 18 |
Hi Thomas, I am still stunned. When should I write:
cat log | grep 'Solving for p' | cut -d' ' -f9 | sed -n 'p;N;N;N;N' | tr -d ','" title 'p' with lines (four 'N') OR cat log | grep 'Solving for p' | cut -d' ' -f9 | sed -n 'p;N;N' | tr -d ','" title 'p' with lines (just two 'N' ???) OR cat log | grep 'Solving for p' | cut -d' ' -f13 | sed -n 'p;N;N;N;N' | tr -d ','" title 'p' with lines ??? What is the differences to three ways?? Thanks |
|
September 2, 2009, 02:35 |
|
#18 | |
New Member
Patrick Mueller
Join Date: Jun 2009
Location: Kaiserslautern
Posts: 8
Rep Power: 17 |
Quote:
at first you determine which field you need. f13 means that you use the 13th field in the row, while you start counting with the comma after "solving for p". e.g. GAMG: Solving for p, Initial residual = 0.193462, Final residual = 1.37372e-05, No Iterations 8 The 9th field in this example would be the number 1.37e-05. The 13th would be the field after "8", which in my case doesn't exist. (Fields are seperated by an spare field, this is defined by: "by cut -d' '") Therefore you have to check your logfile and decide which field you want to plot. In the normal case this would be the 9th (-> f9). The number of "N" you have to write is determined by the number of iterations for p per timestep. In my case GAMG iterated p three times, so I have to ignore two iterations and write two Ns. In Thomases case, p is iterated five times, so he writes four Ns. I hope I could help you and didn't write too confusing, my first coffee still isn't done Greetings |
||
October 19, 2009, 09:35 |
|
#19 |
Senior Member
stephane sanchi
Join Date: Mar 2009
Posts: 314
Rep Power: 18 |
Dear Wolfgang, dear OF users,
Your utility for plotting the residuals works fine ! But I have difficulties in plotting the forces. I have the following file. What is the gnuplot command to plot Time versus viscous force in Z-direction ? # Time forces(pressure, viscous) moment(pressure, viscous) 1 (((1004.63 -5494.47 -84811.2) (-0.0374886 -0.0406053 198.671)) ((892.014 943.938 -82187.3) (-0.0179318 -0.0364229 -76.003))) 2 (((644.515 -3547.57 -121082) (-0.0537444 0.172973 204.824)) ((510.954 640.954 -73474.2) (-0.0724901 -0.0655304 -74.3758))) 3 (((25.51 -475.303 -90723.7) (-0.0715687 0.446436 209.538)) ((-67.716 124.304 -30308.4) (-0.115215 -0.0974344 -72.0424))) 4 (((-535.122 1943.6 -44831) (-0.0842006 0.560531 210.419)) ((-442.742 -316.419 10907.2) (-0.107376 -0.103469 -70.0699))) 5 (((-633.929 2570.15 4849.92) (-0.0969208 0.553209 210.327)) ((-433.453 -408.939 29814.8) (-0.0604264 -0.0826774 -69.0365))) 6 (((-334.82 1661.22 28439.5) (-0.0418605 0.582708 213.964)) ((-203.231 -256.368 24363.6) (-0.0309029 -0.00757822 -68.957))) 7 (((160.717 261.099 30270.3) (-0.156219 0.117149 220.562)) ((78.173 -8.60102 6858.77) (0.0489021 0.00722051 -70.0195))) 8 (((517.415 -791.764 17582.5) (-0.283258 -0.337861 224.95)) ((246.292 212.329 -9360.35) (0.0700387 -0.0303728 -71.5801))) 9 (((495.253 -1062.81 -5910.24) (-0.500476 -0.331616 224.337)) ((226.706 241.192 -16497.8) (0.0157957 -0.105875 -72.9496))) 10 (((229.94 -659.331 -22150.2) (-0.548931 -0.219443 220.292)) ((99.4034 139.613 -14183.1) (-0.0509668 -0.171714 -73.6661))) Regards, Stephane. |
|
October 20, 2009, 09:33 |
|
#20 |
Senior Member
stephane sanchi
Join Date: Mar 2009
Posts: 314
Rep Power: 18 |
the answer is
plot "< cat forces.dat | tr -d '(' | tr -d ')'" using 1:4 stephane |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
plot residuals in multiregion solver | val46 | OpenFOAM | 4 | December 12, 2016 07:06 |
To Plot Residuals on the fly. | neeraj | OpenFOAM Running, Solving & CFD | 5 | October 2, 2013 07:23 |
[PyFoam] why pyFoamPlotRunner doesn't plot continuity residuals? | immortality | OpenFOAM Community Contributions | 10 | May 5, 2013 07:13 |
plot of residuals | hawkeye321 | OpenFOAM | 5 | December 7, 2012 10:05 |
[Virtualization] OpenFOAM oriented tutorial on using VMware Player - support thread | wyldckat | OpenFOAM Installation | 2 | July 11, 2012 17:01 |