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

plot residuals

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

Like Tree1Likes
  • 1 Post By pupo

Reply
 
LinkBack Thread Tools Display Modes
Old   June 9, 2016, 09:41
Default plot residuals
  #1
Member
 
Asmaa
Join Date: Mar 2016
Posts: 50
Rep Power: 3
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, 7 views)
File Type: txt Residuals.txt (466 Bytes, 7 views)
foamiste is offline   Reply With Quote

Old   June 9, 2016, 10:13
Default
  #2
Member
 
Pedro
Join Date: Nov 2014
Posts: 50
Rep Power: 4
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 likes this.

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

Old   June 9, 2016, 10:20
Angry
  #3
Member
 
Asmaa
Join Date: Mar 2016
Posts: 50
Rep Power: 3
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, 10:24
Default
  #4
Member
 
Pedro
Join Date: Nov 2014
Posts: 50
Rep Power: 4
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, 10:28
Exclamation
  #5
Member
 
Asmaa
Join Date: Mar 2016
Posts: 50
Rep Power: 3
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, 10:32
Default
  #6
Member
 
Pedro
Join Date: Nov 2014
Posts: 50
Rep Power: 4
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, 10:47
Default
  #7
Member
 
Asmaa
Join Date: Mar 2016
Posts: 50
Rep Power: 3
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, 25 views)
File Type: png Capture du 2016-06-09 14-47-48.png (67.6 KB, 19 views)
foamiste is offline   Reply With Quote

Old   June 9, 2016, 10:55
Default
  #8
Member
 
Pedro
Join Date: Nov 2014
Posts: 50
Rep Power: 4
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, 22 views)
pupo is offline   Reply With Quote

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

Old   September 13, 2016, 06:12
Default
  #10
Member
 
carno
Join Date: Mar 2009
Posts: 41
Rep Power: 10
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

Reply

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
Tutorial of how to plot residuals ! wolle1982 OpenFOAM Running, Solving & CFD 142 February 23, 2017 10:07
Foam warnings - related to swak4Foam Salam-H OpenFOAM Running, Solving & CFD 20 August 2, 2015 15: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 09:47
Residuals Plot kamalipour FLUENT 2 December 15, 2011 04:44


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