Angle_Style cosine/delta

Dear all,

The following code appears in the compute section of angle_cosine_delta.cpp:

// angle (cos and sin)

c = delx1delx2 + dely1dely2 + delz1delz2;
c /= r1
r2;

if (c > 1.0) c = 1.0;
if (c < -1.0) c = -1.0;

theta = acos©;

s = sqrt(1.0 - c*c);
if (s < SMALL) s = SMALL;
s = 1.0/s;

cot = c/s;

Why is the line ‘s=1.0/s’ necessary? Shouldn’t cot(theta) simply be cos(theta)/sin(theta)?

Best,
Karthik

DISCLAIMER The sender of this email is an alumnus of National University of Singapore (NUS). Kindly note that NUS is not responsible for the contents of this email, and views and opinions expressed are solely the sender’s.

Good Q - don’t know the answer. My guess is that the code is
correct, but the variable names may have been inherited from
other code.

Axel’s name is at the top of the file, so I’m CCing him.

Steve

Good Q - don't know the answer. My guess is that the code is
correct, but the variable names may have been inherited from
other code.

Axel's name is at the top of the file, so I'm CCing him.

you must have put my name there, because i e-mailed this to you a
long, long time ago.
it was written by a group member of the klein group while we were
still at upenn. i don't know any of the details.
but i have to agree, the code *does* look suspicious.

it should be straightforward to verify this by manually creating a few
data files with just a single angle interaction defined at different
angles and comparing the results from LAMMPS with a pencil and paper
calculation.

axel.