You are on page 1of 7

PROGRAM -7

(a)To plot the variation of Z,U,Cv,S,F as the function temperatures by using Maxwell Boltzmann
Statistics

CODE:
clc
clf
clear
//Declaring Constant Values
k=1.38*10^(-23) // Boltzmann Constant
e=1.6e-19 // Charge on Electron
dT=100 // temperature range
N=3 // number of particles
E=0.5 //change in energy in eV
Ej=E*e //change of energy in joules
T=100:50:10000 // temperature range
T1=T;
T1(length(T))=[ ];
T2=T1;
T2(length(T1))=[ ];
for i=1:length(T)
b(i)=1/(T(i)*k) //beta
Z(i)=(1+exp(-b(i)*Ej)+exp(-b(i)*2*Ej))^N //partition function
end
U=N*k*(T1'^2).*diff(log(Z),1)./dT // internal energy
F=-N*k*T'.*log(Z) //Helmholtz free energy
S=-diff(F,1)./dT //entropy
Cv=diff(U,1)./dT //specific heat
// plotting of various functions
figure;
plot(T,Z,'g','linewidth',3)
xlabel("Temperature(K)------->",'fontsize',2)
ylabel("Partition Function(Z)------>",'fontsize',2)
title('Partition Function Vs Temperature','fontsize',3)
figure;
plot(T1,U,'r','linewidth',3)
xlabel("Temperature(K)-------->",'fontsize',2)
ylabel("Internal Energy(U)------->",'fontsize',2)
title('Internal Energy Vs Temperature','fontsize',3)
figure;
plot(T1,S,'m','linewidth',3)
xlabel("Temperature(K)------>",'fontsize',2)
ylabel("Entropy(S)------->",'fontsize',2)
title('Entropy Vs Temperature','fontsize',3)
figure;
plot(T,F,'c','linewidth',3)
xlabel("Temperature(K)-------->",'fontsize',2)
ylabel("Free Energy(F)------->",'fontsize',2)
title('Free Energy Vs Temperature','fontsize',3)
figure;
plot(T2,Cv,'b','linewidth',3)
xlabel("Temperature(K)------->",'fontsize',2)
ylabel("Specific Heat(Cv)----->",'fontsize',2)
title('Specific Heat Vs Temperature','fontsize',3)

OUTPUT
(b)To plot the variation of Z,U,Cv,S,F as the function temperatures by using Bose Einstein Statistics
clc
clf
clear
//Declaring Constant Values
k=1.38*10^(-23) // Boltzmann Constantly
e=1.6e-19 // Charge on Electron
dT=100 // temperature range
N=2 // number of particles
E=0.5 //change in enery in Joules
Ej=E*e
E1=0*e
E2=0.1*e
E3=0.2*e
T=100:50:10000 // temperature range
T1=T;
T1(length(T))=[ ];
T2=T1;
T2(length(T1))=[ ];
for i=1:length(T)
b(i)=1/(T(i)*k) //beta
Z(i)=(exp(-2*b(i)*E1)+exp(-2*b(i)*E2)+exp(-2*b(i)*E3)+exp(-b(i)*(E1+E2))+exp(-b(i)*(E2+E3))+exp(-b(i)*(E3+E1)))^N //partition
function
end
U=N*k*(T1'^2).*diff(log(Z),1)./dT // internal energy
F=-N*k*T'.*log(Z)
S=-diff(F,1)./dT
Cv=diff(U,1)./dT
// plotting of various functions
figure;
plot(T,Z,'g','linewidth',3)
xlabel("Temperature(K)------->",'fontsize',2)
ylabel("Partition Function(Z)------>",'fontsize',2)
title('Partition Function Vs Temperature','fontsize',3)
figure;
plot(T1,U,'r','linewidth',3)
xlabel("Temperature(K)-------->",'fontsize',2)
ylabel("Internal Energy(U)------->",'fontsize',2)
title('Internal Energy Vs Temperature','fontsize',3)
figure;
plot(T1,S,'m','linewidth',3)
xlabel("Temperature(K)------>",'fontsize',2)
ylabel("Entropy(S)------->",'fontsize',2)
title('Entropy Vs Temperature','fontsize',3)
figure;
plot(T,F,'c','linewidth',3)
xlabel("Temperature(K)-------->",'fontsize',2)
ylabel("Free Energy(F)------->",'fontsize',2)
title('Free Energy Vs Temperature','fontsize',3)
figure;
plot(T2,Cv,'b','linewidth',3)
xlabel("Temperature(K)------->",'fontsize',2)
ylabel("Specific Heat(Cv)----->",'fontsize',2)
title('Specific Heat Vs Temperature','fontsize',3)

OUTPUT
(c)To plot the variation of Z,U,Cv,S,F as the function temperatures by using Fermi Dirac Statistics

CODE
clc
clf
clear
//Declaring Constant Values
k=1.38*10^(-23) // Boltzmann Constant
e=1.6e-19 // Charge on Electron
dT=100 // temperature range
N=2 // number of particles
E=0.5 //change in enery in Joules
Ej=E*e
E1=0*e
E2=0.1*e
E3=0.2*e
T=100:50:10000 // temperature range
T1=T;
T1(length(T))=[ ];
T2=T1;
T2(length(T1))=[ ];
for i=1:length(T)
b(i)=1/(T(i)*k) //beta
Z(i)=(exp(-b(i)*(E1+E2))+exp(-b(i)*(E2+E3))+exp(-b(i)*(E3+E1)))^N //partition function
end
U=N*k*(T1'^2).*diff(log(Z),1)./dT // internal energy
F=-N*k*T'.*log(Z)
S=-diff(F,1)./dT
Cv=diff(U,1)./dT
// plotting of various functions
figure;
plot(T,Z,'g','linewidth',3)
xlabel("Temperature(K)------->",'fontsize',2)
ylabel("Partition Function(Z)------>",'fontsize',2)
title('Partition Function Vs Temperature','fontsize',3)
figure;
plot(T1,U,'r','linewidth',3)
xlabel("Temperature(K)-------->",'fontsize',2)
ylabel("Internal Energy(U)------->",'fontsize',2)
title('Internal Energy Vs Temperature','fontsize',3)
figure;
plot(T1,S,'m','linewidth',3)
xlabel("Temperature(K)------>",'fontsize',2)
ylabel("Entropy(S)------->",'fontsize',2)
title('Entropy Vs Temperature','fontsize',3)
figure;
plot(T,F,'c','linewidth',3)
xlabel("Temperature(K)-------->",'fontsize',2)
ylabel("Free Energy(F)------->",'fontsize',2)
title('Free Energy Vs Temperature','fontsize',3)
figure;
plot(T2,Cv,'b','linewidth',3)
xlabel("Temperature(K)------->",'fontsize',2)
ylabel("Specific Heat(Cv)----->",'fontsize',2)
title('Specific Heat Vs Temperature','fontsize',3)

OUTPUT

You might also like