You are on page 1of 24

STATISTICAL MECHANCIS

PRACTICAL FILE
Written in Scilab

Roll No (College)-
17567032

Roll No (Examination)-
17019567007

2020
SHUBHAM FARSWAN
B.Sc.(H) Physics
Index

Main
Topic
Bosefunction
Plotting different Einsteinwith energy at different
1
temperature.

Sub Maxwell-Boltzmann distribution


Topic

Fermi-Dirac distribution

Bose-Einstein distribution

2 Plotting Planck’s constant for Black Body radiation

Comparing it with Raleigh-Jeans Law at high temperature

Comparing it with Raleigh-Jeans Law at low temperature

3 Plotting Specific Heat of Solids at high and low temp..

Dulong - Petit law

Einstein distribution function

Debye distribution fuction


Program 1 Date: 15-01-2020

A.I.M – Plotting different function with energy at


different temperature. Functions are
1.) Maxwell-Boltzmann distribution
2.) Fermi-Dirac distribution
3.) Bose-Einstein distribution

Source Code:
funcprot(0);
clc; // to clear console
clear; // to clear variable browser
clf; // to clear previous figure if any
k=1.38e-23; // Boltzmann constant
mu=0; // chemical potential
Ef=1.6e-19; // fermi energy
N=1000;
n=1;
while n==1 // infinite loop start
disp("-----------------------What You Want To Do------------------------");
disp("1.) Maxwell Boltzmann Distribution");
disp("2.) Fermi Dirac Distribution");
disp("3.) Bose Einstein Distribution");
disp("Input 1,2,3 in consecutive manner For Corresponding Distribution");
i=input("Enter Your Option => ");
select i
case 1
y=[];
E0=0;
Em=1.2e-20;
E=linspace(E0,Em,N); //The Range of the energy
function [MB]=maxwell_Boltzmann(N, T)
for i=1:N
MB(i)=exp(-E(i)/(k*T));
end
//y=resume(MB);
endfunction
n=input("Enter the maximum number of temperature you want to enter ")
for i=1:n
T=input("Enter The Temperature")
y=maxwell_Boltzmann(N,T);
plot(E,y,i+3);
xgrid();
end
title(['Maxwell Boltzmann Distribution ''$f_M.B(\x)$''=''$exp(\E-k*T)$'],"fontsize",3);
xlabel("Energy(J)");
ylabel("Occupation index");
xset("background",30);
xset("foreground",8);
case 2
y=[];
Em=2e-19;
E=linspace(E0,Em,N); // Energy State
function [FD]=fermi_Dirac(N, T)
for i=1:N
FD(i)=1/((exp((E(i)-Ef)/(k*T)))+1);
end
//y=resume(MB);
endfunction
n=input("Enter the maximum number of temperature you want to enter ")
for i=1:n
T=input("Enter The Temperature")
y=fermi_Dirac(N,T);
plot(E,y,i+2);
end
title("Fermi Dirac Distribution");
xlabel("Energy(J)");
ylabel("Occupation index");
xset("background",30);
xset("foreground",8);
xgrid();
case 3
y=[];
Em=2e-20;
E0=1e-20;
E=linspace(E0,Em,N); //The Range of the energy
function [BE]=bose_Einstein(N, T)
for i=1:N
BE(i)=1/(exp((E(i)-mu)/(k*T))-1);
end
//y=resume(MB);
endfunction
n=input("Enter the maximum number of temperature you want to enter ")
for i=1:n
T=input("Enter The Temperature")
y=bose_Einstein(N,T);
subplot(n,n,i)
plot(E,y,i+2);
title("Bose Einstein Distribution");
xlabel("Energy(J)");
ylabel("Occupation index");
xset("background",30);
xset("foreground",8);
end
end
disp("---------------------------------------------------------------");
disp("If you want to continue Then type 1 if not then type 0");
disp("---------------------------------------------------------------");
n=input("Enter your Opinion=> ");
end

After execution of the program:


Output- 1.) Maxwell Boltzmann Distribution
In console

Graphic Window Output:

300K

200K
100K
2.) Fermi Dirac Distribution
In console

Graphic Window output

200K
10K

100K
3.) Bose-Einstein Distribution
In console

In Graphic window
50K

150K

250K
Algorithm:
Step 1: Start
Step 2: Defining Constants
Step 3: While loop
Step 4: Input the option as i (choose MB or FD or BE )
Step 5: Switch as I
If Case 1:
Initiate constants
Input the temperature count as n
In for loop
Input the temperature as T
Call function maxwell boltzmann
In function maxwell boltzman
Take T as argument and
Calculate distribution for each
value of N(predefined constant)
Return MB and assign it to y
End function
Plot the values
End loop
Title,Label,Graphic Settings set
Case end
If Case 2:
Initiate constants
Input the temperature count as n
In for loop
Input the temperature as T
Call function Fermi Dirac
In function Fermi Dirac
Take T as argument and
Calculate distribution for each
value of N(predefined constant)
Return FD and assign it to y
End function
Plot the values
End loop
Title,Label,Graphic Settings set
Case end
If Case 3:
Initiate constants
Input the temperature count as n
In for loop
Input the temperature as T
Call function Bose Einstein
In function Bose Einstein
Take T as argument and
Calculate distribution for each
value of N(predefined constant)
Return BE and assign it to y
End function
Plot the values
End loop
Title,Label,Graphic Settings set
Case end
Step 6: Input the number as n
If n == 1
GoTo Step 4
Else
End the loop
Step 7: Stop
Discussion:
Program 2 Date:02-02-2020

A.I.M -Plotting Planck’s law for Black body radiat-


ion and compare it with Raleigh -Jeans
1.) At High Temperature
2.) At Low Temperature
Source Code:
Code 1.)
funcprot(0);
clc;
clf;
clear;
h=6.626e-34; // Plancks constant
c=3e8; // Speed of light
k=1.34e-23; // Boltzman constant
N=10000;
y0=1e-10;
y1=40e-5;
n=1;
while n==1
disp("--------------------What You Want To Do---------------------");
disp("1.) Planck Radiation Law");
disp("2.) Rayleigh Jeans Law");
disp("3.) Comparision of both");
disp("Input 1,2,3 in consecutive manner For Corresponding Destribution");
i=input("Enter Your Option => ");
select i
case 1
z=[];
y=linspace(y0,y1,N);
function [RI]=planck_Radiation(N, T)
for i=1:N
RI(i)=(8*%pi*h*c)/(y(i).^5*(exp((h*c)/(y(i)*k*T))-1));
end
endfunction
n=input("Enter the maximum number of temperature you want to enter=> ");
for i=1:n
T=input("Enter the tempearature =>");
z=planck_Radiation(N,T);
plot(y,z,i+3);
end
title(['Planck Radiation Law'],"fontsize",3);
xgrid(10);
xlabel("Wavelength");
ylabel("Intensity");
xset("foreground",8);
xset("background",30);
case 2
w=[];
y0=7e-5;
y1=40e-5;
y=linspace(y0,y1,N);
function [RJ]=rayleigh_Jeans(N, T)
for i=1:N
RJ(i) = (8*%pi*k*T)/(y(i).^4)
end
endfunction
n=input("Enter the maximum number of temperature you want to enter=> ");
for i=1:n
T=input("Enter the Temperature=> ");
w=rayleigh_Jeans(N,T);
plot(y(1,:),w(:,1),i+3);
end
title(['Rayleigh Jeans Radiation Law'],"fontsize",3);
xgrid(10);
xlabel("Wavelength");
ylabel("Intensity");
xset("foreground",5);
xset("background",30);
case 3
x=linspace(1e-10,40e-5,500)
y=linspace(7e-5,40e-5,500)
function [PR]=planck_Radiation(l)
PR = 8*%pi*h*c/(l^5)*(1/(exp(h*c/(k*l*T))-1))
endfunction
function [RJ]=rayleigh_Jeans(l)
RJ = 8*%pi*k*T/(l^4)
endfunction
T=input("Enter the value of temperature for which you are comparing these graphs ");
plot(x,planck_Radiation,y,rayleigh_Jeans)
legend("By plancks law","BY Rayleign jeans Law")
title(['Wavelength vs Energy flux'],"fontsize",3)
xlabel("Wavelength(1)")
ylabel("Energy Flux(F(1))")
xgrid(10)
xset("background",30);
xset("foreground",5);
end
disp("---------------------------------------------------------");
disp("If you want to continue Then type 1 if not then type 0");
disp("---------------------------------------------------------");
n=input("Enter your Opinion => ");
end

Code 2.)
clc;
clear;
function [PR]=planck_Radiation(l)
PR = 8*%pi*h*c/(l^5)*(1/(exp(h*c/(k*l*T))-1));
endfunction
function [RJ]=rayleigh_Jeans(l)
RJ = 8*%pi*k*T/(l^4);
endfunction
function [WL]=weins_Law(l;)
WL = 8*%pi*h*c/(l^5)*(1/(exp(h*c/(k*l*T))));
endfunction
h=6.63e-34;
c=3e8;
k=1.38e-23;
T=100;
x=linspace(1e-10,40e-5,500);
y=linspace(7e-5,40e-5,500);
z=linspace(1e-10,40e-5,500);
plot(x,planck_Radiation,y,rayleigh_Jeans,z,weins_Law);
legend("By plancks law","BY Rayleign jeans Law","Wiens Law");
title(['Wavelength vs Energy flux at 100K'],"fontsize",3);
xlabel("Wavelength(1)");
ylabel("Energy Flux(F(1))");
xgrid(10);
xset("background",30);
xset("foreground",5);

Code 3.)
Clear;
clc;
clf;
function fun=f(x)
fun = (8*%pi*h*c/(x^5))*(1/(exp(h*c/(k*x*T))-1));
endfunction
h=6.6e-34;
c=3e8;
k=1.38e-23;
T=500;
x=linspace(1e-10,35e-6,500);
scf(1);
plot(x,f,"red");
T=800;
plot(x,f,"blue");
legend("t = 500k", "t = 800k");
title("Wavelenth vs Energy flux at 500k & 800k");
xlabel("$ wavelength(\lambda)$");
ylabel("$ EnergyFlux(F(\lambda))$");
xgrid(1);
T=5780;
x=linspace(1e-10,3e-6,500);
scf(2);
plot(x,f,"green");
legend("T= 5780k For Sun");
title("Wavelength Vs Energy flux for sun");
xlabel("$ wavelength(\lambda)$");
ylabel("$ EnergyFlux(F(\lambda))$");
xgrid(1);
vis= intg(4D-7,7D-7,f);
t=intg(1D-10,3D-6,f);
F=vis/t*100;
disp(F," Fraction of total solar radiant energy in visible region.");

uv= intg(2D-7,4D-7,f);
Fu=uv/t*100;
disp(Fu," Fraction of total solar radiant energy in uv region.");

for i=1:500
y(i)=f(x(i));
end
[a,b]=max(y);
disp(x(b),"Max Intensity is at wavelength for sun ");
T=500;
x=linspace(1e-10,70e-6,500);
for i = 1:500
y(i)=f(x(i));
end
[a,b]=max(y) ;
xmin=intg(1D-10,x(b),f);
xt=intg(1D-10,70D-6,f);
fl=(xmin/xt)*100;
disp(fl,"% age of Total Energy for Lmax at 300k ");

After execution of the program:


Output - Code 1.)
In console
Graphic Window Output

50k0

200k

In console
Graphic Window Output

In console

Grpahic Window output


*At 300k

Code 2.)
In console
None
Graphic Window output

*At 100K

Code 3.)
In Console

Graphic Window output 1.)

800k

500k

2.)
5780k

Algorithm: (Only For Code 1)


Step 1: Start
Step 2: Defining Constants
Step 3: While loop
Step 4: Input the option as i (choose or FD or BE )
Step 5: Switch as I
If Case 1:
Initiate constants
Input the temperature count as n
In for loop
Input the temperature as T
Call function planck_Radiation
In function planck_Radiation
Take T as argument and
Calculate radiation for each
value of N(predefined constant)
Return Ri and assign it to y
End function
Plot the values
End loop
Title,Label,Graphic Settings set
Case end
If Case 2:
Initiate constants
Input the temperature count as n
In for loop
Input the temperature as T
Call function rayleigh_Jeans
In function rayleigh_Jeans
Take T as argument and
Calculate radiation for each
value of N(predefined constant)
Return RJ and assign it to y
End function
Plot the values
End loop
Title,Label,Graphic Settings set
Case end
If Case 3:
Initiate constants
Input the temperature as T
Call function
In function planck_Radiation
Take T as argument and
Calculate planck_Radiation
Return PR as an argument for
plot
End function
Call function
In function rayleigh_Jeans
Take T as argument and
Calculate rayleigh_Jeans
Return RJ as an argument for
plot
End function
Plot graph
Title,Label,Graphic Settings set
Case end
Step 6: Input the number as n
If n == 1
GoTo Step 4
Else
End the loop
Step 7: Stop

Discussion:
Program 3 Date:**-**-2020
A.I.M – Plotting Specific Heat of Solids at high
and low temperature and comapring them.
1.) Dulong-Petit law
2.) Einstein Distribution function
3.) Debye Distribution function
Source Code:

You might also like