# need help with mass transfer modelling

4 ビュー (過去 30 日間)
AL SIAM SIDDIQUE 2022 年 7 月 7 日
コメント済み: AL SIAM SIDDIQUE 2022 年 7 月 8 日
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
##### 1 件のコメント表示非表示 なし
AL SIAM SIDDIQUE 2022 年 7 月 8 日
thank you so much.

サインインしてコメントする。

### カテゴリ

Find more on Dynamic System Models in Help Center and File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by