I am wanting to solve the KdV equation using NDSolve. The exercise asks that I impose periodic boundary conditions on u and its derivatives. My approach is as follows:
a = 30;
eq = {D[u[t, x], {t, 1}] + D[u[t, x], {x, 3}] ==
6 u[t, x] D[u[t, x], {x, 1}], u[0, x] == -2 Sech[x] ^2,
u[t, -a] == u[t, a]};
sol = NDSolve[eq, u, {t, 0, 30}, {x, -a, a}, MaxStepSize -> 0.07];
data = Flatten[Table[{t, x, u[t, x]} /. sol, {t, 0, 30}, {x, -a, a}],
2];
ListPlot3D[data, Mesh -> None, ColorFunction -> "Rainbow",
PlotRange -> {{0, 30}, {-30, 30}, {-2, 2}}, Lighting -> "Automatic",
AxesLabel -> {"t", "x"}]
I am not really sure what it means to impose periodic boundary conditions on the derivatives, but in the other posts I have seen on this site, periodic boundary conditions are what I have implemented above.
How would I implement periodic boundary conditions on the derivatives?
I have tried adding the code:
D[u[t, -a], {x, 1}] = D[u[t, a], {x, 1}],D[u[t, -a], {t, 1}] = D[u[t, a], {tx, 1}]
In the code above in the 'eq' part of the code, but there was an error.
Does the Boundary Condition:
u[t, -a] == u[t, a]
Also take care of the derivatives?
Derivative[0, 1][u][t, -a] == Derivative[0, 1][u][t, a]
and thisDerivative[1, 0][u][t, -a] == Derivative[1, 0][u][t, a]
$\endgroup$ – zhk Aug 12 '17 at 15:27u[t, -a] == u[t, a]
, but also its spatial derivative is zeroDerivative[0, 1][u][t,a] == 0; Derivative[0, 1][u][t,-a] == 0
. $\endgroup$ – Alexei Boulbitch Aug 14 '17 at 7:13