Compute center of a angle when it passes through the boundary

Dear all,

When I compute the center of a angle as below:
for (n = 0; n < nanglelist; n++)
i1 = anglelist[n][0];
i2 = anglelist[n][1];
i3 = anglelist[n][2];
type = anglelist[n][3];

// find the center-of-mass
tcx = (x[i1][0] + x[i2][0] + x[i3][0])/3.0;
tcy = (x[i1][1] + x[i2][1] + x[i3][1])/3.0;
tcz = (x[i1][2] + x[i2][2] + x[i3][2])/3.0;
it has no problem at local domain, but if some of the atoms belong to one angle pass through the boundary, the compute is incorrect.
Also, I compute some vectors like this

a21x = x[i2][0] - x[i1][0];
a21y = x[i2][1] - x[i1][1];
a21z = x[i2][2] - x[i1][2];

If this is correct when the bond with atom i1 and atom i2 pass across the boundary.


Lynn H. Ye

I think you are asking why code you wrote is incorrect?

I can’t tell you the reason, but if you are writing your

own angle style and do things like the other

angle styles, such as harmonic, do them, then

you won’t have this problem. The 3 atoms

that are referenced in the anglelist are setup by

the neighbor list build so that they are 3 nearby

atoms. That means if the atom straddles the box

boundary, one or more of the atoms may be ghost

atoms, with coords outside the box. So there is

no issue with computing a COM or distances between

any pair of the 3 atoms.