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

Residual plot for OpenFOAM-ext problem.

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

Like Tree1Likes
  • 1 Post By billie

Reply
 
LinkBack Thread Tools Display Modes
Old   May 8, 2013, 15:39
Default Residual plot for OpenFOAM-ext problem.
  #1
Member
 
Sangeeta
Join Date: Jul 2012
Location: Kingston, Canada
Posts: 63
Rep Power: 2
Sargam05 is on a distinguished road
Hello everyone,

I am using OpenFOAM-ext for the stressAnalysis problem. I have successfully used Residual script to plot gnuplot in OpenFOAM1.7.1. I have made changes in the Residual script based on OpenFAOM-ext log file but it is showing some error.

Following is the log file in my case:

Time: 1

Time 1, Corrector 0, Solving for U using DICPCG, residual = 1, relative residual = 59362.4

Time 1, Solving for U, Initial residual = 1, Final residual = 1, Relative residual = 59362.4, No outer iterations 1
ExecutionTime = 26.44 s ClockTime = 27 s
ExecutionTime = 26.6 s


Time: 2

Time 2, Corrector 0, Solving for U using DICPCG, residual = 1, relative residual = 1

Time 2, Solving for U, Initial residual = 1, Final residual = 1, Relative residual = 1, No outer iterations 1
ExecutionTime = 37.93 s ClockTime = 38 s
ExecutionTime = 38.12 s


Time: 3

Time 3, Corrector 0, Solving for U using DICPCG, residual = 0.305633, relative residual = 1

Time 3, Solving for U, Initial residual = 0.305633, Final residual = 0.305633, Relative residual = 1, No outer iterations 1
ExecutionTime = 54.7 s ClockTime = 55 s
ExecutionTime = 54.9 s


Time: 4

Time 4, Corrector 0, Solving for U using DICPCG, residual = 0.229696, relative residual = 1

Time 4, Solving for U, Initial residual = 0.229696, Final residual = 0.229696, Relative residual = 1, No outer iterations 1
ExecutionTime = 66.4 s ClockTime = 67 s
ExecutionTime = 66.59 s


Time: 5

Time 5, Corrector 0, Solving for U using DICPCG, residual = 0.155004, relative residual = 1

Time 5, Solving for U, Initial residual = 0.155004, Final residual = 0.155004, Relative residual = 1, No outer iterations 1
ExecutionTime = 83.12 s ClockTime = 83 s
ExecutionTime = 83.3 s


Time: 6

Time 6, Corrector 0, Solving for U using DICPCG, residual = 0.088822, relative residual = 1

Time 6, Solving for U, Initial residual = 0.088822, Final residual = 0.088822, Relative residual = 1, No outer iterations 1
ExecutionTime = 96.02 s ClockTime = 96 s
ExecutionTime = 96.21 s


Time: 7

Time 7, Corrector 0, Solving for U using DICPCG, residual = 0.0763407, relative residual = 1

Time 7, Solving for U, Initial residual = 0.0763407, Final residual = 0.0763407, Relative residual = 1, No outer iterations 1
ExecutionTime = 109.27 s ClockTime = 110 s
ExecutionTime = 109.45 s


Time: 8

Time 8, Corrector 0, Solving for U using DICPCG, residual = 0.0426613, relative residual = 1

Time 8, Solving for U, Initial residual = 0.0426613, Final residual = 0.0426613, Relative residual = 1, No outer iterations 1
ExecutionTime = 121.37 s ClockTime = 122 s
ExecutionTime = 121.57 s


The script I am using to plot gnuplot is:

set terminal png
set output "filename.png"

set logscale y
set title "Residuals"
set ylabel 'Residual'
set xlabel 'Time'
cat log | grep 'Solving for U' | cut -d' ' -f9 | tr -d ','" title 'U' with lines
pause 1
reread


It is showing following error:

cat log | grep 'Solving for U' | cut -d' ' -f9
^
"Residuals", line 8: invalid command

sangeeta@sangeeta-laptop:~/Desktop/plateHole0.0001stress$ gnuplot Residuals

cat log | grep 'Solving for U' | cut -d' ' -f9 | tr -d ','" title 'Ux' with lines"
^
"Residuals", line 8: invalid command

sangeeta@sangeeta-laptop:~/Desktop/plateHole0.0001stress$ gnuplot Residuals

