pub struct Target {Show 15 fields
pub input_coords: Vec<[F; 3]>,
pub ref_coords: Vec<[F; 3]>,
pub radii: Vec<F>,
pub elements: Vec<String>,
pub count: usize,
pub name: Option<String>,
pub molecule_restraints: Vec<Arc<dyn AtomRestraint>>,
pub atom_restraints: Vec<(Vec<usize>, Arc<dyn AtomRestraint>)>,
pub collective_restraints: Vec<Arc<dyn Restraint>>,
pub perturb_budget: Option<usize>,
pub centering: CenteringMode,
pub rotation_bound: [Option<(Angle, Angle)>; 3],
pub fixed_at: Option<Placement>,
pub relaxers: Vec<Box<dyn Relaxer>>,
pub template: Option<Frame>,
}Expand description
Describes one type of molecule to be packed.
Fields§
§input_coords: Vec<[F; 3]>Input coordinates as provided by the source structure.
ref_coords: Vec<[F; 3]>Flat list of atom positions — the centered reference coordinates. Shape: natoms × 3, stored as Vec<[F; 3]>.
radii: Vec<F>Van der Waals radii per atom.
elements: Vec<String>Element symbols per atom (e.g. "C", "O"). Defaults to "X" if unknown.
count: usizeNumber of copies to pack.
name: Option<String>Optional name for logging.
molecule_restraints: Vec<Arc<dyn AtomRestraint>>Restraints applied to every atom of every molecule copy.
atom_restraints: Vec<(Vec<usize>, Arc<dyn AtomRestraint>)>Per-atom-subset restraints: (atom_indices_0_based, restraint).
Each entry holds the 0-based atom indices (converted from Packmol’s
1-based convention at registration time) and the restraint applied to them.
collective_restraints: Vec<Arc<dyn Restraint>>Group-level restraints evaluated over all copies of this type at
once (e.g. distribution matching). Unlike molecule_restraints, these
couple the copies through their joint coordinate, so they cannot be
expressed as a per-atom AtomRestraint. See Restraint.
perturb_budget: Option<usize>Optional structure-level limit for the perturbation heuristic
(Packmol’s maxmove).
centering: CenteringModeCentering policy.
rotation_bound: [Option<(Angle, Angle)>; 3]Rotation bounds in Euler variable order
[beta(y), gama(z), teta(x)] as (center, half_width) Angle pairs.
fixed_at: Option<Placement>If Some, this molecule is fixed (one copy, placed at the given location).
relaxers: Vec<Box<dyn Relaxer>>Per-target in-loop relaxers (e.g. torsion MC). Called in order each iteration.
template: Option<Frame>Source frame this target was built from, retained so the packer can
replay its full topology (bonds/angles/…) and per-atom metadata onto
the packed coordinates. None for targets built from bare coordinates
(Target::from_coords), whose result frame is coordinates-only.
Implementations§
Source§impl Target
impl Target
Sourcepub fn new(frame: Frame, count: usize) -> Self
pub fn new(frame: Frame, count: usize) -> Self
Create a new target from a molrs::Frame (read from PDB/XYZ) and a copy count.
Positions are extracted from the "atoms" block ("x", "y", "z" columns)
and automatically centered at the geometric center.
VdW radii and element symbols are looked up from the "element" column.
Sourcepub fn from_coords(
frame_positions: &[[F; 3]],
radii: &[F],
count: usize,
) -> Self
pub fn from_coords( frame_positions: &[[F; 3]], radii: &[F], count: usize, ) -> Self
Create a new target directly from coordinate arrays.
Useful for testing or when coordinates are already available.
Stores both raw input coordinates and a geometrically centered reference copy.
Effective usage follows CenteringMode::Auto unless overridden.
pub fn with_name(self, name: impl Into<String>) -> Self
Sourcepub fn with_restraint(self, r: impl AtomRestraint + 'static) -> Self
pub fn with_restraint(self, r: impl AtomRestraint + 'static) -> Self
Attach a restraint applied to every atom of every molecule copy.
Sourcepub fn with_atom_restraint(
self,
indices: &[usize],
r: impl AtomRestraint + 'static,
) -> Self
pub fn with_atom_restraint( self, indices: &[usize], r: impl AtomRestraint + 'static, ) -> Self
Attach a restraint for selected atoms of every molecule copy.
§Atom indexing
Indices are 0-based, matching Rust convention: atom 0 is
the first atom in the PDB/XYZ file. For example, &[0, 1, 2]
selects the first three atoms. If you are porting from a Packmol
.inp file (which uses 1-based indices), subtract 1 at the
call site.
Sourcepub fn with_collective_restraint(self, r: impl Restraint + 'static) -> Self
pub fn with_collective_restraint(self, r: impl Restraint + 'static) -> Self
Attach a group-level restraint evaluated over all copies of this type at once (e.g. distribution matching). The restraint sees every copy’s coordinate jointly and returns a coupled gradient.
Here Restraint is the group/collective trait
(crate::restraint::Restraint) — it sees every copy’s coordinate at
once, not the per-atom AtomRestraint.
Sourcepub fn with_relaxer(self, relaxer: impl Relaxer + 'static) -> Self
pub fn with_relaxer(self, relaxer: impl Relaxer + 'static) -> Self
Attach an in-loop relaxer for this target.
Multiple relaxers can be attached (called in order).
Relaxers require count == 1 because all copies share reference coords.
Mirrors with_restraint — a per-target builder method.
Sourcepub fn with_perturb_budget(self, n: usize) -> Self
pub fn with_perturb_budget(self, n: usize) -> Self
Structure-level budget for the perturbation heuristic
(Packmol’s maxmove). Defaults to count when unset.
Sourcepub fn with_centering(self, mode: CenteringMode) -> Self
pub fn with_centering(self, mode: CenteringMode) -> Self
Set the centering policy.
CenteringMode::Auto(default): free molecules centered, fixed molecules kept in place.CenteringMode::Center: always center.CenteringMode::Off: keep input coordinates unchanged.
Sourcepub fn with_rotation_bound(
self,
axis: Axis,
center: Angle,
half_width: Angle,
) -> Self
pub fn with_rotation_bound( self, axis: Axis, center: Angle, half_width: Angle, ) -> Self
Rotation bound on a single Euler axis, analogous to Packmol’s
constrain_rotation <axis> <center> <delta>. Arguments are
Angle values — Angle::from_degrees(30.0) or
Angle::from_radians(FRAC_PI_6).
Sourcepub fn fixed_at(self, position: [F; 3]) -> Self
pub fn fixed_at(self, position: [F; 3]) -> Self
Fix this molecule at a specific position with zero rotation.
Forces count to 1 — a fixed molecule is by definition a single
copy. Pair with with_orientation if
a non-zero Euler orientation is needed.
Sourcepub fn with_orientation(self, orientation: [Angle; 3]) -> Self
pub fn with_orientation(self, orientation: [Angle; 3]) -> Self
Set the Euler orientation of a previously-fixed target. Must be
called after fixed_at; panics otherwise.