Hi
You can do this with PLUMED. Here is how:
# Find the gyration tensor of the cluster - in doing the command this way, we are giving a weight of one to each of the atoms
g: GYRATION_TENSOR ATOMS=<atoms>
# Diagonalize the gyration tensor to find the principal eigenvector - the output from this command is a 3-dimensional vector called d.vecs-1
d: DIAGONALIZE ARG=g VECTORS=1
# Calculate the length of the principal eigenvector
v2: CUSTOM ARG=d.vecs-1 FUNC=x*x PERIODIC=NO
mag2: SUM ARG=v2 PERIODIC=NO
mag: CUSTOM ARG=mag2 FUNC=sqrt(x) PERIODIC=NO
# Now get the z-component of the principal eigenvector, as the dot product between the z-axis and the eigenvector is basically the z-component of the eigenvector
zcomp: SELECT_COMPONENTS ARG=d.vecs-1 COMPONENTS=3
# And now calculate the angle
ang: CUSTOM ARG=zcomp,mag FUNC=acos(x/y) PERIODIC=NO
It is probably not even necessary to calculate the length of the eigenvector as I think that DIAGONALIZE returns normalised eigenvectors. I would double check that, but if I am right you can just do:
# Find the gyration tensor of the cluster - in doing the command this way, we are giving a weight of one to each of the atoms
g: GYRATION_TENSOR ATOMS=<atoms>
# Diagonalize the gyration tensor to find the principal eigenvector - the output from this command is a 3-dimensional vector called d.vecs-1
d: DIAGONALIZE ARG=g VECTORS=1
# Now get the z-component of the principal eigenvector, as the dot product between the z-axis and the eigenvector is basically the z-component of the eigenvector
zcomp: SELECT_COMPONENTS ARG=d.vecs-1 COMPONENTS=3
# And now calculate the angle
ang: CUSTOM ARG=zcomp FUNC=acos(x) PERIODIC=NO
Notice, this will only work with v2.10 or a higher version. I would recommend using the master version of the code, which you can get with the command:
You then compile and build plumed in the usual way.