All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class jDisco.PDEVariable

java.lang.Object
   |
   +----jDisco.Linkage
           |
           +----jDisco.Link
                   |
                   +----jDisco.Continuous
                           |
                           +----jDisco.PDEVariable

public abstract class PDEVariable
extends jDisco.Continuous
This class may used for the description of state-variables that vary according to partial differential equations.

The class is designed mainly for the solution of nonlinear parabolic initial value problems in one space dimension within a limited interval, xLeft <= x <= xRight. Solution of hyperbolic and elliptic problems may also be attempted.

A PDEVariable-object represents a variable, u(t,x), that varies according to a partial differential equation of the following form:

       du/dt = f(t, x,u, du/dx, 1/xc * d/dx(xc * D * du/dx))
This equation represents the coupled system of partial differential equations, where u is a vector and xLeft < x < xRight.

At the left boundary, x = xLeft, the boundary condition is characterised as follows:

     b1Left * u(t,x) + b2Left * du/dx = b3Left
At the right boundary, x = xRight, the boundary condition is characterised as follows:
     b1Right * u(t,x) + b2Right * du/dx = b3Right
The initial condition (at t = t0) is characterised as follows:
     u(t0,x) = g(x)
The 'diffusion coefficient', D, in the equation above is a function of t, x, and u. c is 0, 1, or 2, depending on whether the problem is Cartesian, cylindrical, or spherical, respectively. The 'left boundary coefficients', b1Left, beLeft, and b3Left, may be functions of t, x, and u. If b1Left and b2Left are both zero, the following condition is used at the left boundary:
     du(t,xLeft)/dt = b3Left
The same is true for the 'right boundary coefficients', b1Right, beRight, and b3Right.

The partial diffeerntial equations are expressed by the user in subclasses of class PDEVariable by overriding the method rate. The two independent variables are denoted by t() and x(). The initial and boundary conditions are specified by overriding the methods initialState, b1Left, b2Left, b3Left, b1Right,b2Right, and b3Right. The diffusion coefficient is specified by overriding the method D.

The equations are solved using the so-called 'method of lines' in which the spatial variable, x, is "discretized", while the time variable, t = time, remains "continuous". Roughly speaking, the method can be described as follows. If one has a time dependent partial differential equation and discretizes the spatial variable, a semi-discrete approximating system of 'ordinary' differential equations results. One then uses an ordinary differential equation integration method, for example the Runge-Kutta-Fehlberg method, for solving the resulting equations to obtain numerical approximations to the original partial differential equation.

The user specifies a spatial mesh consisting of a given number equidistant points between xLeft and xRight. This information is passed to the constructor of PDEVariable, which splits the partial differential equations into a system of approximating ordinary differential.

An example:

Consider the following partial differential equation:

     du/dt = -u * du/dx + x * d/dx(u * du/dx) + t
for x between xLeft = 0 and xRight = 1, and for t beween 0 and 1.2. Further, assume the initial condition
     u(0,x) = x
and the non-linear boundary conditions
     u(t,xLeft) = = 50
     du(t,xRight)/dt = du(t,1)/dt = 1 - sin(u(t,1))
A complete jDisco-program for solving this problem is given below.

 import jDisco.*;
 import jDisco.Process;
 public class PDEExample extends Process {
     PDEVariable u;
class U extends PDEVariable { U(double xLeft, double xRight, int nPoints) { super(xLeft, xRight, nPoints); } public double rate() { return -state() * dx() + x() * ddx() + t(); } public double D() { return state(); } public double initialState() { return x(); } public double b1Left() { return 1; } public double b3Left() { return 50; } public double b1Right() { return 1; } public double b3Right() { return 1 - Math.sin(state()); } }
public void actions() { dtMin = 1.0e-5; dtMax = 1.0; maxAbsError = maxRelError = 1.0e-4; u = new U(0, 1, 21); u.start(); hold(1.2); u.show(); }
public static void main(String[] args) { activate(new PDEExample()); } }
The design and implementation of class PDEVariable has been inspired by the Fortran subroutine PDEONE.

Reference:
Sincovec, R.F and Madsen, N.K.:
"Software for Nonlinear Partial Differential Equations".
ACM Transactions on Mathematical Software,
Vol. 1, No. 3, September 1975, pp. 232-260 and 261-263.


Class Index

 o PDEVariable.Point
Each Point-object represents one of the points of a PDEVariable, (x, state()).

Variable Index

 o c
This integer may be set to 0, 1, or 2, depending on whether the problem is Cartesian, cylindrical, or spherical, respectively.

Constructor Index

 o PDEVariable(double, double, int)
Constructs a PDEVariable-object with nPoints equidistant points.

Method Index

 o b1Left()
Returns 0, but may be overridden.
 o b1Right()
Returns 0, but may be overridden.
 o b2Left()
Returns 0, but may be overridden.
 o b2Right()
Returns 0, but may be overridden.
 o b3Left()
Returns 0, but may be overridden.
 o b3Right()
Returns 0, but may be overridden.
 o D()
The diffusion coefficient.
 o d2x()
Returns an approximation to the second derivative with respect to x, d2/dx2.
 o ddx()
Returns 1/xc * d/dx(xc * D() * du/dx).
 o derivatives()
Computes derivatives for all points.
 o dx()
Returns an approximation to the derivative with respect to x, du/dx.
 o initialState()
The initial state, u(t0, x).
 o leftState()
Returns the state at the left bondary, u(t, xLeft).
 o points()
Returns the two-way list of points.
 o print()
Prints the points of this PDEVariable as a table without heading.
 o print(String)
Prints the points of this PDEVariable as a table.
 o rate()
The rate, du/dt.
 o rightState()
Returns the state at the right bondary, u(t, xRight).
 o show()
Shows the points of this PDEVariable as an untitled graph.
 o show(String)
Shows the points of this PDEVariable as a graph.
 o start()
Starts the continuous variation of this PDEVariable.
 o state()
Returns the state, u(t, x).
 o stop()
Stops the continuous variation of this PDEVariable.
 o t()
Return the current value of t (= time()).
 o x()
Return the current value of x.

Variables

 o c
 public int c
This integer may be set to 0, 1, or 2, depending on whether the problem is Cartesian, cylindrical, or spherical, respectively.

Constructors

 o PDEVariable
 public PDEVariable(double xLeft,
                    double xRight,
                    int nPoints)
Constructs a PDEVariable-object with nPoints equidistant points. between sLeft and xMax.

Methods

 o rate
 public abstract double rate()
The rate, du/dt. Must be supplied in a subclass of PDEVariable.

 o initialState
 public double initialState()
The initial state, u(t0, x). Returns 0, but may be overridden.

 o D
 public double D()
The diffusion coefficient. Returns 1, bu may be overridden.

 o b1Left
 public double b1Left()
Returns 0, but may be overridden.

 o b1Right
 public double b1Right()
Returns 0, but may be overridden.

 o b2Left
 public double b2Left()
Returns 0, but may be overridden.

 o b2Right
 public double b2Right()
Returns 0, but may be overridden.

 o b3Left
 public double b3Left()
Returns 0, but may be overridden.

 o b3Right
 public double b3Right()
Returns 0, but may be overridden.

 o state
 public final double state()
Returns the state, u(t, x).

 o leftState
 public final double leftState()
Returns the state at the left bondary, u(t, xLeft).

 o rightState
 public final double rightState()
Returns the state at the right bondary, u(t, xRight).

 o dx
 public final double dx()
Returns an approximation to the derivative with respect to x, du/dx.

 o ddx
 public final double ddx()
Returns 1/xc * d/dx(xc * D() * du/dx).

 o d2x
 public final double d2x()
Returns an approximation to the second derivative with respect to x, d2/dx2.

 o x
 public final double x()
Return the current value of x.

 o t
 public final double t()
Return the current value of t (= time()).

 o start
 public jDisco.Continuous start()
Starts the continuous variation of this PDEVariable.

Returns:
this.
Overrides:
start in class jDisco.Continuous
 o stop
 public void stop()
Stops the continuous variation of this PDEVariable.

Overrides:
stop in class jDisco.Continuous
 o points
 public jDisco.Head points()
Returns the two-way list of points.

 o print
 public void print(java.lang.String heading)
Prints the points of this PDEVariable as a table.

Parameters:
heading - the heading to be printed above the table.
See Also:
jDisco.Table
 o print
 public void print()
Prints the points of this PDEVariable as a table without heading.

See Also:
jDisco.Table
 o show
 public void show(java.lang.String title)
Shows the points of this PDEVariable as a graph.

Parameters:
title - the title of the graph.
See Also:
jDisco.Graph
 o show
 public void show()
Shows the points of this PDEVariable as an untitled graph.

See Also:
jDisco.Graph
 o derivatives
 protected final void derivatives()
Computes derivatives for all points.

Overrides:
derivatives in class jDisco.Continuous

All Packages  Class Hierarchy  This Package  Previous  Next  Index