7.16 Write a MATLAB program that computes the solution to the (dimensionless) un
ID: 1770672 • Letter: 7
Question
7.16 Write a MATLAB program that computes the solution to the (dimensionless) unsteady diffusion equation ac a2c ar ax2 subject to an initial condition c(x,0) 0 and the boundary conditions c(0,t)-1 and ac/ax = 0 at x = 1 . In other words, this is the solution for the concentration (or temper- ature profile) in an initially empty (cold) slab if we instantaneously put it in contact with a reservoir at the left that is at the maximum concentration (temperature). Use centered finite differences for the spatial derivative and RK4 for the time integration. You should have 51 nodes and a time step of 0.0001. Make a plot that has the concentration profile at the l l dimensionless times t = 0, 0.025, 0.05, . . . ,025.Explanation / Answer
u = 1; % wave-velocity r = 1; % aspect-ratio delx = 0.1; % x-step delt = (delx*sqrt(r))/u; % t-step x = 0:delx:1; % defining x-scale t = 0:delt:1; % defining t-scale %% Implementing Numerical Solution of wave equation. PHI(x,t)=sin(pi*x)*cos(pi*t) PHI = (cos(pi*t))'*sin(pi*x); % Analytical solution %% Implementing Analytical Solution of wave equation PHItt = PHIxx by Finite % Difference Explicit method PHIN = zeros(length(t),1)*zeros(1,length(x)); % initialising solution matrix, row as 'x' and column as 't' PHIN(:,1) = 0; % Applying boundry condition, PHIN(0,t) = 0 PHIN(:,length(x)) = 0; % Applying boundry condition, PHIN(1,t) = 0 PHIN(1,:) = sin(pi*x); % Applying initial condition,PHIN(x,0) = sin(pi*x) % calculting second row, i.e. t = delt corresponding to j = 1, utilising % initial condition PHINt(x,0) = 0 for 0Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.