Code 02
MB, BE & FD StatisticsAnamitra
python
a month ago
1.5 kB
7
Indexable
Never
BSC 6th Sem Python LNB
import numpy as np import matplotlib.pyplot as plt plt.style.use('fivethirtyeight') plt.rcParams['figure.figsize'] = (18, 12) E = np.linspace(-0.5, 0.5, 1001) # Energy Range T = np.linspace(100, 1100, 6) # Temperature In Kelvin e = 1.6e-19 # Electronic Charge K = 1.38e-23 # Boltzmann Constant U = 0 # Chemical Potential a = -1 # Parameter for adjusting the distribution functions # Function to calculate the distribution function f(E) def f(T,a): return 1/((np.exp(((E-U)*e)/(K*T)))+a) # Loop to plot the Bose-Einstein, Maxwell-Boltzmann, and Fermi-Dirac distributions title = ['BE Distribution', 'MB Distribution', 'FD Distribution'] while a<=1: plt.subplot(2,2,a+2) for i in range(len(T)): plt.plot(E, f(T[i],a), label=f'T = {T[i]} K') plt.ylim(0,4) plt.legend(title='Temperature', fontsize=14) plt.xlabel('Energy(eV)', fontsize=14) plt.ylabel(' Value Of The Distribution Function [f(E)]', fontsize=14) plt.title(title[a+1]) a = a+1 # Subplot to compare all three distribution functions at 700 K label = ['BE Distribution', 'MB Distribution', 'FD Distribution'] plt.subplot(2,2,4) for i in [-1,0,1]: plt.plot(E,f(700,i), label=label[i+1]) plt.ylim(0,4) plt.legend(title='Distribution Laws', fontsize=14) plt.xlabel('Energy(eV)', fontsize=14) plt.ylabel(' Value Of The Distribution Function [f(E)]', fontsize=14) plt.title('Comparison Of These Three Distribution Functions At 700K', fontsize=16) plt.show()