**Hi,**

**I have been trying to determine the exact procedure used in improper angle calculation in LAMMPS.**

**I have picked up a part of the code from compute_improper_local.cpp and have tried to figure out what happens - step by step**

vb1x = x[atom1][0] - x[atom2][0];

vb1y = x[atom1][1] - x[atom2][1];

vb1z = x[atom1][2] - x[atom2][2];

domain->minimum_image(vb1x,vb1y,vb1z);

**~~ vb1 = coordinates(1) - coordinates(2)**

vb2x = x[atom3][0] - x[atom2][0];

vb2y = x[atom3][1] - x[atom2][1];

vb2z = x[atom3][2] - x[atom2][2];

domain->minimum_image(vb2x,vb2y,vb2z);

**~~ vb2 = coordinates(3) - coordinates(2)**

vb3x = x[atom4][0] - x[atom3][0];

vb3y = x[atom4][1] - x[atom3][1];

vb3z = x[atom4][2] - x[atom3][2];

domain->minimum_image(vb3x,vb3y,vb3z);

**~~ vb3 = coordinates(4) - coordinates(3)**

**I am correct in assuming that the improper angle should be the angle between the planes of (vb1,vb2) and**

**(vb2,vb3) ??**

ss1 = 1.0 / (vb1x*vb1x + vb1y*vb1y + vb1z*vb1z);
ss2 = 1.0 / (vb2x*vb2x + vb2y

*vb2y + vb2z*vb2z);

ss3 = 1.0 / (vb3x

*vb3x + vb3y*vb3y + vb3z*vb3z);

~~

**Inverse norm_squared**

r1 = sqrt(ss1);

r2 = sqrt(ss2);

r3 = sqrt(ss3);

~~ **Inverse norm of the angles**

c0 = (vb1x * vb3x + vb1y * vb3y + vb1z * vb3z) * r1 * r3;

~~ **cosine of angle between vb1 and vb3? (say) alpha**

c1 = (vb1x * vb2x + vb1y * vb2y + vb1z * vb2z) * r1 * r2;

~~ **cosine of angle between vb2 and vb1? (say) beta**

c2 = -(vb3x * vb2x + vb3y * vb2y + vb3z * vb2z) * r3 * r2;

~~ **negative cosine of angle between vb2 and vb3? (say) gamma**

s1 = 1.0 - c1*c1; ~~ **sin^2 of** **vb2 and vb1?**

if (s1 < SMALL) s1 = SMALL;

s1 = 1.0 / s1;

s2 = 1.0 - c2*c2; ~~ **sin^2 of** **vb2 and vb3?**

if (s2 < SMALL) s2 = SMALL;

s2 = 1.0 / s2;

s12 = sqrt(s1*s2); ~~ 1/sin(angle vb2 and vb1) * 1/sin(angle vb2 and vb3)*c2 + c0) * s12;

c = (c1

**~~ IS c = [ 1-* cos(alpha)*cos(beta) + cos(gamma))/ sin(alpha)/sin(beta) ]??**

if (c > 1.0) c = 1.0;

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

cbuf[n] = 180.0*acos©/MY_PI;

**Question 1:**

**I do not understand how cos_inverse of ‘c’ should be the angle between the two planes? Is there a geometric explanation that I should look at?**

**Question 2:**

**Also, while specifying the improper angles in the input files as ( i j k l )** **should give the same magnitude for the improper angle** as **( l j k i ) . Is that right?**

**Question 3:**

**Finally, for improper style harmonic and cvff does lammps explicitly calculate the displacement of atom “i” from the plane j-k-l? My understanding is that it just calculates the angle between the ijk and jkl planes.**

**Thank you,**

**Regards,**

**Ambarish**