[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)
Show older comments
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.
0 Comments
Accepted Answer
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))
CA_res(t)
CA_res(5085.85)
0 Comments
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!