Skip to main content

Target

Struct Target 

Source
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: usize

Number 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: CenteringMode

Centering 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

Source

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.

Source

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.

Source

pub fn with_name(self, name: impl Into<String>) -> Self

Source

pub fn with_restraint(self, r: impl AtomRestraint + 'static) -> Self

Attach a restraint applied to every atom of every molecule copy.

Source

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.

Source

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.

Source

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.

Source

pub fn with_perturb_budget(self, n: usize) -> Self

Structure-level budget for the perturbation heuristic (Packmol’s maxmove). Defaults to count when unset.

Source

pub fn with_centering(self, mode: CenteringMode) -> Self

Set the centering policy.

Source

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).

Source

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.

Source

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.

Source

pub fn natoms(&self) -> usize

Trait Implementations§

Source§

impl Clone for Target

Source§

fn clone(&self) -> Target

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Target

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V