X = [0.1*i for i in xrange(40)]
Y = [TotalEnergy_GW_onelevel(x) for x in X]
plot(X,Y)
define an integration function in python
-
02-09-2022 - |
Question
My code is:
def A_GW_onelevel(nw):
G4=1.0/(nw-0.001j-(x**2/(nw-x**2/w_b+w_b-0.001j)))
return nw*(1.0/(math.pi))*abs(G4.imag)
def TotalEnergy_GW_onelevel(x):
GW,err=quad(A_GW_onelevel,-4.0,0.0)
return GW
for x in (0.1*i for i in xrange(40)):
print TotalEnergy_GW_onelevel(x)
plot(x, TotalEnergy_GW_onelevel(x))
show()
What I want to do is plot the function TotalEnergy_GW_onelevle(x)=\int d(nw) A_GW_onelevel(nw)
but this code does work. I tried other methods but still cannot find the correct way. I just started doing programming work.
It gives the correct TotalEnergy_GW_onelevel(x) value. But it does not plot anything. In the plotting, there is nothing except the two axis.
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow