0
我试图用pcolormesh绘制二维数组。这是一个黑洞磁层的二维径向球面图。问题是θ在θ上有偏移的原因是什么?通常情况下,磁场线必须是垂直的,并且在赤道处由黑洞稍微弯曲。地图也似乎被抵消了。 Black hole magnetosphere (64 points)这部分我的代码可能是有趣:与pcolormesh,等高线(Python matplotlib)偏移
import numpy as np, matplotlib.pyplot as plt
import matplotlib.animation as animation
import scipy.integrate as integrate
##### Natural unities
M = 1.0
G = 1.0
c = 1.0
##### Gravitational radius
rg = (G * M)/(c*c)
##### spin
a = 0.0
##### Horizon radius
rh = rg + np.sqrt(rg*rg - a*a)
##### r, theta parameters
rmin = 0.9*rh
rmax = 5.0
thmin = 0.001*np.pi
thmax = 0.999*np.pi
Nr = 64
Nth = 64
r = np.logspace(np.log10(rmin),np.log10(rmax),Nr)
th = np.linspace(thmin,thmax,Nth)
r_grid, th_grid = np.meshgrid(r,th)
x = r_grid*np.cos(th_grid)
y = r_grid*np.sin(th_grid)
##### ergosphere
rerg = 1.0 + np.sqrt(1.0-a*a*np.cos(th)*np.cos(th))
xerg = rerg*np.cos(th)
yerg = rerg*np.sin(th)
##### Horizon
xrh = rh*np.cos(th)
yrh = rh*np.sin(th)
############################# schwarzschild's metric
Alpha_sch = 1.0/np.sqrt(1.0+(2.0/r_grid))
sqr_det_gamma_sch = np.sqrt((1.0+2.0/r_grid)*r_grid*r_grid*r_grid*r_grid*np.sin(th_grid)*np.sin(th_grid))
Brg = np.zeros((Nth,Nr))
############################# Flux function
Psy = np.zeros((Nth,Nr))
V = [2,4,6,8,10,12]
##### Wald's solution
Brg = Alpha_sch*np.cos(th_grid)
for i in range (0,Nr):
for j in range(1,Nth):
th3 = th[0:j]
Psy[j,i]=integrate.simps(sqr_det_gamma_sch[0:j,i]*Brg[0:j,i],th3)
plt.figure(figsize=(8,8))
ax = plt.subplot(111)
plt.title('$B^r$')
circle1 = plt.Circle((0,0),rh,color = 'k')
ax.add_artist(circle1)
plt.contour(y,x,Psy,V,colors = 'k')
plt.pcolormesh(y,x,Brg,cmap='bwr',vmin=-1,vmax=1)
cbar = plt.colorbar()
cbar.set_label('Intensité', rotation=270)
plt.xlim(0,rmax)
plt.xlabel('$r_g$')
plt.ylabel('$r_g$')
plt.legend()
plt.show()
当然,如果我在R和THETA偏移减少花费更多点,但还是在这里Black hole magnetosphere (256 points)。如果你们中的一些人能解释我为什么,这将是非常有益的。先谢谢你。
杰里米