CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Main CFD Forum (https://www.cfd-online.com/Forums/main/)
-   -   FORTRAN NaN PROBLEM (https://www.cfd-online.com/Forums/main/131696-fortran-nan-problem.html)

Rakuen March 19, 2014 10:49

FORTRAN NaN PROBLEM
 
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.

FMDenaro March 19, 2014 11:01

Quote:

Originally Posted by Rakuen (Post 480890)
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

Rakuen March 19, 2014 11:08

Quote:

Originally Posted by FMDenaro (Post 480895)
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.

andy_ March 19, 2014 12:53

Quote:

Originally Posted by Rakuen (Post 480890)
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?

Rakuen March 19, 2014 13:31

Quote:

Originally Posted by andy_ (Post 480913)
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.

FMDenaro March 19, 2014 13:36

Quote:

Originally Posted by andy_ (Post 480913)
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...

andy_ March 19, 2014 19:35

Quote:

Originally Posted by Rakuen (Post 480921)
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?

Rakuen March 20, 2014 07:00

Quote:

Originally Posted by andy_ (Post 480984)
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.

andy_ March 20, 2014 08:40

Quote:

Originally Posted by Rakuen (Post 481077)
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.

Aeronautics El. K. March 23, 2014 08:27

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?

Rakuen March 23, 2014 09:14

Quote:

Originally Posted by Aeronautics El. K. (Post 481578)
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.


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