coarse_grain module
Full Documentation for hippynn.molecular_dynamics.coarse_grain module.
Click here for a summary page.
- cg_one_center_of_geometry_pbc(bead_values, frame_cell, wrap_into_cell=True)[source]
 Position center of geometry using PBC
- cg_one_center_of_mass_pbc(bead_values, bead_masses, frame_cell, wrap_into_cell=True)[source]
 Position center of mass using PBC
- cg_one_mass_weighted_average(bead_values, bead_masses)[source]
 General mass-weighted average (eg. for velocities when using COM position mapping)
- coarse_grain_all(values, atom_to_bead, coarse_grain_one, masses=None, cells=None, atom_species=None, bead_species=None, single_frame=False)[source]
 Apply a user-defined
coarse_grain_onefunction to all beads across all frames.The user-supplied function,
coarse_grain_one, should takebead_valuesas an argument, which will correspond the the values ofvaluesfor one bead in one frame. It can optionally takebead_masses,frame_cell,bead_atom_species, andbead_typeas additional arguments. It should return the coarse_grained version ofvaluesfor the bead given the data provided.This function loops over each frame (if single_frame=False) and over each bead (as defined by atom_to_bead) and applies
coarse_grain_oneto each bead. Returns the resulting values in an array of shape (n_frames, n_beads, …) or (n_beads, …) where the trailing dimensions match the output ofcoarse_grain_one.See examples of pre-defined
coarse_grain_oneoptions in hippynn.molecular_dynamics.coarse_grain.- Parameters:
 values – Array of data to coarse-grain. Shape (n_frames, n_atoms, d) if single_frame=False or (n_atoms, d) if single_frame=True.
atom_to_bead – Integer array of shape (n_frames, n_atoms,) or (n_atoms,) mapping each atom to a bead.
coarse_grain_one – Function to coarse-grain one bead’s data.
masses – (Optional) Array of shape (n_frames, n_atoms,) or (n_atoms,) of masses. Values for the current frame/bead passed to
coarse_grain_oneif provided.cells – (Optional) Array of shape (n_frames, 3, 3) or (3, 3) of cell matrices. The cell for the current frame is passed to
coarse_grain_oneif provided.atom_species – (Optional) Array of shape (n_frames, n_atoms,) or (n_atoms,) of atom species, defined in any manner you choose. Values for the current frame passed to
coarse_grain_oneif provided.bead_species – (Optional) Array of shape (n_frames, max_bead_idx+1,) or (max_bead_idx+1,) where
max_bead_idxis the maximum value inatom_to_bead. Values for the current frame/bead passed tocoarse_grain_oneif provided.single_frame – (Optional) Use to specify if data arrays contain a frame axis. Defaults to False.
- Returns:
 Array of coarse-grained values. Shape (n_frames, n_beads, …) if single_frame=False or (n_beads, …) if single_frame=True.
- compute_bead_indices(atom_to_bead)[source]
 Compute bead indices from an atom-to-bead mapping.
- Parameters:
 atom_to_bead – Array of shape (n_atoms,) mapping each atom to a bead.
- Returns:
 Tuple (beads, bead_indices) where: - beads is a sorted array of unique bead labels. - bead_indices is a dict mapping each bead label to its atom indices.