/*
    Test if the stepper cache buffers are flushed when starting a new run
*/

setgridsize(1,1,1)
setcellsize(1,1,1)

msat = 1000e3
alpha = 0.1
B_ext = vector(0, 0, 0.05)

setsolver(5) // This steppers uses a cache buffer
fixdt = 1e-12

m = uniform(1,0,0)
steps(1)
rotation_wanted := acos( vector(1,0,0).dot(m.average()) )

m = uniform(-1,0,0)
steps(1)
rotation := acos( vector(-1,0,0).dot(m.average()) )

// Note that the rotation angle should be the same for the two cases for symmetry reasons.
// However, if the cache buffers are not removed, this will lead to an erroneous result in
// the second case.

expect("m rotation angle", rotation, rotation_wanted, 1e-5)