Question: THIS NEEDS TO BE CODED IN MATLAB using BVP5C. do not solve by hand. I have the code for the bvp5c but I'm having trouble
THIS NEEDS TO BE CODED IN MATLAB using BVP5C. do not solve by hand.
I have the code for the bvp5c but I'm having trouble writing in the ODE when it's given in cylindrical coordinates. I've attached the code below that can be modified for this cylindrical coordinate below.
function bvp5c_version_easy_units %Uses bvp5c to solve 1-D wall mass transfer clear close all clc
%define all variables while making all units the same D=2.4E-9; %m^2/s Na=25E-3; %mol/m^3-s Note: This is a sink so the signs are changed in Eqs below w=40E-6; %m Cw=4E-2; %mol/m^3 deq=@(x,y)deq1(x,y,Na,D); %Anonymous function passes parameters to deq1 bc=@(ya,yb)bc1(ya,yb,Cw); %Anonymous function passes parameters to bc1 solinit=bvpinit(linspace(0,w,100),[0 0]); sol=bvp5c(deq,bc,solinit); x=linspace(0,w,100); C=deval(sol,x); plot(x,C(1,:)) ylabel('C (mol/m^3)') xlabel('x (m)') xlim([0 40E-6])
%Canal = Na/(2*D)*(((w^2)/4)-x.^2)+ Cw; Canal=-Na/(2*D)*(x*w-x.^2)+Cw; %analytical solution for Cw on each boundary %Canal=-Na/(2*D)*(w^2-x.^2)*10+Cw; %analytical solution for zero flux on left and Cw on right boundary figure subplot(2,1,1) plot(x,C(1,:)) ylabel('C (mol/m^3)') xlim([0 40E-6]) subplot(2,1,2) Cerr=(C(1,:)-Canal)./Canal; plot(x,Cerr) xlabel('x (m)') ylabel('Err = (C_{num} - C_{anal})/C_{anal}') xlim([0 40E-6])
figure flux=-D*C(2,:); %mol/s-m^2 plot(x,flux) % ylabel('flux (mol/s-m^2)') xlabel('x (m)') xlim([0 40E-6]) C(1,1) function dydx=deq1(x,y,Na,D) %Plane wall diffusion ODE dydx=[y(2) %y1 = C; Units: mol/m^4 Na/D]; %y2 = C'; Units: mol/m^5 function res=bc1(ya,yb,Cw) %Boundary conditions %Notes %1 There is one entry at each end of the domain. %2 ya is a vector %representing the boundary conditions on the left side. % ya(1) is the first variable (in this case the concentration) % ya(2) is the second variable (in this case the derivative of the % concentration) %3 yb has a similar interpretation on the right side %4 res is the residual vector. Write entries with the understanding that % the solver will iterate until the residual goes to zero. res=[ya(1)-Cw %Set left side conc to Cw yb(1)-Cw]; %Set right side concentration to Cw
7. The cylindrical version of the governing equation for 1D, steady state diffusion is 1 ddC 48 drdr 0 = DAB Assume we have dr r=0 Solve to find the general solution Solve Problem 7 using bvp5c with Cw 4 x 108 mol/cm3, DAB 1 x 10 5 cm2/s, N-25 x 10-6 M/S, R = 40 x 10-6 m 7. The cylindrical version of the governing equation for 1D, steady state diffusion is 1 ddC 48 drdr 0 = DAB Assume we have dr r=0 Solve to find the general solution Solve Problem 7 using bvp5c with Cw 4 x 108 mol/cm3, DAB 1 x 10 5 cm2/s, N-25 x 10-6 M/S, R = 40 x 10-6 m
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
