[lammps-users] fix wall/harmonic - ramp syntax error

Dear Lammps users, I am strongly conscious that I am going to ask a silly question for the vast majority of you. Nevertheless I accept the risk of being blamed because I cannot really understand the cause of the error message I am getting.

I am simulating a moving wall slowly compressing a set of molecules, by using the following instructions:

  • variable ramp1 equal ramp(-100,-90)

  • fix mywall1 all wall/harmonic zlo v_ramp1 400.0 0.0 5.0

So far, so good. The wall is moving from the “lower z” face of the simulation cell in the positive z direction. No problem.

Now I am trying to move the wall from the upper z face toward the negative z direction.

In a separate script I make use of the following instructions, which should be symmetrical to the above ones, moving the wall from the “upper z” face to the negative z direction:

  • variable ramp2 equal ramp(+100,+90)

  • fix mywall2 all wall/harmonic zhi v_ramp2 400.0 0.0 5.0

Now I get the error message: “Variable ramp2: invalid syntax in variable formula”. I checked the ramp formula: value = x + (y-x) * (timestep-startstep) / (stopstep-startstep), and the variable instruction should be OK.

I am struggling on this subject since a couple of days. Any suggestion or comment would be very helpful.

Thanks in advance for your patience

Paolo Botto

the error is - as the error message clearly indicates - with the equal style variable definition for “ramp2”. it has nothing to do with the fix wall command.
the ‘+’ character is not a unary operator (unlike ‘-’). there is no mention of a unary + operator in the documentation of the variable command (only ‘-’ and ‘!’).
so “ramp(100,90)” would be correct as would “ramp(0+100,0+90)”, but not “ramp(+100,+90)”


Dear Axel, thanks for the explanation and for the patience. Happy new year.