cat log | grep 'Solving for U' | cut -d' ' -f9 | tr -d ','" title 'Ux' with lines"
^
"Residuals", line 8: invalid command


Am I using wrong script? Can anyone explain how I can change the script to plot residual gnuplot based on log file (which I have mentioned above)?

Best regards,
Sangeeta
Sargam05 is offline   Reply With Quote

Old   May 9, 2013, 04:47
Default
  #2
Senior Member
 
Tushar
Join Date: Jul 2009
Location: India
Posts: 102
Blog Entries: 1
Rep Power: 5
Tushar@cfd is on a distinguished road
Quote:
Originally Posted by Sargam05 View Post
Hello everyone,

I am using OpenFOAM-ext for the stressAnalysis problem. I have successfully used Residual script to plot gnuplot in OpenFOAM1.7.1. I have made changes in the Residual script based on OpenFAOM-ext log file but it is showing some error.

Following is the log file in my case:

Time: 1

Time 1, Corrector 0, Solving for U using DICPCG, residual = 1, relative residual = 59362.4

Time 1, Solving for U, Initial residual = 1, Final residual = 1, Relative residual = 59362.4, No outer iterations 1
ExecutionTime = 26.44 s ClockTime = 27 s
ExecutionTime = 26.6 s


Time: 2

Time 2, Corrector 0, Solving for U using DICPCG, residual = 1, relative residual = 1

Time 2, Solving for U, Initial residual = 1, Final residual = 1, Relative residual = 1, No outer iterations 1
ExecutionTime = 37.93 s ClockTime = 38 s
ExecutionTime = 38.12 s


Time: 3

Time 3, Corrector 0, Solving for U using DICPCG, residual = 0.305633, relative residual = 1

Time 3, Solving for U, Initial residual = 0.305633, Final residual = 0.305633, Relative residual = 1, No outer iterations 1
ExecutionTime = 54.7 s ClockTime = 55 s
ExecutionTime = 54.9 s


Time: 4

Time 4, Corrector 0, Solving for U using DICPCG, residual = 0.229696, relative residual = 1

Time 4, Solving for U, Initial residual = 0.229696, Final residual = 0.229696, Relative residual = 1, No outer iterations 1
ExecutionTime = 66.4 s ClockTime = 67 s
ExecutionTime = 66.59 s


Time: 5

Time 5, Corrector 0, Solving for U using DICPCG, residual = 0.155004, relative residual = 1

Time 5, Solving for U, Initial residual = 0.155004, Final residual = 0.155004, Relative residual = 1, No outer iterations 1
ExecutionTime = 83.12 s ClockTime = 83 s
ExecutionTime = 83.3 s


Time: 6

Time 6, Corrector 0, Solving for U using DICPCG, residual = 0.088822, relative residual = 1

Time 6, Solving for U, Initial residual = 0.088822, Final residual = 0.088822, Relative residual = 1, No outer iterations 1
ExecutionTime = 96.02 s ClockTime = 96 s
ExecutionTime = 96.21 s


Time: 7

Time 7, Corrector 0, Solving for U using DICPCG, residual = 0.0763407, relative residual = 1

Time 7, Solving for U, Initial residual = 0.0763407, Final residual = 0.0763407, Relative residual = 1, No outer iterations 1
ExecutionTime = 109.27 s ClockTime = 110 s
ExecutionTime = 109.45 s


Time: 8

Time 8, Corrector 0, Solving for U using DICPCG, residual = 0.0426613, relative residual = 1

Time 8, Solving for U, Initial residual = 0.0426613, Final residual = 0.0426613, Relative residual = 1, No outer iterations 1
ExecutionTime = 121.37 s ClockTime = 122 s
ExecutionTime = 121.57 s


The script I am using to plot gnuplot is:

set terminal png
set output "filename.png"

set logscale y
set title "Residuals"
set ylabel 'Residual'
set xlabel 'Time'
cat log | grep 'Solving for U' | cut -d' ' -f9 | tr -d ','" title 'U' with lines
pause 1
reread


It is showing following error:

cat log | grep 'Solving for U' | cut -d' ' -f9
^
"Residuals", line 8: invalid command

sangeeta@sangeeta-laptop:~/Desktop/plateHole0.0001stress$ gnuplot Residuals

cat log | grep 'Solving for U' | cut -d' ' -f9 | tr -d ','" title 'Ux' with lines"
^
"Residuals", line 8: invalid command

