Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Effective diffusivity of a random suspension of impermeable disks

This example combines the pymrm immersed boundary method with a Monte-Carlo placement of many non-overlapping circular particles and a grid-convergence study of a derived engineering quantity: the effective diffusion coefficient of the porous medium formed by the fluid around the impermeable particles.

The physical model is exactly the impermeable-particle case of the ibm_touching_particles example -- at every particle surface a homogeneous Neumann condition ∂c/∂n=0\partial c/\partial n = 0 is imposed on the fluid side (no diffusion into the solid), and the solid interior is pinned by a zero Dirichlet value. Steady diffusion is driven across the domain by c=1c=1 at the inlet (left) and c=0c=0 at the outlet (right), with no-flux top/bottom walls.

We

  1. place n_particles disks at random -- non-overlapping with each other, clear of the side walls, and at least one coarse grid cell from inlet and outlet;

  2. size the disks so that at the coarsest grid the diameter is resolved by 5 cells (diameter / h = 5);

  3. solve the impermeable-particle diffusion problem and evaluate the effective diffusivity DeffD_\mathrm{eff} from the through-flux;

  4. refine the same physical geometry on successively finer grids and watch DeffD_\mathrm{eff} converge.

disk radius R          : 0.0750  (diameter = 6 coarse cells)
coarse cell size h     : 0.0250

Monte-Carlo placement

A simple rejection sampler draws candidate centres uniformly in the admissible box and keeps a candidate only if it clears every previously accepted disk by at least gap_cells coarse cells (here gap_cells = 0, so disks may just touch):

  • inlet / outlet (left, right): the disk edge stays at least wall_cells coarse cells from x=0x=0 and x=Lx=L, keeping the Dirichlet boundary columns clean;

  • side walls (top, bottom): the disk may reach right up to -- and touch -- the no-flux walls; the immersed boundary handles cut cells in the outermost cell layer with a first-order reconstruction.

The centres are generated once, in physical coordinates, and reused unchanged on every grid -- this is what makes the later grid-convergence study meaningful. Letting particles touch each other and the walls can, on a coarse grid, pinch off small enclosed fluid pockets; these are dealt with in the solver (next section).

placed 18 particles
solid area fraction phi : 0.318
<Figure size 550x550 with 1 Axes>

Solver and the effective diffusivity

For a given grid resolution N the solver:

  • describes the disks as Circle particles and builds the immersed-boundary data with construct_ibm_particles (exact wall positions and normals; contact='merge' so touching disks stay connected), taking the sign-correct classification field from info.pseudo_sdf;

  • assembles the bare Laplacian with the domain BCs and scales it by −D-D;

  • applies the homogeneous Neumann condition on the fluid side of every crossing via construct_ibm_boundary_values ({'a': 1, 'b': 0, 'd': 0} ⇒\Rightarrow ∂c/∂n=0\partial c/\partial n = 0) and pins the solid interior to the zero Dirichlet value (values_inside = 0, so its G_in contribution vanishes);

  • solves the steady system and integrates the boundary flux.

Effective diffusivity. In steady state the total molar throughput is Q=∫0HJ dyQ = \int_0^H J\,\mathrm dy with J=−D ∂c/∂xJ = -D\,\partial c/\partial x the local flux. The effective diffusivity follows from Fick’s law applied to the homogenised slab,

Deff=JˉΔc/L=Q LH Δc,Jˉ=QH,D_\mathrm{eff} = \frac{\bar J}{\Delta c / L} = \frac{Q\,L}{H\,\Delta c},\qquad \bar J = \frac{Q}{H},

i.e. the average flux divided by the imposed concentration gradient Δc/L\Delta c / L. Here H=L=1H = L = 1 and Δc=1\Delta c = 1, so numerically DeffD_\mathrm{eff} equals the throughput QQ; dividing by the fluid DD gives the dimensionless obstruction factor Deff/D≤1D_\mathrm{eff}/D \le 1. Because the particles are impermeable and the fluid is source-free, the inflow and outflow throughputs must agree; their mismatch is a useful discretisation diagnostic that vanishes under refinement.

Enclosed fluid pockets and the singular matrix

Because the particles may now touch each other and the top/bottom walls, a coarse grid can pinch off individual fluid cells that end up surrounded by solid (and no-flux walls) on every face. Such a cell only ever sees homogeneous Neumann conditions, so nothing fixes its concentration: its steady-state matrix row is identically zero and the system is singular (spsolve returns nan with a “matrix is exactly singular” warning).

A clean, physical remedy is to solve a transient step instead of the pure steady problem. We add the accumulation term ∂c/∂t\partial c/\partial t (mass matrix M=I/Δt\mathsf M = \mathsf I/\Delta t), initialise c=0c=0 everywhere, and take a single implicit-Euler step with a very large Δt\Delta t:

(1ΔtI−D div grad) c1=1Δt c0−gbc,c0=0.\Big(\tfrac{1}{\Delta t}\mathsf I - D\,\mathrm{div}\,\mathrm{grad}\Big)\,c^{1} = \tfrac{1}{\Delta t}\,c^{0} - g_\mathrm{bc},\qquad c^{0}=0 .

The mass term places 1/Δt1/\Delta t on every diagonal, so the matrix is nonsingular everywhere. On cells connected to the inlet/outlet, Δt→∞\Delta t\to\infty recovers the steady solution (the departure is O(1/Δt)O(1/\Delta t)). An enclosed pocket has no flux across any face, so it cannot change from its initial value and simply stays at c=0c=0 -- the same harmless value we would otherwise have to pin by hand. With Δt=108\Delta t = 10^{8} (against the diffusion time L2/D=1L^2/D = 1) the connected region is at steady state to ∼10−9\sim 10^{-9}. The iso column below counts the enclosed cells the accumulation term silently regularises.

Concentration field on a reference grid

We first solve on a moderately fine grid and plot the concentration field. The iso-concentration lines meet each impermeable disk at right angles (zero normal derivative) and squeeze through the fluid channels between particles.

<Figure size 620x520 with 2 Axes>
D_eff/D    = 0.4082
imbalance  = 1.26e-02

Grid-convergence study

Now we solve the same particle configuration on a sequence of grids obtained by successive halving of the cell size, N = 40, 80, 160, 320, so the disk diameter is resolved by 5, 10, 20 and 40 cells respectively. We track Deff/DD_\mathrm{eff}/D, the inflow/outflow imbalance, and the number of crossings whose one-sided reconstruction had to drop below second order (a marker of under-resolution -- pervasive at the coarsest grid, gone once the disks are comfortably resolved).

    N     h=L/N  diam/h    D_eff/D   imbalance  crossings   deg<2   iso
   40   0.02500       6    0.25669    1.66e+00        412     412     4
   80   0.01250      12    0.34699    1.46e-02        858      49     3
  160   0.00625      24    0.40823    1.26e-02       1726      36     2
  320   0.00313      48    0.42527    1.77e-03       3456      32     3

Observed order and Richardson extrapolation

With the cell size halved between levels, a method of order pp reduces successive increments of DeffD_\mathrm{eff} by a factor 2p2^p. Estimating pp from the last three levels and extrapolating gives a grid-independent estimate

Deff∞≈Deff(k)+Deff(k)−Deff(k−1)2p−1.D_\mathrm{eff}^{\infty} \approx D_\mathrm{eff}^{(k)} + \frac{D_\mathrm{eff}^{(k)} - D_\mathrm{eff}^{(k-1)}}{2^{p} - 1}.
successive increments dD_eff : [0.0903  0.06124 0.01704]
observed orders p            : [0.56 1.85]
Richardson estimate D_eff/D  : 0.43184  (order p = 1.85)
2-D Maxwell estimate (dilute): 0.51735  at phi = 0.318

Convergence plot

Left: Deff/DD_\mathrm{eff}/D approaches the Richardson limit as the grid is refined. Right: the error ∣Deff(N)−Deff∞∣|D_\mathrm{eff}(N) - D_\mathrm{eff}^{\infty}| against the cell size on a log-log scale, with a second-order reference slope. The immersed-boundary Neumann treatment is second-order accurate, so the derived DeffD_\mathrm{eff} inherits close to second-order convergence once the disks are resolved.

<Figure size 1100x440 with 2 Axes>

Summary

  • A Monte-Carlo rejection sampler placed non-overlapping impermeable disks, clear of the side walls and at least one coarse cell from the inlet/outlet; the configuration is fixed in physical space and reused on every grid.

  • The transport problem is the impermeable-particle case of the immersed boundary method: homogeneous Neumann (∂c/∂n=0\partial c/\partial n = 0) on the fluid side of each disk via construct_ibm_boundary_values, and a zero Dirichlet value inside.

  • The effective diffusivity Deff=Jˉ/(Δc/L)D_\mathrm{eff} = \bar J / (\Delta c / L) was obtained from the boundary throughput; inflow and outflow agree to a tolerance that tightens under refinement.

  • A grid-convergence study (diameter resolved by 5 -> 40 cells) shows Deff/DD_\mathrm{eff}/D converging at close to second order to a Richardson limit that agrees with the dilute 2-D Maxwell estimate (1−ϕ)/(1+ϕ)(1-\phi)/(1+\phi) for insulating cylinders.