RgPlan
Compute the radius of gyration for a selection of atoms.
Constructor
from warp_md import RgPlan
plan = RgPlan(selection, mass_weighted=False)
Atom selection to analyze
Whether to use mass-weighted radius of gyration
run() Method
result = plan.run(
trajectory,
system,
chunk_frames=128,
device="auto",
frame_indices=None
)
Returns: 1D array of Rg values (one per frame)
Example
import warp_md as wmd
# Load trajectory
system = wmd.System("topology.prmtop")
traj = wmd.open_trajectory("trajectory.nc", system)
# Calculate radius of gyration for protein
protein_sel = system.select("protein")
plan = wmd.RgPlan(protein_sel, mass_weighted=True)
rg_values = plan.run(traj, system)
print(f"Average Rg: {rg_values.mean():.2f} Å")
RadgyrTensorPlan
Compute the full radius of gyration tensor.
Constructor
plan = RadgyrTensorPlan(selection, mass_weighted=False)
Atom selection to analyze
Whether to use mass-weighted calculations
run() Method
Returns a 2D array with shape (n_frames, 7) containing:
- Column 0: Rg (scalar)
- Columns 1-3: Diagonal elements (Gxx, Gyy, Gzz)
- Columns 4-6: Off-diagonal elements (Gxy, Gxz, Gyz)
Example
# Calculate full Rg tensor
sel = system.select("resid 1:50")
plan = wmd.RadgyrTensorPlan(sel, mass_weighted=True)
tensor_data = plan.run(traj, system)
rg = tensor_data[:, 0]
gxx = tensor_data[:, 1]
gyy = tensor_data[:, 2]
gzz = tensor_data[:, 3]
print(f"Rg anisotropy: {(gxx - gyy).std():.3f}")
VolumePlan
Compute the unit cell volume over a trajectory.
Constructor
No parameters required.
run() Method
Returns: 1D array of volume values in Ų (one per frame)
Example
# Monitor box volume during NPT simulation
plan = wmd.VolumePlan()
volumes = plan.run(traj, system)
import matplotlib.pyplot as plt
plt.plot(volumes)
plt.xlabel("Frame")
plt.ylabel("Volume (Ų)")
plt.title("Box Volume vs Time")
plt.show()
Requires trajectory to have box information. Returns zeros if no box data is present.