- #1
gfd43tg
Gold Member
- 950
- 50
Homework Statement
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*10^{12} \frac{ft^3}{hr}##. 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 ##2*10^{-10} \frac{lb mol}{ft^3}##.
Given Information:
[tex]F_{CO,A} + F_{CO,S} - Q*C_{CO} = V\frac{dC_{CO}}{dt}[/tex]
[tex]F_{CO,A} = a + b sin(\pi*t/6)[/tex]
Where ##a = 20254815 \frac {lb mol}{hr}## and ##b = 0.5*a \frac {lb mol}{hr}##
[tex]V=4*10^{13} ft^3[/tex]
##Q=1.67*10^{13} \frac{ft^3}{hr}## for ##t \lt 72## and ##Q= 1.67*10^{12} \frac{ft^3}{hr}## for ##t \ge 72##
[tex]F_{CO,S}=C_{CO,S}*Q[/tex]
[tex]C_{CO,S} = 2*10^{-10} \frac{lb mol}{ft^3}[/tex]
Initial condition: [tex]C_{CO,t=0} = 2*10^{-10} \frac{lb mol}{ft^3}[/tex]
Homework Equations
The crux of my problem is using ode45 to solve this differential equation
##F_{CO,A} + F_{CO,S} - Q*C_{CO} = V\frac{dC_{CO}}{dt}##
The Attempt at a Solution
Hello, I want to give a little context for this problem so that you can understand what is going on. ##F_{CO,S}## is the flow rate of carbon monoxide entering the basin with a concentration of carbon monoxide ##C_{CO,s}## from the Santa Ana winds. ##F_{CO,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\frac{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 \ge 72##, and I'm not sure how to remedy this in the ode45 built in function. It is that ##Q## is a piecewise function of ##t##, as well as ##C_{CO} = f(t)##. Anyways, here is what I wrote so far. I know the function handle is supposed to have @(t,x) for a derivative ##\frac {dx}{dt}##, so I used in my function handle ##@(t,C_{CO})## for ##\frac {dC_{CO}}{dt}##. I keep getting the error Undefined function or variable 't'.
Code:
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');
Last edited: