solve_heat_1d_variable
Solve 1D heat diffusion with variable conductivity alpha(x) via an explicit conservative flux scheme and Dirichlet boundaries.
Instructions
Solve u_t = d/dx(alpha(x) * du/dx) with an explicit flux scheme.
``alpha_expr`` is an expression in x and must be strictly positive on the
spatial grid. Face conductivities ``alpha(x_{i+1/2})`` and
``alpha(x_{i-1/2})`` are evaluated on half nodes, giving the conservative
flux form
u_i^{n+1} = u_i^n + dt/dx^2 * (
alpha_{i+1/2} (u_{i+1}^n - u_i^n)
- alpha_{i-1/2} (u_i^n - u_{i-1}^n))
The explicit scheme is rejected when ``dt * max(alpha) / dx^2 > 0.5``.
``nx`` is the number of intervals (nx+1 nodes), ``nt`` the number of time
steps. The ends use constant Dirichlet values. The full (t, x) grid is
saved to .npz; returned arrays are downsampled to at most 100 space and
50 time points.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| nt | No | ||
| nx | No | ||
| left | No | ||
| right | No | ||
| t_end | No | ||
| length | No | ||
| initial | No | sin(pi*x) | |
| alpha_expr | Yes |