Page 1 of 1

run control

Posted: Fri Oct 16, 2015 3:38 am
by ylzang

Code: Select all

dt = 0.2
    tstop = 500
    while (t<tstop) {
    fadvance()}
    dt = 0.02
    tstop = 700
    while (t<tstop) {
    fadvance()
    count+=1
For the first period, when t< 500 ms, it was calculated at t = 0.2,0.4..., and finally 500. For the second period, in my simulation, it was calculated at 500.02, 500.04,... and finally 700.02. Why the the time point at 700.02 can be calculated? I think the last time point should be 700. Thanks.

Re: run control

Posted: Fri Oct 16, 2015 3:55 pm
by ted
Sounds like finite precision arithmetic and roundoff error. At a minimum read this:
viewtopic.php?f=8&t=1686&p=12613

Re: run control

Posted: Sat Oct 17, 2015 10:07 pm
by ylzang
ted wrote:Sounds like finite precision arithmetic and roundoff error. At a minimum read this:
viewtopic.php?f=8&t=1686&p=12613
just the roundoff error? the default value of float_epsilon is 1e-11. Do you mean I cannot control the last recorded data point to be at 700 ms? I understand the second last point may be like 699.999999... . It is still smaller than 700, so the next time point close to 700.02 will be calculated. I knew this before, just did not realise it may cause problems even setting the float_epsilon to be 1e-11.

Re: run control

Posted: Sun Oct 18, 2015 10:51 am
by ted

Code: Select all

oc>x = 0
oc>for i=1,2500 x+=0.2
oc>x
	500 
oc>x-500
	-1.9838353e-11
oc>x = 0
oc>for i=1,35000 x+=0.02
oc>x-700
	-3.4663117e-10
Got it now?

Re: run control

Posted: Sun Oct 18, 2015 9:14 pm
by ylzang
ted wrote:

Code: Select all

oc>x = 0
oc>for i=1,2500 x+=0.2
oc>x
	500 
oc>x-500
	-1.9838353e-11
oc>x = 0
oc>for i=1,35000 x+=0.02
oc>x-700
	-3.4663117e-10
Got it now?
got it.