Example settings: L=1, N=5, k=1, u0=0, uL=1, s(x)=0. Expected profile is linear.
| x | u(x) | Comment |
|---|---|---|
| 0.0000 | 0.0000 | Left boundary |
| 0.1667 | 0.1667 | Interior node |
| 0.3333 | 0.3333 | Interior node |
| 0.5000 | 0.5000 | Midpoint |
| 0.6667 | 0.6667 | Interior node |
| 0.8333 | 0.8333 | Interior node |
| 1.0000 | 1.0000 | Right boundary |
This calculator solves the steady one-dimensional diffusion/Poisson model:
Using a uniform grid with spacing dx = L/(N+1), the second derivative is approximated by the central difference:
This creates a tridiagonal linear system, solved efficiently with the Thomas algorithm in O(N) time.
- Set L and choose the distance unit.
- Pick N interior points; larger N improves accuracy.
- Enter boundary values u0 and uL.
- Select a source term and adjust parameters p1, p2.
- Press Solve to view stats, the table, and the chart.
- Use Download CSV or Download PDF to export results.
1) What this solver computes
This calculator computes a steady one-dimensional field u(x) on [0,L] where diffusion (or conductivity) balances a prescribed forcing. It targets engineering-style boundary value problems used in heat conduction, electrostatics, and pressure/deflection checks with fixed endpoints.
2) Governing equation and boundary data
The model is -k d²u/dx² = s(x) with u(0)=u0 and u(L)=uL. Here k is a positive coefficient that scales curvature. The source options include zero (Laplace), constant, linear, and sinusoidal forcing, each controlled by p1 and p2.
3) Grid resolution and step size
The grid uses N interior nodes plus two boundaries, so total nodes are N+2. The spacing is dx=L/(N+1). For quick exploration, N=25 is often sufficient. For smooth solutions, N=100 typically yields visually converged curves, while N=500–2000 supports mesh studies and stronger forcing.
4) Accuracy and truncation error
The second derivative uses a central difference that is second-order accurate, meaning the truncation error scales like O(dx²). If you halve dx (roughly doubling N), the discretization error often drops by about a factor of four for sufficiently smooth u(x). A practical check is to compare results at N, 2N, and 4N.
5) Conditioning and parameter limits
Because the matrix diagonal scales with 2k and the right-hand side scales with dx², extreme combinations of very small k and very large N can amplify roundoff. The form enforces safe bounds (for example k>0 and N≤5000) to reduce numerical issues while keeping realistic problem sizes.
6) Runtime and memory footprint
The tridiagonal system is solved with the Thomas algorithm in O(N) time. Internally, the method stores three diagonals and one right-hand side, so memory grows roughly with a few arrays of length N. Even at N=5000, this remains lightweight for typical server limits.
7) Reading the table and chart
The output table lists x, the solution u(x), and the forcing s(x) at every node. The chart overlays u(x) and s(x) to highlight how curvature follows the source. Use the min/max summary to detect overshoot, steep gradients, or unexpected boundary influences.
8) Exports and reporting
CSV exports all nodes for post-processing in spreadsheets or scripts. The PDF export is intentionally compact for documentation; it samples rows if the grid is dense so the report fits on one page (downsampling begins above roughly 45 printed rows). Add run notes to preserve context with your latest export.
FAQs
1) What problem type does this solver handle?
It solves steady 1D diffusion/Poisson boundary value problems with fixed endpoint values: -k d²u/dx² = s(x), u(0)=u0, u(L)=uL.
2) How do I choose a good N value?
Start with N=25 for a quick view. Increase to N=100 for smoother curves. For verification, run N, 2N, and 4N and compare changes in u(x).
3) Why must k be positive?
A positive k matches diffusion-like physics and produces a well-posed system with a stable tridiagonal matrix. Negative or zero k can invert the operator, making solutions non-physical or numerically unstable.
4) What do p1 and p2 mean for each source?
For constant forcing, p1=S0. For linear, p1=a and p2=b. For sinusoidal, p1=A and p2=φ (radians). For zero forcing, both are ignored.
5) How accurate are the computed values?
The central difference for d²u/dx² is second-order accurate, so discretization error typically scales like O(dx²). Accuracy improves quickly as you refine the grid, especially when the solution is smooth.
6) Why does the PDF show fewer rows than the CSV?
The PDF is designed to fit on one page for reporting. If the grid is dense, it samples rows so the table remains readable. The CSV always includes every node for full-resolution post-processing.
7) Can I use this for time-dependent diffusion?
This page solves the steady spatial problem only. For time dependence, you would add a time discretization (explicit, implicit, or Crank–Nicolson) and step forward in time while reusing the same spatial finite difference operator.