Skip to content

polykin.transport.diffusion¤

profile_constc_sphere ¤

profile_constc_sphere(Fo: float, rstar: float) -> float

Concentration profile for transient diffusion in a sphere subjected to a constant surface concentration boundary condition.

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

\[ \frac{C - C_0}{C_s - C_0} = 1 + \frac{2}{\pi r^*} \sum_{n=1}^\infty \frac{(-1)^n}{n} \exp(- n^2 \pi^2 Fo) \sin (n \pi r^*) \]

where \(Fo = D t/a^2\) is the Fourier number, and \(r^*=r/a\) is the normalized radial distance from the center of the sphere.

References

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

Fourier number, \(D t/a^2\).

TYPE: float

rstar

Normalized radial distance from the center of the sphere, \(r/a\).

TYPE: float

RETURNS DESCRIPTION
float

Normalized concentration.

See also

Examples:

Determine the fractional concentration change after 100 s at the center of a polymer sphere with a radius of 0.2 mm and a diffusivity of 1e-10 m²/s.

>>> from polykin.transport import profile_constc_sphere
>>> t = 1e2    # s
>>> a = 0.2e-3 # m
>>> r = 0      # m
>>> D = 1e-10  # m²/s
>>> Fo = D*t/a**2
>>> rstar = r/a
>>> profile_constc_sphere(Fo, rstar)
0.8304935009764246
Source code in src/polykin/transport/diffusion.py
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
def profile_constc_sphere(Fo: float, rstar: float) -> float:
    r"""Concentration profile for transient diffusion in a sphere subjected
    to a constant surface concentration boundary condition. 

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

    $$ \frac{C - C_0}{C_s - C_0} =
        1 + \frac{2}{\pi r^*} \sum_{n=1}^\infty \frac{(-1)^n}{n} 
        \exp(- n^2 \pi^2 Fo) \sin (n \pi r^*) $$

    where $Fo = D t/a^2$ is the Fourier number, and $r^*=r/a$ is the normalized
    radial distance from the center of the sphere.

    **References**

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

    Parameters
    ----------
    Fo : float
        Fourier number, $D t/a^2$.
    rstar : float
        Normalized radial distance from the center of the sphere, $r/a$.

    Returns
    -------
    float
        Normalized concentration.

    See also
    --------
    * [`uptake_constc_sphere`](uptake_constc_sphere.md): related method to
      determine the mass uptake.

    Examples
    --------
    Determine the fractional concentration change after 100 s at the center of
    a polymer sphere with a radius of 0.2 mm and a diffusivity of 1e-10 m²/s.
    >>> from polykin.transport import profile_constc_sphere
    >>> t = 1e2    # s
    >>> a = 0.2e-3 # m
    >>> r = 0      # m
    >>> D = 1e-10  # m²/s
    >>> Fo = D*t/a**2
    >>> rstar = r/a
    >>> profile_constc_sphere(Fo, rstar)
    0.8304935009764246
    """
    N = 4  # Number of terms in series expansion (sufficient for convergence)

    if abs(rstar) < eps:
        # Solution for particular case r->0
        B = -(pi**2)*Fo
        S = sum((-1 if n % 2 else 1) * exp(B*n**2) for n in range(1, N))
        result = 1 + 2*S
    else:
        if Fo == 0:
            result = 0
        elif Fo < 1/4:
            # Solution for small times
            A = 2*sqrt(Fo)
            S = sum(erfc(((2*n + 1) - rstar)/A) - erfc(((2*n + 1) + rstar)/A)
                    for n in range(0, N))
            result = S/rstar
        else:
            # Solution for normal times
            B = -(pi**2)*Fo
            S = sum((-1 if n % 2 else 1) / n * exp(B*n**2) * sin(rstar*pi*n)
                    for n in range(1, N))
            result = 1 + (2/(pi*rstar))*S

    return result

Graphical Illustration¤

The numbers in the legend are values of \(D t / a^2\).

profile_constc_sphere