Gyradius

class mdcraft.analysis.polymer.Gyradius(groups: AtomGroup | tuple[AtomGroup], groupings: str | tuple[str] = 'atoms', n_chains: int | tuple[int] = None, n_monomers: int | tuple[int] = None, *, components: bool = False, unwrap: bool = False, parallel: bool = False, verbose: bool = True, **kwargs)[source]

Bases: _PolymerAnalysisBase

Serial and parallel implementations to calculate the radius of gyration \(R_\mathrm{g}\) of a polymer.

The radius of gyration is used to describe the dimensions of a polymer chain, and is defined as

\[R_\mathrm{g}=\sqrt{ \frac{\sum_i^N m_i\|\mathbf{r}_i -\mathbf{R}_\mathrm{com}\|^2}{\sum_i^N m_i}}\]

where \(m_i\) and \(\mathbf{r}_i\) are the mass and position, respectively, of particle \(i\), and \(\mathbf{R}_\mathrm{com}\) is the center of mass.

Parameters:
groupsMDAnalysis.AtomGroup or array-like

Groups of polymers to be analyzed.

Note

All polymers in each group must have the same chain length.

groupingsstr or array-like, default: "atoms"

Determines whether the centers of mass are used in lieu of individual atom positions. If groupings is a str, the same value is used for all groups.

Note

In a standard trajectory file, segments (or chains) contain residues (or molecules), and residues contain atoms. This heirarchy must be adhered to for this analysis module to function correctly. If your trajectory file does not contain the correct residue or segment information, provide the number of chains and chain lengths in n_chains and n_monomers, respectively.

Valid values:

  • "atoms": Atom positions (generally or for coarse-grained simulations).

  • "residues": Residues’ centers of mass (for atomistic simulations).

n_chainsint or array-like, optional

Number of chains \(M\) in each polymer group. Must be provided if the trajectory does not adhere to the standard container heirarchy. If an int is provided, the same value is used for all groups.

Shape: \((N_\mathrm{groups},)\).

n_monomersint or array-like, optional

Number of monomers \(N\) in each chain in each polymer group. Must be provided if the trajectory does not adhere to the standard container heirarchy. If an int is provided, the same value is used for all groups.

Shape: \((N_\mathrm{groups},)\).

componentsbool, keyword-only, default: False

Specifies whether the components of the radii of gyration are calculated and returned instead.

unwrapbool, keyword-only, default: False

Determines whether atom positions are unwrapped.

parallelbool, keyword-only, default: False

Determines whether the analysis is performed in parallel.

verbosebool, keyword-only, default: True

Determines whether detailed progress is shown.

**kwargs

Additional keyword arguments to pass to MDAnalysis.analysis.base.AnalysisBase.

Attributes:
universeMDAnalysis.Universe

MDAnalysis.core.universe.Universe object containing all information describing the system.

results.unitsdict

Reference units for the results. For example, to get the reference units for results.gyradii, call results.units["gyradii"].

results.gyradiinumpy.ndarray

Radii of gyration.

Shape: \((N_\mathrm{groups},\,N_\mathrm{frames})\) or \((N_\mathrm{groups},\,N_\mathrm{frames},\,3)\).

Reference unit: \(\mathrm{Å}\).

Methods

run

Performs the calculation.

save

Saves results to a binary or archive file in NumPy format.

run(start: int = None, stop: int = None, step: int = None, frames: slice | ndarray[int] = None, verbose: bool = None, **kwargs) SerialAnalysisBase | ParallelAnalysisBase

Performs the calculation.

See also

For parallel-specific keyword arguments, see ParallelAnalysisBase.run().

Parameters:
startint, optional

Starting frame for analysis.

stopint, optional

Ending frame for analysis.

stepint, optional

Number of frames to skip between each analyzed frame.

framesslice or array-like, optional

Index or logical array of the desired trajectory frames.

verbosebool, optional

Determines whether detailed progress is shown.

**kwargs

Additional keyword arguments to pass to MDAnalysis.lib.log.ProgressBar.

Returns:
selfSerialAnalysisBase or ParallelAnalysisBase

Analysis object with results.

save(file: str | TextIO, archive: bool = True, compress: bool = True, **kwargs) None

Saves results to a binary or archive file in NumPy format.

Parameters:
filestr or file

Filename or file-like object where the data will be saved. If file is a str, the .npy or .npz extension will be appended automatically if not already present.

archivebool, default: True

Determines whether the results are saved to a single archive file. If True, the data is stored in a .npz file. Otherwise, the data is saved to multiple .npy files.

compressbool, default: True

Determines whether the .npz file is compressed. Has no effect when archive=False.

**kwargs

Additional keyword arguments to pass to numpy.save(), numpy.savez(), or numpy.savez_compressed(), depending on the values of archive and compress.