djanloo / quilt

A multiscale neural simulator
MIT License
0 stars 0 forks source link

Bug in interpolation with Natural Continuous Extensions #18

Closed djanloo closed 2 months ago

djanloo commented 2 months ago

A system of an oscillator, a transducer and a spiking population is evolved. When the rate of the oscillator reaches the transducer it experiences jitters, most probably due to an interpolation bug in the MemoryRK class.

bug_NCE

djanloo commented 2 months ago

This probably has something to do with the extra timestep of initialization of OscillatorNetwork.

[2024-06-25 17:07:34] - PID 126121939617600 - ERROR: NCERK interpolated at theta = 1 is different from the next point.
Interpolating from n = 12
X[n] = 0.907022
X[n+1] = 0.89745
interpolation(theta=1) =0.903574
delta(theta = 1) = -0.00344811
b_0(theta = 1 ): 0.333333
b_0: 0.333333
    adding to delta b_0 * K_0
         K_0 = -1.9327e-07
b_1(theta = 1 ): 0.166667
b_1: 0.166667
    adding to delta b_1 * K_1
         K_1 = -0.00374113
b_2(theta = 1 ): 0.166667
b_2: 0.166667
    adding to delta b_2 * K_2
         K_2 = -0.00336703
b_3(theta = 1 ): 0.333333
b_3: 0.333333
    adding to delta b_3 * K_3
         K_3 = -0.00679007
evaluation history is:
( 0, 0, 0, 0, ) -- ( 0, 0, 0, 0, ) -- ( 0, 0, 0, 0, ) -- ( 0, 0, 0, 0, ) -- ( 0, 0, 0, 0, ) -- ( 0, 0, 0, 0, ) -- ( 0, 0, 0, 0, ) -- ( 0, 0, 0, 0, ) -- ( 0, 0, 0, 0, ) -- ( 0, 0, 0, 0, ) -- ( 0, 0, 0, 0, ) -- ( 0, 0, 0, 0, ) -- ( -1.9327e-07, -0.00374113, -0.00336703, -0.00679007, ) -- ( -0.00677819, -0.00982417, -0.00950271, -0.0122764, ) -- ( -0.012266, -0.0147156, -0.0144401, -0.0166572, ) -- ( -0.0166482, -0.0185876, -0.0183524, -0.0200941, ) -- ( -0.0200862, -0.0215907, -0.0213907, -0.0227279, ) -- ( -0.0227211, -0.0238567, -0.0236876, -0.0246825, ) -- ( -0.0246768, -0.0255015, -0.02536, -0.0260676, ) -- ( -0.026063, -0.0266285, -0.026512, -0.026982, ) -- ( -0.0269786, -0.0273326, -0.02724, -0.0275188, ) -- ( -0.0275177, -0.0277068, -0.0276393, -0.0277749, ) -- ( -0.0277765, -0.0278503, -0.0278108, -0.027853, ) -- 
state history is:
( 0.91047) -- ( 0.91047) -- ( 0.91047) -- ( 0.91047) -- ( 0.91047) -- ( 0.91047) -- ( 0.91047) -- ( 0.91047) -- ( 0.91047) -- ( 0.91047) -- ( 0.91047) -- ( 0.91047) -- ( 0.907022) -- ( 0.89745) -- ( 0.882949) -- ( 0.864545) -- ( 0.84311) -- ( 0.819385) -- ( 0.793993) -- ( 0.767455) -- ( 0.740194) -- ( 0.712538) -- ( 0.684718) -- 
djanloo commented 2 months ago

It seems that, despite having the same length, evaluation history of the Runge-Kutta Ks are shifted of one timestep.

bug_NCE2

Adding +1 to the index solves the continuity but the integrator still does not work (should be continuous in first derivative).

djanloo commented 2 months ago

Initialization of ContinuousRK states/evaluations were misaligned by one timestep. See the comment in 7b57226.