PDE
A page describing the methods provided by the Pde class; they are extremely useful for implementing PDEs in SincLib.
Overview
The Pde class in the sinc.pde.PdeLib provides many helpful methods for implementing PDEs in SincLib. They include:
- Some sane defaults.
- Pre-computation of various constants.
- Mesh-node computation.
- Solution function creation from a basis vector.
- Certain Kronecker-product computation.
Defaults
Problem defaults:
Many of the problem defaults for the PDE class act similarly to the standard ones from the defaults system. See this page for more information about the defaults system, or this one for more information about the SincBase class, which explains some of the basic defaults.- transform: The conformal map to use.
- f: The inhomogeneous part of the equation. That is, if L is the partial differential operator, then the system should be of the form L[u] = f.
- g: The initial condition or boundary condition, depending on the problem.
- dimensions: The number of dimensions (in space and time, if applicable) for this problem.
- problem_file: The problem file to use.
Constants:
The defaults constants you may specify are as follows. Each of these can be specified as a single value, or as a tuple where the length of the tuple is the number of dimensions. So, if dimensions=2, M=(32,16) means that M for the x dimension is 32 and 16 for the y dimension.- M: Number of nodes to use for the approximation; given as a tuple of length dimensions.
- beta: The sinc constant beta.
- alpha: The sinc constant alpha.
- transform: The transform to use. Note that you often want to use the wedge / bullet transforms in the time dimension and the eyelet / none in the space dimension.
- d: The sinc constant d.
Update
The function update creates the correct tuples for the following constants:- N: The number of sinc nodes to use above zero for the dimension.
- h: The appropriate mesh size for the dimension.
It additionally computes tuples holding the following matrices:
- I0: The matrix I0 (the identity matrix).
- I1: The sinc matrix I1.
- I2: The sinc matrix I2.
Mesh Nodes
Let D represent the number of dimensions. We can easily compute the sinc nodes needed for dimension i; they are Bi = (phii(z-M), phii(z-M+1), ..., phii(zN-1), phii(zN)), where zk = kh is a sinc node. This results in D lists of coordinates, each Mi+Ni+1 long. However, we'd really like one array, A, of dimensions (M1+N1+1)x...x(MD+ND+1) whereA[i1, i2, ..., iD]= (B1[i1], B2[i2], ..., BD[iD])
The function makeNodes does precisely this. Given an array, nodes = [B1, B2, ..., BD],
and a tuple consisting of the dimensions of A, nodeShape = (M1+N1+1,...,MD+ND+1), makeNodes returns the array A as described above. Example usage:for i in range(self.dimensions):
self.nodes.append( cSincLib.genSincNodes( self.psi[i], self.M[i], self.N[i], self.h[i] ) )
self.nodeShape = self.nodeShape + (len(self.nodes[i]),)
self.nnodes = self.makeNodes( self.nodes, self.nodeShape )
Solution Function
Let u be the solution function. If you set the solution array to self.soln_vec, then the function solution provided by the Pde class, given a tuple x=(x1, x2, ..., xD), will return the value of u(x). The array soln_vec should have shape (M1+N1+1,...,MD+ND+1), and should have values:soln_vec[i1, i2, ..., iD] = u(B1[i1], B2[i2], ..., BD[iD])
Kronecker Product Computations
The following sum of Kronecker products is a common sight in sinc PDE calculations. For 2D:
For 3D:
The extension to N dimensions is straightforward. The makeProd function implements this calculation. It takes the position in the summation, and the N-length array (for 3D, A=[Ax, Ay, Az]). The calculation of the above equation would be implemented like this:
The extension to N dimensions is straightforward. The makeProd function implements this calculation. It takes the position in the summation, and the N-length array (for 3D, A=[Ax, Ay, Az]). The calculation of the above equation would be implemented like this:
result = makeProd(0, A[0])
for i in range(1,dimensions):
result += makeProd(i, A[i])