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 Community New Posts Updated Threads Search

Like Tree4Likes
  • 3 Post By pupo
  • 1 Post By manishm.cfd

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 9, 2016, 09:41
Default plot residuals
  #1
Senior Member
 
Asmaa
Join Date: Mar 2016
Posts: 102
Rep Power: 10
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, 175 views)
File Type: txt Residuals.txt (466 Bytes, 228 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: 11
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, saidc. and Tom Lauriks like 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
Senior Member
 
Asmaa
Join Date: Mar 2016
Posts: 102
Rep Power: 10
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: 11
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
Senior Member
 
Asmaa
Join Date: Mar 2016
Posts: 102
Rep Power: 10
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: 11
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
Senior Member
 
Asmaa
Join Date: Mar 2016
Posts: 102
Rep Power: 10
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, 226 views)
File Type: png Capture du 2016-06-09 14-47-48.png (67.6 KB, 178 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: 11
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, 242 views)
pupo is offline   Reply With Quote

Old   June 9, 2016, 10:57
Default
  #9
Senior Member
 
Asmaa
Join Date: Mar 2016
Posts: 102
Rep Power: 10
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: 70
Rep Power: 17
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, 00: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, 08: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, 05:08
Default
  #13
Member
 
Cristina Hernandez
Join Date: May 2018
Posts: 35
Rep Power: 7
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, 20:59
Default
  #14
Member
 
Mohammad M F
Join Date: Jan 2016
Location: Washington DC, USA
Posts: 43
Rep Power: 10
mmohaqeqf is on a distinguished road
Look here:
Plot the residuals using pyFoamPlotWatcher
mmohaqeqf is offline   Reply With Quote

Old   January 14, 2022, 15:48
Default I cannot plot residuals in OpenFOAM for Windows 10
  #15
New Member
 
Christian
Join Date: Jun 2020
Posts: 1
Rep Power: 0
chriscabaq96 is on a distinguished road
Hello Community, I have problems with the residuals. I have the residuals and the log file, but when I put the command gnuplot residuals I have the following announcement:
Traceback (most recent call last):
File "/usr/lib/command-not-found", line 28, in <module>
from CommandNotFound import CommandNotFound
File "/usr/lib/python3/dist-packages/CommandNotFound/CommandNotFound.py", line 19, in <module>
from CommandNotFound.db.db import SqliteDatabase
File "/usr/lib/python3/dist-packages/CommandNotFound/db/db.py", line 5, in <module>
import apt_pkg
ImportError: /opt/OpenFOAM/OpenFOAM-v2012/ThirdParty/platforms/linux64/gcc-6.3.0/lib64/libstdc++.so.6: version `GLIBCXX_3.4.26' not found (required by /lib/x86_64-linux-gnu/libapt-pkg.so.6.0)

Thanks in advance.
Christian
chriscabaq96 is offline   Reply With Quote

Reply


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 171 February 20, 2024 02:55
[swak4Foam] Foam warnings - related to swak4Foam Salam-H OpenFOAM Community Contributions 20 August 2, 2015 15:40
plot residuals pigna OpenFOAM Running, Solving & CFD 2 December 19, 2014 02: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 03:44


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