In [1]:
%matplotlib inline
In [2]:
import matplotlib.pyplot as plt
import numpy as np
In [3]:
a = 20.
b = 1.3*a
In [4]:
N = 1000
R = 1.1
theta, phi = np.meshgrid(np.linspace(0., np.pi, N), np.linspace(0., 2.*np.pi, N))
In [5]:
x = a*R*np.cos(theta)
y = b*R*np.sin(theta)*np.cos(phi)
z = b*R*np.sin(theta)*np.sin(phi)
In [6]:
p2 = 1.
p1 = a**2 + b**2 - (x**2) - (y**2) - (z**2)
p0 = (a*b)**2 - (b*x)**2 - (a*y)**2 - (a*z)**2
In [7]:
delta = p1**2 - 4.*p2*p0
In [8]:
lamb = (-p1 + np.sqrt(delta))/(2.*p2)
In [9]:
dlamb_dx = (2.*x/(a**2 + lamb))/((x/(a**2 + lamb))**2 + (y/(b**2 + lamb))**2 + (z/(b**2 + lamb))**2)
dlamb_dy = (2.*y/(b**2 + lamb))/((x/(a**2 + lamb))**2 + (y/(b**2 + lamb))**2 + (z/(b**2 + lamb))**2)
dlamb_dz = (2.*z/(b**2 + lamb))/((x/(a**2 + lamb))**2 + (y/(b**2 + lamb))**2 + (z/(b**2 + lamb))**2)
In [10]:
r2 = x**2 + y**2 + z**2
delta = np.sqrt(r2*r2 + (a**2 - b**2)**2 - 2.*(a**2 - b**2)*(x**2 - y**2 - z**2))
dlamb_dx_Emerson85 = x*(1. + (r2 - a**2 + b**2)/delta)
dlamb_dy_Emerson85 = y*(1. + (r2 + a**2 - b**2)/delta)
dlamb_dz_Emerson85 = z*(1. + (r2 + a**2 - b**2)/delta)
In [11]:
np.allclose(dlamb_dx, dlamb_dx_Emerson85)
Out[11]:
In [12]:
np.allclose(dlamb_dy, dlamb_dy_Emerson85)
Out[12]:
In [13]:
np.allclose(dlamb_dz, dlamb_dz_Emerson85)
Out[13]: