- The following is a much more productive SageMath/Python code due to Gerry Myerson's idea to convert to a hyperbola (when $r > 0$) or an ellipse (when $r < 0$).
from time import time
t0 = time()
r = 2
listA = []
top = 100
for n in range(1, top + 1):
for d in range(1, top + 1):
if gcd(n,d) == 1:
t = QQ(n) / QQ(d)
a = t^2 / (r - t^2)
e = sqrt(a * (a + 1) / r)
if (e in QQ) and a != -1 and a != 0:
listA.append(a)
print(listA)
print(len(listA))
print(time() - t0)
[<6087 values of a, instead of original 66>]
6087
0.41802382469177246