CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Running, Solving & CFD

plot residuals

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

Like Tree3Likes
  • 2 Post By pupo
  • 1 Post By manishm.cfd

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 9, 2016, 10:41
Default plot residuals
  #1
Member
 
Asmaa
Join Date: Mar 2016
Posts: 85
Rep Power: 6
foamiste is on a distinguished road
hello foamers,

I need to plot residuals with gnuplot in openFoam, I followed all instructions in this link http://www.cfd-online.com/Forums/ope...residuals.html but it doesn't work
I attached two files log and Residuals!! Can someone please plot it for me and then explain how did he do it?
Attached Files
File Type: txt log.txt (114.7 KB, 110 views)
File Type: txt Residuals.txt (466 Bytes, 143 views)
foamiste is offline   Reply With Quote

Old   June 9, 2016, 11:13
Default
  #2
Member
 
Pedro
Join Date: Nov 2014
Posts: 50
Rep Power: 8
pupo is on a distinguished road
Hi.

Are you running on windows or in Linux?

If you are using Linux, please remove the .txt extensions and run "gnuplot Residuals". It works, the problem is you are capturing all the pressure sub iterations, that's why you see way more pressure curves than velocity curves. In your case you 6 GAMG solver iterations per iteration, therefore, the "p" line should only present every 6th point.

Code:
set logscale y
set title "Residuals"
set ylabel 'Residual'
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,\
     "< cat log | grep 'Solving for Uz' | cut -d' ' -f9 | tr -d ','" title 'Uz' with lines,\
     "< cat log | grep 'Solving for p'  | cut -d' ' -f9 | tr -d ','" every 6 title 'p'   with lines
pause 1
reread


If you are using windows ( which i suspect you are because of the .txt) gnupot is not installed by default. how are you trying to run?

cheers
foamiste and Tom Lauriks like this.

Last edited by pupo; June 9, 2016 at 20:34.
pupo is offline   Reply With Quote

Old   June 9, 2016, 11:20
Angry
  #3
Member
 
Asmaa
Join Date: Mar 2016
Posts: 85
Rep Power: 6
foamiste is on a distinguished road
I am using windows , i have installed gnuplot and i try to load "residuals" file and plot it and I get this error message "Bad data on line 1"

And for the extension .txt I just add it to load files here in this forum otherwise it can't be loaded
foamiste is offline   Reply With Quote

Old   June 9, 2016, 11:24
Default
  #4
Member
 
Pedro
Join Date: Nov 2014
Posts: 50
Rep Power: 8
pupo is on a distinguished road
the problem is, this file mostly uses linux functions to parse the file.

every line of the log is read by a combo of

Code:
< cat log | grep 'Solving for Ux' | cut -d' ' -f9 | tr -d ','
Functions like cat, grep, cut, and tr are not available in windows

The only solution is for you to program your own parsing file using python, mathlab or something like that. And if you are doing that, you might just as well cut gnuplot completely and use either of those tools to plot the graphs.

I know there is a python residual script somewhere on the internet, but i've not been able to find it yet.

Good luck
pupo is offline   Reply With Quote

Old   June 9, 2016, 11:28
Exclamation
  #5
Member
 
Asmaa
Join Date: Mar 2016
Posts: 85
Rep Power: 6
foamiste is on a distinguished road
In fact i have a partition of linux in my computer.. I try with it to plot residuals but It doesn't respond .. I update gnuplot and I follow all the instructions but it react as if I don't give any command..
foamiste is offline   Reply With Quote

Old   June 9, 2016, 11:32
Default
  #6
Member
 
Pedro
Join Date: Nov 2014
Posts: 50
Rep Power: 8
pupo is on a distinguished road
are you sure you have navigated to the folder where you have both the residuals and log files?

once there run "gnuplot Residuals" and the plot should pop.

In case you missed it, for the graph to look good for your particular case, Residuals should look like this:

Code:
set logscale y
set title "Residuals"
set ylabel 'Residual'
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,\
     "< cat log | grep 'Solving for Uz' | cut -d' ' -f9 | tr -d ','" title 'Uz' with lines,\
     "< cat log | grep 'Solving for p' | cut -d' ' -f9 | tr -d ','" every 6 title 'p'   with lines
pause 1
reread
pupo is offline   Reply With Quote

Old   June 9, 2016, 11:47
Default
  #7
Member
 
Asmaa
Join Date: Mar 2016
Posts: 85
Rep Power: 6
foamiste is on a distinguished road
As you see I tried both of commands and I don't get anything
Attached Images
File Type: png Capture du 2016-06-09 14-46-30.png (57.2 KB, 150 views)
File Type: png Capture du 2016-06-09 14-47-48.png (67.6 KB, 121 views)
foamiste is offline   Reply With Quote

Old   June 9, 2016, 11:55
Default
  #8
Member
 
Pedro
Join Date: Nov 2014
Posts: 50
Rep Power: 8
pupo is on a distinguished road
This is really weird. The command is running, you should see a gnuplot window popping up.

