|
[Sponsors] |
[Tutorials] Tutorial of how to plot residuals ! |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
February 22, 2017, 23:22 |
Works but?
|
#141 |
Senior Member
Peter Hess
Join Date: Apr 2011
Location: Austria
Posts: 250
Rep Power: 17 |
Hello Everybody!
Thank for the great feedback. I tried the code and it works! I changed the code slightly like this: set logscale y set title "Tmax heater" set ylabel 'Tmax' set xlabel 'Iteration' plot "< cat log.chtMultiRegionSimpleFoam | grep 'Min/max' | cut -d' ' -f3 | tr -d ','" title 'Tmax' pause 1 reread It works actually but I have a problem. In my log.chtMultiRegionSimpleFoam file, one iteration looks like this: Solving for fluid region bottomAir DILUPBiCG: Solving for Ux, Initial residual = 2.470196e-05, Final residual = 2.969919e-07, No Iterations 1 DILUPBiCG: Solving for Uy, Initial residual = 1.437032e-05, Final residual = 1.604827e-07, No Iterations 1 DILUPBiCG: Solving for Uz, Initial residual = 1.741628e-05, Final residual = 4.959543e-07, No Iterations 1 DILUPBiCG: Solving for h, Initial residual = 0.009048544, Final residual = 5.287758e-05, No Iterations 2 Min/max T:303.7611 304.39 GAMG: Solving for p_rgh, Initial residual = 4.127734e-05, Final residual = 1.326083e-06, No Iterations 1000 time step continuity errors : sum local = 1.355654e-07, global = -4.023393e-19, cumulative = -0.0886042 Min/max rho:1.156752 1.159142 Solving for fluid region topAir DILUPBiCG: Solving for Ux, Initial residual = 1.136693e-05, Final residual = 3.449505e-08, No Iterations 1 DILUPBiCG: Solving for Uy, Initial residual = 8.489421e-05, Final residual = 1.582533e-07, No Iterations 1 DILUPBiCG: Solving for Uz, Initial residual = 2.811805e-05, Final residual = 3.09551e-08, No Iterations 1 DILUPBiCG: Solving for h, Initial residual = 0.0001787168, Final residual = 1.17763e-06, No Iterations 1 Min/max T:300 304.1752 GAMG: Solving for p_rgh, Initial residual = 0.0001523519, Final residual = 7.043136e-07, No Iterations 2 time step continuity errors : sum local = 3.013158e-07, global = -2.91909e-07, cumulative = -0.08860449 Min/max rho:1.142718 1.158621 Solving for solid region heater DICPCG: Solving for h, Initial residual = 0.006304606, Final residual = 0.0004823271, No Iterations 1 Min/max T:304.0113 304.3917 Solving for solid region leftSolid DICPCG: Solving for h, Initial residual = 0.009657879, Final residual = 0.0003739408, No Iterations 1 Min/max T:303.7599 304.1081 Solving for solid region rightSolid DICPCG: Solving for h, Initial residual = 0.01246801, Final residual = 0.0004664707, No Iterations 1 Min/max T:303.8347 304.1204 ExecutionTime = 453.44 s ClockTime = 454 s Time = 2000 In this iteration Min/max appears 5 times! The code above prints the Tmax 5 times... How could I print just the Min/max for a specific region, lets say for region heater? For any feedback I would be very thankful! Regards Peter Last edited by peterhess; February 23, 2017 at 00:58. |
|
February 23, 2017, 06:54 |
|
#142 | |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
Quote:
Bernhard
__________________
Note: I don't use "Friend"-feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request |
||
February 23, 2017, 10:07 |
|
#143 |
Senior Member
Peter Hess
Join Date: Apr 2011
Location: Austria
Posts: 250
Rep Power: 17 |
Hello Bernhard,
Thanks for the suggestion. I will work on it and see whats happends. Regards Peter Last edited by peterhess; February 23, 2017 at 12:03. |
|
November 20, 2017, 06:40 |
|
#144 |
New Member
Serkan
Join Date: Jun 2017
Location: Belgium
Posts: 6
Rep Power: 9 |
It still works properly. Thank you so much.
|
|
December 6, 2017, 13:08 |
|
#145 |
Member
Honza Höll
Join Date: Mar 2016
Location: Brno, CZ
Posts: 37
Rep Power: 10 |
Hi foamers,
I used some ideas written here and wrote own script to plot residuals vs time on the fly during simulation. My script is for interFoam solver but it can be changed for others. file residuals.sh prepares input data for gnuplot every n seconds and run gnuplot file gnupl_input is gnuplot file which defines plot design Paste these files into case folder, edit files and run ./residuals.sh during simulation. Enjoy. |
|
December 8, 2017, 08:01 |
|
#146 | |
Senior Member
Robert
Join Date: May 2015
Location: Bremen, GER
Posts: 292
Rep Power: 12 |
This might be a bit off-topic, but i hope someone can help me. As written multiple times the original residual script works fine. Also for me. Now, as i am running transient simulation i came up with the idea of monitoring my Courant Number using the approach taken in the residual script.
The output i want to plot is: Code:
Courant Number mean: 0.0108355 max: 0.113549 Code:
plot "< cat piso.log | grep 'Courant Number' | cut -d' ' -f4 | tr -d ','" title 'Co mean' with lines,\ "< cat piso.log | grep 'max:' | cut -d' ' -f8 | tr -d ','" title 'Co max' with lines, reread Quote:
Regards Robert |
||
December 8, 2017, 13:07 |
|
#147 |
Member
Honza Höll
Join Date: Mar 2016
Location: Brno, CZ
Posts: 37
Rep Power: 10 |
Have you tried run second command to separate co max number simply in bash? Try simply cat, then add grep, cut an so on. I think it is on 6th position not 8th.
|
|
December 12, 2017, 05:16 |
Revised plot residuals vs time on the fly during simulation
|
#148 | |
New Member
George XU
Join Date: Dec 2009
Posts: 9
Rep Power: 17 |
Quote:
Revised scripts are updated in case it is useful. |
||
December 13, 2017, 03:55 |
|
#149 |
Member
Honza Höll
Join Date: Mar 2016
Location: Brno, CZ
Posts: 37
Rep Power: 10 |
Hey that's great! What kind of coding (UTF, ...) did you use for residual.sh? I'm not able to open it correctly in Vim or Gedit.
|
|
December 13, 2017, 04:40 |
|
#150 | |
New Member
George XU
Join Date: Dec 2009
Posts: 9
Rep Power: 17 |
Quote:
Here they are. |
||
July 11, 2018, 11:01 |
plot residual
|
#151 |
Member
Ben 017
Join Date: Nov 2017
Posts: 70
Rep Power: 9 |
Hello,
I don't know if this thread is still active, but i have a question My problem now is the difference between ux uy and P residual plot. why pressure goes up to 2000 while ux and uy ends at 500 iterations. Could you help me to know why? You may see my plot of residuals on attached picture I will be happy to get your support. Regard! |
|
July 11, 2018, 11:42 |
|
#152 |
Senior Member
Peter Hess
Join Date: Apr 2011
Location: Austria
Posts: 250
Rep Power: 17 |
Hello!
Why: Well because you have proberly 4 times pressure corrections (nNonOrthogonalCorrectors 3; ) in your PISO in the fvSolution. The code shown above searches every time for "Solving for Ux, Solving for Ux, Solving for p". The code find in every itteration 1 X Solving for Ux and 1 X Solving for Uy and 4 X Solving for p. 4 X 500 = 2000 ! Solution: Well, instead of plotting the p and ux, uy on the same graph, I suggest to plot them separately. Make a file called plot_U and use the following code inside: set title "Residuals" set ylabel 'Residual_U' set xlabel 'Iteration' plot "< cat log | grep 'Solving for Ux' | cut -d' ' -f9 | tr -d ','" title 'Ux' with lines,\ "< cat log | grep 'Solving for Uy' | cut -d' ' -f9 | tr -d ','" title 'Uy' with lines pause 1 reread Make other file called plot_p and use the following code inside: set title "Residuals" set ylabel 'Residual_p' set xlabel 'Iteration' plot "< cat log | grep 'Solving for p' | cut -d' ' -f9 | tr -d ','" title 'p' with lines pause 1 reread Start gnuplot by typing: gnuplot plot_p | gnuplot plot_U Like that two graphs will be started simultaneously. Or simply reduce the nNonOrthogonalCorrectors to 0 and plot as before... Regards Peter Last edited by peterhess; July 11, 2018 at 15:03. |
|
July 11, 2018, 16:13 |
|
#153 |
Member
Ben 017
Join Date: Nov 2017
Posts: 70
Rep Power: 9 |
I thank 4r the feedback.
That approach is much better though it is not answering my question. Why does pressure residuals goes up to 2000 velocity stop at 500 iteration? (previous post) Is there a scientific reason? Thank you! |
|
July 11, 2018, 23:48 |
|
#154 |
Senior Member
Peter Hess
Join Date: Apr 2011
Location: Austria
Posts: 250
Rep Power: 17 |
Hello,
I answerd the question in the first section of my post. It has no scientific reason. If you take a look to your log file you will see in one itteration something like this: 1: smoothSolver: Solving for Ux, Initial residual = 0.931847, Final residual = 7.06554e-06, No Iterations 21 1: smoothSolver: Solving for Uy, Initial residual = 0.899434, Final residual = 7.32104e-06, No Iterations 20 1: DICPCG: Solving for p, Initial residual = 0.965189, Final residual = 0.0378369, No Iterations 20 2: DICPCG: Solving for p, Initial residual = 0.0197448, Final residual = 0.000760858, No Iterations 4 3: DICPCG: Solving for p, Initial residual = 0.000761143, Final residual = 3.19517e-05, No Iterations 19 4: DICPCG: Solving for p, Initial residual = 3.19457e-05, Final residual = 9.21943e-07, No Iterations 10 That means, in one calculation itteration you are printing 4 times for pressure. The total number of itterations is 500. The 2000 itterations come from 4 times pressure corrections X 500! Do the following to see the effect: Reducing the nNonOrthogonalCorrectors in fvSolution from 3 to 0 will result: 1: smoothSolver: Solving for Ux, Initial residual = 0.931847, Final residual = 7.06554e-06, No Iterations 21 1: smoothSolver: Solving for Uy, Initial residual = 0.899434, Final residual = 7.32104e-06, No Iterations 20 1: DICPCG: Solving for p, Initial residual = 0.965189, Final residual = 0.0378369, No Iterations 20 Like that the counter for the pressure and the velocities are identical! Regards Peter |
|
July 12, 2018, 01:11 |
|
#155 | |
Member
Ben 017
Join Date: Nov 2017
Posts: 70
Rep Power: 9 |
Quote:
Do you have an idea about convergence? So far I think it occurs at a certain iteration where the solution is not changing compared to the previous iteration. For my case(earlier posted) I think after 150 iterations the solution was not still changing. hence simulation converged. Is that true? Regard! |
||
July 12, 2018, 03:27 |
|
#156 |
Senior Member
Peter Hess
Join Date: Apr 2011
Location: Austria
Posts: 250
Rep Power: 17 |
Hello!
Well this is a complatly different topic than the thread in this discussion. This topic has been discussed so often in the Forum. Search for those threads and you will find much informations. Or open a new thread Regards Peter |
|
February 15, 2019, 10:24 |
|
#157 |
New Member
Join Date: Jan 2019
Posts: 10
Rep Power: 7 |
Hi everyone,
I've been using this script, and I'm wondering if anyone can help me with non-orthogonal correctors. In this thread a few people have talked about using sed -n 'p;N...' to only plot the first sub-iteration for pressure, which works great, although I have changed the number of non-orthogonal correctors part way through my case, does anyone know how to account for this. Is it possible to read the first X steps of the log and plot in one way, and then plot the remaining steps in a different way, to adjust for the change in non-orthogonal correctors? Thanks, Kieran |
|
September 29, 2019, 22:23 |
gnuplot window keeps popping up
|
#158 |
New Member
Join Date: Nov 2018
Posts: 2
Rep Power: 0 |
Thank you for that plotting solution!
But I have a question: gnuplot window keeps popping up even after the simulation is over. I think thats because it rereads the log every n seconds no matter if simulation is over or not.. How could I tell it to stop if new data isn't added to the log anymore? |
|
August 18, 2020, 09:51 |
|
#159 |
New Member
Join Date: Aug 2020
Posts: 7
Rep Power: 6 |
While trying to plot Residuals by following the steps above I am getting an error message like this. Please help me out. gnuplot> load "Residuals" "Residuals" line 10: warning: Skipping data file with no valid points "Residuals" line 10: warning: Skipping data file with no valid points "Residuals" line 10: warning: Skipping data file with no valid points "Residuals" line 10: warning: Skipping data file with no valid points "Residuals" line 10: warning: Skipping data file with no valid points "Residuals" line 10: warning: Skipping data file with no valid points gnuplot> plot "< cat log | grep 'Solving for Ux' | cut -d' ' -f9 | tr -d ','" title 'Ux' with lines, "< cat log | grep 'Solving for Uy' | cut -d' ' -f9 | tr -d ','" title 'Uy' with lines, "< cat log | grep 'Solving for Uz' | cut -d' ' -f9 | tr -d ','" title 'Uz' with lines, "< cat log | grep 'Solving for omega' | cut -d' ' -f9 | tr -d ','" title 'omega' with lines, "< cat log | grep 'Solving for k' | cut -d' ' -f9 | tr -d ','" title 'k' with lines, "< cat log | grep 'Solving for p' | cut -d' ' -f9 | tr -d ','" title 'p' with lines ^ "Residuals" line 10: x range is invalid |
|
August 18, 2020, 12:41 |
|
#160 |
Senior Member
Peter Hess
Join Date: Apr 2011
Location: Austria
Posts: 250
Rep Power: 17 |
I got this error also before...
I dont know why that happens, anyway the probleme could be solved by adding: set xrange [1:*] at the start of the skript. Regards Peter |
|
|
|
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 |