Trying to code from Polymath

6 views (last 30 days)
this Polymath code into a Matlab code but I don't know how. Please I need to help. Please.......
  2 Comments
Juan Camilo Guerrero Paredes
Later I did this but dont work.
[V,F] = ode15s('Function14',[0 50],[ 15 , 20 , 0 , 0 , 0 , 0 ]);
v0 =10;
Ca0= 1.5;
La0= 1.5/v0;
Lb0= 2.0/v0;
Xa = (15-F(:,1))/15;
figure
plot(V,F(:,1),V,F(:,2),V,F(:,3),V,F(:,4),V,F(:,5),V,F(:,6))
xlabel('Volumen (dm3)'),
ylabel('Flujo molar (mol/s)')
legend('Fa','Fb','Fc','Fd','Fe','Ff')

Sign in to comment.

Accepted Answer

Navya Singam
Navya Singam on 13 Jan 2022
Hi,
MATLAB Version of the Polymath code
%%Initial conditions
IC=[1,1,1,1,1,1];
Vspan=[0 50];
[V,CT]=ode15s(@fn,Vspan,IC);
%%Extracting the parameters
ca=CT(:,1);
cb=CT(:,2);
cc=CT(:,3);
cd=CT(:,4);
ce=CT(:,5);
cf=CT(:,6);
%Plot graph
figure
plot(V,ca,V,cb,V,cc,V,cd,V,ce,V,cf)
xlabel('Volume (dm3)')
ylabel('Flujo molar (mol/s)')
legend('Fa','Fb','Fc','Fd','Fe','Ff')
%ODE function
function dCTdV = fn(~,CT)
%data
V=50;
v0=10;
ca0=1.5;
cb0=2.0;
kd1=0.25;
ke2=0.1;
kf3=5;
tau=V/v0;
%extract parameters
ca=CT(1);
cb=CT(2);
cc=CT(3);
cd=CT(4);
ce=CT(5);
cf=CT(6);
%supporting functions
rd1=kd1*ca*cb^2;
re2=ke2*ca*cd;
rf3=kf3*cb*cc^2;
ra=-rd1-3*re2;
rb=-2*rd1-rf3;
rc=rd1+re2-2*rf3;
rd=rd1-2*re2+rf3;
re=re2;
rf=rf3;
%odes
dCTdV = [(ca-ca0-ra*tau);(cb-cb0-rb*tau);(rc*tau-cc);(rd*tau-cd);(tau*re-ce);(tau*rf-cf)];
end
Refer to this to know more about ode15s solver.
  1 Comment
Juan Camilo Guerrero Paredes
Thanks very much. Navya Singam.....Thanks for helping me I try the code and it works I'm still learning about matLab. Greetings from Colombia.

Sign in to comment.

More Answers (0)

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by