Message Boards Message Boards

Mathematica 10.4.0 kernel crashing when defining multiple lists together

Posted 9 years ago

Hi, I am using Mathematica 10.4.0 on ubuntu 16.04.

I am trying to solve a set of differential equations using finite difference method. I am getting a weird crash everytime I define lists of mixed finite difference derivatives together. My code is below. If I delete the last two lines of the code (MXwx011 and MXwx101), it works fine....but the kernel crashes everytime I run the last three lines together (MXwx110, MXwx011, and MXwx101). I do not understand what is wrong. This is really weird.The whole thing was running perfectly fine before I had inserted boundary conditions (BCwx1) in the definition of the grid (Wx1) to make the code faster. I would really appreciate any help to resolve this issue. Thank you.

NN = 20; RMax = 20.0; delta = 1.0/NN;
xgrid = RMax*N[delta* Range[0, NN]]; ygrid = RMax*N[delta* Range[0, NN]]; zgrid = RMax*N[delta* Range[0, NN]];

fdd[l_, m_, n_] := NDSolve`FiniteDifferenceDerivative[
   Derivative[l, m, n], {xgrid, ygrid, zgrid}, 
   "DifferenceOrder" -> {4, 4, 4}];

BCwx1 = Flatten[{Table[{Subscript[wx1, 0, j, k] -> 0.0}, {j, 0, NN}, {k, 0, NN}], 
    Table[{Subscript[wx1, i, 0, k] -> 0.0}, {i, 0, NN}, {k, 0, NN}], 
    Table[{Subscript[wx1, i, j, 0] -> 0.0}, {i, 0, NN}, {j, 0, NN}], 
    Table[{Subscript[wx1, NN, j, k] -> 0.0}, {j, 0, NN}, {k, 0, NN}], 
    Table[{Subscript[wx1, i, NN, k] -> 0.0}, {i, 0, NN}, {k, 0, NN}], 
    Table[{Subscript[wx1, i, j, NN] -> 0.0}, {i, 0, NN}, {j, 0, NN}]},
    3];

Wx1 = Table[Subscript[wx1, i, j, k] /. BCwx1, {i, 0, NN}, {j, 0, NN}, {k, 0, NN}];


MXwx110 = D[Subscript[A, 1, 1][x, y, z], {x, 1}, {y, 1}, {z, 0}] -> fdd[1, 1, 0][Wx1];
MXwx011 =  D[Subscript[A, 1, 1][x, y, z], {x, 0}, {y, 1}, {z, 1}] -> fdd[0, 1, 1][Wx1];
MXwx101 = D[Subscript[A, 1, 1][x, y, z], {x, 1}, {y, 0}, {z, 1}] ->  fdd[1, 0, 1][Wx1];
Attachments:
POSTED BY: A Saurab
3 Replies

Confirmed and reported the problem to developers who work on that code. Apologies for the misbehavior.

POSTED BY: Daniel Lichtblau
Posted 9 years ago

Thanks for the response. Earlier, I was using the same approach that you have mentioned but applying boundary conditions after calling fdd was extremely slow somehow. This is why I moved to the current algorithm. Also, I have narrowed down the bug to NDSolve`FiniteDifferenceDerivative not been able to calculate mixed derivatives with respect to y&z (MXwx011). Kernel is crashing every time. My code is perfectly fine for mixed derivatives with respect to x&y or x&x though, which is why this is so weird. For now, I have decided to define my own finite difference derivatives explicitly but still this bug is bizarre !

POSTED BY: A Saurab

The answer seems to be embedded in your question. Just apply the BC after calling add in the last three lines One programming wise comment - the replacement rules given in BCwx1 are long and not elegant. you can use Mathematica's pattern matching capabilities to make it one liner which says it all, just look at the code below that 1. Makes the replacement rules of the BCs much more elegant and efficient 2. Changes the order to first call fdd[..] and only then apply the BCs good luck yehuda

NN = 20; RMax = 20.0; delta = 1.0/NN;
xgrid = RMax*N[delta* Range[0, NN]];
ygrid = RMax*N[delta* Range[0, NN]];
zgrid = RMax*N[delta* Range[0, NN]];

fdd[l_, m_, n_] := 
  NDSolve`FiniteDifferenceDerivative[
   Derivative[l, m, n], {xgrid, ygrid, zgrid}, 
   "DifferenceOrder" -> {4, 4, 4}];
Wx1 = Table[Subscript[wx1, i, j, 
   k], {i, 0, NN}, {j, 0, NN}, {k, 0, NN}];
BCwx1 = (Subscript[wx1, 0 | NN, _, _] | Subscript[wx1, _, 0 | NN, _] |
      Subscript[wx1, _, _, 0 | NN]) -> 0.0;
MXwx110 = 
  D[Subscript[A, 1, 1][x, y, z], {x, 1}, {y, 1}, {z, 
     0}] -> (fdd[1, 1, 0][Wx1] /. BCwx1);
MXwx011 = 
  D[Subscript[A, 1, 1][x, y, z], {x, 0}, {y, 1}, {z, 
     1}] -> (fdd[0, 1, 1][Wx1] /. BCwx1);
MXwx101 = 
  D[Subscript[A, 1, 1][x, y, z], {x, 1}, {y, 0}, {z, 
     1}] -> (fdd[1, 0, 1][Wx1] /. BCwx1);
Attachments:
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract