Trinh @ Bath

This is an old revision of the document!


  1. % KS_MONOTONIC_CALLER will solve the K-S equation for the case of the
  2. % monotonic shock conditions
  3. % -------------------------------------------------------------------
  4. %
  5. % Written 19 Mar 2021 for the INI Spring School
  6. % EXPONENTIAL ASYMPTOTICS FOR PHYSICAL APPLICATIONS
  7.  
  8. clear
  9.  
  10. ep = 0.05; % Set epsilon value
  11. zmin = -25; zmax = 12; % Set domain
  12.  
  13. % Define the initial condition at infinity
  14. A = 2;
  15. ubc = @(z) 1 - A*exp(-2*z);
  16. upbc = @(z) -2*(-A)*exp(-2*z);
  17. uppbc = @(z) 4*(-A)*exp(-2*z);
  18. ic = [ubc(zmax); upbc(zmax); uppbc(zmax)];
  19.  
  20. % Define the differential equation
  21. fwd = @(t,Y) KSode(t,Y,ep);
  22.  
  23. % Solve the ODE from z = zmax going backwards to z = zmin
  24. options = odeset('RelTol', 1e-9, 'AbsTol', 1e-9);
  25. [z, Y] = ode45(fwd, [zmax, zmin], ic, options);
  26. u = Y(:,1);
  27.  
  28. figure(1)
  29. hold all
  30. plot(z, u);
  31. plot(z, tanh(z), 'k--');
  32. xlabel('z'); ylabel('u(z)');
  33. ylim([-5,5]);
  34. title('Monotonic shock solution (u0 = tanh(z) shown dashed)');
  35. drawnow
  1. function Yp = KSode(z, Y, ep)
  2. % KSODE provides the first-order differential equation definition for
  3. % ep^2 u''' + (1 - 4 ep^2) u' = 1 - u^2
  4.  
  5. u = Y(1);
  6. up = Y(2);
  7. upp = Y(3);
  8.  
  9. uppp = (1 - u^2 - (1 - 4*ep^2)*up)/ep^2;
  10.  
  11. Yp = [up; upp; uppp];