1
$\begingroup$

My question is related to my issue from yesterday (Initializing very large matrices). It was recommended to use SparseArray to initialize large matrices efficiently. However, I struggle to do so with my current issue. I want to initialize a matrix that approximates the Laplace operator in 3D with periodic boundary conditions. My ansatz for this is to calculate Kronecker products from the identity matrix $I$ and the matrix $A$, $$\Delta_{3D}=I\otimes I \otimes A+I\otimes A\otimes I+A\otimes I \otimes I\,\, ,$$ where the matrix $A$ is the 1D-Laplace operator with periodic boundary conditions defined through:

A = SparseArray[{Band[{1, 1}] -> -2, Band[{2, 1}] -> 1, Band[{1, 2}] -> 1, 
      {M, 1} -> 1, {1, M} -> 1}, {M, M}];

My general goal is to calculate the smallest eigenvalues of such a big matrix. I am using the following code, but when I run it on my (maybe too old) laptop, Mathematica crashes.

M = 128;

A = SparseArray[{Band[{1, 1}] -> -2, Band[{2, 1}] -> 1, 
    Band[{1, 2}] -> 1, {M, 1} -> 1, {1, M} -> 1}, {M, M}];
Ident = IdentityMatrix[M];
Laplace = KroneckerProduct[Ident, Ident, A] + 
   KroneckerProduct[Ident, A, Ident] + 
   KroneckerProduct[A, Ident, Ident];

AbsoluteTiming[Eigenvalues[1.0*Laplace, -2, 
   Method -> {"Arnoldi", "Criteria" -> "Magnitude", 
     "MaxIterations" -> 10000}] // Chop]

I would be glad for any suggestions that make my code working (or even working faster and more efficiently).

$\endgroup$
6
  • $\begingroup$ If you only want the smallest eigenvalue of a large matrix, iterative methods that only calculate a few eigenvalues are better than calculate all eigenvalues. See e.g: [link] (en.wikipedia.org/wiki/…) $\endgroup$ Commented Oct 8, 2024 at 11:11
  • 1
    $\begingroup$ This is actually my plan. Thats why i use the Arnoldi method for the eigenvalues. By putting the -2 in the eigenvalue command i tell mathematica to only calculate the smallest 2 eigenvalues $\endgroup$ Commented Oct 8, 2024 at 11:20
  • 1
    $\begingroup$ I can confirm that. I ran this on my M1 Max and after quite some time the kernel crashed. I don't think your hardware is the problem. My machine has 64GB of RAM and it was not even half full. I think you should file a bug report with the Wolfram User Support. Make sure to include the code. You can also send them a link to this post instead. $\endgroup$ Commented Oct 8, 2024 at 12:00
  • 2
    $\begingroup$ To solve your problem I wonder whether you really have to/want to solve this numerically. The eigenfunctions of the Laplacian on the 3D torus $\mathbb{R}^3 / \mathbb{Z}^3$ are well-known. They are of the form $\mathrm{e}^{\mathrm{i} \pi (n_1 x_1 + n_2 x_2 + n_3 x_3)}$, where $n_1$, $n_2$, $n_3$ are natural numbers (or zero). $\endgroup$ Commented Oct 8, 2024 at 12:03
  • 1
    $\begingroup$ Yes, thats true. My real task looks a little bit different, but i comprehensed my issue. If you care: It is about the BdG- formalism in quantum mechanics. But thanks for help. I will send to the Wolfram user support. $\endgroup$ Commented Oct 8, 2024 at 13:01

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.