I am a python newbie. I am trying to evaluate Planck equation using python. I have written a simple program. But when I give input to it is giving me an error. can anyone hep me where I am going wrong? Here is the program and the error:
Program:
from __future__ import division
from sympy.physics.units import *
from math import *
import numpy
from scipy.interpolate import interp1d
#Planck's Law evaluation at a single wavelength and temperature
def planck_law(wavelength,temperature):
T=temperature
f=c/wavelength
h=planck
k=boltzmann
U=2*h/(c**3)*(f**3)/(exp(h*f/(k*T))-1)
return U.evalf()
Input: I have imported the function as 'cp' and the input is as follows
value = (cp.planck_law(400,2000))
Error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>`enter code here`
File "Camera_performance.py", line 14, in planck_law
U=2*h/(c**3)*(f**3)/(exp(h*f/(k*T))-1)
File "/usr/lib/python2.7/dist-packages/sympy/core/expr.py", line 221, in __float__
raise TypeError("can't convert expression to float")
TypeError: can't convert expression to float