Rg ― Radius of Gyration

5.2. Rg ― Radius of Gyration#

Consider how the sizes of particles with different shapes can be compared. \(R_g\) can be used for that purpose.

\(R_g\) is computed (defined) as follows:

  • compute the center of mass (or density)

  • compute the weighted average of squared deviation from the center

  • compute the square root of the above avarage

Using the known formula for \(R_g\), the next code computes Rg’s of several ellipsoids with different lenghts of semi-axes, \(a\), \(b\) and \(c\).

import numpy as np
import matplotlib.pyplot as plt
from molass.Shapes import Ellipsoid
from molass.DensitySpace import VoxelSpace
from molass.SAXS.Simulator import compute_saxs, draw_saxs

fig, axes = plt.subplots(nrows=2, ncols=4, figsize=(16, 8), subplot_kw=dict(projection='3d'))

for i in range(2):
    for j in range(4):
        ax = axes[i, j]
        a = 16 * (2 - i)
        b = 8 * (i + 1)
        c = 2 * ((i + 1)*(j + 1))
        rg = np.sqrt((a**2 + b**2 + c**2)/5)
        ax.set_title(f'(a, b, c)={(a, b, c)}; $R_g={rg:.1f}$')
        ellipsoid = Ellipsoid(a, b, c)
        space = VoxelSpace(64, ellipsoid)
        space.plot_as_dots(ax)
../../_images/8c834187b8e20e3e123f003ef63e31f28139b87776f195d5deeceaabdb40c1de.png

In the above plot, the shapes are defined with uniform density, meaning the density is uniformly one throughout each shape. The next plot illustrates this fact more clearly.

import numpy as np
import matplotlib.pyplot as plt
from molass.Shapes import Ellipsoid
from molass.DensitySpace import VoxelSpace

fig, axes = plt.subplots(ncols=2, figsize=(10,5), subplot_kw=dict(projection='3d'))
a, b, c = 16, 16, 16
ellipsoid = Ellipsoid(a, b, c)
space = VoxelSpace(64, ellipsoid)
space.plot_with_density(axes)
fig.tight_layout()
../../_images/2c51ac3a1c009f8feba258330d91d573bb703c209be8a54a2f09e6b5fc8f4ca0.png

Next method computes \(R_g\) without using the formula, namely by computing the square root of the weighted average of the squared deviations from the center.

space.compute_rg()
12.373697563931419

Confirm the concept with another plot that depicts a sphere with a Gaussian (non-uniform) density distribution.

from molass.DensitySpace import VoxelSpace
from molass.DensitySpace.Densities import gaussian_density_for_demo
fig, axes = plt.subplots(ncols=2, figsize=(10,5), subplot_kw=dict(projection='3d'))

N = 64
density = gaussian_density_for_demo(N)
space = VoxelSpace(N, density=density)
space.plot_with_density(axes)
fig.tight_layout()
../../_images/ad75efbbd9dfd80e913d1b46cbcd249a00e18ca270f6b797e48c07565faf63d2.png

Compare this \(R_g\) with the previous result.

space.compute_rg()
9.486832051163836