Monday, March 5, 2012

6.18


A mass balance for a pollutant in a well-mixed lake can be written as

V * dc/dt = W - Q*c - k * V * sqrt(c)

Given the parameter values V = 1 * 10^6 m^3 , Q = 1 * 10^5 * m^3/yr,W = 1 * 10^6 g/yr, and k = .25 m^0.5/g^0.5/yr, use the modified secant method to solve for the steady-state concentration. Employ an initial guess of c = 4 g/m^3 and delta = .5. Perform three iterations and determine the percent relative error after the third iteration.

Matlab Code:

V = 1.0 * 10^6; % m^3 
Q = 1.0 * 10^5 ; % m^3/yr,
W = 1.0 * 10^6 ; %g/yr
k = .25; % m^0.5/g^0.5/yr,

c = -20:20;

f = @(c) W - Q .* c - k * V * sqrt(c);

hold on
plot(c, f(c))


c = 4; % g/m^3
delta = .05; 

for ii = 1:5
    plot(c, f(c), '*r')
    
    c_new = c - (delta * c * f(c))/(f(c + delta * c) - f(c));
    c = c_new;
end
hold off

percent_relative_error = ((c_new - c)/c_new) *100


The resulting percent relative error was 0

No comments:

Post a Comment