Skip to content

polykin.copolymerization¤

sequence_multi ¤

sequence_multi(
    Pself: FloatVectorLike,
    k: Optional[Union[int, IntArrayLike]] = None,
) -> FloatArray

Calculate the instantaneous sequence length probability or the number-average sequence length.

For a multicomponent system, the probability of finding \(k\) consecutive units of monomer \(i\) in a chain is:

\[ S_{i,k} = (1 - P_{ii})P_{ii}^{k-1} \]

and the corresponding number-average sequence length is:

\[ \bar{S}_i = \sum_{k=1}^{\infty} k S_{i,k} = \frac{1}{1 - P_{ii}} \]

where \(P_{ii}\) is the self-transition probability \(i \rightarrow i\), which is a function of the monomer composition and the reactivity ratios.

References

  • NA Dotson, R Galván, RL Laurence, and M Tirrel. Polymerization process modeling, Wiley, 1996, p. 177.
PARAMETER DESCRIPTION
Pself

Vector of self-transition probabilities, \(P_{ii}\), corresponding to the diagonal of the matrix of transition probabilities.

TYPE: FloatVectorLike(N)

k

Sequence length, i.e., number of consecutive units in a chain. If None, the number-average sequence length will be computed.

TYPE: int | IntArrayLike(M) | None DEFAULT: None

RETURNS DESCRIPTION
FloatArray(N, M)

If k is None, the number-average sequence lengths, \(\bar{S}_i\). Otherwise, the sequence probabilities, \(S_{i,k}\).

See also

Examples:

>>> from polykin.copolymerization import sequence_multi
>>> from polykin.copolymerization import transitions_multi
>>> import numpy as np

Define reactivity ratio matrix.

>>> r = np.ones((3, 3))
>>> r[0, 1] = 0.2
>>> r[1, 0] = 2.3
>>> r[0, 2] = 3.0
>>> r[2, 0] = 0.9
>>> r[1, 2] = 0.4
>>> r[2, 1] = 1.5

Evaluate self-transition probabilities.

>>> f = [0.5, 0.3, 0.2]
>>> Pself = transitions_multi(f, r).diagonal()
>>> Pself
array([0.24193548, 0.29487179, 0.20930233])

Evaluate number-average sequence lengths for all monomers.

>>> S = sequence_multi(Pself)
>>> S
array([1.31914894, 1.41818182, 1.26470588])

Evaluate probabilities for certain sequence lengths.

>>> S = sequence_multi(Pself, k=[1, 5])
>>> S
array([[0.75806452, 0.00259719],
       [0.70512821, 0.00533091],
       [0.79069767, 0.00151742]])
Source code in src/polykin/copolymerization/multicomponent.py
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
def sequence_multi(Pself: FloatVectorLike,
                   k: Optional[Union[int, IntArrayLike]] = None,
                   ) -> FloatArray:
    r"""Calculate the instantaneous sequence length probability or the
    number-average sequence length.

    For a multicomponent system, the probability of finding $k$ consecutive
    units of monomer $i$ in a chain is:

    $$ S_{i,k} = (1 - P_{ii})P_{ii}^{k-1} $$

    and the corresponding number-average sequence length is:

    $$ \bar{S}_i = \sum_{k=1}^{\infty} k S_{i,k} = \frac{1}{1 - P_{ii}} $$

    where $P_{ii}$ is the self-transition probability $i \rightarrow i$, which
    is a function of the monomer composition and the reactivity ratios.

    **References**

    * NA Dotson, R Galván, RL Laurence, and M Tirrel. Polymerization
    process modeling, Wiley, 1996, p. 177.

    Parameters
    ----------
    Pself : FloatVectorLike (N)
        Vector of self-transition probabilities, $P_{ii}$, corresponding to
        the diagonal of the matrix of transition probabilities.
    k : int | IntArrayLike (M) | None
        Sequence length, i.e., number of consecutive units in a chain.
        If `None`, the number-average sequence length will be computed.

    Returns
    -------
    FloatArray (N, M)
        If `k is None`, the number-average sequence lengths, $\bar{S}_i$.
        Otherwise, the sequence probabilities, $S_{i,k}$.

    See also
    --------
    * [`transitions_multi`](transitions_multi.md):
      instantaneous transition probabilities.
    * [`tuples_multi`](tuples_multi.md):
      instantaneous tuple fractions.

    Examples
    --------
    >>> from polykin.copolymerization import sequence_multi
    >>> from polykin.copolymerization import transitions_multi
    >>> import numpy as np

    Define reactivity ratio matrix.
    >>> r = np.ones((3, 3))
    >>> r[0, 1] = 0.2
    >>> r[1, 0] = 2.3
    >>> r[0, 2] = 3.0
    >>> r[2, 0] = 0.9
    >>> r[1, 2] = 0.4
    >>> r[2, 1] = 1.5

    Evaluate self-transition probabilities.
    >>> f = [0.5, 0.3, 0.2]
    >>> Pself = transitions_multi(f, r).diagonal()
    >>> Pself
    array([0.24193548, 0.29487179, 0.20930233])

    Evaluate number-average sequence lengths for all monomers.
    >>> S = sequence_multi(Pself)
    >>> S
    array([1.31914894, 1.41818182, 1.26470588])

    Evaluate probabilities for certain sequence lengths.
    >>> S = sequence_multi(Pself, k=[1, 5])
    >>> S
    array([[0.75806452, 0.00259719],
           [0.70512821, 0.00533091],
           [0.79069767, 0.00151742]])

    """

    Pself = np.asarray(Pself)

    if k is None:
        S = 1/(1. - Pself + eps)
    else:
        if isinstance(k, (list, tuple)):
            k = np.array(k, dtype=np.int32)
        if isinstance(k, np.ndarray):
            Pself = Pself.reshape(-1, 1)
        S = (1. - Pself)*Pself**(k - 1)

    return S