Skip to main content

polysim_core/polymer/
chain.rs

1/// A single, fully resolved polymer chain instance.
2///
3/// A `PolymerChain` is the output of a builder: it holds the concrete SMILES
4/// string for the generated chain together with metadata computed at build time.
5#[derive(Debug, Clone)]
6pub struct PolymerChain {
7    /// SMILES string representing this specific chain.
8    pub smiles: String,
9    /// Number of repeat units incorporated into the chain.
10    pub repeat_count: usize,
11    /// Number-average molecular weight in g/mol.
12    ///
13    /// Currently `0.0` until `properties::molecular_weight` is implemented.
14    pub mn: f64,
15}
16
17impl PolymerChain {
18    /// Creates a new `PolymerChain` with the given SMILES, repeat count, and Mn.
19    pub fn new(smiles: String, repeat_count: usize, mn: f64) -> Self {
20        Self {
21            smiles,
22            repeat_count,
23            mn,
24        }
25    }
26}
27
28impl std::fmt::Display for PolymerChain {
29    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
30        write!(f, "{}", self.smiles)
31    }
32}