set_mask()

Dear developers,

I have a question with regards to set_mask() function of a fix.

How is the sequence of calling fixes determined?
For example,

FixNVE:: setmask() {
   int mask = 0;
   mask |= INITIAL_INTEGRATE;
   mask |= FINAL_INTEGRATE;
   mask |= PRE_EXCHANGE;
   mask |= MIN_PRE_EXCHANGE;
   return mask;
}

so, at the end mask=2^0+2^6+2^2+2^14
how is that number used later to determine the sequence?
how do I make my fix to execute final_integrate() after the integrator?

p/s/ I looked at modify.cpp and fmask, but it is not clear to me how this is implemented.

Kind regards,
Denis

Dear developers,

I have a question with regards to set_mask() function of a fix.

How is the sequence of calling fixes determined?

first by the integrator or minimizer algorithm.
and then by the order in which fixes are defined.

For example,

FixNVE:: setmask() {
   int mask = 0;
   mask |= INITIAL_INTEGRATE;
   mask |= FINAL_INTEGRATE;
   mask |= PRE_EXCHANGE;
   mask |= MIN_PRE_EXCHANGE;
   return mask;
}

so, at the end mask=2^0+2^6+2^2+2^14
how is that number used later to determine the sequence?

the various flags indicate at what part of time
integration (minimization) the fix is to be called
(or not).

how do I make my fix to execute final_integrate() after the integrator?

by defining it after the integrator fix.

p/s/ I looked at modify.cpp and fmask, but it is not clear to me how
this is implemented.

you have to look at files like verlet.cpp

axel.

Dear Axel,

Thanks for your prompt reply,
some comments are below....

Dear developers,

I have a question with regards to set_mask() function of a fix.

How is the sequence of calling fixes determined?

first by the integrator or minimizer algorithm.
and then by the order in which fixes are defined.

For example,

FixNVE:: setmask() {
   int mask = 0;
   mask |= INITIAL_INTEGRATE;
   mask |= FINAL_INTEGRATE;
   mask |= PRE_EXCHANGE;
   mask |= MIN_PRE_EXCHANGE;
   return mask;
}

so, at the end mask=2^0+2^6+2^2+2^14
how is that number used later to determine the sequence?

the various flags indicate at what part of time
integration (minimization) the fix is to be called
(or not).

so this works as a flag only and if the fix is turned on at
particular step, it has no influence on the sequence, right?

how do I make my fix to execute final_integrate() after the integrator?

by defining it after the integrator fix.

That's exactly why I looked into this.
I would like to have the fix defined relatively at the beginning of the input file and
then use it throughout with different integrators, e.g.
fix MYFIX...
fix nve..
unfix nve...
...
fix npt..
unfix npt...
...

and I don't want to cal "fix MYFIX..." every time I do another round of nve/npt/... 'steps'.
Do you see any simple workaround for this?

p/s/ I looked at modify.cpp and fmask, but it is not clear to me how
this is implemented.

you have to look at files like verlet.cpp

verlet.cpp calls
modify->final_integrate();
which uses 'list_final_integrate';
the latter is built in
list_init(int mask, int &n, int *&list) which walks through all fixes for i=0:nfix;
But I would rather not modify this part of the code...

Kind regards,
Denis.

so this works as a flag only and if the fix is turned on at
particular step, it has no influence on the sequence, right?

correct. it is a bitmask and works as such.

[...]

and I don't want to cal "fix MYFIX..." every time I do another round of
nve/npt/... 'steps'.
Do you see any simple workaround for this?

i see two straightforward ways:

1) generate your inputs using a preprocessor
   or use the "include" feature of lammps script.

2) generate derived classes of the integrators
   that you want to amend and have them
   call your fix

after all this is more a matter of convenience
and not a technical feature. how many inputs
are your to write by yourself and how much
time/effort would you save?

if those are a *lot* of inputs, then option 1)
is the way to go in any case.

axel.

[...]

and I don't want to cal "fix MYFIX..." every time I do another round of
nve/npt/... 'steps'.
Do you see any simple workaround for this?

i see two straightforward ways:

1) generate your inputs using a preprocessor
   or use the "include" feature of lammps script.

That's what I do already, it's not a matter of
repeating the same line in the input script to calling my fix,
it's a matter of storing information it has/calculated before.

2) generate derived classes of the integrators
   that you want to amend and have them
   call your fix

after all this is more a matter of convenience
and not a technical feature. how many inputs
are your to write by yourself and how much
time/effort would you save?

if those are a *lot* of inputs, then option 1)
is the way to go in any case.

It seems it is not as straightforward as I though, so
i think I will reorganize my input script and keep one integrator defined
before my fix.

Anyway, thanks for making this clear to me.

Kind regards,
Denis.

That's what I do already, it's not a matter of
repeating the same line in the input script to calling my fix,
it's a matter of storing information it has/calculated before.

well, in that case you should consider having
two fixes which can access each other's information.

axel.