Calculator inputs
The page stays in one main column, while the input fields switch across three, two, or one column responsively.
Formula used
The calculator solves the one dimensional heat equation ut = αuxx with constant Dirichlet boundary values. Crank Nicolson averages the spatial second derivative between time levels n and n+1, which makes the method second order accurate in both space and time for smooth solutions.
Here r = αΔt / Δx². The calculator forms this tridiagonal linear system at every time step and solves it with the Thomas algorithm, which is efficient for banded systems.
How to use this calculator
- Enter α, L, and total time T for the diffusion problem.
- Choose spatial intervals Nx and time steps Nt for the grid.
- Set the constant left and right boundary values.
- Pick an initial profile and tune base, amplitude, position, and width.
- Choose a selected time ratio to inspect an intermediate profile.
- Submit the form, then review the metrics, table, and Plotly graphs above the form.
Example data table
The example below uses the default sine profile with α = 0.15, L = 1.00, T = 0.50, Nx = 20, and Nt = 60.
| Node | x | Initial | Mid profile | Final | Exact final |
|---|---|---|---|---|---|
| 0 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 |
| 3 | 0.150000 | 45.399050 | 31.378933 | 21.688503 | 21.655747 |
| 5 | 0.250000 | 70.710678 | 48.873833 | 33.780635 | 33.729616 |
| 8 | 0.400000 | 95.105652 | 65.735160 | 45.434853 | 45.366233 |
| 10 | 0.500000 | 100.000000 | 69.118038 | 47.773032 | 47.700880 |
| 13 | 0.650000 | 89.100652 | 61.584623 | 42.566083 | 42.501796 |
| 15 | 0.750000 | 70.710678 | 48.873833 | 33.780635 | 33.729616 |
| 18 | 0.900000 | 30.901699 | 21.358648 | 14.762679 | 14.740383 |
| 20 | 1.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 |
Frequently asked questions
1. What does this calculator solve?
It solves the one dimensional heat equation with constant boundary values by marching the solution forward in time with the Crank Nicolson finite difference method.
2. Why use Crank Nicolson instead of a purely explicit scheme?
Crank Nicolson is unconditionally stable for the heat equation and usually produces smoother, more accurate results than a coarse explicit method using the same grid.
3. What does the ratio r mean?
r = αΔt / Δx² measures how strongly diffusion acts during one time step relative to the square of the spatial step. Large r stays stable here, but accuracy can still suffer.
4. Which boundary conditions are supported here?
This file supports constant Dirichlet boundaries, meaning the left and right endpoint values remain fixed for all time steps throughout the simulation.
5. When is the exact error displayed?
The page shows exact final and intermediate comparisons when you use the sine profile with zero boundaries and zero base value, which has a closed form decay solution.
6. Why can a stable result still look inaccurate?
Stability prevents blow up, not poor resolution. If the mesh is too coarse, steep gradients blur, peaks shift slightly, and the final profile may lose detail.
7. What is included in the CSV export?
The CSV file contains the chosen parameters, Δx, Δt, the ratio r, and the full computed temperature grid for every time step and node.
8. What does the PDF export capture?
The PDF button captures the visible result section, including summary cards, notes, the sampled table, and both Plotly graphs in a printable report layout.