Example Plotting a Cone using Cylindrical Coordinates
clc
clear
M=20;
N=20;
t0=0;
t00=2*pi;
dt=(t00-t0)/M;
R=0.2;
t=(t0:dt:t00);
%Using two for loops to generate the discrete angles
for i=1:M;
p=0;
for j=1:N;
p=p+dt;
t(i,j)=p;
end
end
for i=1:M;
for j=1:N;
x(i,j)=R*cos(t(i,j));
y(i,j)=R*sin(t(i,j));
z(i,j)=1;
end
end
plot3(x,y,z,'r*')
grid on
axis equal
R1=0
for i=1:M;
for j=1:N;
x1(i,j)=R1*cos(t(i,j));
y1(i,j)=R1*sin(t(i,j));
z1(i,j)=1.2;
end
end
hold on
plot3(x1,y1,z1,'r*')
clear
M=20;
N=20;
t0=0;
t00=2*pi;
dt=(t00-t0)/M;
R=0.2;
t=(t0:dt:t00);
%Using two for loops to generate the discrete angles
for i=1:M;
p=0;
for j=1:N;
p=p+dt;
t(i,j)=p;
end
end
for i=1:M;
for j=1:N;
x(i,j)=R*cos(t(i,j));
y(i,j)=R*sin(t(i,j));
z(i,j)=1;
end
end
plot3(x,y,z,'r*')
grid on
axis equal
R1=0
for i=1:M;
for j=1:N;
x1(i,j)=R1*cos(t(i,j));
y1(i,j)=R1*sin(t(i,j));
z1(i,j)=1.2;
end
end
hold on
plot3(x1,y1,z1,'r*')
Laminar Combustion Velocity Calculatour.
Burning Velocity Calculation.
This example covers the change of both temeprature and pressure at the same time.
Burning Velocity Calculation.
This example covers the change of both temeprature and pressure at the same time.
Methane Burning Velcoity
clc
clear
%Burning Velocity for Methane/air combustion
alphap=-0.504;
alphaT=2.105;
%choosing the number of points
N=10;
DT=400-300;
DP=10/1;
dt=DT/N;
dp=DP/N;
T(1)=300;
P(1)=1;
for i=1:N;
%Data Range Generation
T(i+1)=T(i)+dt;
P(i+1)=P(i)+dp;
%Constant Value Cells
P0(i)=1;
SL0(i)=0.259;
T1(i)=300;
%formula algebric simplification
a(i)=P(i)/P0(i);
b(i)=T(i)/T1(i);
aa(i)=(a(i))^alphap;
bb(i)=(b(i))^alphaT;
%Putting the formula togather
SL(i)=SL0(i)*aa(i)*bb(i);
end
plot(SL,T(1:N),'-*')
grid on
xlabel('Burning Velocity (m/s)')
ylabel('Temperature (K)')
title('Methane Burning Velocity versus (Temperature+Pressure)')
clear
%Burning Velocity for Methane/air combustion
alphap=-0.504;
alphaT=2.105;
%choosing the number of points
N=10;
DT=400-300;
DP=10/1;
dt=DT/N;
dp=DP/N;
T(1)=300;
P(1)=1;
for i=1:N;
%Data Range Generation
T(i+1)=T(i)+dt;
P(i+1)=P(i)+dp;
%Constant Value Cells
P0(i)=1;
SL0(i)=0.259;
T1(i)=300;
%formula algebric simplification
a(i)=P(i)/P0(i);
b(i)=T(i)/T1(i);
aa(i)=(a(i))^alphap;
bb(i)=(b(i))^alphaT;
%Putting the formula togather
SL(i)=SL0(i)*aa(i)*bb(i);
end
plot(SL,T(1:N),'-*')
grid on
xlabel('Burning Velocity (m/s)')
ylabel('Temperature (K)')
title('Methane Burning Velocity versus (Temperature+Pressure)')
Example Plotting Concenration in a 2D plane.
clc
clear
LX=1;
LY=1;
LZ=1;
N=50;
M=50;
L=50;
DX=LX/M;
DY=LY/N;
DZ=LZ/L;
for i=1:M;
for j=1:N;
n(i,j)=rand(1,1)*exp(-0.001*i*j);
end
end
for i=1:M;
for j=1:N;
V(i,j)=DX*DY*DZ;
C(i,j)=n(i,j)/V(i,j);
end
end
contour(C,12)
title('Concentration in a 2D Domain')
xlabel('X')
ylabel('Y')
clear
LX=1;
LY=1;
LZ=1;
N=50;
M=50;
L=50;
DX=LX/M;
DY=LY/N;
DZ=LZ/L;
for i=1:M;
for j=1:N;
n(i,j)=rand(1,1)*exp(-0.001*i*j);
end
end
for i=1:M;
for j=1:N;
V(i,j)=DX*DY*DZ;
C(i,j)=n(i,j)/V(i,j);
end
end
contour(C,12)
title('Concentration in a 2D Domain')
xlabel('X')
ylabel('Y')
Example
clc
clear
LX=1;
LY=1;
LZ=1;
N=50;
M=50;
L=50;
DX=LX/M;
DY=LY/N;
DZ=LZ/L;
A=2000;
EA=3000;
R=8314;
for i=1:M;
for j=1:N;
ppp(i,j)=rand(1,1);
na(i,j)=ppp(i,j)*exp(-0.001*i*j);
nb(i,j)=1-na(i,j);
T(i,j)=300*((i*DX)^2)%+2*i*DX);
end
end
for i=1:M;
for j=1:N;
Volume(i,j)=DX*DY*DZ;
CA(i,j)=na(i,j)/Volume(i,j);
CB(i,j)=nb(i,j)/Volume(i,j);
end
end
for i=1:M;
for j=1:N;
P(i,j)=-EA/R*T(i,j)
K(i,j)=A*exp(P(i,j));
V(i,j)=K(i,j)*((CA(i,j))^na(i,j))*((CB(i,j))^nb(i,j))
end
end
figure(1)
contour(CA)
title('Concentration in a 2D Domain')
xlabel('X')
ylabel('Y')
figure(2)
contour(CB)
title('Concentration in a 2D Domain')
xlabel('X')
ylabel('Y')
figure(3)
contour(V)
title('Speed of Reaction in a 2D Domain')
xlabel('X')
ylabel('Y')
grid on
pause(10)
close all
clear
LX=1;
LY=1;
LZ=1;
N=50;
M=50;
L=50;
DX=LX/M;
DY=LY/N;
DZ=LZ/L;
A=2000;
EA=3000;
R=8314;
for i=1:M;
for j=1:N;
ppp(i,j)=rand(1,1);
na(i,j)=ppp(i,j)*exp(-0.001*i*j);
nb(i,j)=1-na(i,j);
T(i,j)=300*((i*DX)^2)%+2*i*DX);
end
end
for i=1:M;
for j=1:N;
Volume(i,j)=DX*DY*DZ;
CA(i,j)=na(i,j)/Volume(i,j);
CB(i,j)=nb(i,j)/Volume(i,j);
end
end
for i=1:M;
for j=1:N;
P(i,j)=-EA/R*T(i,j)
K(i,j)=A*exp(P(i,j));
V(i,j)=K(i,j)*((CA(i,j))^na(i,j))*((CB(i,j))^nb(i,j))
end
end
figure(1)
contour(CA)
title('Concentration in a 2D Domain')
xlabel('X')
ylabel('Y')
figure(2)
contour(CB)
title('Concentration in a 2D Domain')
xlabel('X')
ylabel('Y')
figure(3)
contour(V)
title('Speed of Reaction in a 2D Domain')
xlabel('X')
ylabel('Y')
grid on
pause(10)
close all
Unless otherwise noted, all content on this site is @Copyright by Ahmed Al Makky 2012-2013 - http://cfd2012.com