3D情节给出了空盒子,

时间:2017-09-11 13:23:19

标签: python-2.7 numpy matplotlib



from __future__ import division
import numpy as np
import math
from scipy.special import kv #calling bassel func
from scipy.special import iv #calling bassel func
from scipy.integrate import quad
from scipy.misc import derivative
import matplotlib.pylab as plt
from mpl_toolkits.mplot3d import Axes3D
from matplotlib import cm

#######################################################
def B(x):
	#bassel func~~~~~
	#first 
	v0 = 0  #order of bessel func
	K0 = kv(v0, r/x) #BESSEL Function
	I0 = iv(v0, r/x) #BESSEL Function
	#~~~second 
	v1 = 1  #order of bessel func
	K1 = kv(v1, r/x) #BESSEL Function
	I1 = iv(v1, r/x) #BESSEL Function
	c = (I0*K0)-(I1*K1)
	return c
#######################################################

Ms = 3e+11
ms1 = 1e11
#~~~~~~~~~~~~~~~~~~
mh = np.linspace(9.5,11.5,20)
mhalo = 10**((-0.0210331*mh**5) + (1.042316*mh**4) - (20.553*mh**3) + (201.74*mh**2) - (985.821*mh) + (1929.48))
Mh = mhalo
#~ r = 6 #in Kpc
r = np.linspace(0.01,6,20) #in Kpc

#~~~~~~~~~~~~~~~~~~
#virial radius:
Rv = 259.3*(Mh/1e12)**(1/3)
#Disk mass halo mass relation:
Md = 2.3e10*(Mh/Ms)**(3.1)/(1+(Mh/Ms)**(2.2))
#disk length to halo mass relation:
Rd = 10**(0.633+(0.379*np.log10(Md/ms1)) + (0.069*(np.log10(Md/ms1))**2))
#optical radius:
Ropt = 3.2*Rd
#Burkert-halo central density:
rho0 = 10**(-23.5153 - 0.918*(Md/ms1)**(0.308))
#burket core radius:
r0 = 10**(0.66+0.58*(np.log10(Mh/ms1)))
#burket halo density:
rho = rho0*r0**3/((r+r0)*((r**2)+(r0**2)))
#burket Halo mass:
Mhr = (1.48e31*1.6*4*rho0*r0**3)*(np.log(1+(r/r0))- np.arctan(r/r0) + 0.5*(np.log(1+(r/r0)**2)))
#Halo velocity:
Vh = 658.1*(Mhr/(ms1*r))**0.5
#disk velocity:
x = 2*Rd
Vd = 658.1*((0.5*Md/(ms1*Rd))**0.5)*(r/Rd)*B(x)**0.5

#total velocity:
vurc = ((Vd**2) + (Vh**2))**0.5

XX = r
YY = vurc
ZZ = mh

fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
img = ax.plot_surface(XX, YY, ZZ)
plt.tick_params(axis='x', which='major', labelsize=15)
plt.tick_params(axis='y', which='major', labelsize=15)
plt.tick_params(axis='z', which='major', labelsize=15)
ax.set_xlabel('R/Ropt', fontsize = 15)
ax.set_ylabel('V/Vopt', fontsize = 15)
ax.set_zlabel('log(M_vir)', fontsize = 15)
plt.show()




在下面的代码中,3D绘图命令无法正常工作,只会绘制空框。虽然,我的所有阵列大小相同。任何人都可以把我赶出去。

0 个答案:

没有答案