Finite difference method with derivative boundary conditions in MATLAB

2 replies · 1K views · last reply
582153236
Messages
14
Reaction score
0

Homework Statement


I'm trying to plot the steady state concentration of yA vs. x, yB vs x and yu vs x using centered finite difference method.
Three coupled partial differential equations: dyA/dtau = D d2yA/dx2 - yA yB^2 - gamma yA; dyB/dtau = D d2yB/dx2 - 2 yA yB^2 - delta yB + zeta yU; dyU/dtau = D d2yU/dx2 + delta yB - zeta yU.

Boundary conditions as typeset equations: at x = 0, dyA/dx(0,t) = -(1-yA), dyB/dx(0,t) = -(beta-yB), yU(0,t) = 0; at x = 1, dyA/dx(1,t) = -epsilon yA, dyB/dx(1,t) = -eta yB squared, dyU/dx(1,t) = -theta yU.


Homework Equations


Centered finite difference approximation for the second derivative: f''(x) ≈ (f(x+h) - 2f(x) + f(x-h)) / h^2, with the step size h squared in the denominator.

The Attempt at a Solution


τ represents the dimensionless time variable, so steady state would mean that the left hand side of each of the differential equations is 0.

I began this problem by replacing the derivatives that appear in the differential equations with the finite difference approximations for them. For example, yA:
Red circular icon with an exclamation mark, next to the text "Invalid Equation" in a LaTeX rendering error box.

I also used the boundary conditions:
Boundary condition equation: partial of yA with respect to x at x=0, at time t, equals negative (1 minus yA at x=0, t).

but I don't know at which point, I am taking yA on the right side from. In the below equation should yA on the right side be yA,1 or something else (since the below equation estimates the derivative at the node n=1?
Invalid Equation error label in red text on a light background, the kind of message shown when a LaTeX equation fails to render.


More importantly, how do I deal with this type of boundary condition in Matlab? I am used to dealing with boundary conditions such as yA(0,t)=0 for which I can simply initialize Y(1)=0 in MATLAB but in this case I'm given a derivative boundary condition.
 
What you do is add a fictitious point at -1 such that:

[tex]\frac{y_{1}-y_{-1}}{2h}=-(1-y_0)[/tex]

Combining this with ##\frac{(y_{-1}+2y_0+y_1)}{h^2}## gives:

[tex]\frac{(y_{-1}-2y_0+y_1)}{h^2}=\frac{2(y_1-y_0)}{h^2}-\frac{2(1-y_0)}{h}[/tex]

You solve the time-dependent equation at x = 0, and use this in that equation. This is a standard way of handling that type of flux boundary condition.

Chet
 
  • Like
Likes   Reactions: 582153236