pub struct RandomPacking {
pub config: RsaConfig,
pub spheres: Vec<PackingSphere>,
pub n_rejected: usize,
pub jammed: bool,
}Expand description
Random packing via Random Sequential Adsorption (RSA).
In RSA, spheres are placed one at a time at random positions, accepted only if they do not overlap with already-placed spheres. The process terminates at the jamming limit (~64% for equal spheres in 3D).
Fields§
§config: RsaConfigRSA configuration.
spheres: Vec<PackingSphere>Placed spheres.
n_rejected: usizeNumber of rejected attempts.
jammed: boolWhether the packing has reached the jamming limit.
Implementations§
Source§impl RandomPacking
impl RandomPacking
Sourcepub fn try_place_sphere(&mut self, rng: &mut impl Rng) -> bool
pub fn try_place_sphere(&mut self, rng: &mut impl Rng) -> bool
Attempt to place one sphere at a random location.
Returns true if placement succeeded.
Sourcepub fn is_valid_placement(&self, candidate: &PackingSphere) -> bool
pub fn is_valid_placement(&self, candidate: &PackingSphere) -> bool
Check if a sphere can be placed without overlap.
Sourcepub fn run(&mut self) -> usize
pub fn run(&mut self) -> usize
Run the RSA algorithm until jammed.
Returns the number of spheres placed.
Sourcepub fn packing_fraction(&self) -> f64
pub fn packing_fraction(&self) -> f64
Compute the current packing fraction (volume fraction).
Sourcepub fn theoretical_jamming_limit() -> f64
pub fn theoretical_jamming_limit() -> f64
Compute the theoretical jamming limit for monodisperse RSA in 3D.
The RSA jamming limit in 3D is approximately 0.3841.
Sourcepub fn count_contacts(&self, tolerance: f64) -> usize
pub fn count_contacts(&self, tolerance: f64) -> usize
Return the number of contacts (overlapping pairs) in the packing.
Auto Trait Implementations§
impl Freeze for RandomPacking
impl RefUnwindSafe for RandomPacking
impl Send for RandomPacking
impl Sync for RandomPacking
impl Unpin for RandomPacking
impl UnsafeUnpin for RandomPacking
impl UnwindSafe for RandomPacking
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<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.