[Mass Transfer] How do I solve the following infinite series analytical solution to find time (t)? The answers in solution manuals show that the answer is 5085.85 seconds.

4 views (last 30 days)
The equation that needs solving is as follows (Problem 27.18 from Fundamentals of Momentum, Heat, and Mass Transfer - J.Welty):
I have written my code as follows but the code keeps running without returning any values.
% Constants
D = 1.5e-7; % Diffusivity
r = 0; % Radius at center
R = 0.1; % Radius at edge
CAO = 0.2; % Initial Conc.
CA_target = 0.1 * CAO; % Target Conc.
CA_term = (((CA_target-CAO)/-CAO)-1)/2;
% Define the function CA as a function of time (t)
CA = @(t, n) (-1)^n * exp(-4*D*((n * pi * t)/R)^2);
% Iteration
n = 1; % Initialize n
series_sum = CA(0, n);
while abs(series_sum - CA_term) > 1e-6 % Check for convergence
n = n + 1; % Increment n
series_sum = series_sum + CA(0, n);
end
% Solve for t using an anonymous function
t = fzero(@(t) CA(n), 0);
fprintf('The time needed to reach CA_term is: %.2f\n', t);
I'm really new to matlab so any help would really be appreciated. Thanks.

Accepted Answer

Torsten
Torsten on 5 Jun 2023
Edited: Torsten on 5 Jun 2023
D = 1.5e-7; % Diffusivity
R = 0.05; % Radius
CA0 = 0.2; % Initial Conc.
CAS = 0.0;
CA_target = 0.1*CA0; % Target Conc.
N = 100;
CA_res = @(t)(CA_target-CA0)/(CAS-CA0) - (1+2*sum((-1).^(1:N).*exp(-D*(1:N).^2*pi^2*t/R^2)));
t0 = 1000;
t = fsolve(CA_res,t0,optimset('TolX',1e-14,'TolFun',1e-14))
Equation solved. fsolve completed because the vector of function values is near zero as measured by the value of the function tolerance, and the problem appears regular as measured by the gradient.
t = 5.0586e+03
CA_res(t)
ans = 4.5519e-15
CA_res(5085.85)
ans = -0.0016

More Answers (0)

Categories

Find more on MATLAB in Help Center and File Exchange

Products


Release

R2023a

Community Treasure Hunt

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

Start Hunting!