Difference between revisions of "Template:CIEI-China/model/code"

(Created page with "<html> <body> <pre> <code> clear %Model 1 %Osmosis Pressure k_x=14; k_h=10; a=0.1; b=0.2; s=20; p=5; f=@(t,x)[-k_h*x/(k_x*(1-x)+x)-a*p+b*s]; [t,y]=ode23(f,[0 10],0.5); plot(...")
 
 
Line 1: Line 1:
 
<html>
 
<html>
 
<body>
 
<body>
 
+
<div>
 
<pre>
 
<pre>
 
<code>
 
<code>
Line 218: Line 218:
 
</code>
 
</code>
 
</pre>
 
</pre>
 +
 +
</div>
 
</body>
 
</body>
 
</html>
 
</html>

Latest revision as of 08:50, 31 October 2017

	
clear
%Model 1
%Osmosis Pressure
k_x=14;
k_h=10;
a=0.1;
b=0.2;
s=20;
p=5;
f=@(t,x)[-k_h*x/(k_x*(1-x)+x)-a*p+b*s];
[t,y]=ode23(f,[0 10],0.5);
plot(t,y,'b')
hold on
p=10;
f=@(t,x)[-k_h*x/(k_x*(1-x)+x)-a*p+b*s];
[t,y]=ode23(f,[0 10],0.5);
plot(t,y,'r')
p=15;
f=@(t,x)[-k_h*x/(k_x*(1-x)+x)-a*p+b*s];
[t,y]=ode23(f,[0 10],0.5);
plot(t,y,'g')
p=20;
f=@(t,x)[-k_h*x/(k_x*(1-x)+x)-a*p+b*s];
[t,y]=ode23(f,[0 10],0.5);
plot(t,y,'k')
xlabel('time')
ylabel('X_s')
legend('p=5','p=10','p=15','p=20')
title(‘The influence of osmosis pressure on concentration of solute’)
grid on
clear
%Salinity
figure
k_x=14;
k_h=10;
a=0.1;
b=0.1;
p=20;
s=5;
f=@(t,x)[-k_h*x/(k_x*(1-x)+x)+a*p-b*s];
[t,y]=ode23(f,[0 10],0.5);
plot(t,y,'b')
hold on
s=10;
f=@(t,x)[-k_h*x/(k_x*(1-x)+x)+a*p-b*s];
[t,y]=ode23(f,[0 10],0.5);
plot(t,y,'r')
s=15;
f=@(t,x)[-k_h*x/(k_x*(1-x)+x)+a*p-b*s];
[t,y]=ode23(f,[0 10],0.5);
plot(t,y,'g')
s=20;
f=@(t,x)[-k_h*x/(k_x*(1-x)+x)+a*p-b*s];
[t,y]=ode23(f,[0 10],0.5);
plot(t,y,'k')
xlabel('time')
ylabel('X_s')
legend('s=5','s=10','s=15','s=20')
title(‘The influence of salinity on concentration of solute’)
grid on
clear
%Model 1
%Osmosis pressure
fai=0.5;
A=2;
k_s=10;
a=0.1;
b=0.1;
s=20;
p=5;
f=@(t,x)[-fai*A*k_s*x-a*p+b*s];
[t,y]=ode23(f,[0 10],0.5);
plot(t,y,'b')
hold on
p=10;
f=@(t,x)[-fai*A*k_s*x-a*p+b*s];
[t,y]=ode23(f,[0 10],0.5);
plot(t,y,'r')
p=15;
f=@(t,x)[-fai*A*k_s*x-a*p+b*s];
[t,y]=ode23(f,[0 10],0.5);
plot(t,y,'g')
p=20;
f=@(t,x)[-fai*A*k_s*x-a*p+b*s];
[t,y]=ode23(f,[0 10],0.5);
plot(t,y,'k')
xlabel('time')
ylabel('X_s')
legend('p=5','p=10','p=15','p=20')
title(‘The influence of osmosis pressure on concentration of solue’)
grid on
clear
%Salinity
figure
fai=0.5;
A=2;
k_s=10;
a=0.1;
b=0.1;
p=20;
s=5;
f=@(t,x)[-fai*A*k_s*x+a*p-b*s];
[t,y]=ode23(f,[0 10],0.6);
plot(t,y,'b')
hold on
s=10;
f=@(t,x)[-fai*A*k_s*x+a*p-b*s];
[t,y]=ode23(f,[0 10],0.6);
plot(t,y,'r')
s=15;
f=@(t,x)[-fai*A*k_s*x+a*p-b*s];
[t,y]=ode23(f,[0 10],0.6);
plot(t,y,'g')
s=20;
f=@(t,x)[-fai*A*k_s*x+a*p-b*s];
[t,y]=ode23(f,[0 10],0.6);
plot(t,y,'k')
xlabel('time')
ylabel('X_s')
legend('s=5','s=10','s=15','s=20')
title(‘The influence of salinity on concentration of solute’)
grid on
clear
%Model 1
%Osmosis pressure
k_x=14;
k_x2=12;
k_h2=8;
k_h=10;
a=0.1;
b=0.2;
s=20;
p=5;
f=@(t,x)[-k_h*x(1)/(k_x*(1-x(1))+x(1))-a*p+b*s;-k_h2*x(2)/(k_x2*(1-x(2))+x(2))-a*p+b*s];
[t1,y1]=ode23(f,[0 10],[0.5,0.4]);
p=10;
f=@(t,x)[-k_h*x(1)/(k_x*(1-x(1))+x(1))-a*p+b*s;-k_h2*x(2)/(k_x2*(1-x(2))+x(2))-a*p+b*s];
[t2,y2]=ode23(f,[0 10],[0.5,0.4]);
p=15;
f=@(t,x)[-k_h*x(1)/(k_x*(1-x(1))+x(1))-a*p+b*s;-k_h2*x(2)/(k_x2*(1-x(2))+x(2))-a*p+b*s];

