CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > General Forums > Main CFD Forum

FORTRAN NaN PROBLEM

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 19, 2014, 10:49
Default FORTRAN NaN PROBLEM
  #1
New Member
 
Rakuen
Join Date: Oct 2011
Posts: 6
Rep Power: 14
Rakuen is on a distinguished road
Hi,

When i am runnning my fortran code with deltax or deltay is about 1 micron, it writes NaN after a while. It starts smooth but then blows. Is it only about mesh or any other thing?

Thank you.
Rakuen is offline   Reply With Quote

Old   March 19, 2014, 11:01
Default
  #2
Senior Member
 
Filippo Maria Denaro
Join Date: Jul 2010
Posts: 6,764
Rep Power: 71
FMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura about
Quote:
Originally Posted by Rakuen View Post
Hi,

When i am runnning my fortran code with deltax or deltay is about 1 micron, it writes NaN after a while. It starts smooth but then blows. Is it only about mesh or any other thing?

Thank you.

check the matrix bounds using the correct compiler options, use the debug and the the flow chart until discovering the error...some variable is accessing location of memory already declared
FMDenaro is offline   Reply With Quote

Old   March 19, 2014, 11:08
Default
  #3
New Member
 
Rakuen
Join Date: Oct 2011
Posts: 6
Rep Power: 14
Rakuen is on a distinguished road
Quote:
Originally Posted by FMDenaro View Post
check the matrix bounds using the correct compiler options, use the debug and the the flow chart until discovering the error...some variable is accessing location of memory already declared
Thank you for your reply,

What do you mean "correct compiler options" and "flow chart". Can you give me more specific information about that.
Rakuen is offline   Reply With Quote

Old   March 19, 2014, 12:53
Default
  #4
Senior Member
 
andy
Join Date: May 2009
Posts: 268
Rep Power: 17
andy_ is on a distinguished road
Quote:
Originally Posted by Rakuen View Post
When i am runnning my fortran code with deltax or deltay is about 1 micron, it writes NaN after a while. It starts smooth but then blows. Is it only about mesh or any other thing?
This looks like the simulation becoming unstable which can happen because of violating convective and/or diffusive stability limits, unstable boundary conditions, stiff sources, etc...

NaN is Not a Number and you get it when the computer is asked to perform an undefined operation like 0/0 plus a bunch of others. It is trivial to find with a debugger if you are able to recompile the code for debugging and then run it under a debugger?
andy_ is offline   Reply With Quote

Old   March 19, 2014, 13:31
Default
  #5
New Member
 
Rakuen
Join Date: Oct 2011
Posts: 6
Rep Power: 14
Rakuen is on a distinguished road
Quote:
Originally Posted by andy_ View Post
This looks like the simulation becoming unstable which can happen because of violating convective and/or diffusive stability limits, unstable boundary conditions, stiff sources, etc...

NaN is Not a Number and you get it when the computer is asked to perform an undefined operation like 0/0 plus a bunch of others. It is trivial to find with a debugger if you are able to recompile the code for debugging and then run it under a debugger?
Thanks for your reply, as i wrote before NaN happens when i reduce deltax or deltay to micron level. CFL number is suitable to satisfy stability.

My problem is that why is it happening with SMALLER mesh?

Thank you.
Rakuen is offline   Reply With Quote

Old   March 19, 2014, 13:36
Default
  #6
Senior Member
 
Filippo Maria Denaro
Join Date: Jul 2010
Posts: 6,764
Rep Power: 71
FMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura about
Quote:
Originally Posted by andy_ View Post
This looks like the simulation becoming unstable which can happen because of violating convective and/or diffusive stability limits, unstable boundary conditions, stiff sources, etc...

NaN is Not a Number and you get it when the computer is asked to perform an undefined operation like 0/0 plus a bunch of others. It is trivial to find with a debugger if you are able to recompile the code for debugging and then run it under a debugger?

yes, it could be also a numerical instability, but generally that appears after many iterations, not running for a while...
FMDenaro is offline   Reply With Quote

Old   March 19, 2014, 19:35
Default
  #7
Senior Member
 
andy
Join Date: May 2009
Posts: 268
Rep Power: 17
andy_ is on a distinguished road
Quote:
Originally Posted by Rakuen View Post
Thanks for your reply, as i wrote before NaN happens when i reduce deltax or deltay to micron level. CFL number is suitable to satisfy stability.

