pub struct SelfAvoidingWalk<S: GrowthStrategy> {
pub n_chains: usize,
pub chain_length: usize,
pub bond_length: F,
pub target_density: F,
pub pbc: Pbc3,
pub seed: u64,
pub strategy: S,
}Expand description
Configuration for a periodic/reflective, fixed-bond-length self-avoiding
random walk that grows n_chains independent chains of chain_length
monomers each.
Construct it as a struct literal and inject a GrowthStrategy via the
strategy field, then call generate:
use molrs::builder::{OffLattice, SelfAvoidingWalk};
let walk = SelfAvoidingWalk {
n_chains: 2,
chain_length: 20,
bond_length: 1.53,
target_density: 0.05,
pbc: [true, true, true],
seed: 9062,
strategy: OffLattice { excluded_radius: 1.0 },
};
let out = walk.generate().unwrap();
assert_eq!(out.paths.len(), 2);target_density is in monomers per unit volume — mass is out of scope,
so the cubic box edge is a = (n_chains * chain_length / target_density).cbrt()
(a lattice strategy may round it up to stay commensurate).
Fields§
§n_chains: usizeNumber of independent chains to grow.
chain_length: usizeNumber of monomers per chain.
bond_length: FFixed distance between consecutive monomers.
target_density: FTarget number density (monomers per unit volume) used to size the box.
pbc: Pbc3Per-axis boundary flags: true = periodic (wrap), false = reflective.
seed: u64Seed for the deterministic RNG; equal seeds give identical paths.
strategy: SThe monomer-placement policy (a struct implementing GrowthStrategy).
Implementations§
Source§impl<S: GrowthStrategy> SelfAvoidingWalk<S>
impl<S: GrowthStrategy> SelfAvoidingWalk<S>
Sourcepub fn generate(&self) -> Result<WalkOutput, WalkError>
pub fn generate(&self) -> Result<WalkOutput, WalkError>
Grow all chains and return their paths plus the box used.
Deterministic in seed. Returns WalkError::InvalidConfig for
out-of-range parameters, WalkError::BoxError if the box cannot be
built, and WalkError::DeadEnd if a chain cannot be completed within
the retry/backtrack/restart budget.
Auto Trait Implementations§
impl<S> Freeze for SelfAvoidingWalk<S>where
S: Freeze,
impl<S> RefUnwindSafe for SelfAvoidingWalk<S>where
S: RefUnwindSafe,
impl<S> Send for SelfAvoidingWalk<S>where
S: Send,
impl<S> Sync for SelfAvoidingWalk<S>where
S: Sync,
impl<S> Unpin for SelfAvoidingWalk<S>where
S: Unpin,
impl<S> UnsafeUnpin for SelfAvoidingWalk<S>where
S: UnsafeUnpin,
impl<S> UnwindSafe for SelfAvoidingWalk<S>where
S: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more