need help with mass transfer modelling
18 ビュー (過去 30 日間)
古いコメントを表示
Hi guys,
It would be great if someone can help me with this. I am quite new to modelling, I am trying to model this mass transfer equation
dx/dt=K(C*-x)
x is dissolved CO2 in molten carbonate
C* is solubility of CO2 in molten in the equilibrium
So I am trying to get a plot of CL with following conditions
C*= 150 : 250
t= 0 to 1200
k =0.02
thanks
my function code is
function f= ODEfun(x,t)
for C=(150:250)
k=0.05;
dxdt=k*(C-x);
f=[dxdt];
end
end
% I did the below code in separate file where I called the function
tspan= [0 1200];
x=0; %initial condition
[v y]= ode45(@ODEfun,tspan, x);
plot(v,y);
1 件のコメント
Sam Chak
2022 年 7 月 7 日
C has many values.
Why not writing out the first few equations in math notations?
It helps to understand how to translate that into MATLAB code.
回答 (1 件)
Alan Stevens
2022 年 7 月 7 日
Here's one way of doing it:
% You need to do the time integration for each C separately
C = 150:50:250; % Choose your own values of C
tspan = 0:10:1200;
x0 = 0;
lgnd = [];
% Loop through C values
for i = 1:numel(C)
[t, X] = ode45(@(t,x)ODEfn(t,x,C(i)), tspan, x0, C(i));
plot(t,X)
hold on
end
grid
xlabel('time'), ylabel('x')
function dxdt = ODEfn(~ ,x, C)
k = 0.05;
dxdt(:,1) = k*(C-x);
end
参考
カテゴリ
Help Center および File Exchange で Particle & Nuclear Physics についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!