Professional Documents
Culture Documents
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.
Fermi-Dirac distribution
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
300K
200K
100K
2.) Fermi Dirac Distribution
In console
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
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 ");
50k0
200k
In console
Graphic Window Output
In console
Code 2.)
In console
None
Graphic Window output
*At 100K
Code 3.)
In Console
800k
500k
2.)
5780k
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: