-1

I'm trying to calculate the blackbody spectral radiance using planck function:

import numpy as np
import matplotlib.pyplot as plt
from scipy import interpolate, integrate


# Physical constants:
h = 6.6260693e-34                
c = 299792485.0                
k = 1.380658e-23               
T = 6500

wl_min = 0.1
wl_max = 8.0
wl = np.linspace(wl_min, wl_max, 1000)

f = ((((2.0*h*c**2)/(wl*1e-6)**5)*(1.0/(np.exp(((h*c)/(k*T*wl*1e-6)))-1)))*1e-6)

plt.figure()
plt.plot(wl, f)
plt.show()

plot

Then I integrated the wavelength range (from 0.1 to 8.0) and I got a power of 3.22e7 [W]

Power = integrate.trapz(f,wl)

Now, my problem!

I would like to do the opposite: knowing the power value, find the temperature value. I can do it in Matlab but I don't know how to do it in python:

matlab code

Could you help me?

talonmies
  • 70,661
  • 34
  • 192
  • 269
c3dr1c
  • 1

1 Answers1

0

Here is an solution, if it is useful to someone else:

from scipy.optimize import newton_krylov

fun = lambda T2: - Power + integrate.trapz(((((2.0*h*c**2)/(wl*1e-6)**5)*(1.0/(np.exp(((h*c)/(k*T2*wl*1e-6)))-1)))*1e-6),wl)

res = scipy.optimize.newton_krylov(fun, 6000)
c3dr1c
  • 1