For example, have me running "gnuplot Residuals" in a folder "CFDProblem" containing only the 2 folders you have attached.

I'm sorry, i can't help any further
Attached Images
File Type: jpg problemCFD.jpg (50.2 KB, 162 views)
pupo is offline   Reply With Quote

Old   June 9, 2016, 11:57
Default
  #9
Member
 
Asmaa
Join Date: Mar 2016
Posts: 85
Rep Power: 6
foamiste is on a distinguished road
Ok thank you
foamiste is offline   Reply With Quote

Old   September 13, 2016, 07:12
Default
  #10
Member
 
carno
Join Date: Mar 2009
Posts: 69
Rep Power: 13
Carno is on a distinguished road
I have similar problem.
when I give command
Code:
gnuplot Residuals
Following output comes,
Code:
$ gnuplot Residuals -

plot "< cat log | grep 'Solving for p' | cut -d' ' -f9 | tr -d ','" title 'p' with lines,"< cat log | grep 'Solving f                                             or 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,"< c                                             at log | grep 'Solving for k' | cut -d' ' -f9 | tr -d ','" title 'k' with lines,"< cat log | grep 'time step continui                                             ty errors' | cut -d' ' -f9 | tr -d ','" title 'continuity error' with lines,"< cat log | grep 'Solving for omega' | c                                             ut -d' ' -f9 | tr -d ','" title 'omega' with lines
                                                                                                                                                                                                                                                                                                                                                                                                                                                     ^
"Residuals", line 11: Bad data on line 208 of file < cat log | grep 'Solving for k' | cut -d' ' -f9 | tr -d ','
Earlier I use to plot very nicely. Suddenly this started happening.
My Residual file is,
Code:
set logscale y
set title "Residuals"
set ylabel 'Residual'
set xlabel 'Iteration'
plot "< cat log | grep 'Solving for p' | cut -d' ' -f9 | tr -d ','" title 'p' with lines,\
"< 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 k' | cut -d' ' -f9 | tr -d ','" title 'k' with lines,\
"< cat log | grep 'time step continuity errors' | cut -d' ' -f9 | tr -d ','" title 'continuity error' with lines,\
"< cat log | grep 'Solving for omega' | cut -d' ' -f9 | tr -d ','" title 'omega' with lines

pause 1
reread
Carno is offline   Reply With Quote

Old   April 17, 2018, 01:05
Default openFoam : RESIDUAL PLOT IN WINDOWS
  #11
New Member
 
ManishR
Join Date: Apr 2013
Posts: 2
Rep Power: 0
manishm.cfd is on a distinguished road
go to required directory

Depending on solver type following command to generate "log" folder
simpleFoam > log &

type following command to generate individual residual files like Ux_0,p_0 etc.

foamLog log >/dev/null


Now, Open gnuplot console and follow this

set logscale y
set title "Residuals"
set ylabel 'Residual'
set xlabel 'Iteration'

now for plotting Ux residues type following command
plot "logs/Ux_0" with lines,



Hope this helps


Now I am looking for "continuous residual plots as run goes on" in windows ( as we see it in any commercial tool)
mcfdma likes this.
manishm.cfd is offline   Reply With Quote

Old   June 13, 2018, 09:49
Default
  #12
New Member
 
Luigi Fumagalli
Join Date: Oct 2014
Posts: 1
Rep Power: 0
gigifumagalli is on a distinguished road
Hello everyone!
Has anyone found a way to plot the residuals on windows?
Thanks
gigifumagalli is offline   Reply With Quote

Old   July 1, 2018, 06:08
Default
  #13
Member
 
Cristina Hernandez
Join Date: May 2018
Posts: 35
Rep Power: 4
crizpi21 is on a distinguished road
Quote:
Originally Posted by foamiste View Post
As you see I tried both of commands and I don't get anything

Hi foamiste, did you manage to solve your problem?
I am experiencing the same, when I run gnuplot Residuals in my Ubuntu shell for Windows 10 I don't get anything.

Hope someone can help me!
crizpi21 is offline   Reply With Quote

Old   November 29, 2020, 21:59
Default
  #14
New Member
 
Mohammad
Join Date: Jan 2016
Posts: 9
Rep Power: 6
mmohaqeqf is on a distinguished road
Look here:
Plot the residuals using pyFoamPlotWatcher
mmohaqeqf is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Tutorials] Tutorial of how to plot residuals ! wolle1982 OpenFOAM Community Contributions 162 December 2, 2020 13:21
[swak4Foam] Foam warnings - related to swak4Foam Salam-H OpenFOAM Community Contributions 20 August 2, 2015 16:40
plot residuals pigna OpenFOAM Running, Solving & CFD 2 December 19, 2014 03:32
How to plot residuals of all iterations in Fluent FJSJ FLUENT 4 September 20, 2013 10:47
Residuals Plot kamalipour FLUENT 2 December 15, 2011 04:44


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