2
$\begingroup$

I'm solving a PDE in matlab using ode15s, and since the spatial dimension is 2, and number of variables grow large very quickly, I need to supply the structure of the jacobian (called JPattern in Matlab) by indicating the position of nonzero elements of the jacobian. The jacobian 'pattern' for each point in 2D (indicated as c) is as follow:

0 0 0 1 0 0 0
0 0 1 1 1 0 0
0 1 0 1 0 1 0
1 1 1 c 1 1 1
0 1 0 1 0 1 0
0 0 1 0 1 0 0
0 0 0 1 0 0 0

To make myself more clear, if it is just the laplacian, then the pattern is

0 0 1 0 0
0 0 1 0 0
1 1 c 1 1
0 0 1 0 0
0 0 1 0 0

It is easy to turn the laplacian to the finite difference matrix, which is just a banded matrix with five diagonals grouped together, with another five diagonals separated by the number of rows (or columns depending on how the points are ordered). With periodic B.C., there are extra points in the 'corners' of each sub matrix inside. What about the one for my problem? Are there ways to figure out the finite difference matrix given a pattern like the above?

$\endgroup$
  • $\begingroup$ Instead of supplying a JPattern which is used to more efficiently compute a finite difference Jacobian could you just compute the Jacobian? Depending on the complexity of the problem, they may be about the same difficulty to compute. $\endgroup$ – Steven Roberts Apr 9 at 16:28
  • $\begingroup$ @StevenRoberts I can. In fact I compute it numerically to verify the above is correct. The biggest problem (and motivation for supplying JPattern) is memory problem. When I compute the Jacobian column by column (each time perturbing one variable at a time), I will need to start with a sparse matrix when the problem size is not too small. But then I'm not too sure how to successively change the column of a sparse matrix from all zeros to having a few non-zeros elements without breaking the sparse structure and doing it reasonably efficiently. $\endgroup$ – Physicist Apr 9 at 16:57
  • $\begingroup$ So at best you can get a finite difference approximation of the Jacobian but cannot compute it analytically? $\endgroup$ – Steven Roberts Apr 9 at 17:00
  • $\begingroup$ No idea how to compute it analytically. And whatever method I use to compute the jacobian (analytically, numerically, or just give the JPattern and let Matlab do it) it has to be a sparse matrix or else I'm forever stuck with a problem size of 128x128 on my computer which is insufficient for my purpose. $\endgroup$ – Physicist Apr 9 at 17:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.