Question: Why does this pattern of prime numbers appear in the magic sum of pseudo-magic squares of squares, and does this represent an infinite "family" of solutions?
Consider a magic square of square numbers: \begin{array}{ccc} a^2 & b^2 & c^2 \\ d^2 & e^2 & f^2 \\ g^2 & h^2 & i^2 \end{array}
Specifically, a pseudo-magic square (sometimes called semi-magic in the literature), of distinct, perfect square numbers.
All rows: $(a^2 + b^2 + c^2)$, $(d^2 + e^2 + f^2)$, $(g^2 + h^2 + i^2)$
All columns: $(a^2 + d^2 + g^2)$, $(b^2 + e^2 + h^2)$, $(c^2 + f^2 + i^2)$
Either diagonal, primary: $(a^2 + e^2 + i^2)$ or secondary: $(c^2 + e^2 + g^2)$ but not both, must sum to the constant S (the magic sum).
For example, consider this well-known solution found by Lee Swallows in the late 1990s and featured more recently by Matt Parker on the YouTube channel Numberphile:
\begin{array}{ccc} 127^2 & 46^2 & 58^2 \\ 2^2 & 113^2 & 94^2 \\ 74^2 & 82^2 & 97^2 \end{array} $$S = 21609$$
Pattern:
I coded a search program to computationally brute-force all valid solutions for magic sums $S$ up to $10^8$. I noticed a pattern emerging. Often, though not always, $S$ is also a perfect square number. There appears to be a main "family" of solutions where $S$ follows the pattern:
$\sqrt{S}= 3p^2$
$S = (3p^2)^2 = 9p^4$
Where $p$ is a prime number satisfying:
$p \equiv 1 \pmod{6}$
This condition selects primes such as 7, 13, 19, 31, 37, 43, and so on. For the example above: $$S = 21609 \quad 21609/9 = 2401 \quad \sqrt[4]{2401} = 7$$
Question:
Given there are infinitely many primes where $p \equiv 1 \pmod{6}$, does this represent an infinite family of pseudo-magic squares?
I was able to verify that these squares continue beyond $S = 10^8$ and I generated all of them up to prime 811, resulting in very large entries:
\begin{array}{ccc} 167^2 & 1266158^2 & 1513346^2 \\ 1698254^2 & 770617^2 & 644558^2 \\ 1004642^2 & 1302446^2 & 1089817^2 \\ \end{array} $$S = 1973163^2 \quad p = 811$$
If anyone is interested in the full list of squares that I found, please let me know, I was unable to find a full concise list anywhere on the internet.