# 3rd Order NonLinear PDE in MATLAB

• May 23rd 2010, 04:54 AM
Maccaman
3rd Order NonLinear PDE in MATLAB
I am trying to solve the KDV equation using Matlab. The KDV equation, $\frac{\partial u}{\partial t} + 6u \frac{\partial u}{\partial x} + \frac{\partial^3 u}{\partial x} = 0$, which is a model of waves on shallow water surfaces.

I have some code that models the Wave Equation:

Code:

[p,e,t]=initmesh('squareg'); x=p(1,:); y=p(2,:); u0=atan(cos(pi/2*x));                                  % Initial Condition ut0=3*sin(pi*x).*exp(sin(pi/2*y));            % Initial Condition n=500;                                                              % List of times tlist=linspace(0,5,n);                                    % Generates a row vector tlist of n points linearly spaced between and including a and b uu=hyperbolic(u0,ut0,tlist,'squareb3',p,e,t,1,0,0,1); % Squareb3 is boundary conditions delta=-1:0.1:1; [uxy,tn,a2,a3]=tri2grid(p,t,uu(:,1),delta,delta); gp=[tn;a2;a3]; umax=max(max(uu)); umin=min(min(uu)); newplot M=moviein(n); for i=1:n, pdeplot(p,e,t,'xydata',uu(:,i),'zdata',uu(:,i), ... 'mesh','on','xygrid','on','gridparam',gp,... 'colorbar','off','zstyle','discontinuous'); axis([-1 1 -1 1 umin umax]);... caxis([umin umax]); M(:,i)=getframe; end
This code uses the 'hyperbolic' command (line 8 of the code) to define the wave equation.
In Matlab, the general hyperbolic PDE is described by

$d \ \frac{\partial^2 u}{\partial t^2} \ - \ \nabla \ (c \nabla u) + a u = f$ (call this eqn (a)

Since the wave equation is given by:

$\frac{\partial^2 u}{\partial t^2} \ - \nabla u = 0$

then in eqn (a) d = 1, c = 1, a = 0, and f = 0.

Basically what I am trying to do is convert, if possible, the KDV equation into the eqn (a) format and add it to the code.
Can this be done?