(* d_diskdv.m *)

(* For discretization of the combined KdV-mKdV equation *)
(* derived by Herbst and Hereman *)

(* KdV subcase! *)

(* Take the discretized KdV by itself: set bb = 0 *)

bb = 0;   

(* leave aa free, you could set it to 1/6 *)

(* aa = alpha, bb = beta, cc = gamma, dd = delta *)
(* set hh = 1; *)

u[1][n_]'[t]:= -Expand[ (cc + aa*u[1][n][t] + bb*u[1][n][t]^2)*( 
dd*((1/2)*u[1][n+2][t]-u[1][n+1][t]+u[1][n-1][t]-(1/2)*u[1][n-2][t])+
(aa/2)*( 
u[1][n+1][t]^2-u[1][n-1][t]^2+u[1][n][t]*(u[1][n+1][t]-u[1][n-1][t])+
u[1][n+1][t]*u[1][n+2][t]-u[1][n-1][t]*u[1][n-2][t] )+ 
(bb/2)*( u[1][n+1][t]^2*(u[1][n+2][t]+u[1][n][t])-
u[1][n-1][t]^2*(u[1][n-2][t]+u[1][n][t]) ) ) ];

(* 
Print["Factored form of the equation :"];
Print[ 
 -Factor[ (cc + aa*u[1][n][t] + bb*u[1][n][t]^2)*( 
 dd*((1/2)*u[1][n+2][t]-u[1][n+1][t]+u[1][n-1][t]-(1/2)*u[1][n-2][t])+
 (aa/2)*( 
 u[1][n+1][t]^2-u[1][n-1][t]^2+u[1][n][t]*(u[1][n+1][t]-u[1][n-1][t])+
 u[1][n+1][t]*u[1][n+2][t]-u[1][n-1][t]*u[1][n-2][t] )+ 
 (bb/2)*( u[1][n+1][t]^2*(u[1][n+2][t]+u[1][n][t])-
 u[1][n-1][t]^2*(u[1][n-2][t]+u[1][n][t]) ) ) ]
];
*)

noeqs = 1;
name = "Herbst/Taha Discretization of KdV Equation";

(* NO weight on alpha *)
parameters = {aa};
weightpars = {cc,dd};

(* WITH weight on alpha *)
(*
parameters = {};
weightpars = {aa,cc,dd};
*)

formrho = 0;

(*
formrho =  u[1][n][t]*(
 (1/3)*u[1][n][t]^2 + u[1][n][t]*u[1][n+1][t] + u[1][n+1][t]^2 +
 (1/aa)*u[1][n+2][t] + u[1][n+1][t]*u[1][n+2][t]
);
*)

(* 
weightu[1] = 1/4; 
weight[aa] = 1/4;
weight[cc] = 1/2;
weight[dd] = 1/2;
*)

(*
weightu[1] = 1/2; 
weight[aa] = 0;
weight[cc] = 1/2;
weight[dd] = 1/2;
*)

(* d_diskdv.m *)

