polysim_core/distribution/mod.rs
1//! Chain length distribution models for polydisperse polymer ensembles.
2//!
3//! Each distribution implements [`ChainLengthDistribution`] and can sample
4//! repeat-unit counts given target Mn, PDI, and repeat-unit molar mass.
5
6pub mod flory;
7pub mod log_normal;
8pub mod schulz_zimm;
9
10pub use flory::Flory;
11pub use log_normal::LogNormal;
12pub use schulz_zimm::SchulzZimm;
13
14use rand::RngCore;
15
16/// A distribution that can sample chain lengths (as repeat-unit counts).
17pub trait ChainLengthDistribution {
18 /// Sample `num_chains` chain lengths (each ≥ 1).
19 ///
20 /// - `mn` — target number-average molecular weight (g/mol).
21 /// - `pdi` — target polydispersity index (Mw/Mn, ≥ 1.0).
22 /// - `m0` — molar mass of a single repeat unit (g/mol).
23 /// - `rng` — random number generator (pass a seeded RNG for reproducibility).
24 fn sample(
25 &self,
26 mn: f64,
27 pdi: f64,
28 m0: f64,
29 num_chains: usize,
30 rng: &mut dyn RngCore,
31 ) -> Vec<usize>;
32
33 /// Human-readable name for display purposes.
34 fn name(&self) -> &'static str;
35}