Jump to content
# -*- coding: utf-8 -*-
"""
Created on Wed Feb 21 17:35:49 2018

@author: Abhishek Sharma
"""

import array as ar
import math
import pylab as plt
p=ar.array('f',[])
q=ar.array('f',[])
r=ar.array('f',[])
s=ar.array('f',[])
t=ar.array('f',[])
u=ar.array('f',[])
k=8.62*(math.pow(10,-5))
x=ar.array('f',[(-0.2),(-0.18),(-0.16),(-0.14),(-0.12),(-0.1),(-0.08),(-0.06),(-0.04),(-0.02),(0.0),(0.02),(0.04),(0.06),(0.08),(0.1),(0.12),(0.14),(0.16),(0.18),(0.2)])
print (x)
for i in range (0,21):
    p.append(1/(1+(math.exp(x[i]))))
    q.append(1/(1+(math.exp(x[i]/(k*100)))))
    r.append(1/(1+(math.exp(x[i]/(k*200)))))
    s.append(1/(1+(math.exp(x[i]/(k*300)))))
    t.append(1/(1+(math.exp(x[i]/(k*400)))))
    u.append(1/(1+(math.exp(x[i]/(k*500)))))
    


print (q)

p1=plt.plot(p,x)
p2=plt.plot(q,x)
p3=plt.plot(r,x)
p4=plt.plot(s,x)
p5=plt.plot(t,x)
p6=plt.plot(u,x)
plt.legend((p1,p2,p3,p4,p5,p6),('0k','100k','200k','300k','400k','500k')
plt.xlabel('F(E)')
plt.ylabel('ENERGY')
plt.title('fermi-dirac distribution   F(E) Vs  Energy')
plt.show()

This is my code. I cant get the plot. Please help me.

Link to post
Share on other sites

Found the issue, you have to close the bracket for the line shown. If you don't close it then that'll interfere with the lines below it.

plt.legend((p1,p2,p3,p4,p5,p6),('0k','100k','200k','300k','400k','500k'))

Always remember this rule: you must have the same number of open brackets as you have close brackets.. if that made any sense.

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×