modify->clearstep_compute() and addstepcompute

Dear all,

This question relates to the use of variables in the input script, which can then be used to define parameters used by fixes (for example) in LAMMPS.

I am trying to implement something for fix wall/gran. I noticed that even though velocity.cpp and fix_add_force.cpp seem to be doing something similar, the relevant code in the case of velocity.cpp (lines 469-477) does not do the following (fix_add_force lines 267-281 does, 4Dec12 version):

    modify->clearstep_compute();
...
...
and after the quantity needed is calculated through input->variable->compute_equal() or input->variable->compute_atom()

    modify->addstep_compute(update->ntimestep + 1);

I looked into what the above functions do and the first one clears the invoked_flag of all computes, while the second one adds the next timestep to the list of timesteps that the time-dependent computes should be invoked (I think).

I was wondering whether the calls to clearstep_compute() and addstepcompute() are needed in fix_add_force.cpp . Will this not cause unnecessary calling of all time-dependent computes, irrespective of whether any computes are used? Would it not clear all invoked_flags no matter whether the computes were called at the current timestep or not? Could these 2 functions have been called elsewhere (eg in Variable::evaluate) inside an if statement activated by a compute?

Or stated in a different way, what is the effect of not calling these 2 functions in velocity.cpp? I.e. is it best to include them or not in my extra code?
This point is probably minor but half of the LAMMPS files include the extra code and half don't, so there could be effects on users of other fixes, eg fix_gravity, when a variable gravity is specified.

Thank you,

George

Dear all,

This question relates to the use of variables in the input script, which can then be used to define parameters used by fixes (for example) in LAMMPS.

I am trying to implement something for fix wall/gran. I noticed that even though velocity.cpp and fix_add_force.cpp seem to be doing something similar, the relevant code in the case of velocity.cpp (lines 469-477) does not do the following (fix_add_force lines 267-281 does, 4Dec12 version):

    modify->clearstep_compute();
...
...
and after the quantity needed is calculated through input->variable->compute_equal() or input->variable->compute_atom()

    modify->addstep_compute(update->ntimestep + 1);

I looked into what the above functions do and the first one clears the invoked_flag of all computes, while the second one adds the next timestep to the list of timesteps that the time-dependent computes should be invoked (I think).

I was wondering whether the calls to clearstep_compute() and addstepcompute() are needed in fix_add_force.cpp . Will this not cause unnecessary calling of all time-dependent computes, irrespective of whether any computes are used? Would it not clear all

please note, that the code in velocity.cpp is only called when a velocity
command is issued, i.e. between runs, whereas the fix_add_force.cpp code
is executed repeatedly during the propagation of a system. this requires to
do extra work that usually is not required outside of propagation, since this
will be done during the "setup"-phase of any propagation anyway.

invoked_flags no matter whether the computes were called at the
current timestep or not? Could these 2 functions have been called
elsewhere (eg in Variable::evaluate) inside an if statement activated
by a compute?

Or stated in a different way, what is the effect of not calling these 2 functions in velocity.cpp? I.e. is it best to include them or not in my extra code?
This point is probably minor but half of the LAMMPS files include the extra code and half don't, so there could be effects on users of other fixes, eg fix_gravity, when a variable gravity is specified.

true, but there is so much code in LAMMPS and only so few people that
have the time to implement everything everywhere. fee free to update other
fixes so they can handle variables as valid input. i am certain that steve
and other LAMMPS users will appreciate it.

axel.

Or stated in a different way, what is the effect of not calling these 2 functions in velocity.cpp? I.e. is it best to include them or not in my extra >code?
This point is probably minor but half of the LAMMPS files include the extra code and half don't, so there could be effects on users of other >fixes, eg fix_gravity, when a variable gravity is specified.

Axel is correct - fixes that evaluate variables should have the
clearstep/addstep logic b/c they are called during a run,
though it really only affects things that need energy and virials. If
the variable is evaluated outside a run (e.g. velocity
command) then the clearstep/addstep is not needed. There is very
little overhead associated with clearstep/addstep.

Steve