Crank Nicolson Method Calculator for Heat Equation Analysis

Model diffusion through balanced implicit explicit weighting. Choose boundary values, mesh sizes, and initial profiles. Study convergence, export results, and review every timestep clearly.

Use this page to solve the one dimensional heat equation with constant boundary values, inspect the Crank Nicolson ratio, compare profiles across time, and export the computed grid.

Calculator inputs

The page stays in one main column, while the input fields switch across three, two, or one column responsively.

Maths Heat equation Crank Nicolson
Positive constant controlling diffusion speed.
Spatial domain from x = 0 to x = L.
Final simulation time.
Higher values improve spatial detail.
Higher values improve temporal resolution.
Choose the starting temperature shape.
Constant boundary value at x = 0.
Constant boundary value at x = L.
Added before the selected profile shape.
Main height of the initial profile.
Used by the Gaussian and step profiles.
Gaussian spread relative to rod length.
0 shows the start, 1 shows the final step.
Evenly sampled rows for the display table.
Reset to defaults

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.

(uᶰ⁺¹ᵢ - uᶰᵢ) / Δt = (α / 2Δx²) [(uᶰ⁺¹ᵢ₊₁ - 2uᶰ⁺¹ᵢ + uᶰ⁺¹ᵢ₋₁) + (uᶰᵢ₊₁ - 2uᶰᵢ + uᶰᵢ₋₁)]
-(r/2)uᶰ⁺¹ᵢ₋₁ + (1 + r)uᶰ⁺¹ᵢ - (r/2)uᶰ⁺¹ᵢ₊₁ = (r/2)uᶰᵢ₋₁ + (1 - r)uᶰᵢ + (r/2)uᶰᵢ₊₁

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

  1. Enter α, L, and total time T for the diffusion problem.
  2. Choose spatial intervals Nx and time steps Nt for the grid.
  3. Set the constant left and right boundary values.
  4. Pick an initial profile and tune base, amplitude, position, and width.
  5. Choose a selected time ratio to inspect an intermediate profile.
  6. 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.

Related Calculators

divergence theorem calculatorschrodinger equation solverhessian matrix calculatormethod of characteristics solverpotential function solverstream function calculatortransport equation solveradvection equation solvernumerical solution finderfirst order pde solver

Important Note: All the Calculators listed in this site are for educational purpose only and we do not guarentee the accuracy of results. Please do consult with other sources as well.