[t3,y3]=ode23(f,[0 10],[0.5,0.4]);
p=20;
f=@(t,x)[-k_h*x(1)/(k_x*(1-x(1))+x(1))-a*p+b*s;-k_h2*x(2)/(k_x2*(1-x(2))+x(2))-a*p+b*s];
[t4,y4]=ode23(f,[0 10],[0.5,0.4]);
hold on
plot(t1,y1(:,1),'b')
plot(t2,y2(:,1),'r')
plot(t3,y3(:,1),'g')
plot(t4,y4(:,1),'k')
xlabel('time')
ylabel('X_s')
legend('p=5','p=10','p=15','p=20')
title(‘ The influence of osmosis pressure of Group 1 on concentration of solute’)
grid on
figure
hold on
plot(t1,y1(:,2),'b')
plot(t2,y2(:,2),'r')
plot(t3,y3(:,2),'g')
plot(t4,y4(:,2),'k')
xlabel('time')
ylabel('X_s')
legend('p=5','p=10','p=15','p=20')
title(‘ The influence of osmosis pressure of Group 2 on concentration of solute’)
grid on
clear
%Salinity
figure
k_x=14;
k_x2=12;
k_h2=8;
k_h=10;
a=0.1;
b=0.1;
p=20;
s=5;
f=@(t,x)[-k_h*x(1)/(k_x*(1-x(1))+x(1))+a*p-b*s;-k_h2*x(2)/(k_x2*(1-x(2))+x(2))+a*p-b*s];
[t1,y1]=ode23(f,[0 10],[0.5,0.4]);
s=10;
f=@(t,x)[-k_h*x(1)/(k_x*(1-x(1))+x(1))+a*p-b*s;-k_h2*x(2)/(k_x2*(1-x(2))+x(2))+a*p-b*s];
[t2,y2]=ode23(f,[0 10],[0.5,0.4]);
s=15;
f=@(t,x)[-k_h*x(1)/(k_x*(1-x(1))+x(1))+a*p-b*s;-k_h2*x(2)/(k_x2*(1-x(2))+x(2))+a*p-b*s];

[t3,y3]=ode23(f,[0 10],[0.5,0.4]);
s=20;
f=@(t,x)[-k_h*x(1)/(k_x*(1-x(1))+x(1))+a*p-b*s;-k_h2*x(2)/(k_x2*(1-x(2))+x(2))+a*p-b*s];
[t4,y4]=ode23(f,[0 10],[0.5,0.4]);
hold on
plot(t1,y1(:,1),'b')
plot(t2,y2(:,1),'r')
plot(t3,y3(:,1),'g')
plot(t4,y4(:,1),'k')
xlabel('time')
ylabel('X_s')
legend('p=5','p=10','p=15','p=20')
title(‘ The influence of osmosis pressure of Group 1 on concentration of solute’)

grid on
figure
hold on
plot(t1,y1(:,2),'b')
plot(t2,y2(:,2),'r')
plot(t3,y3(:,2),'g')
plot(t4,y4(:,2),'k')
xlabel('time')
ylabel('X_s')
legend('p=5','p=10','p=15','p=20')
title(‘ The influence of osmosis pressure of Group 2 on concentration of solute’)

grid on