same value for first and second solution
Afficher commentaires plus anciens
function newfypAmir
format long g
%Define all parameters
global Pr A C M K SS
M = 1;
K = 1;
A = 3;
C = -12;
Pr = 0.5;
SS = 0;
%Boundary layer thickness & stepsize
etaMin = 0;
etaMax1 = 15;
etaMax2 = 12; %15, 10
stepsize1 = etaMax1;
stepsize2= etaMax2;
%%%%%%%%%%%%%%%%%%%%%% First solution %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
options = bvpset('stats','off','RelTol',1e-10);
solinit = bvpinit (linspace (etaMin, etaMax1, stepsize1), @OdeInit1);
sol = bvp4c(@OdeBVP, @OdeBC, solinit, options);
eta = linspace (etaMin, etaMax1, stepsize1);
y = deval (sol, eta);
%Displaying the output for first solution
fprintf('\nFirst solution:\n');
fprintf('f" = %7.9f\n',y(3));
fprintf('f` = %7.9f\n',y(2));
fprintf('theta = %7.9f\n',y(4));
fprintf('\n');
%%%%%%%%%%%%%%%%%%%%%% Second solution %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
options = bvpset('stats','off','RelTol',1e-10);
solinit = bvpinit (linspace (etaMin, etaMax2, stepsize2), @OdeInit2);
sol = bvp4c (@OdeBVP, @OdeBC, solinit, options);
eta = linspace (etaMin, etaMax2, stepsize2);
y = deval (sol, eta);
%Displaying the output for second solution
fprintf('\nSecond solution:\n');
fprintf('f" = %7.9f\n',y(3));
fprintf('f` = %7.9f\n',y(2));
fprintf('theta = %7.9f\n',y(4));
fprintf('\n');
%Define the ODE function
function ff = OdeBVP(~, y, Pr, M, K, A, C, SS)
global Pr M K A C SS
ff = [
y(2)
y(3)
( y(2)*y(2) - y(1)*y(3) - K*(1-y(2)) - M*M*(1-y(2)) - 1 ) / Pr
y(5)
-1*y(1)*y(5)
];
%Define the boundary condition
function res = OdeBC(ya, yb, A, C, SS)
global A C SS
res = [
ya(1)-SS
ya(2)-C-A*ya(3)
ya(4)-1
yb(2)-1
yb(4)];
%Setting the initial guess for first solution
function v = OdeInit1 (~, A, C, SS)
global A C SS
v = [0.5
0
0
0
0];
%Setting the initial guess for second solution
function v1 = OdeInit2 (x, A, C, SS)
global A C SS
v1 = [exp(-x)
exp(-x)
exp(-x)
exp(-x)
exp(-x)];
1 commentaire
Réponses (0)
Catégories
En savoir plus sur Programming dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!