Combining 2 different models
显示 更早的评论
Hi there,
I need help regarding combining two mathematical models in such a way that the output of one becomes the input to the other. Can anybody suggest, how should I proceed? Thanks.
Further to the comments, Please find below the coding of the first model. Now after 30 iterations i plot the curves, which have been commented now. From the output (15) generated, I only want to use the first 6 values in my 2nd model.
clear all
close all
SteadySMSR1
clc
global Pt0 u u01 u02 u03 u04 u05 u06 u013 u0 counter s1 s2 s3 s4 s5 s6 s7 s8 s9 s10 s11 s12 s13 s14 s15 kg hw
u0 = [0.2355;0.0254; 0.0207;0.6145; 0.0943;0.0096;0.2356;00255;0.0205;0.6147;0.0940;0.0097;899;902;1];
u01=0.2501; u02=0.0075; u03=0.0022; u04=0.7221; u05=0.0083; u06=0.0098; u013=893; %***Inlet condition*****
u=u0;
tfinal=1200;
tinc=10;
tmesh=1:tinc:tfinal;
s1(1,1:length(tmesh))=0.2501;
s2(1,1:length(tmesh))=0.0075;
s3(1,1:length(tmesh))=0.0022;
s4(1,1:length(tmesh))=0.7221;
s5(1,1:length(tmesh))=0.0083;
s6(1,1:length(tmesh))=0.0098;
s7(1,1:length(tmesh))=0.2501;
s8(1,1:length(tmesh))=0.0075;
s9(1,1:length(tmesh))=0.0022;
s10(1,1:length(tmesh))=0.7221;
s11(1,1:length(tmesh))=0.0083;
s12(1,1:length(tmesh))=0.0098;
s13(1,1:length(tmesh))=893;
s14(1,1:length(tmesh))=893;
f1='Report1';
f2='Report2';
f3='Report3';
f4='Report4';
f5='Report5';
f6='Report6';
f7='Report7';
f8='Report8';
f9='Report9';
f10='Report10';
f11='Report11';
f12='Report12';
f13='Report13';
f14='Report14';
f15='Report15';
options = odeset('RelTol',1e-8);
counter=2;
waithandle=waitbar(0,' Step2 : ------ Dynamic Simulation ------ '); % Initialize waitbar
% ----- Solving the system of PDEs -----
while counter<32
if (counter+0.01<=32),
waitbar(counter/31,waithandle);
end
[t1 u1]=ode23s(@simulationMSR1,1:tinc:tfinal-1,u0,options);
s1(counter,:)=u1(:,1)';
s2(counter,:)=u1(:,2)';
s3(counter,:)=u1(:,3)';
s4(counter,:)=u1(:,4)';
s5(counter,:)=u1(:,5)';
s6(counter,:)=u1(:,6)';
s7(counter,:)=u1(:,7)';
s8(counter,:)=u1(:,8)';
s9(counter,:)=u1(:,9)';
s10(counter,:)=u1(:,10)';
s11(counter,:)=u1(:,11)';
s12(counter,:)=u1(:,12)';
s13(counter,:)=u1(:,13)';
s14(counter,:)=u1(:,14)';
s15(counter,:)=u1(:,15)';
load('ReportS','w');
a1=w(counter,1);
a2=w(counter,2);
a3=w(counter,3);
a4=w(counter,4);
a5=w(counter,5);
a6=w(counter,6);
a7=w(counter,7);
a8=w(counter,8);
a9=w(counter,9);
a10=w(counter,10);
a11=w(counter,11);
a12=w(counter,12);
a13=w(counter,13);
a14=w(counter,14);
a15=1;
u0=[a1;a2;a3;a4;a5;a6;a7;a8;a9;a10;a11;a12;a13;a14;a15];
Pt0=Pt0-(delP/L)*delz;
counter=counter+1;
end
close(waithandle);
% ----- Saves the results -----
save(f1,'s1');
save(f2,'s2');
save(f3,'s3');
save(f4,'s4');
save(f5,'s5');
save(f6,'s6');
save(f7,'s7');
save(f8,'s8');
save(f9,'s9');
save(f10,'s10');
save(f11,'s11');
save(f12,'s12');
save(f13,'s13');
save(f14,'s14');
save(f15,'s15');
% save(f16,'s16');
bbb=clock;
% ----- 3D plotts of the model -----
% figure(1);
% x=1:1:31;
% time=1:tinc:tfinal;
% z=0:14.35/30:14.35;
%
% figure(1);mesh(time,x,s1);title('CH4 mol fraction');
% figure(2);mesh(time,x,s2);title('CO2 mol fraction');
% figure(3);mesh(time,x,s3);title('CO mol fraction');
% figure(4);mesh(time,x,s4);title('H2O mol fraction');
% figure(5);mesh(time,x,s5);title('H2 mol fraction');
% % figure(6);mesh(time,x,s6);title('N2 mol fraction');
% figure(7);mesh(time,x,s13);title('Temperatre');
% s15(1,:)=s15(2,:)
% figure(8);mesh(time,x,s15);title('Activity');
% % figure(9);mesh(time,x,s16);title('Pressure drop');
采纳的回答
更多回答(1 个)
Andrew Newell
2011-5-11
out1 = model1(in1);
out2 = model2(out1,otherVariables);
2 个评论
Amjad
2011-5-14
Andrew Newell
2011-5-14
The problem is, you provided so little information in your question that my answer could easily have been what you needed. There still isn't enough information to answer your question. I suggest that you go to the top of this page, click on "Edit", and edit your original question. Provide the code that produces the output or the format of your output files, let us know what information you need for the second model, and then we might be able to get somewhere.
类别
在 帮助中心 和 File Exchange 中查找有关 Mathematics 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!