need help with mass transfer modelling
显示 更早的评论
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 个)
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
类别
在 帮助中心 和 File Exchange 中查找有关 Numerical Integration and Differential Equations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
