Adapting bond length sinusoidally of a dimer

Dear experts and my fellow users
I am trying to adapt in time (sinusoidally) the bond length of one of my molecule, therefore I tried coding it in LAMMPS as shown below

variable 	rand equal normal(0.0,0.2,43563)
variable	stepbefore equal "(((step-10)/10)+1)+((((step-10)/10)+1)==0)"
variable	stepnow equal "(((step)/10)+1)"
set		mol 1 bond 1
variable 	r0phase equal "(0.1+v_rand)*dt"
fix 		Vec all vector 10 v_r0phase
variable	bond equal 1.5+0.1*sin(f_Vec[v_stepbefore]+f_Vec[v_stepnow])
fix 		adapt gM adapt 10 bond harmonic r0 1 v_r0phase #v_bond

thermo          10
thermo_style    custom step time v_stepbefore v_stepnow v_bond 

The idea simply is to record variable phase (sin(v_r0phase)) in time in a vector (v_Vec) and then use the ith component of vector in the fix adapt.
The process runs smoothly if I do not supply v_bond in fix adapt (thats why commented and this is what I require), but when I put it in the fix adapt then I get the error that my fix_vector in variable bond is accessed out of range. Why this is so?
I want the phase at a previous time to calculate the current phase.
Can I do this by invoking a python function in LAMMPS?