Skip to content

polykin.copolymerization¤

transitions_multi ¤

transitions_multi(
    f: FloatVectorLike, r: FloatSquareMatrix
) -> FloatSquareMatrix

Calculate the instantaneous transition probabilities for a multicomponent system.

For a multicomponent system, the transition probabilities are given by:

\[ P_{ij} = \frac{r_{ij}^{-1} f_j} {\displaystyle \sum_{k=1}^{N} r_{ik}^{-1} f_k} \]

where \(f_i\) is the molar fraction of monomer \(i\) and \(r_{ij}=k_{ii}/k_{ij}\) is the multicomponent reactivity ratio matrix.

References

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

Vector of instantaneous monomer compositions, \(f_i\).

TYPE: FloatVectorLike(N)

r

Matrix of reactivity ratios, \(r_{ij}=k_{ii}/k_{ij}\).

TYPE: FloatSquareMatrix(N, N)

RETURNS DESCRIPTION
FloatSquareMatrix(N, N)

Matrix of transition probabilities, \(P_{ij}\).

See also

Examples:

>>> 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 transition probabilities.

>>> f = [0.5, 0.3, 0.2]
>>> P = transitions_multi(f, r)
>>> P
array([[0.24193548, 0.72580645, 0.03225806],
       [0.21367521, 0.29487179, 0.49145299],
       [0.58139535, 0.20930233, 0.20930233]])
Source code in src/polykin/copolymerization/multicomponent.py
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
def transitions_multi(f: FloatVectorLike,
                      r: FloatSquareMatrix
                      ) -> FloatSquareMatrix:
    r"""Calculate the instantaneous transition probabilities for a
    multicomponent system.

    For a multicomponent system, the transition probabilities are given
    by:

    $$ P_{ij} = \frac{r_{ij}^{-1} f_j}
                     {\displaystyle \sum_{k=1}^{N} r_{ik}^{-1} f_k} $$

    where $f_i$ is the molar fraction of monomer $i$ and $r_{ij}=k_{ii}/k_{ij}$
    is the multicomponent reactivity ratio matrix.

    **References**

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

    Parameters
    ----------
    f : FloatVectorLike (N)
        Vector of instantaneous monomer compositions, $f_i$.
    r : FloatSquareMatrix (N, N)
        Matrix of reactivity ratios, $r_{ij}=k_{ii}/k_{ij}$.

    Returns
    -------
    FloatSquareMatrix (N, N)
        Matrix of transition probabilities, $P_{ij}$.

    See also
    --------
    * [`inst_copolymer_multi`](inst_copolymer_multi.md):
      instantaneous copolymer composition.
    * [`sequence_multi`](sequence_multi.md):
      instantaneous sequence lengths.
    * [`tuples_multi`](tuples_multi.md):
      instantaneous tuple fractions.

    Examples
    --------
    >>> 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 transition probabilities.
    >>> f = [0.5, 0.3, 0.2]
    >>> P = transitions_multi(f, r)
    >>> P
    array([[0.24193548, 0.72580645, 0.03225806],
           [0.21367521, 0.29487179, 0.49145299],
           [0.58139535, 0.20930233, 0.20930233]])

    """
    f = np.asarray(f)

    # N = len(f)
    # P = np.empty((N, N))
    # for i in range(N):
    #     for j in range(N):
    #         P[i, j] = f[j]/r[i, j] / np.sum(f/r[i, :])
    P = (f/r) / np.sum(f/r, axis=1)[:, np.newaxis]

    return P