Package dev.nm.analysis.differentialequation.pde.finitedifference.parabolic.dim1.convectiondiffusionequation
Class CrankNicolsonConvectionDiffusionEquation1D
- java.lang.Object
-
- dev.nm.analysis.differentialequation.pde.finitedifference.parabolic.dim1.convectiondiffusionequation.CrankNicolsonConvectionDiffusionEquation1D
-
- All Implemented Interfaces:
PDESolver
public class CrankNicolsonConvectionDiffusionEquation1D extends Object implements PDESolver
This class uses the Crank-Nicolson scheme to obtain a numerical solution of a one-dimensional convection-diffusion PDE. The complexity of this algorithm is \(O(mn^3)\), where m is the number of grid points in the time-axis, n is the number of grid points in the space-axis. The truncation error is of order \(O(\Delta t^2 + \Delta x^2)\). The advantage of the Crank-Nicolson scheme is that it guarantees unconditional stability, but only under the situation that the coefficients of the PDE (such as \sigma and \mu) are fixed (may be relaxed to be linear in state variable). Unconditional stability means that the solution will not be oscillating no matter what you choose for the step size (but doesn't mean that the solution is close to the true result). In general for non-linear \sigma and \mu, the stability cannot be guaranteed. It is very possible to get an oscillating result especially near the boundary grids, but currently our solver can do nothing about this. Even if we find a possible scheme to deal with the boundary points with second-order accuracy, we do not always get stable solutions under non-linear coefficients. Hence, our solver works well only under some conditions (e.g., fixed constants, domain not too big) but not for a general case.- See Also:
- "ref/convection-diffusion-pde/CrankNicolsonForConvectionDiffusionEquation.pdf"
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
CrankNicolsonConvectionDiffusionEquation1D.Coefficients
Gets the coefficients of a discretized 1D convection-diffusion equation for each time step.
-
Constructor Summary
Constructors Constructor Description CrankNicolsonConvectionDiffusionEquation1D()
Constructs a Crank-Nicolson solver for a 1 dimensional convection-diffusion PDE.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description PDESolutionTimeSpaceGrid1D
solve(ConvectionDiffusionEquation1D pde, int M, int N)
Solves a 1 dimensional convection-diffusion equation.
-
-
-
Method Detail
-
solve
public PDESolutionTimeSpaceGrid1D solve(ConvectionDiffusionEquation1D pde, int M, int N)
Solves a 1 dimensional convection-diffusion equation.- Parameters:
pde
- a 1 dimensional convection-diffusion equationM
- the number of grid points along the time-axis (excluding the initial condition)N
- the number of grid points along the space-axis (excluding the two boundaries)- Returns:
- the solution \(u(t,x)\) at the grid points
-
-