need help with mass transfer modelling
조회 수: 4 (최근 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에서 Numerical Integration and Differential Equations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
