This is an old revision of the document!
% KS_MONOTONIC_CALLER will solve the K-S equation for the case of the
% monotonic shock conditions
% -------------------------------------------------------------------
%
% Written 19 Mar 2021 for the INI Spring School
% EXPONENTIAL ASYMPTOTICS FOR PHYSICAL APPLICATIONS
clear
ep = 0.05; % Set epsilon value
zmin = -25; zmax = 12; % Set domain
% Define the initial condition at infinity
A = 2;
ubc = @(z) 1 - A*exp(-2*z);
upbc = @(z) -2*(-A)*exp(-2*z);
uppbc = @(z) 4*(-A)*exp(-2*z);
ic = [ubc(zmax); upbc(zmax); uppbc(zmax)];
% Define the differential equation
fwd = @(t,Y) KSode(t,Y,ep);
% Solve the ODE from z = zmax going backwards to z = zmin
options = odeset('RelTol', 1e-9, 'AbsTol', 1e-9);
[z, Y] = ode45(fwd, [zmax, zmin], ic, options);
u = Y(:,1);
figure(1)
hold all
plot(z, u);
plot(z, tanh(z), 'k--');
xlabel('z'); ylabel('u(z)');
ylim([-5,5]);
title('Monotonic shock solution (u0 = tanh(z) shown dashed)');
drawnow
function Yp = KSode(z, Y, ep) % KSODE provides the first-order differential equation definition for % ep^2 u''' + (1 - 4 ep^2) u' = 1 - u^2 u = Y(1); up = Y(2); upp = Y(3); uppp = (1 - u^2 - (1 - 4*ep^2)*up)/ep^2; Yp = [up; upp; uppp];