sangeeta@sangeeta-laptop:~/Desktop/plateHole0.0001stress$ gnuplot Residuals

cat log | grep 'Solving for U' | cut -d' ' -f9 | tr -d ','" title 'Ux' with lines"
^
"Residuals", line 8: invalid command


Am I using wrong script? Can anyone explain how I can change the script to plot residual gnuplot based on log file (which I have mentioned above)?

Best regards,
Sangeeta
You missed to use the keywords: plot "< before your command.
plot "< cat log | grep 'Solving for U' | cut -d' ' -f9 | tr -d ','" title 'U' with lines

Tushar@cfd is offline   Reply With Quote

Old   May 9, 2013, 04:55
Default
  #3
Senior Member
 
Tushar
Join Date: Jul 2009
Location: India
Posts: 102
Blog Entries: 1
Rep Power: 5
Tushar@cfd is on a distinguished road
Also, refer the following page:

Tutorial of how to plot residuals !
Tushar@cfd is offline   Reply With Quote

Old   May 9, 2013, 14:53
Default
  #4
Member
 
Sangeeta
Join Date: Jul 2012
Location: Kingston, Canada
Posts: 63
Rep Power: 2
Sargam05 is on a distinguished road
Hi Tushar,

Thank so much for the inputs. I have used "plot" as you suggested:

set terminal png
set output "filename.png"
set logscale y
set title "Residuals"
set ylabel 'Residual'
set xlabel 'Iteration'
plot "< cat log | grep 'Solving for U' | cut -d' ' -f9 | tr -d ','" title 'U' with lines
pause 1
reread

but still it is showing following error:

plot "< cat log | grep 'Solving for U' | cut -d' ' -f9 | tr -d ','" title 'U' with lines
^
"Residuals", line 8: Bad data on line 1

I did go through some posts for plotting gnuplot for residuals and I have tried to do this as mentioned in the posts but still it is showing some error. Do you have any idea way it is coming?

Thanks,
Sangeeta
Sargam05 is offline   Reply With Quote

Old   May 10, 2013, 01:48
Default
  #5
Senior Member
 
Tushar
Join Date: Jul 2009
Location: India
Posts: 102
Blog Entries: 1
Rep Power: 5
Tushar@cfd is on a distinguished road
Quote:
Originally Posted by Sargam05 View Post
Hi Tushar,

Thank so much for the inputs. I have used "plot" as you suggested:

set terminal png
set output "filename.png"
set logscale y
set title "Residuals"
set ylabel 'Residual'
set xlabel 'Iteration'
plot "< cat log | grep 'Solving for U' | cut -d' ' -f9 | tr -d ','" title 'U' with lines
pause 1
reread

but still it is showing following error:

plot "< cat log | grep 'Solving for U' | cut -d' ' -f9 | tr -d ','" title 'U' with lines
^
"Residuals", line 8: Bad data on line 1

I did go through some posts for plotting gnuplot for residuals and I have tried to do this as mentioned in the posts but still it is showing some error. Do you have any idea way it is coming?

Thanks,
Sangeeta

Try these steps.. I always follow these for plotting residuals.


Open the case folder in your console window (terminal).

execute the $application (for eg. icoFoam or any $Foam which you are using) and simultaneously write a log file using the following command in the terminal:

$application >log


Then open gnuplot in the same console window, and execute the following command:

set logscale y
set title "Residuals"
set ylabel 'Residual'
set xlabel 'Iteration'
plot "< cat log | grep 'Solving for U' | cut -d' ' -f9 | tr -d ','" title 'U' with lines
pause 1
reread

I wish this will solve your problem.
Tushar@cfd is offline   Reply With Quote

Old   May 10, 2013, 02:02
Default
  #6
Senior Member
 
Tushar
Join Date: Jul 2009
Location: India
Posts: 102
Blog Entries: 1
Rep Power: 5
Tushar@cfd is on a distinguished road
Try to edit your output log file like the following and then follow the procedure as mentioned in my earlier post....


// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Create time

Create mesh for time = 0

Reading transportProperties

Reading field p

Reading field U

Reading/calculating face flux field phi


Starting time loop

Time: 1

Solving for U using DICPCG, Initial residual = 1, Final residual = 1, Relative residual = 59362.4, No outer iterations 1
ExecutionTime = 26.44 s ClockTime = 27 s
ExecutionTime = 26.6 s


