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 
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?

Re: Error in Time Calculation in transition mode
Hi Mani,
It is just adding dt to previous time, Thanks Morteza 
Re: Error in Time Calculation in transition mode
Hi Mani,
It is just adding dt to previous time, Thanks Morteza 
Re: Error in Time Calculation in transition mode
This will be inherently inaccurate as you keep accumulating roundoff 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 18:04. 