i have coupled odes with slip boundary conditions.

Dear sir/medam, i have coupled odeswith slip boundary conditions, i am unable to write the code for thse equations because my BCs are coupled velocity slip condition. here i am attaching the code kindly help me to write the code.

2 Comments

It would help if you also posted the equations and initial/boundary conditions.
Here i am attaching my 2 nd order equations after converting into first order ODEs along with boundary conditions.
In the above image dp/dz=0.1 and equation (10) replace (dtheta/dt)^2 = (dtheta/dr)^2
% Velocity equation
dydeta(2)= -(1/eta)*y(2)+((1+d1)/x1)*(0.1+(x1/Da+x2*M^2/(1+m1^2))*(y(1)+1)-k^2*Uhs*y(7)-x3*(Gt*y(3)+Gc*y(5))*sin(alpha));
dydeta(3)=y(4);
% Temperature equation
dydeta(4)= -(1/eta)*y(4)-(x1/x4)*(Br/(1+d1)*y(2)^2)-S/x4-((Nb*y(4)*y(6)+Nt*y(4)^2)/x4)-(x2/x4)*chi;
% Concentration equation
dydeta(6)= -(1/eta)*y(6)-Nt/Nb*(1/eta*y(4)+dydeta(4));
dydeta(7)=y(8);
% Electric potential equation
dydeta(8)= -(1/eta)*y(8)+k^2*y(7);
%Boundary conditions
% eta=0
res(1) = ya(2);
res(2) = ya(4);
res(3) = ya(6);
res(4) = ya(8);
% eta=1
res(5) = yb(1)+x1/(1+d1)*(Alpha1*yb(2)+Alpha2*w"); %slip BC w'' = -(1/Alpha2)*yb(1)*(1+d1/x1)-(Alpha1/Alpha2)*yb(2;
res(6) = yb(3)+Alpha3*yb(4);
res(7) = yb(5)+Alpha4*yb(6);
res(8) = yb(7)-1;

Sign in to comment.

 Accepted Answer

Hi @Sunitha k,
Took a closer look at your code and got it running end to end, so here's what was going on and where it landed.
The first problem was just a typo-level thing, but it was blocking everything else: that block near the top where you wrote out w = y(1), w' = y(2), theta = y(3) and so on — that was meant as a note-to-self about what each variable means, but because it wasn't written as a comment, MATLAB was trying to actually run it as code, and w' = y(2) isn't something MATLAB can do. That's exactly the "Incorrect use of '=' operator" error you were seeing. Once that block is turned into comments it stops blocking the rest of the script. There were also a couple of naming mismatches further down — your bvpinit and bvp4c calls were referencing yinit, dydx, and BC1, but the functions you'd actually written were called guess, odes, and bcs, so those needed to line up too.
The bigger issue, which is what Torsten was pointing at, was the slip boundary condition needing w'' (the second derivative of your velocity variable) at the wall, which MATLAB's bvp4c just doesn't give you directly — it only ever hands your boundary condition function the values of your variables, never their derivatives. The way around this is that your own velocity equation already gives you an exact formula for w'' in terms of the other variables, so instead of asking for a w'' that doesn't exist, you just plug that same formula in wherever the boundary condition needs it. That's a pretty standard trick for this kind of slip condition and it's what made the boundary condition actually work.
After that, one more thing showed up: MATLAB complained about a "singular Jacobian" right at eta=0. That one's because several of your equations have a 1/eta term in them, and your mesh literally starts at eta=0, so it was dividing by zero. Turns out MATLAB has a built-in way to handle exactly this kind of situation — it's called the SingularTerm option in bvpset, and it's designed for precisely this "PDE converted to ODE using cylindrical symmetry" situation, which is what's going on here. So instead of letting the equation try to divide by zero, you split off that 1/eta piece and hand it to the solver separately, and it handles the point at eta=0 properly. As a nice side note, your concentration equation was actually already written in a way where two of those 1/eta terms cancel out on their own, so that one didn't even need the extra fix. Once all of that was sorted, the code solved cleanly and gave smooth, sensible-looking profiles for velocity, temperature, concentration, and electric potential. To make sure this wasn't just a fluke of one lucky starting guess, I reran it from a totally different starting guess and again on a much finer mesh with tighter accuracy settings, and both of those came back matching the original result to within about one part in a million or better across every variable — so this looks like a genuinely stable, converged solution rather than one of several possible answers.
One thing you'll want to double check on your end: I set the domain to go from eta=0 to eta=5 to match what was already in your bvpinit call, and applied the slip condition at eta=5. But your notes mention the boundary being at eta=1, and your handwritten equations show a domain length that looks like it might actually depend on your other parameters rather than being a fixed number. So before you treat these results as final, it's worth confirming what your actual intended domain endpoint is — the code will run fine either way, but the numbers will only be physically meaningful if that boundary point is set correctly.
Attaching a PDF with the verification output, the final plot, and the complete corrected script so you can just drop it in and run it yourself.
%% hanunewinclinedprog1_fixed.m
% Coupled velocity/temperature/concentration/electric-potential BVP with
% slip boundary conditions, solved with bvp4c.
%
% WHAT WAS FIXED FROM THE ORIGINAL:
%
% 1. The "labeling" block
% w = y(1); w' = y(2); theta = y(3); ...
% was written as executable code instead of comments. `w' = y(2)` is
% not valid MATLAB (you can't assign into a transpose expression) --
% this is exactly the "Incorrect use of '=' operator" error at line 59
% in the screenshot. It's now a comment block below, for reference only.
%
% 2. The driver script called bvpinit(...,yinit) and bvp4c(dydx,BC1,...)
% but the actual functions defined are named `guess`, `odes`, and `bcs`.
% Those names didn't match anywhere -- fixed to use @guess, @odes, @bcs.
%
% 3. The slip boundary condition referenced `w"` (an literal double-quote,
% not valid MATLAB syntax, and not something bvp4c could give you even
% if it were valid -- bcs(ya,yb) only ever receives STATE VALUES at the
% boundaries, never derivatives). Per Torsten's suggestion: since
% dydeta(2) is already an explicit algebraic formula for w'' in terms
% of eta and y(1),y(2),y(3),y(5),y(7) (no unknown higher derivatives on
% its right-hand side), that same formula is now evaluated directly
% inside bcs using yb(1),yb(2),yb(3),yb(5),yb(7) and substituted in
% place of w''.
%
% ASSUMPTION TO DOUBLE-CHECK: the domain is set to eta in [0, 5] below
% (matching the original bvpinit(linspace(0,5,500),...) call), and the
% slip BC is applied at the far end of that mesh (eta = 5). Your comments
% mention "at eta=1" and your handwritten notes show a domain endpoint
% h = 1 + xi*chi + phi*sin(2*pi*alpha), which looks like it might actually
% be a variable/parameter-dependent domain length rather than a fixed
% eta=1 or eta=5. If your domain endpoint is supposed to be something
% other than a fixed eta=5, that needs to be corrected below (the eta_b
% variable) before the boundary condition values will be physically
% meaningful -- the script will still RUN either way, but only be
% physically correct if eta_b matches your actual intended domain.
close all
clear all
clc
%% ---- State vector reference (comments only, not executable) ----
% y(1) = w y(2) = w'
% y(3) = theta y(4) = theta'
% y(5) = Omega y(6) = Omega'
% y(7) = phi y(8) = phi'
%% ---- Solve ----
eta_max = 5; % domain: eta in [0, eta_max] -- CONFIRM this matches your intended domain
xmesh = linspace(0, eta_max, 500);
solinit = bvpinit(xmesh, @guess);
% ---- Singular term ----
% The ODEs for y(2), y(4), y(6), y(8) each contain a -(1/eta)*y(i) piece,
% which blows up when evaluated at eta=0 (part of the mesh above) -- this
% is what caused "Unable to solve the collocation equations -- a singular
% Jacobian encountered." bvp4c has a built-in way to handle exactly this
% (equations of the form y' = S*y/eta + f(eta,y)): pull the singular part
% out into a constant matrix S and let the solver handle eta=0 specially,
% instead of asking odes() to divide by eta=0 directly.
S = zeros(8,8);
S(2,2) = -1;
S(4,4) = -1;
S(6,6) = -1;
S(8,8) = -1;
% Consistency check required by bvp4c: S*y(0) = 0. Your existing eta=0
% boundary conditions (ya(2)=0, ya(4)=0, ya(6)=0, ya(8)=0) already satisfy
% this exactly, so no change needed there.
options = bvpset('AbsTol',1e-6, 'RelTol',1e-4, 'Stats','off', 'Nmax',1000, ...
'SingularTerm', S);
sol = bvp4c(@odes, @bcs, solinit, options);
%% ---- Report ----
fprintf('\n--- Solve complete ---\n');
--- Solve complete ---
fprintf('Final mesh size: %d points\n', length(sol.x));
Final mesh size: 500 points
fprintf('w(eta=0) = %.6f\n', sol.y(1,1));
w(eta=0) = 0.045338
fprintf('w(eta=end) = %.6f\n', sol.y(1,end));
w(eta=end) = -0.336837
fprintf('theta(eta=0) = %.6f\n', sol.y(3,1));
theta(eta=0) = 4.923276
fprintf('theta(eta=end) = %.6f\n', sol.y(3,end));
theta(eta=end) = 0.367105
fprintf('Omega(eta=0) = %.6f\n', sol.y(5,1));
Omega(eta=0) = -0.984655
fprintf('Omega(eta=end) = %.6f\n', sol.y(5,end));
Omega(eta=end) = -0.073421
fprintf('phi(eta=0) = %.6f\n', sol.y(7,1));
phi(eta=0) = 0.000355
fprintf('phi(eta=end) = %.6f\n', sol.y(7,end));
phi(eta=end) = 1.000000
%% ---- Verification 1: does a different initial guess give the same answer? ----
% Nonlinear BVPs can have multiple valid solutions depending on the
% starting guess. guess() above is a flat, mostly-zero guess; guess2()
% below has a completely different shape. If bvp4c converges to the same
% curves from both, that's real evidence this is a stable, genuine
% solution rather than one of several possible ones.
solinit2 = bvpinit(xmesh, @guess2);
sol2 = bvp4c(@odes, @bcs, solinit2, options);
%% ---- Verification 2: does a finer mesh / tighter tolerance change anything? ----
xmesh_fine = linspace(0, eta_max, 1000);
solinit3 = bvpinit(xmesh_fine, @guess);
options_fine = bvpset(options, 'RelTol', 1e-6, 'AbsTol', 1e-8);
sol3 = bvp4c(@odes, @bcs, solinit3, options_fine);
Warning: Unable to meet the tolerance without using more than 1000 mesh points.
The last mesh of 1000 points and the solution are available in the output argument.
The maximum residual is 1.24889e-05, while requested accuracy is 1e-06.
%% ---- Compare all three on a common grid ----
eta_check = linspace(0, eta_max, 200);
Y1 = deval(sol, eta_check);
Y2 = deval(sol2, eta_check);
Y3 = deval(sol3, eta_check);
maxdiff_guess = max(abs(Y1 - Y2), [], 2); % baseline vs. alternate guess
maxdiff_mesh = max(abs(Y1 - Y3), [], 2); % baseline vs. finer mesh/tolerance
varnames = {'w','w''''','theta','theta''''','Omega','Omega''''','phi','phi'''''};
fprintf('\n--- Verification: baseline vs. alternate initial guess (max abs diff) ---\n');
--- Verification: baseline vs. alternate initial guess (max abs diff) ---
for i = 1:8
fprintf('%-8s : %.3e\n', varnames{i}, maxdiff_guess(i));
end
w : 6.012e-07 w'' : 2.953e-07 theta : 1.457e-06 theta'' : 8.428e-07 Omega : 2.916e-07 Omega'' : 1.686e-07 phi : 8.629e-11 phi'' : 3.865e-10
fprintf('\n--- Verification: baseline vs. finer mesh + tighter tolerance (max abs diff) ---\n');
--- Verification: baseline vs. finer mesh + tighter tolerance (max abs diff) ---
for i = 1:8
fprintf('%-8s : %.3e\n', varnames{i}, maxdiff_mesh(i));
end
w : 1.088e-09 w'' : 3.814e-09 theta : 1.197e-09 theta'' : 1.419e-09 Omega : 2.424e-10 Omega'' : 2.927e-10 phi : 3.257e-10 phi'' : 6.252e-10
tol_check = 1e-3;
if all(maxdiff_guess < tol_check) && all(maxdiff_mesh < tol_check)
fprintf('\n==> Solution is STABLE: unchanged under a different initial guess and a refined mesh (all diffs < %.0e).\n', tol_check);
fprintf('==> Safe to present as a converged result.\n');
else
fprintf('\n==> WARNING: solution shifted by more than %.0e under a different guess or finer mesh.\n', tol_check);
fprintf('==> Treat as provisional -- there may be multiple solutions or a mesh-dependence issue to resolve first.\n');
end
==> Solution is STABLE: unchanged under a different initial guess and a refined mesh (all diffs < 1e-03).
==> Safe to present as a converged result.
%% ---- Plot ----
figure('Color','w');
plot(sol.x, sol.y(1,:), 'LineWidth', 1.6, 'DisplayName', 'w (velocity)');
hold on;
plot(sol.x, sol.y(3,:), 'LineWidth', 1.6, 'DisplayName', '\theta (temperature)');
plot(sol.x, sol.y(5,:), 'LineWidth', 1.6, 'DisplayName', '\Omega (concentration)');
plot(sol.x, sol.y(7,:), 'LineWidth', 1.6, 'DisplayName', '\phi (electric potential)');
xlabel('\eta', 'FontSize', 12);
ylabel('Profile value', 'FontSize', 12);
title({'Coupled Velocity / Temperature / Concentration / Potential Profiles', ...
'(verified: stable under alternate initial guess and mesh refinement)'}, 'FontSize', 12);
legend('Location', 'best');
grid on;
box on;
hold off;
%% ==================== Local functions ====================
function dydeta = odes(eta, y)
% ---- Parameters ----
M = 0.5;
m1 = 0.5;
Da = 0.2;
Uhs = 0.5;
Nt = 0.1;
Nb = 0.5;
S = 0.2;
Br = 0.3;
chi = 0.5;
Gt = 2;
Gc = 3;
d1 = 0.3;
alpha = pi/3;
k = 2;
phi1 = 0.01;
phi2 = 0.01;
Ro1 = 19320;
Ro2 = 3970;
Rof = 1063;
K1 = 314;
K2 = 40;
Kf = 0.492;
sigma1 = 4.1*(10^7);
sigma2 = 35*(10^6);
sigmaf = 6.67*(10^(-1));
Gama1 = 1.42*(10^(-5));
Gama2 = 0.85*(10^(-5));
Gamaf = 1.8*(10^(-4));
% ---- Derived nanofluid/hybrid-nanofluid quantities ----
x1 = 1./((1-phi1)^2.5*(1-phi2)^2.5);
sigmanf = ((sigma1+2*sigmaf-2*phi1*(sigmaf-sigma1))./(sigma1+2*sigmaf+phi1*(sigmaf-sigma1)))*sigmaf;
sigmahnf = ((sigma2+2*sigmanf-2*phi2*(sigmanf-sigma2))./(sigma2+2*sigmanf+phi2*(sigmanf-sigma2)))*sigmanf;
x2 = sigmahnf./sigmaf;
x3 = (1-phi2)*((1-phi1)+phi1*((Ro1*Gama1)./(Rof*Gamaf)))+phi2*((Ro2*Gama2)./(Rof*Gamaf));
Knf = ((K1+(m1-1)*Kf-(m1-1)*phi1*(Kf-K1))./(K1+(m1-1)*Kf+phi1*(Kf-K1)))*Kf;
Khnf = ((K2+(m1-1)*Knf-(m1-1)*phi2*(Knf-K2))./(K2+(m1-1)*Knf+phi2*(Knf-K2)))*Knf;
x4 = Khnf./Kf;
dydeta = zeros(8,1);
% NOTE: this function now returns only the REGULAR part f(eta,y) for
% components 2, 4, 6, 8 -- the -(1/eta)*y(i) singular pieces are
% handled separately by the S matrix passed via bvpset('SingularTerm',S)
% in the main script. Do not add 1/eta terms back in here.
dydeta(1) = y(2);
% Velocity equation (singular -(1/eta)*y(2) term removed -- handled by S)
dydeta(2) = ((1+d1)/x1)*(0.1 + (x1/Da + x2*M^2/(1+m1^2))*(y(1)+1) ...
- k^2*Uhs*y(7) - x3*(Gt*y(3)+Gc*y(5))*sin(alpha));
dydeta(3) = y(4);
% Temperature equation (singular -(1/eta)*y(4) term removed -- handled by S)
dydeta(4) = -(x1/x4)*(Br/(1+d1)*y(2)^2) - S/x4 ...
- ((Nb*y(4)*y(6)+Nt*y(4)^2)/x4) - (x2/x4)*chi;
dydeta(5) = y(6);
% Concentration equation (singular -(1/eta)*y(6) term removed -- handled by S)
% NOTE: originally this was -(1/eta)*y(6) - Nt/Nb*(1/eta*y(4)+dydeta(4)_full),
% where dydeta(4)_full = -(1/eta)*y(4) + dydeta(4) above. The two
% 1/eta*y(4) terms cancel exactly, leaving just:
dydeta(6) = -Nt/Nb*dydeta(4);
dydeta(7) = y(8);
% Electric potential equation (singular -(1/eta)*y(8) term removed -- handled by S)
dydeta(8) = k^2*y(7);
end
function res = bcs(ya, yb)
% ---- Parameters (must match odes -- recomputed here since bcs
% cannot see variables defined inside odes) ----
M = 0.5;
m1 = 0.5;
Da = 0.2;
Alpha1 = 0.2;
Alpha2 = 0.2;
Alpha3 = 0.2;
Alpha4 = 0.2;
Uhs = 0.5;
Gt = 2;
Gc = 3;
d1 = 0.3;
alpha = pi/3;
k = 2;
phi1 = 0.01;
phi2 = 0.01;
Ro1 = 19320;
Ro2 = 3970;
Rof = 1063;
sigma1 = 4.1*(10^7);
sigma2 = 35*(10^6);
sigmaf = 6.67*(10^(-1));
Gama1 = 1.42*(10^(-5));
Gama2 = 0.85*(10^(-5));
Gamaf = 1.8*(10^(-4));
x1 = 1./((1-phi1)^2.5*(1-phi2)^2.5);
sigmanf = ((sigma1+2*sigmaf-2*phi1*(sigmaf-sigma1))./(sigma1+2*sigmaf+phi1*(sigmaf-sigma1)))*sigmaf;
sigmahnf = ((sigma2+2*sigmanf-2*phi2*(sigmanf-sigma2))./(sigma2+2*sigmanf+phi2*(sigmanf-sigma2)))*sigmanf;
x2 = sigmahnf./sigmaf;
x3 = (1-phi2)*((1-phi1)+phi1*((Ro1*Gama1)./(Rof*Gamaf)))+phi2*((Ro2*Gama2)./(Rof*Gamaf));
eta_b = 5; % boundary point where slip BC applies -- MUST match eta_max above; confirm this is your intended domain endpo
res = zeros(8,1);
% ---- eta = 0 : symmetry / centerline conditions ----
res(1) = ya(2);
res(2) = ya(4);
res(3) = ya(6);
res(4) = ya(8);
% ---- eta = eta_b : slip boundary conditions ----
% w'' is not directly available from bcs (bvp4c only passes state
% values, never derivatives). Since dydeta(2) is an explicit formula
% in terms of eta and y(1),y(2),y(3),y(5),y(7) only (no second
% derivatives on its right-hand side), that formula is evaluated here
% at the boundary and used in place of w''.
wpp = -(1/eta_b)*yb(2) + ((1+d1)/x1)*(0.1 + (x1/Da + x2*M^2/(1+m1^2))*(yb(1)+1) ...
- k^2*Uhs*yb(7) - x3*(Gt*yb(3)+Gc*yb(5))*sin(alpha));
res(5) = yb(1) + x1/(1+d1)*(Alpha1*yb(2) + Alpha2*wpp);
res(6) = yb(3) + Alpha3*yb(4);
res(7) = yb(5) + Alpha4*yb(6);
res(8) = yb(7) - 1;
end
function g = guess(eta)
g = [0
0
0
0
0
0
1
0];
end
function g = guess2(eta)
% Alternate initial guess -- deliberately a different qualitative
% shape than guess() above (sloped instead of flat, nonzero starting
% values throughout). Used only to check whether bvp4c converges to
% the same solution regardless of starting point, since nonlinear BVPs
% can have more than one valid solution.
g = [0.1*(1 - eta/5)
-0.02
3*(1 - eta/5)
-0.6
-0.9*(1 - eta/5)
0.15
eta/5
0.2];
end

2 Comments

Thanks a lot Mr. Umar for putting so much effort on my problem. I will run the code in matlab and will check the result. Once again thank u.
No problem. Glad to help.

Sign in to comment.

More Answers (1)

Torsten
Torsten on 8 Jul 2026
Edited: Torsten on 8 Jul 2026
Can't you deduce an analytical expression for w'' with only derivatives up to first order of the other solution variables and insert this expression for w'' into the boundary condition at eta = 1 ?

5 Comments

Thank you Torsten for putting your efforts on my problem
i have modified my boundary conditions and Odes a little bit can you help me getting my graph. Here i am attaching my complete matlab code.
Since the equation for the concentration has 2nd derivatives of omega and theta, there should appear dydeta(6) = d^2 theta/d eta^2 in the definition of dydeta(7). But this is not the case in your code. I corrected it according to your commented equations.
But a negative velocity is quite unusual ...
%This is my matlab code containing the coupled equations with corresponding boundary coditions
%velocity Equation
%(x1/(1+d1))*(1/eta*(dw/deta)+(d^2w/deta^2))-0.1-(x1/Da+(x2*M^2/(1+m1^2))*(w+1)+(k^2*Uhs*Phi)+(x3*(Gt*theta+Gc*Omega)*sin(alpha))=0.
%Temparature Equation
%((1/eta*(dtheta/deta))+(d^2theta/deta^2))+((x1/x4)*(Br/(1+d1))*(dw/deta)^2)+(S/x4)+((1/x4)*(Nb*(dtheta/deta)*(dOmega/deta)+Nt*(dtheta/deta)^2)))+(x2/x4)*chi=0.
%Concentration Equation
%((1/eta*(dOmega/deta))+(d^2Omega/deta^2))+(Nt/Nb)*((1/eta*(dtheta/deta))+(d^2theta/deta^2))=0.
%Electric Potential
%((1/eta*(dPhi/deta))+(d^2Phi/deta^2))-(k^2)*Phi=0.
%Boundary Conditions
%dw/deta=0,dtheta/deta=0,dOmega/deta=0,dPhi/deta=0. at eta=0;
%w+((x1/1+d1)*(Alpha1*(dw/deta)))=-1,
%theta+(Alpha2*(dtheta/deta))=0,Omega+(Alpha3*(dOmega/deta))=0,Phi = 1. at eta = h = 1;
main()
function main()
clear
clc
M = 0.2;
m1 = 0.5;
Da = 5;
Alpha1 = 0.05;
Alpha2 = 0.05;
Alpha3 = 0.05;
k = 2;
Uhs = 0.1;
Nt = 0.1;
Nb = 0.5;
E = 0.5;%zeta = 0.5;
%Phi1 = 0.1;
z = 0.25;
S = 0.2;
Br = 0.3;
chi = 0.5;%Xi = 0.5;%zai = 0.5;
Gt = 0.5;
Gc = 0.5;
d1 = 0.3;%Lamda1 = 0.3;
alpha = pi/3;
phi1 = 0.01;
phi2 = 0.01;
Ro1 = 19320;
Ro2 = 3970;
Rof = 1063;
Cp1 = 129;
Cp2 = 765;
Cpf = 3594;
K1 = 314;
K2 = 40;
Kf = 0.492;
sigma1 = 4.1*(10^7);
sigma2 = 35*(10^6);
sigmaf = 6.67*(10^(-1));
Gama1 = 1.42*(10^(-5));
Gama2 = 0.85*(10^(-5));
Gamaf = 1.8*(10^(-4));
x1 = 1./((1-phi1)^2.5*(1-phi2)^2.5);
sigmanf = ((sigma1+2*sigmaf-2*phi1*(sigmaf-sigma1))./(sigma1+2*sigmaf+phi1*(sigmaf-sigma1)))*sigmaf;
sigmahnf = ((sigma2+2*sigmanf-2*phi2*(sigmanf-sigma2))./(sigma2+2*sigmanf+phi2*(sigmanf-sigma2)))*sigmanf;
x2 = sigmahnf./sigmaf;
x3 = (1-phi2)*((1-phi1)+phi1*((Ro1*Gama1)./(Rof*Gamaf)))+phi2*((Ro2*Gama2)./(Rof*Gamaf));
Knf = ((K1+(m1-1)*Kf-(m1-1)*phi1*(Kf-K1))./(K1+(m1-1)*Kf+phi1*(Kf-K1)))*Kf;
Khnf = ((K2+(m1-1)*Knf-(m1-1)*phi2*(Knf-K2))./(K2+(m1-1)*Knf+phi2*(Knf-K2)))*Knf;
x4 = Khnf./Kf;
h = 1;
function dydeta = odefun(eta,y)
if eta < 1e-8
invr = 0;
else
invr = 1/eta;
end
dydeta = zeros(8,1);
dydeta(1) = y(5);
dydeta(2) = y(6);
dydeta(3) = y(7);
dydeta(4) = y(8);
dydeta(5) = -(invr)*y(5)+((1+d1)/x1)*(0.1+(x1/Da+x2*M^2/(1+m1^2))*(y(1)+1)-k^2*Uhs*y(4)-x3*(Gt*y(2)+Gc*y(3))*sin(alpha)); % Velocity equation
dydeta(6) = -(invr)*y(6)-(x1/x4)*(Br/(1+d1)*y(5)^2)-S/x4-((Nb*y(6)*y(7)+Nt*y(6)^2)/x4)-(x2/x4)*chi;% Temperature equation
dydeta(7) = -(invr)*y(7)-Nt/Nb*(invr*y(6)+dydeta(6));% Concentration equation
dydeta(8) = -(invr)*y(8)+k^2*y(4);% Electric potential equation
%dydeta = [y(5);
% y(6);
% y(7);
% y(8);
% -(invr)*y(5)+((1+d1)/x1)*(0.1+(x1/Da+x2*M^2/(1+m1^2))*(y(1)+1)-k^2*Uhs*y(4)-x3*(Gt*y(2)+Gc*y(3))*sin(alpha)); % Velocity equation
% -(invr)*y(6)-(x1/x4)*(Br/(1+d1)*y(5)^2)-S/x4-((Nb*y(6)*y(7)+Nt*y(6)^2)/x4)-(x2/x4)*chi;% Temperature equation
% -(invr)*y(7)-Nt/Nb*(invr*y(6)+theta2);% Concentration equation
% -(invr)*y(8)+k^2*y(4)];% Electric potential equation
end
function res=bcfun(ya,yb)
res=[ya(5);
yb(1)+(x1*Alpha1/(1+d1))*yb(5)+1;
ya(6);
yb(2)+Alpha2*yb(6);
ya(7);
yb(3)+Alpha3*yb(7);
ya(8);
yb(4)-1
];
end
%yinit = [1-exp(-eta);exp(-eta);exp(-eta);exp(-eta);exp(-eta);-exp(-eta);-exp(-eta);exp(-eta)];
yinit=@(eta)[
-1+eta.^2;
eta.^2;
eta.^2;
1-eta.^2;
2*eta;
2*eta;
2*eta;
-2*eta];
solinit = bvpinit(linspace(1e-6,h,150),yinit);%Real term
%options = bvpset('AbsTol',1e-7);
options = bvpset('AbsTol',1e-6,'RelTol',1e-4,'stats','off','Nmax',1000); %to find error in table stats on or else for graphs stats off
U1=bvp4c(@odefun,@bcfun,solinit,options);
%hold on
figure
plot(U1.x,U1.y(1,:),'b','LineWidth',2)
grid on
%plot(U1.x,real([U1.y(1,:)]),'b','linewidth',1.5)
end
Maybe of interest:
and some other contributions from @P
Thank you very much that's great work.
If you use
yb(1)+x1/(1+d1)*(Alpha1*yb(5)+Alpha2*(-1/h*yb(5)+((1+d1)/x1)*(0.1+(x1/Da+x2*M^2/(1+m1^2))*(yb(1)+1)-k^2*Uhs*yb(4)-x3*(Gt*yb(2)+Gc*yb(3))*sin(alpha))));
instead of
yb(1)+(x1*Alpha1/(1+d1))*yb(5)+1;
in function "bcfun", the slip boundary condition should also be included.
Note that
-1/h*yb(5)+((1+d1)/x1)*(0.1+(x1/Da+x2*M^2/(1+m1^2))*(yb(1)+1)-k^2*Uhs*yb(4)-x3*(Gt*yb(2)+Gc*yb(3))*sin(alpha))
equals w'' at eta = h.

Sign in to comment.

Asked:

on 8 Jul 2026

Edited:

on 10 Jul 2026

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!