【发布时间】:2021-02-08 04:42:14
【问题描述】:
我正在尝试绘制黑体辐射的积分。但由于某种原因,图表上有一个小飞艇。我也收到了警告。
IntegrationWarning:算法不收敛。舍入误差 被检测到
我认为这可能高估了集成。但我不确定如何解决这个问题。
import scipy.integrate as integrate
import numpy as np #math module
import matplotlib #Plotting module
import matplotlib.pyplot as plt
#constants
h = 6.626e-34
c = 3.0e+8
k = 1.38e-23 # Boltzmann constant
T = range(1, 6000)
plot = []
for t in T:
integrand = lambda x : (((2*h*(c**2))/(x**5))*(1/(np.exp((h*c)/(x*k*t))-1)))
result,err = integrate.quad(integrand, 0, np.inf, epsabs=0, limit=50)
plot.append(result)
plt.figure(figsize=(10,10)) #Create a figure of a certain size
plt.plot(T,plot) #Make a plot in the figure.
plt.xlabel('Temperature K', fontsize=14) #X Label
plt.ylabel('Intensity (W/sr m^3)', fontsize=14) #Y label
plt.title("Plank's Formula over all spectra")
【问题讨论】: