Skip to content

polykin.transport.diffusion¤

uptake_sphere ¤

uptake_sphere(t: float, a: float, D: float) -> float

Fractional mass uptake for transient diffusion in a sphere.

For a sphere of radius \(a\), where the concentration is initially \(C_0\) everywhere, and the surface concentration is maintained at \(C_s\), the fractional mass uptake is:

\[ \frac{M_t}{M_{\infty}} = 1 - \frac{6}{\pi^2} \sum_{n=1}^{\infty}\frac{1}{n^2} \exp \left( \frac{-D n^2 \pi^2 t}{a^2} \right) \]

where \(t\) is the time, and \(D\) is the diffusion coefficient.

References

  • J. Crank, "The mathematics of diffusion", Oxford University Press, 1975, p. 91.
PARAMETER DESCRIPTION
t

Time (s).

TYPE: float

a

Radius of sphere (m).

TYPE: float

D

Diffusion coefficient (m²/s).

TYPE: float

RETURNS DESCRIPTION
float

Fractional mass uptake.

See also
  • profile_sphere: related method to determine the concentration profile.

Examples:

Determine the fractional mass uptake after 100 seconds for a polymer sphere with a radius of 0.2 mm and a diffusion coefficient of 1e-10 m²/s.

>>> from polykin.transport.diffusion import uptake_sphere
>>> uptake_sphere(t=1e2, a=0.2e-3, D=1e-10)
0.9484368978658284
Source code in src/polykin/transport/diffusion.py
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
def uptake_sphere(t: float,
                  a: float,
                  D: float
                  ) -> float:
    r"""Fractional mass uptake for transient diffusion in a sphere. 

    For a sphere of radius $a$, where the concentration is initially $C_0$
    everywhere, and the surface concentration is maintained at $C_s$, the
    fractional mass uptake is:

    $$ \frac{M_t}{M_{\infty}} = 
        1 - \frac{6}{\pi^2} \sum_{n=1}^{\infty}\frac{1}{n^2}
        \exp \left( \frac{-D n^2 \pi^2 t}{a^2} \right) $$

    where $t$ is the time, and $D$ is the diffusion coefficient.

    **References**

    * J. Crank, "The mathematics of diffusion", Oxford University Press, 1975,
      p. 91.

    Parameters
    ----------
    t : float
        Time (s).
    a : float
        Radius of sphere (m).
    D : float
        Diffusion coefficient (m²/s).

    Returns
    -------
    float
        Fractional mass uptake.

    See also
    --------
    * [`profile_sphere`](profile_sphere.md): related method to determine the
      concentration profile.

    Examples
    --------
    Determine the fractional mass uptake after 100 seconds for a polymer sphere
    with a radius of 0.2 mm and a diffusion coefficient of 1e-10 m²/s.
    >>> from polykin.transport.diffusion import uptake_sphere
    >>> uptake_sphere(t=1e2, a=0.2e-3, D=1e-10)
    0.9484368978658284
    """
    N = 4  # Number of terms in series expansion (optimal value)

    A = sqrt(D*t)/a
    if A == 0.:
        result = 0.
    elif A < 0.5:
        # Solution for small times
        S = sum(ierfc(n/A) for n in range(1, N))
        result = 6*A * (1/sqrt(pi) + 2*S) - 3*A**2
    else:
        # Solution for normal times
        B = -D*pi**2*t/a**2
        S = sum(1/n**2 * exp(B*n**2) for n in range(1, N))
        result = 1 - (6/pi**2)*S

    return result

Graphical Illustration¤

uptake_sphere