CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Main CFD Forum (https://www.cfd-online.com/Forums/main/)
-   -   Error in Time Calculation in transition mode (https://www.cfd-online.com/Forums/main/12056-error-time-calculation-transition-mode.html)

Morteza August 22, 2006 09:40

Error in Time Calculation in transition mode
 
Hi Guys,

I have a weird error in my code. When my code is marching in time in transition mode, somewhere between T_0 and T_END an error in claculation of time is occured. As an example, for dt=0.1, at Time=5.9 the value of Time in next time step is calculated as Time=5.9999999999 instead of 6.0 or for dt=0.2, it happens in Time=23.2 and Time is 23.3999999 instead of 23.4. I used Double Precision for dt and Time variables but still I have this problem. I appreciate to receive your advise to fix this issue.

Thanks Morteza

Mani August 23, 2006 06:51

Re: Error in Time Calculation in transition mode
 
How do you advance the time: Do you keep adding dt to the previous time, or do you multiply dt with an integer number of time steps?

Morteza August 23, 2006 07:21

Re: Error in Time Calculation in transition mode
 
Hi Mani,

It is just adding dt to previous time,

Thanks Morteza

Morteza August 23, 2006 07:54

Re: Error in Time Calculation in transition mode
 
Hi Mani,

It is just adding dt to previous time,

Thanks Morteza

Mani August 24, 2006 07:16

Re: Error in Time Calculation in transition mode
 
This will be inherently inaccurate as you keep accumulating round-off errors. The general advice is to use an integer as increment (number of time steps) and obtain the current time by multiplication of that integer with dt.


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