CodeEntropy.levels.nodes.covariance module

Frame-level covariance (second-moment) construction.

This module computes per-frame second-moment matrices for force and torque vectors at each hierarchy level (united_atom, residue, polymer). Results are incrementally averaged across molecules within a group for the current frame.

Responsibilities: - Build bead-level force/torque vectors using ForceTorqueCalculator. - Construct per-frame force/torque second moments (outer products). - Optionally construct combined force-torque block matrices. - Average per-frame matrices across molecules in the same group.

Not responsible for: - Defining groups/levels/beads mapping (provided via shared context). - Axis construction policy (delegated to axes_manager). - Accumulating across frames (handled by the higher-level reducer).

class CodeEntropy.levels.nodes.covariance.FrameCovarianceNode[source]

Bases: object

Build per-frame covariance-like (second-moment) matrices for each group.

This node computes per-frame second-moment matrices (outer products) for force and torque generalized vectors at hierarchy levels:

  • united_atom

  • residue

  • polymer

Within a single frame, outputs are incrementally averaged across molecules that belong to the same group. Frame-to-frame accumulation is handled elsewhere (by a higher-level reducer).

run(ctx: dict[str, Any]) dict[str, Any][source]

Compute frame-local force, torque, and optional force-torque matrices.

Parameters:

ctx – Frame context containing shared workflow data. The shared data must provide reduced_universe, groups, levels, beads, and args.

Returns:

The frame covariance payload written to ctx["frame_covariance"].

Raises:

KeyError – If ctx or the shared workflow data is missing required keys.