Time: 2

Solving for U using DICPCG, Initial residual = 1, Final residual = 1, Relative residual = 1, No outer iterations 1
ExecutionTime = 37.93 s ClockTime = 38 s
ExecutionTime = 38.12 s


Time: 3

Solving for U using DICPCG, Initial residual = 0.305633, Final residual = 0.305633, Relative residual = 1, No outer iterations 1
ExecutionTime = 54.7 s ClockTime = 55 s
ExecutionTime = 54.9 s


Time: 4

Solving for U using DICPCG, Initial residual = 0.229696, Final residual = 0.229696, Relative residual = 1, No outer iterations 1
ExecutionTime = 66.4 s ClockTime = 67 s
ExecutionTime = 66.59 s


Time: 5

Solving for U using DICPCG, Initial residual = 0.155004, Final residual = 0.155004, Relative residual = 1, No outer iterations 1
ExecutionTime = 83.12 s ClockTime = 83 s
ExecutionTime = 83.3 s

Time: 6

Solving for U using DICPCG, Initial residual = 0.088822, Final residual = 0.088822, Relative residual = 1, No outer iterations 1
ExecutionTime = 96.02 s ClockTime = 96 s
ExecutionTime = 96.21 s


Time: 7

Solving for U using DICPCG, Initial residual = 0.0763407, Final residual = 0.0763407, Relative residual = 1, No outer iterations 1
ExecutionTime = 109.27 s ClockTime = 110 s
ExecutionTime = 109.45 s


Time: 8

Solving for U using DICPCG, Initial residual = 0.0426613, Final residual = 0.0426613, Relative residual = 1, No outer iterations 1
ExecutionTime = 121.37 s ClockTime = 122 s
ExecutionTime = 121.57 s

#########

I think that was the problem with your case, I hope now you are able to plot.
Tushar@cfd is offline   Reply With Quote

Old   May 10, 2013, 12:35
Default
  #7
Member
 
Sangeeta
Join Date: Jul 2012
Location: Kingston, Canada
Posts: 63
Rep Power: 2
Sargam05 is on a distinguished road
Hi Tushar,

Thank you so much for the suggestions! I have edited some of the initial part of the log file and used the command you mentioned in gnuplot but it is still showing following error:

Terminal type set to 'wxt'
gnuplot> set logscale y
gnuplot> set title "Residuals"
gnuplot> set ylabel 'Residual'
gnuplot> set xlabel 'Iteration'
gnuplot> plot "< cat log | grep 'Solving for U' | cut -d' ' -f9 | tr -d ','" title 'U' with lines
^
Bad data on line 1

gnuplot> pause 1
gnuplot> reread

I do not know if something is wrong in logs file. I am also attaching the log and logs folders as attachment. Please let me know if something is wrong in these folders.

Best regards,
Sangeeta
Attached Files
File Type: zip log.zip (11.7 KB, 3 views)
File Type: zip logs.zip (3.5 KB, 3 views)
Sargam05 is offline   Reply With Quote

Old   May 11, 2013, 02:00
Default
  #8
Senior Member
 
Tushar
Join Date: Jul 2009
Location: India
Posts: 102
Blog Entries: 1
Rep Power: 5
Tushar@cfd is on a distinguished road
Quote:
Originally Posted by Sargam05 View Post
Hi Tushar,

Thank you so much for the suggestions! I have edited some of the initial part of the log file and used the command you mentioned in gnuplot but it is still showing following error:

Terminal type set to 'wxt'
gnuplot> set logscale y
gnuplot> set title "Residuals"
gnuplot> set ylabel 'Residual'
gnuplot> set xlabel 'Iteration'
gnuplot> plot "< cat log | grep 'Solving for U' | cut -d' ' -f9 | tr -d ','" title 'U' with lines
^
Bad data on line 1

gnuplot> pause 1
gnuplot> reread

I do not know if something is wrong in logs file. I am also attaching the log and logs folders as attachment. Please let me know if something is wrong in these folders.

Best regards,
Sangeeta
Can you please upload the controlDict file?
Tushar@cfd is offline   Reply With Quote

Old   May 11, 2013, 05:24
Default
  #9
New Member
 
Daniel Pielmeier
Join Date: Apr 2012
Posts: 26
Rep Power: 3
billie is on a distinguished road
Quote:
Originally Posted by Sargam05 View Post
Time: 8

