Skip to content

Commit

Permalink
add Flory_Af
Browse files Browse the repository at this point in the history
  • Loading branch information
HugoMVale committed Feb 25, 2024
1 parent d19fb0a commit d6fc753
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 21 deletions.
26 changes: 14 additions & 12 deletions docs/reference/stepgrowth/solutions.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
# Solutions (polykin.stepgrowth)

| Equation | Case |
|----------------------------------------------------------|-----------------------------------------------------------------|
| [`Case_1`](#polykin.stepgrowth.solutions.Case_1) | AA + BB |
| [`Case_3`](#polykin.stepgrowth.solutions.Case_3) | AA + BB' |
| [`Case_5`](#polykin.stepgrowth.solutions.Case_5) | AA + BB + B' |
| [`Case_6`](#polykin.stepgrowth.solutions.Case_6) | AA + A'B |
| [`Case_7`](#polykin.stepgrowth.solutions.Case_7) | AB + A'B' |
| [`Case_8`](#polykin.stepgrowth.solutions.Case_8) | AA + BB + B'B' |
| [`Case_9`](#polykin.stepgrowth.solutions.Case_9) | AA + A'A' + BB + B'B' |
| [`Case_10`](#polykin.stepgrowth.solutions.Case_10) | AA + BB' + B''B'' |
| [`Case_11`](#polykin.stepgrowth.solutions.Case_11) | AA + A'B' + BB |
| [`Stockmayer`](#polykin.stepgrowth.solutions.Stockmayer) | A + A$_2$ + A$_3$ + A$_4$ + ... + B + B$_2$ + B$_3$ + B$_4$ ... |
| Equation | Case | $M_n$ | $M_w$ | $M_z$ |
|----------------------------------------------------------|-------------------------------------------------------------------|--------|-------|-------|
| [`Case_1`](#polykin.stepgrowth.solutions.Case_1) | AA + BB ||| |
| [`Case_3`](#polykin.stepgrowth.solutions.Case_3) | AA + BB' ||| |
| [`Case_5`](#polykin.stepgrowth.solutions.Case_5) | AA + BB + B' || | |
| [`Case_6`](#polykin.stepgrowth.solutions.Case_6) | AA + A'B || | |
| [`Case_7`](#polykin.stepgrowth.solutions.Case_7) | AB + A'B' || | |
| [`Case_8`](#polykin.stepgrowth.solutions.Case_8) | AA + BB + B'B' || | |
| [`Case_9`](#polykin.stepgrowth.solutions.Case_9) | AA + A'A' + BB + B'B' || | |
| [`Case_10`](#polykin.stepgrowth.solutions.Case_10) | AA + BB' + B''B'' || | |
| [`Case_11`](#polykin.stepgrowth.solutions.Case_11) | AA + A'B' + BB || | |
| [`Flory_Af`](#polykin.stepgrowth.solutions.Flory_Af) | A$_f$ ||||
| [`Stockmayer`](#polykin.stepgrowth.solutions.Stockmayer) | A + A$_2$ + A$_3$ + ... + A$_f$ + B + B$_2$ + B$_3$ + ... + B$_g$ ||| |

::: polykin.stepgrowth.solutions
options:
Expand All @@ -25,4 +26,5 @@
- Case_9
- Case_10
- Case_11
- Flory_Af
- Stockmayer
57 changes: 52 additions & 5 deletions src/polykin/stepgrowth/solutions.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
import numpy as np
from numpy import dot

from polykin.utils.types import FloatArray, FloatArrayLike, FloatVectorLike
from polykin.utils.types import FloatArray, FloatArrayLike, FloatVectorLike, \
IntVectorLike

__all__ = ['Case_1',
'Case_3',
Expand Down Expand Up @@ -659,8 +660,8 @@ def Case_11(pB: Union[float, FloatArrayLike],

def Stockmayer(A: FloatVectorLike,
B: FloatVectorLike,
f: FloatVectorLike,
g: FloatVectorLike,
f: IntVectorLike,
g: IntVectorLike,
MA: FloatVectorLike,
MB: FloatVectorLike,
pB: Union[float, FloatArrayLike]
Expand Down Expand Up @@ -698,9 +699,9 @@ def Stockmayer(A: FloatVectorLike,
Vector (N) with relative mole amounts of A monomers.
B : FloatVectorLike
Vector (M) with relative mole amounts of B monomers.
f : FloatVectorLike
f : IntVectorLike
Vector (N) with functionality of A monomers.
g : FloatVectorLike
g : IntVectorLike
Vector (M) with functionality of B monomers.
MA : FloatVectorLike
Vector (N) with molar mass of reacted A monomers.
Expand Down Expand Up @@ -759,3 +760,49 @@ def Stockmayer(A: FloatVectorLike,
(1 - pA*pB*(fe - 1)*(ge - 1)))/(pB*(sMA/sfA) + pA*(sMB/sgB))

return (Mn, Mw)


def Flory_Af(f: int,
MA: float,
p: Union[float, FloatArrayLike]
) -> tuple[Union[float, FloatArray],
Union[float, FloatArray],
Union[float, FloatArray]]:
r"""Flory's analytical solution for the hopolymerization of an Af monomer.
The expressions for the number-, mass-, and z-average molar masses are:
\begin{aligned}
M_n &= M_{A_f}\frac{1}{1 - (f/2)p} \\
M_w &= M_{A_f}\frac{1 + p}{1 - (f-1)p} \\
M_z &= M_{A_f}\frac{(1 + p)^3 - f(3 + p)p^2}{(1 + p)[1 - (f-1)p]^2}
\end{aligned}
**References**
* P. J. Flory, Molecular Size Distribution in Three Dimensional
Polymers. I. Gelation, J. Am. Chem. Soc. 1941, 63, 11, 3083.
* M. Gordon, Proc. R. Soc. London, Ser. A, 1962, 268, 240.
Parameters
----------
f : int
Functionality.
MA : float
Molar mass of reacted Af monomer.
p : float | FloatArrayLike
Conversion of A groups.
Returns
-------
tuple[float | FloatArray, ...]
Tuple of molar mass averages, ($M_n$, $M_w$, $M_z$).
"""

p = np.asarray(p)

Mn = MA/(1 - (f/2)*p)
Mw = MA*(1 + p)/(1 - p*(f - 1))
Mz = MA*((1 + p)**3 - (3 + p)*f*p**2)/((1 + p)*(1 - p*(f-1))**2)

return (Mn, Mw, Mz)
8 changes: 4 additions & 4 deletions tests/stepgrowth/test_solutions.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,10 @@ def test_StockMayer():
pB = 0.998
r_BB_AA = 0.98
A = [1.]
f = [2.]
f = [2]
MA = [MAA]
B = [r_BB_AA]
g = [2.]
g = [2]
MB = [MBB]
Mn0, Mw0 = Case_1(pB, r_BB_AA, MAA, MBB)
Mn, Mw = Stockmayer(A, B, f, g, MA, MB, pB)
Expand All @@ -187,10 +187,10 @@ def test_StockMayer():
pB = 0.978
r_BC_AA = 0.95
A = [1.]
f = [2.]
f = [2]
MA = [MAA]
B = [r_BC_AA]
g = [1.]
g = [1]
MB = [MBC]
Mn0, Mw0 = Case_3(pB, 0, r_BC_AA, MAA, MBC)
Mn, Mw = Stockmayer(A, B, f, g, MA, MB, pB)
Expand Down

0 comments on commit d6fc753

Please sign in to comment.