accessing previous time step value (recursive variable type)

Hi !

Is there a way to compute a variable depending on its previous value (on the previous time step)?
Something like V_i=a*V_{i-1}+b ...

I found that the store/state fix could possibly work, but it seems it will write at each time step in a file and not keep the variable into the memory.

Thanks a lot,
joris

In general, no. Because variables are not even
evaluated unless they are needed on a specific timestep.
You could write a fix to do this and store whatever
you want from previous timesteps. That's not really
what fix store/state is designed for.

You could use a second variable to store the current
value of the first variable. If you used a loop (via the
jump command), it would be possible to have the
2nd variable store the value of the 1st variable on the
previous loop iteration, simply by assigning them at
the right point in the loop.

Steve

Thks for the suggestions Steve !
I'll consider writing a fix. Or turn to python coupling...

Steve,
I tried your second option:

# init previous step variable to 0
variable Uprev atom 0

# loop
variable a loop 10
label loop

# create variable from random and last time step
variable Ux atom normal(0,1,1)+v_Uprev
# evaluate the constant variable that will be used during the run (via addforce)
variable Uxconst atom ${Ux}

run 1000
next a
#save previous step variable
variable Uprev atom ${Uxconst}
jump in.flume loop

However, immediate evaluation of variable "${}" seems not to work with atom_type variable. Is it the case ?

Thanks,
joris

However, immediate evaluation of variable "${}" seems not to work with
atom_type variable. Is it the case ?

yes. those are expanded even *before* the script text
is parsed, so they cannot work for atom style variables.

axel.