Time 8, Corrector 0, Solving for U using DICPCG, residual = 0.0426613, relative residual = 1

Time 8, Solving for U, Initial residual = 0.0426613, Final residual = 0.0426613, Relative residual = 1, No outer iterations 1
ExecutionTime = 121.37 s ClockTime = 122 s
ExecutionTime = 121.57 s
Quote:
Originally Posted by Sargam05 View Post
gnuplot> plot "< cat log | grep 'Solving for U' | cut -d' ' -f9 | tr -d ','" title 'U' with lines
^
Bad data on line 1
You grep for 'Solving for U' split by space and use the 9th field but as you can see there are different lines in your log file containing the grep string. The problem is for the line with the corrector the 9th field is "DICPCG" and gnuplot only works with numbers. You have restrict your grep string so it only matches the line with your residual.
billie is offline   Reply With Quote

Old   May 11, 2013, 14:13
Default
  #10
Member
 
Sangeeta
Join Date: Jul 2012
Location: Kingston, Canada
Posts: 63
Rep Power: 2
Sargam05 is on a distinguished road
Hi Tushar and Daniel,

Thank you for the reply. Tushar please find controlDict file as attachment.

Daniel even after changing the script based on log file following error is comping:

plot "< cat log | grep 'Solving for U using DICPCG' | cut -d' ' -f9 | tr -d ','" title 'U' with lines
^
"Residuals", line 8: Bad data on line 1
Attached Files
File Type: zip controlDict.zip (597 Bytes, 2 views)
Sargam05 is offline   Reply With Quote

Old   May 11, 2013, 14:42
Default
  #11
New Member
 
Daniel Pielmeier
Join Date: Apr 2012
Posts: 26
Rep Power: 3
billie is on a distinguished road
Quote:
Originally Posted by Sargam05 View Post
Hi Tushar and Daniel,

Thank you for the reply. Tushar please find controlDict file as attachment.

Daniel even after changing the script based on log file following error is comping:

plot "< cat log | grep 'Solving for U using DICPCG' | cut -d' ' -f9 | tr -d ','" title 'U' with lines
^
"Residuals", line 8: Bad data on line 1
It is always a good idea to test this first in a console.

Check the output of:

Code:
cat log | grep 'Solving for U using DICPCG' | cut -d' ' -f9 | tr -d ','
It should give you a series of "DICPCG". This is because the line you are grepping for the residual is in field 12 and not in field 9. So you can either use
Code:
cat log | grep 'Solving for U using DICPCG' | cut -d' ' -f12 | tr -d ','
or
Code:
cat log | grep 'Solving for U,' | cut -d' ' -f9 | tr -d ','
Tushar@cfd likes this.
billie is offline   Reply With Quote

Old   May 11, 2013, 21:37
Default
  #12
Member
 
Sangeeta
Join Date: Jul 2012
Location: Kingston, Canada
Posts: 63
Rep Power: 2
Sargam05 is on a distinguished road
Hi Daniel,

Thank you so much for the suggestions. Now it plotting residuals. I appreciate your help!

I also like to thank Tushar for his inputs.

Best regards,
Sangeeta
Sargam05 is offline   Reply With Quote

Old   Today, 06:50
Default
  #13
Senior Member
 
Tushar
Join Date: Jul 2009
Location: India
Posts: 102
Blog Entries: 1
Rep Power: 5
Tushar@cfd is on a distinguished road
Quote:
Originally Posted by Sargam05 View Post
Hi Daniel,

Thank you so much for the suggestions. Now it plotting residuals. I appreciate your help!

I also like to thank Tushar for his inputs.

Best regards,
Sangeeta
It's good to see, you are getting your residual plots.
Tushar@cfd 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
How to write k and epsilon before the abnormal end xiuying OpenFOAM Running, Solving & CFD 7 March 15, 2013 06:08
SLTS+rhoPisoFoam: what is rDeltaT??? nileshjrane OpenFOAM Running, Solving & CFD 4 February 25, 2013 04:13
High Courant Number @ icoFoam Artex85 OpenFOAM Running, Solving & CFD 9 January 3, 2012 08:06
Problems with simulating TurbFOAM barath.ezhilan OpenFOAM 13 July 16, 2009 05:55
Negative value of k causing simulation to stop velan OpenFOAM Running, Solving & CFD 1 October 17, 2008 05:36


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