[lammps-users] Fix move with compute variables

Hi all,

I've been using fix move with the wiggle option to do some simple resonance simulations. Now I find that I need more complicated resonance patterns than what wiggle can do. So I wrote a compute to get the pattern and used that with the variable option to fix move, expecting this to work:

compute pattern bottom my_resonance_compute parameters
variable 0 equal "0"
variable pattern_z atom "c_pattern[1]"
variable pattern_vz atom "c_pattern[2]"
fix resonance bottom move variable &
                 v_0 v_0 v_pattern_z v_0 v_0 v_pattern_vz &
                 units box

However, this doesn't produce the result I want because the values of the pattern_z and pattern_vz variables are not recomputed each timestep as fix move requires. So I added this to fix_move.cpp:

@@ -570,6 +572,7 @@ void FixMove::initial_integrate(int vflag)

      // pre-compute variable values

+ modify->clearstep_compute();
      if (xvarstr) {
        if (xvarstyle == EQUAL) dx = input->variable->compute_equal(xvar);
        else input->variable->compute_atom(xvar,igroup,&displace[0][0],3,0);

That seems to work. However, I see in some other places (fix_print.cpp, fix_adapt.cpp) there is also a call to modify->addstep_compute(). Does this function need to be called, and if so with what argument?

Thanks.

yep - that's a bug - and the solution is the clearstep() and addstep() calls.
The variable was being re-evaluated every timestep, but not the compute
it contains (which is typically rare for a variable used in this mode, to use
a compute).

A few other fixes that now recently allow for variable args, also had
this problem.
Posted a 18Oct10 patch.

Thanks,
Steve