Modified Equations

advect= Derivative[1,0][q][t,x]-> -u Derivative[0,1][q][t,x]

cfl = ν -> u k/h

Define a function to obtain the truncation of the Taylor series expansion up to some order

ModifiedEq[scheme_,n_,pde_,k_,h_,cfl_]:=Simplify[Normal[Series[scheme,{k,0,n},{h,0,n}]] /. {cfl,pde}]

Upwind scheme

upwind = q[t+k,x]==q[t,x]- ν(q[t,x]-q[t,x-h])

Zeroth-order expansion should yield a true identity for a consistent scheme

ModifiedEq[upwind,0,advect,k,h,cfl]

Successive order expansions up to the order of the scheme should yield the PDE being modeled

ModifiedEq[upwind,1,advect,k,h,cfl]

upModEq=ModifiedEq[upwind,2,advect,k,h,cfl]

Simplify[upModEq /. Derivative[2,0][q][t,x]-> (u^2) Derivative[0,2][q][t,x]]

Lax-Wendroff scheme

lw = q[t+k,x]==q[t,x]- ν/2(q[t,x+h]-q[t,x-h])+ (ν^2)/2(q[t,x+h]-2 q[t,x]+q[t,x-h])

Zeroth-order expansion should yield a true identity for a consistent scheme

ModifiedEq[lw,0,advect,k,h,cfl]

Successive order expansions up to the order of the scheme should yield the PDE being modeled

ModifiedEq[lw,1,advect,k,h,cfl]

ModifiedEq[lw,2,advect,k,h,cfl]

Simplify[% /. Derivative[2,0][q][t,x]-> (u^2) Derivative[0,2][q][t,x]]

lwModEq=ModifiedEq[lw,3,advect,k,h,cfl]

Simplify[lwModEq /. {Derivative[2,0][q][t,x]-> (u^2) Derivative[0,2][q][t,x],Derivative[3,0][q][t,x]-> -(u^3) Derivative[0,3][q][t,x]}]