While studying at Masaryk University in Brno, I wrote my bachelor thesis - Electrostatics and magnetostatics on the hypersphere. The title says it all. My task was to solve scalar and vector Poisson equations for electrostatic and magnetostatic potentials. I managed to find a solution for the electrostatic potential. Still, unfortunately, the magnetostatic (vector) potential was too much of a task and would require extra time, which I did not have at the time. I managed to defend my thesis with the grade A in June of 2024. If you are interested in the Thesis, you can download it here or here.
I wrote some code for my bachelor thesis which I share here for anyone interested.
What do I mean by hypersphere? In my thesis by hypersphere I mean 3-sphere
where
Cartesian coordinates are not the best coordinates for describing the hypersphere (trust me...) and more "natrual" choice of coordinates can make the work with the hypersphere a lot easier. One of the more "natural" coordinate system that I used in my thesis is hyperspherical coordinate system represented by the map
where
which will be useful later :).
For the human mind, the hypersphere
where
Now we can visualize the functions on the hypersphere
N_fig = 120 # Grid number defines the "resolution" of the Figures
x_values = np.linspace(-2,2,N_fig) # Defiing the grid for the plotting
y_values = np.linspace(-2,2,N_fig)
z_values = np.linspace(-2,2,N_fig)
x,y,z = np.meshgrid(x_values, y_values, z_values)
Then, using the inverse map R3_R4
and R4_S3
like this
def R3_R4(x_values, y_values, z_values): # Inverse stereographic projection
X = (2*x_values)/(x_values**2+y_values**2+z_values**2+1)
Y = (2*y_values)/(x_values**2+y_values**2+z_values**2+1)
Z = (2*z_values)/(x_values**2+y_values**2+z_values**2+1)
W = (x_values**2+y_values**2+z_values**2-1)/(x_values**2+y_values**2+z_values**2+1)
return(X,Y,Z,W)
def R4_S3(X,Y,Z,W): # Inverse hyperspherical map
zeta = np.arctan2(W,Z)
theta = np.arctan2(np.sqrt(Z**2+W**2),Y)
phi = np.arctan2(np.sqrt(W**2+Z**2+Y**2),X)
return(phi, theta, zeta)
To confuse the reader - the code denotes the coordinates in X
, Y
, Z
, W
and in x_values
, y_values
, z_values
instead of
Now, we can assign the hyperspherical coordinate to each point of the grid in the subspace
Now the only thing that remains to do is to plot the function. I decided to use the isosurfaces (surfaces with constant function value) to be plotted and used Plotly graphing library to plot the figure of the isosurfaces of the function.
func_values_g = np.real(func_g(zeta_g,theta_g,phi_g)) # Evaluation of the func_g for each point of the plot grid
fig = go.Figure(layout=layout, data = go.Volume( # Making the plot
x=x.flatten(),
y=y.flatten(),
z=z.flatten(),
value = func_values_g.flatten(),
isomin = np.min(func_values_g),
isomax = np.max(func_values_g),
# isomin = -1,
# isomax = 1,
surface_count = 10,
opacity = 0.5,
#surface_fill = 0.9,
colorscale = "plasma",
caps = dict(x_show = False, y_show = False, z_show = False)
))
fig.update_layout(scene_camera=camera)
fig.show()
In my thesis I chose the function
Materials and code that I use for my bachelor thesis - electrostatics and magnetostatics on a hypersphere
Scripts that are in a folder called "scripts" ( :) ) are unfortunately not well documented (sometimes not at all).
Most of my scripts are used to decompose functions on the hypersphere (sphere in four dimensions) into eigenfunctions of the Laplace operator. In other words hyperspherical harmonics (the most interesting are the Gegenbauer polynomials that are used).
I also have scripts that allow me to visualize the functions on the hypersphere. My script allows me to plot any hyperspherical function to 3d space using hyperstereographic projection. The resulting image can look something like this:
The function shown is the function of
The plot in the picture carries some kind of visible numerical artifacts, especially in the yellow parts of the plot. If I have enough time for my thesis I will try to get rid of them.