We could simply apply the chain rule, to avoid some confusions we let $ C(x,t) = C(x^* + vt,t^*) = C^*(x^*,t^*)$:
$$
\frac{\partial C}{\partial x} = \frac{\partial C^*}{\partial x^{\phantom{*}}}= \frac{\partial C^*}{\partial x^*} \frac{\partial x^*}{\partial x^{\phantom{*}}} + \frac{\partial C^*}{\partial t^*} \frac{\partial t^*}{\partial x^{\phantom{*}}} = \frac{\partial C}{\partial x^*}
$$
remember here in chain rule, the partial derivative is being taken wrt the first and second variable if not to confuse this wrt the total derivative, similary we could have $\displaystyle \frac{\partial^2 C}{\partial x^2} = \frac{\partial^2 C^*}{\partial {x^*}^2} $,
$$
\frac{\partial C}{\partial t} = \frac{\partial C^*}{\partial t} = \frac{\partial C^*}{\partial x^*} \frac{\partial x^*}{\partial t^{\phantom{*}}} + \frac{\partial C^*}{\partial t^*} \frac{\partial t^*}{\partial t^{\phantom{*}}} = -v\frac{\partial C^*}{\partial x^*} + \frac{\partial C^*}{\partial t^*}
$$
Plugging back to the original equation you will see the convection term is gone if we have done this velocity cone rescaling, you could think the original equation like a diffusion on a car with velocity $v$ measured by a standing person, after the change of variable it is just a pure diffusion measured on a car:
$$
\frac{\partial C^*}{\partial t^*} = D\frac{\partial^2 C^*}{\partial {x^*}^2}
$$
and the initial condition changes to $C^*(x^*,0) = C(x^*+vt^*,t^*)\Big\vert_{t^*=0}= f(x^*)$, the boundary condition remains the same.
You may use the method of lines (MOL) in two different manners: by discretizing either the time variable, so you obtain a boundary value problem for each time step (for example applying a $\theta$-method discretization):
$$\frac{U^{n+1}(x) - U^{n}(x)}{\Delta t} = D \left( \theta \frac{d^2 U^{n+1}}{d x^2} + (1- \theta)\frac{d^2 U^n}{d x^2} \right), \quad 0 \leq \theta \leq 1, $$ which is to be solved in each time step with two boundary conditions for $U^n(x)$ (the solution in the step $t_n = t_0 + n \Delta t$) and specifying an initial value for $U^0(x)$; or by discretizing the spatial variable, fixing $t$:
$$ \frac{d U_i(t)}{d t} = \frac{D}{\Delta x^2} (U_{i+1} (t) - 2 U_i(t) + U_{i-1} (t)),$$ which is to be solved with a given initial condition $U_i(0)$ (the solution at the grid point $x_i = x_0 + i \Delta x$) and applying the boundary conditions at both end of your domain. This last form of expressing MOL can me more suitable to implement in Matlab, as it can be rearranged in matrix form as a linear system:
$$\vec{U}'(t) = A \vec{U}(t), \quad \vec{U} = (U_0, \ldots, U_N),$$
and then apply, for example, ode23 to solve for every unknown $U_i$. The tridiagonal matrix $A$ is given by the coefficients of the second order discretization:
$$A = \frac{D}{\Delta x^2}<a_{k,j-1}, a_{kk}, a_{k,j+1}>= \frac{D}{\Delta x^2}<1, -2, 1>.$$
However, the $a_{11}, a_{12}$ and $a_{N,N-1}$, $a_{NN}$ terms depend on whether the boundary conditios are either Dirichlet's or Neumann's, as well as the size of $A$ and unknowns $U_i$.
I hope this may be useful to you.
Cheers!
Best Answer
This seems to do the trick in maple...