Discretization of a system of ODEs with two variables.

조회 수: 5(최근 30일)
Andrian Mirza
Andrian Mirza 2021년 5월 9일
댓글: Tanmay Das 2021년 8월 5일
I try to solve this system:
I have trouble trying to discretize the system. As you see above the system has two variables, t and n. n is the length of the pipe (better saying it is a segment of the pipe)
t is the time. I need n to be discrete though. Can you help solving this?
The code I came up with so far:
syms C_bulk(t) C_stag(t) SC(t) t Y
i = 0;
while i < n
% Differential Equations
A_pipe = pi*d_pipe^2/4;
V_bulk = i*A_pipe;
%C_bulk0 = P_in*y0/(R*T)*M_Hg;
C_bulk0 = 5000*10^(-12);
N_max = 1.2140*10^19;
Fug = 0.144992321;
s_0 = 1;
A_bulk = (d_pipe - 4.25*10^(-5))^2*pi/4;
A_stag = A_pipe - A_bulk;
V_stag = (d_pipe^2/4*i - V_bulk/n);
SSA = 1;
Z = 0.61;
v = 10^(17);
q_max = N_max*M_Hg/NA;
ode1 = diff(C_bulk,t) == F_vol/V_bulk*(C_bulk0 - C_bulk) + k_m/V_bulk*A_stag*(C_stag - C_bulk);
ode2 = diff(C_stag,t) == k_m/V_stag*A_stag*(-C_stag + C_bulk)-(Fug*C_stag*R*T1*NA/(M_Hg*sqrt(2*pi*M_Hg*R*T1))*s_0*(1-SC)/(V_stag*N_max)*A_pipe*q_max*SSA - v*SC*exp(-(126-28.82*SC)/(R*T1)))*A_pipe*q_max*SSA/V_stag;
ode3 = diff(SC,t) == (C_stag*Fug*Z*R*T1*NA/(M_Hg*sqrt(2*pi*M_Hg*R*T1))*s_0*(1-SC)/N_max - v*SC*exp(-1000*(151-28.82*SC)/(R*T1)));
odes = [ode1, ode2 ode3];
[VF,Subs] = odeToVectorField(odes);
odefcn = matlabFunction(VF, 'Vars',{t,Y});
i = i + L/n;
end
  댓글 수: 2
Tanmay Das
Tanmay Das 2021년 8월 5일
Your code has some uninitialized variables. Please add detailed reproduction steps.

댓글을 달려면 로그인하십시오.

답변(0개)

Community Treasure Hunt

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

Start Hunting!

Translated by