How this calculation works
Evolve nonlinear advection with positive viscosity using conservative fluxes and bounded time steps.
u_t+(u²/2)_x=νu_xx;periodic x∈[0,1].A worked example
sin(2πx),ν=0.02,T=0.1 yields fine-grid maximum≈0.9030035 and mean near zero.
Good to know
Periodic unit interval,positive viscosity≤0.5,terminal time≤2,20–100 coarse cells,initial magnitude≤10;Rusanov flux+centered diffusion,CFL-controlled steps≤50,000,no inviscid entropy claim.
Reference: Clawpack conservative Riemann methods (opens in a new tab) ↗
Nonlinear advection changes the diffusion problem
The viscous Burgers equation combines transport of a field by its own value with ordinary diffusion. In conservative form it is u_t+(u²/2)_x=νu_xx. This page evolves a scalar profile on a periodic unit interval with strictly positive viscosity,so the solution wraps continuously between the two ends.
The nonlinear flux distinguishes this model from linear heat diffusion. A positive hump can move and steepen while viscosity smooths gradients. The numerical method must control both the transport time scale and the shorter diffusion time scale as the mesh is refined.
Compare this with the One dimensional heat equation calculator with finite differences. Evolve nonlinear advection plus viscosity rather than linear heat diffusion.
Define the initial profile and viscosity
Enter an initial expression in x,sampled at cell centers,along with positive viscosity,a terminal time and a coarse cell count. The supported profile magnitude is bounded,and a finite periodic interpretation is assumed. The expression's endpoint values should agree if a smooth periodic initial condition is intended.
The interface supports twenty through one hundred coarse cells and runs a doubled-cell comparison. It does not accept inflow/outflow boundary data or variable viscosity. A finite sample check cannot prove smoothness everywhere,so narrow singularities in a user expression remain outside the intended model even if most samples look finite.
Conservative flux preserves the mean
Each interface flux uses the neighboring values and a Rusanov stabilization speed based on the largest absolute field value. Flux differences update the cell averages conservatively. Periodic interfaces cancel in the sum,so the discrete mean should remain constant apart from floating-point roundoff.
The diffusion term uses the standard centered second difference and also has zero periodic sum. The page reports a mass residual to check that conserved mean. Conservation does not alone establish accuracy:an overly diffusive method can conserve mass while smoothing the solution substantially more than the continuum equation.
Time steps obey two restrictions
At each update,the step is limited by a transport CFL condition and an explicit diffusion restriction,as well as the remaining terminal time. Refining the grid reduces the allowable step,especially when viscosity makes the h-squared diffusion scale dominant. The number of actual steps is therefore an output rather than an independently fixed control.
Every updated state is checked for finite numerical range,and a step cap prevents runaway work. Reaching that cap raises an error instead of returning an unfinished time as though it were the requested endpoint. Positive viscosity is required;the inviscid entropy-solution problem has different numerical and mathematical requirements.
The periodic sine example
The default starts from sin(2πx),uses viscosity0.02 and evolves to time0.1. Its initial spatial mean is zero,and the computed terminal mean remains close to zero. The doubled eighty-cell run has maximum magnitude around0.903,while its negative minimum has the corresponding symmetry.
These numbers are outputs of the stated numerical mesh,not an exact analytic solution. Unlike a pure heat equation,the sine profile is not simply multiplied by one exponential decay factor:the nonlinear term changes its shape. Comparing the entire profile is therefore more informative than checking only one amplitude.
A coarse-fine comparison exposes sensitivity
For each coarse cell,the comparison averages its two corresponding fine cells,then computes an RMS difference. This aligns cell averages rather than comparing different center locations directly. The value is a mesh sensitivity diagnostic and should not be labeled a proven upper error bound.
The Rusanov flux adds numerical diffusion in addition to the entered physical viscosity. That contribution decreases under refinement but can matter for small viscosity or coarse cells. A sharper profile may need more resolution than the bounded interface provides,even when the time-step stability restrictions are satisfied.
Keep the boundary and flux convention
The output includes the coarse terminal profile,refinement difference,mean residual and fine-step count. It does not automatically search for shocks,estimate measurement noise or solve a conservation law on an arbitrary physical interval. Scaling length and time requires changing the dimensional model consistently.
A constant profile is a useful separate check:both flux differences and diffusion vanish,so it should remain constant at every accepted time. Save the initial expression,positive viscosity,terminal time,periodic unit domain and grid size when reproducing a nonconstant calculation.
A few questions, answered
Is this the inviscid equation?
No. This interface requires strictly positive physical viscosity.
What boundary model is used?
The unit interval is periodic,so both ends join.
Is mass preserved?
The conservative periodic update preserves the discrete mean up to roundoff and reports its residual.
Why refine the grid?
Numerical diffusion and spatial error can remain even when each time step is stable.