0% found this document useful (0 votes)
15 views3 pages

Eq. (18) Eq. (2) : Mol M S

The document presents a nonlinear second-order ordinary differential equation (ODE) related to concentration diffusion, along with its initial conditions. It provides a MATLAB solution approach to transform the ODE into a system of first-order ODEs and solve it using MATLAB's ode45 function. Additionally, it includes the setup for defining parameters and plotting the results of the concentration and its gradient profile.

Uploaded by

Luis Plazas
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views3 pages

Eq. (18) Eq. (2) : Mol M S

The document presents a nonlinear second-order ordinary differential equation (ODE) related to concentration diffusion, along with its initial conditions. It provides a MATLAB solution approach to transform the ODE into a system of first-order ODEs and solve it using MATLAB's ode45 function. Additionally, it includes the setup for defining parameters and plotting the results of the concentration and its gradient profile.

Uploaded by

Luis Plazas
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

ε ∂(yi P)

= −∇ · Ni + ri (mol m−3 s−1 ) (1)


RT ∂t

 −1
P 1 − αy1 1 dy1
N1 = − + (18)
RT D12
eff D1,k
eff dz

where
 1/2
M1
α=1−
M2
Substituting Eq. (18) into Eq. (2) gives
 −1  
d2 y1 α 1 − αy1 1 dy1 2
+ eff + eff =0 (19)
dz2 D12 D12
eff D1,k dz

Eq. (19) is in the form of an ordinary differential equation,


which can be solved by using the two following initial con-
ditions:

IC.1 : y1 |z=0 = y1,bulk


 
dy1  JRT 1 − αy1,bulk 1
IC.2 :  =− + eff
dz z=0 2PF D12
eff D1,k

Looking at your differential equation, I see you have a nonlinear second-order ODE (equation 19) with defined initial conditions. I'll help you set up a MATLAB solution for this problem.

Here's how you can solve this differential equation using MATLAB:

1. First, we need to rewrite your second-order ODE as a system of first-order ODEs


2. Then we'll use MATLAB's ODE solver (like ode45)
3. Finally, implement the initial conditions

Let's start by defining your system:

```matlab
function dy = diffusion_system(z, y, alpha, D12_eff, D1k_eff)
% y(1) = y1 (the concentration)
% y(2) = dy1/dz (the first derivative)

% From equation (19), solving for d²y1/dz²


bracket_term = (1-alpha*y(1))/D12_eff + 1/D1k_eff;

dy = zeros(2,1);
dy(1) = y(2); % dy1/dz = y(2)
dy(2) = -alpha/D12_eff * bracket_term^(-1) * y(2)^2; % d²y1/dz² from equation (19)
end
```

Now let's create the main script to solve this:

```matlab
% Define parameters
alpha = 1 - (M1/M2)^0.5; % You need to provide M1 and M2 values
D12_eff = ; % Effective diffusion coefficient (provide value)
D1k_eff = ; % Effective diffusion coefficient (provide value)
J = ; % Flux (provide value for IC.2)
R = ; % Gas constant
T = ; % Temperature
F = ; % Parameter F (provide value)
y1_bulk = ; % Bulk concentration (provide value)

% Initial conditions from IC.1 and IC.2


y0 = [y1_bulk; -J*R*T/(2*P*F)*((1-alpha*y1_bulk)/D12_eff + 1/D1k_eff)];

% Define z range for integration


z_span = [0, z_max]; % Define appropriate z_max

% Solve the ODE system


options = odeset('RelTol', 1e-6, 'AbsTol', 1e-8);
[z, Y] = ode45(@(z,y) diffusion_system(z, y, alpha, D12_eff, D1k_eff), z_span, y0, options);

% Extract results
y1 = Y(:,1); % Concentration profile
dy1_dz = Y(:,2); % Gradient profile

% Plot results
figure;
plot(z, y1);
xlabel('z');
ylabel('y_1');
title('Concentration profile');

figure;
plot(z, dy1_dz);
xlabel('z');
ylabel('dy_1/dz');
title('Conc

You might also like