# help! The difference between the lammps gets and calculates by myself

Dear lammps-users

The values that lammps calculate for the command variable are difference with numbers calculated by myself with the format from lammps manual. And sometimes the differences are so big that I cannot think it can be explained with error. The partial commands are:

units real

dimension 3

pair_style lj/cut 10.0

pair_coeff 1 1 0.2394 3.405 10.0

pair_coeff 2 2 0.2394 3.405 10.0

pair_coeff 1 2 0.2394 3.405 3.822

group solide type 1

group reflect type 2

group ALL molecule >= 0

variable vel equal swiggle(0,0.4974,389.105058)

variable replacement equal cwiggle(0,30.8,389.105058)

variable vvx equal 0

variable vvy equal 0

variable vxx equal 0

variable vyy equal 0

fix 3 solide move variable v_vvx v_vvy v_replacement v_vxx v_vyy v_vel

timestep 1

And some values that the differences are too big are listed in table below. Where the rep and velocity represents the value that calculate by myself, the replacem and vel come from lammps. why is the difference so large? And how should I do to eliminate the difference?

I added these lines to bench/in.lj (and shrank the problem size):

region box block 0 4 0 4 0 4

variable vel equal swiggle(0,0.4974,389.105058)

variable replacement equal cwiggle(0,30.8,389.105058)

thermo_style custom step v_vel v_replacement
thermo 1000
run 1000000

and observed that swiggle varies between -0.49 and 0.49.

And cwiggle varies between 0 and 2*30.8

This is what the variable doc page says they should do:

The swiggle(x,y,z) and cwiggle(x,y,z) functions each take 3 arguments:
x = value0, y = amplitude, z = period. They use the elapsed time to
oscillate the value by a sin() or cos() function over the course of a
run, according to one of these formulas, where omega = 2 PI / period:

value = value0 + Amplitude * sin(omega*(timestep-startstep)dt)
value = value0 + Amplitude * (1 - cos(omega
(timestep-startstep)*dt))

where dt = the timestep size.

Note the 2nd formula has a 1-cos()

So I’m not seeing a problem.

Steve