My problem is that why is it happening with SMALLER mesh?
Do you have diffusion terms? If you do and all or part of the terms are explicit then you will need to check your diffusion number as well as your CFL limit.

If you have additional source terms these can have stability limits.

You are solving non-linear equations and so the linearisation can have stability issues.

You have boundary conditions which can have all sorts of stability issues.

Plus umpteen others.

The most common problem with self written code is of course mistakes in the coding which can also show up as NaN.

Is there a reason you haven't run the code under a debugger and found out why your code is failing?
andy_ is offline   Reply With Quote

Old   March 20, 2014, 07:00
Default
  #8
New Member
 
Rakuen
Join Date: Oct 2011
Posts: 6
Rep Power: 14
Rakuen is on a distinguished road
Quote:
Originally Posted by andy_ View Post
Do you have diffusion terms? If you do and all or part of the terms are explicit then you will need to check your diffusion number as well as your CFL limit.

If you have additional source terms these can have stability limits.

You are solving non-linear equations and so the linearisation can have stability issues.

You have boundary conditions which can have all sorts of stability issues.

Plus umpteen others.

The most common problem with self written code is of course mistakes in the coding which can also show up as NaN.

Is there a reason you haven't run the code under a debugger and found out why your code is failing?
Thank you Andy,

Diffusion number is what i didn't concern about before. Diffusion terms are solved with an algorithm in my code that i didn't write.

I have never felt debugging necessary. Actually, i don't know how to debug my code. Can you tell me how i detect where my code is failing or giving NaN by running under a debugger?

By the way, about 1 million time step is solved for giving NaN. But it is short as compared as my total time step.
Rakuen is offline   Reply With Quote

Old   March 20, 2014, 08:40
Default
  #9
Senior Member
 
andy
Join Date: May 2009
Posts: 268
Rep Power: 17
andy_ is on a distinguished road
Quote:
Originally Posted by Rakuen View Post
Diffusion number is what i didn't concern about before. Diffusion terms are solved with an algorithm in my code that i didn't write.

I have never felt debugging necessary. Actually, i don't know how to debug my code. Can you tell me how i detect where my code is failing or giving NaN by running under a debugger?
If you are running locally on workstation then pressing the debug button followed by the run button may be all that is required. If you are running remotely on a parallel computer then you may have to look up how to debug.

The notion that you can write CFD code without needing to debug it seems absurd. As does trying to debug a program without knowing what it does. It looks like you may be wise to take some time out to learn the code and the tools required before proceeding with your task. If you have access to local supervision I would strongly advise that over posting to forums like this.
andy_ is offline   Reply With Quote

Old   March 23, 2014, 08:27
Default
  #10
Senior Member
 
Lefteris
Join Date: Oct 2011
Location: UK
Posts: 337
Rep Power: 15
Aeronautics El. K. is on a distinguished road
Just a very wild guess:
you said that you're getting NaN when you make the Δx, Δy in the order of 10e-6. Can it be the case that the computer rounds this to 0? Are you using single or double precision?
__________________
Lefteris

Aeronautics El. K. is offline   Reply With Quote

Old   March 23, 2014, 09:14
Default
  #11
New Member
 
Rakuen
Join Date: Oct 2011
Posts: 6
Rep Power: 14
Rakuen is on a distinguished road
Quote:
Originally Posted by Aeronautics El. K. View Post
Just a very wild guess:
you said that you're getting NaN when you make the Δx, Δy in the order of 10e-6. Can it be the case that the computer rounds this to 0? Are you using single or double precision?
Thank you for your reply,


I an using double precision and if the computer rounds a variable to 0, it starts to write NaN at the beginning of the run.


Now i am investigating my equation of state. My working fluid is water. There might be a problem under EOS.


Thank you.
Rakuen 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
user fortran 'USER_GETVAR' problem D.ko CFX 0 April 30, 2013 10:58
Problem with plasma test case: residuals are NAN rafpepe SU2 2 January 20, 2013 09:37
Fortran compiler problem Luke Siemens 2 September 18, 2008 03:43
Problem with Fortran installation. skarp CFX 0 August 4, 2007 07:09
'C' or FORTRAN or 'C++' Yogesh Talekar Main CFD Forum 20 October 21, 1999 04:00


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