Suppose we have the inhomogeneous advection equation $$\left(\frac{\partial}{\partial x}+\frac{1}{c}\frac{\partial}{\partial t}\right)u(t,x)=v(t,x)$$ for $u,v:\mathbb{R}\times\mathbb{R}\to\mathbb{R}$ (with boundary conditions not yet specified).

Assuming that we had no $v$, i.e. the homogeneous part of the equation, the Crank-Nicolson method would yield


where $\mu=\frac{\Delta t}{\Delta x}$ and $u^n_\ell=u(n\Delta t,\ell\Delta x)$.

I don't know how to deal with the inhomogeneity in these schemes though.


Your equation can be written in the following fashion (any spatial derivative approximation is valid), once space is discretised: $$\frac{1}{c}\frac{du_i}{dt}=-\left(\frac{\partial u}{\partial x}\right)_i(t) + v_i(t) \tag{*}$$ Keep in mind that $v_i(t) = v(x_i,t)$.

Now the system of equations depends only on time $t$ you can apply Crack Nicholson method to solve the system of ODEs. Fo simplicity let the rght hand side of $(*)$ be named as: $$F_i(t) = v_i(t)-\left(\frac{\partial u}{\partial x}\right)_i(t) $$ and therefore $(*)$ cab ne rewritten as follows: $$\frac{1}{c}\frac{du_i}{dt}=F_i(t) \tag{**}$$

The Cranck-Nicholson method can be deduced from a $\theta$ method setting $\theta=1/2$, therefore, the time discretised equation $(**)$ is:

$$\frac{1}{c}\frac{u_i^{n+1}-u_i^{n}}{\delta t}=\theta\, F_i(t^{n+1}) + (1-\theta)F_i(t^n)=\frac{1}{2}\left[ F_i(t^{n+1})+F_i(t^n)\right]$$

Do not forget that we had the expression for $F_i(t)$, in which the function $v_i(t)$ is also present.

Hope you now know how to deal with that term.

  • $\begingroup$ Thank you for your answer, but suppose we want to propagate the equation in $x$, then I guess discretising the $t$ axis would yield: $$u^{n+1}_i=u^n_i+\frac{\Delta x}{2}(F_i(x^{n+1})+F_i(x^n)),$$ where $$F_i(x)=v_i(x)-\frac{1}{c}\left(\frac{\partial u}{\partial t}\right)_i(x),$$ right? $\endgroup$
    – Jason Born
    Jun 19 '17 at 9:32
  • $\begingroup$ I think you want to solve the system in a Lagrangian frame of reference?, where your equation is simply: $$\frac{du(t,x(t))}{dt}=v(t,x(t))$$ with $$\frac{dx(t)}{dt}=c$$. In this case you only have the path of a single particle through time. The time only goes forwards, you must provide an initial condition $u(0,x)=u^0(x)$ and then solve for the next time. You can not solve time before space. $\endgroup$
    – HBR
    Jun 19 '17 at 11:38
  • $\begingroup$ For implementation and the $F_i(t)$ term, I guess I would have to discretise the differential operator using a finite difference approximation and assign an initial condition for $v$? $\endgroup$
    – Jason Born
    Jun 21 '17 at 17:06
  • $\begingroup$ $v$ is a given function of time. Imagine that $u=\exp{(-t)}\sin{x}$, for example. You must only provide an initial condition for $u$ $\endgroup$
    – HBR
    Jun 21 '17 at 17:31
  • 1
    $\begingroup$ Yes you are right! $\endgroup$
    – HBR
    Jul 2 '17 at 18:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.