ODE45 problem with concentration of CO
Mostra commenti meno recenti
Smog begins to build up again immediately after a Santa Ana wind passes through the basin. The volumetric flow rate through the basin has dropped to 1.67 x 10^12 ft3/hr (1.5 mph). Plot the concentration of carbon monoxide in the basin as a function of time for up to 72 hours and just after a Santa Ana wind. The initial concentration of CO is 0.08 ppm (2 x 10^-10 lbmol/ft3).
Given F_CO,A + F_CO,S - Q*C_CO = V(dC_CO/dt)
F_CO,A = a + b sin(π*t/6)
Where a = 35,000 lb mol/h and b = 30,000 lb mol/h
V=4x10^13 ft3
Q =1.67x10^13 ft3/hr for t <72, Q= 1.67x10^12 ft3/hr for t ≥72
F_CO,S= C_CO,S*Q
C_CO,S = 2x10^-10 lb mol/ft3
Initial condition: C_CO(t=0)= 2x10^-10 lb mol/ft3
Hello, I want to give a little context for this problem so that you can understand what is going on. FCO,S is the flow rate of carbon monoxide entering the basin with a concentration of carbon monoxide (CO) CCO,s. FCO,A is the flow rate of carbon monoxide created by the cars driving inside the basin. Q*C_CO is the flow rate of carbon monoxide exiting the basin, and C_CO is changing with time because this is an unsteady state process. My problem is essentially solving the differential equation given in the problem
F_CO,A + F_CO,S - Q*C_CO = V(dC_CO/dt)
There are a couple of problems for me. First, there is the fact that Q changes depending on if t < 72 or if t >= 72, and I'm not sure how to remedy this in the ode45 built in function. Anyways, here is what I wrote so far. Keep in mind my a and b are different from the problem statement, but it should have no effect on where my issue lies here.
tSpan = [0 100]; % hr
if t < 72
Q = 1.67e13; % ft^3/hr
else
Q = 1.67e12; % ft^3/hr
end
C_COs = 2e-10; % lb mol/ft^3
F_COs = C_COs*Q; % lb mol/hr
a = 20254815; % lb mol/hr
b = 0.5*a; % lb mol/hr
F_COa = a + b*sin(pi*t/6); % lb mol/hr
Volume = 4e13; % ft^3
fHan = @(t,C_CO) (F_COa + F_COs - C_CO*Q)/Volume;
[T, C_CO] = ode45(fHan,tSpan,C_COs);
plot(T,C_CO)
xlabel('time (hours)');
ylabel('CO Concentration (lb mol/ft^3)');
title('CO Concentration vs. time');
and I get an error Undefined function or variable 't'. Well, I remember with ode45 you need to have your function handle be @(t,x). Also, how do I make it so that it knows with my if/else conditions how to handle the changing volumetric flow rate, Q?
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Ordinary Differential Equations in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!