Fundamentals / Numerical mathematics / Numerical partial differential equations

Resolve an outflow layer by fitting the numerical face flux

A dilute solute moves down a channel and diffuses against its mean flow. Fixed concentrations at the ends generate a thin downstream layer. Construct the cell flux directly from the differential equation, then ask how a solver can return nearly the right total throughput while still predicting an impossible local concentration.

Solve the physical flux problem before discretising

Let \(x\in[0,1]\), positive constant speed \(a\), and constant diffusivity \(D\). Steady conservation gives \(\partial_x J=0\) with \(J=au-Du_x\). Impose \(u(0)=1\), \(u(1)=0\). Find \(u(x)\) and the flux. Where must the sharp gradient occur when \(a/D\) is large?

Work through the solution

Constant flux turns the equation into \(u'-(a/D)u=-J/D\). Multiplication by \(e^{-ax/D}\) and integration gives a constant plus an exponential. The boundary values yield

\[u(x)=[1-e^{-(a/D)(1-x)}]/[1-e^{-a/D}],\]
\[J=a/[1-e^{-a/D}].\]

Far upstream for large \(a/D\) the concentration stays near one and most of the flux is advective. At the downstream wall the concentration is zero, but the diffusive term carries the same positive flux. The layer thickness scale is \(D/a\), a length. Constant throughput requires convection and diffusion to trade roles across the layer.

Explore the related calculation with adjustable inputs. Change the parameters in the experiment on this same project page and compare its output with this part of the derivation.

Derive the Scharfetter–Gummel face relation

Take a segment from \(x_i\) to \(x_{i+1}\) of length \(h\) with given endpoint concentrations \(u_i,u_{i+1}\). Solve the same constant-coefficient equation across that segment and express the face flux in a form with a well-defined zero-velocity limit.

Work through the solution

Define \(P=ah/D\) and \(B(P)=P/(e^P-1)\) with \(B(0)=1\). Integrating between the endpoints gives

\[u_{i+1}=e^P u_i-(J/a)(e^P-1).\]

Solving for the common flux and using \(B(-P)=e^P B(P)\) yields

\[J_{i+1/2}=(D/h)[B(-P)u_i-B(P)u_{i+1}].\]

At \(P=0\) it reduces to the centred diffusive flux. For large positive \(P\), \(B(P)\) becomes small while \(B(-P)\) approaches \(P\); the advective part then uses the upstream value. Both coefficients stay positive for real \(P\), supporting monotone solutions of this one-dimensional problem.

Explore the related calculation with adjustable inputs. Change the parameters in the experiment on this same project page and compare its output with this part of the derivation.

Numerical evaluation requires more than inserting the formula literally. Near zero use \(P/\operatorname{expm1}(P)\) or the series \(1-P/2+P^2/12+\cdots\). At very large positive \(P\), use \(B(P)=P e^{-P}/(1-e^{-P})\) to avoid exponential overflow. The identity \(B(-P)=B(P)+P\) avoids a second evaluation. Equal face fluxes across adjacent cells impose local conservation: whatever leaves one control volume enters its neighbour. For constant properties and no internal source, the exact local solution on each segment matches the analytic global nodal values, even when few grid points lie within the layer.

Diagnose a nearly correct throughput with impossible concentrations

Set \(a=1\), \(D=1/24\) and use eight equal segments. Compare the penultimate nodal concentration from exponential fitting, centred advection and first-order upwinding. Why can global throughput hide the error?

Work through the solution

The cell Péclet number is three. For any two-point constant flux relation with constant coefficients the homogeneous nodal variation is \(r^i\). Exponential fitting gives \(r=e^P\); centred advection gives

\[r=(1+P/2)/(1-P/2)=-5;\]

upwinding gives

\[r=1+P=4.\]

With these Dirichlet values the solution is \((r^N-r^i)/(r^N-1)\). At node seven the three values are approximately \(0.9502,\ 1.2000,\ 0.7500\). The centred approximation exceeds the inflow concentration and alternates around it because \(r\) is negative. Upwinding preserves the admissible interval but makes the layer broader. Exponential fitting gives the true nodal value for this local model.

Explore the related calculation with adjustable inputs. Change the parameters in the experiment on this same project page and compare its output with this part of the derivation.

For each scheme, a constant concentration transports advective flux \(au\), while its \(r^i\) homogeneous part has zero net flux. The numerical throughput consequently equals \(a r^N/(r^N-1)\). With eight cells the centred scheme predicts about \(1.00000256\), remarkably close to the true \(1.00000000004\), despite its local overshoot of twenty percent. A scale measuring total output could validate the wrong spatial solver. Report a pointwise quantity, a monotonicity check and flux conservation in addition to throughput if the concentration near the outlet matters.

Test fitted nodes and resolve the inside of a cell

Vary the number of segments and the global Péclet number in the live graph. Under which interpretation is exponential fitting exact, and how could a plotted straight line through its last two values mislead an experimenter?

Work through the solution

Under the specified homogeneous coefficients, zero sources and exact boundary data, the fitted scheme reproduces the analytic solution at every node and returns its correct constant flux. It does not make a piecewise-linear drawing between those nodes the exact local profile. With eight cells at global Péclet number 24, the midpoint of the last cell is \(1/16\) from the outlet. The exact concentration is about \(1-e^{-1.5}=0.777\); linear interpolation between \(0.9502\) and zero gives only \(0.4751\). Reconstruction inside the cell requires the exponential solution with the two endpoint values, or more resolution. Distinguish the face flux actually used in the method from a derivative estimated by visually differentiating the drawn polyline.

Explore the related calculation with adjustable inputs. Change the parameters in the experiment on this same project page and compare its output with this part of the derivation.

Try cell Péclet numbers just below and above two. The centred solution changes from a very sharp monotone profile to a sign-alternating boundary correction. The fitted flux changes continuously through the same transition. If coefficients vary significantly within a cell or a source deposits mass inside it, one needs a corresponding local model, source integration or refinement. An exact result for one constant-coefficient test helps isolate the subsequent approximation. It cannot establish accuracy for every heterogeneous transport problem.

The Sesame semiconductor solver documents exponential fitting of its carrier fluxes.

Notebook practice · When diffusion destabilises a uniform state