Is it possible to solve an equation with only a single derivative such as:

$$\frac{\partial U(x,t)}{\partial t} = A - BU(x,t)$$

with finite difference methods?

I ask as I am trying to solve the below equation using a finite difference method.

$$\frac{\partial \vec{m}(x,t)}{\partial t} = -\frac{\partial \vec{j}_{m}}{\partial x} - \frac{\vec{m}(x,t) \times \hat{M}(x)}{\lambda_{J}^2} - \frac{\hat{M}(x) \times \left( \vec{m}(x,t) \times \hat{M}(x) \right)}{\lambda_{\phi}} - \frac{\vec{m}(x,t) - m_\infty}{\lambda_{sf}^2}$$

I have implemented this with a forward difference scheme and it is unstable (even when $dt \ll \frac{dx}{2}$). I have attached an outline of the implementation if anyone wants to check this out!

Click Me For Difference Scheme Implementation


The $\vec{j}_m$ term is called the spin current and is defined in the document. It is calculated from the gradient of the spin accumulation $\frac{ \partial \vec{m}(x,t)}{\partial x}$ as in the document (bottom of the page).

I have used Dirichlet boundary conditions for now, although will probably use Neumann BCs at a later stage. The set up would involve using a magnetic material ($\hat{M} > 0$) surrounded by enough non-magnetic material either side to allow the solution to decay to $0$.

  • $\begingroup$ You have to solve a boundary value problem for each time step. You have a second order differential equation in space to solve and therefore it needs two boundary conditions. How do you solve this? $\endgroup$
    – HBR
    Aug 24 '17 at 8:35
  • 1
    $\begingroup$ For those of us from a different field, could you add the definition of $j_m$ to the question? Based on you notes, it looks diffusive, so your canonical form is incomplete. $\endgroup$
    – origimbo
    Aug 24 '17 at 9:58
  • $\begingroup$ Thanks for your comments, I have editted the question to include more info. However, @HBR I thought this was a first order PDE as $\vec{m}(x,t)$ is only differentiated wrt x once? I could include the code (python or C++) I have so far if this helps? $\endgroup$
    – Matt Ellis
    Aug 25 '17 at 6:33

In essence it does not matter what $\vec{j}$ means, but what it is. All worth to know is that your conservation equation is something like: $$\frac{\partial m}{\partial t} +\textrm{div}\,\vec{j}(m) = S(m) \tag{*}$$

The flux $\vec{j}(m)$ is a vector quantity that usually (and in this case it does) depends on the spatial difference in the variable $m$, $i.e.$ its gradient.

For parabolic equations, $i.e$ where a magnitude $m$ diffusses, the flux $\vec{j}$ is measured in the inverse direction of its gradient:

$$\vec{j}=-\kappa\, \vec{\textrm{grad}}\,m$$ Where the proportionality matrix $\kappa$ is definite positive, $i.e.$ $x^T\kappa x\geq 0$. If $\kappa = c i$ (being $c$ a scalar and $i$ the unit matrix) it is clear that $k>0$.

If $\kappa$ is negative definite, then the equation is ill-posed or simply may not have a solution. On the other hand if $\kappa$ is none of them the equation is hyperpolic.

The solution of $(*)$ (for the sake of clarity will be treated as the equation $\partial_t m- \partial_x^2m=0$) can be discretised as follows: $$\frac{m^{n+1}-m^n}{\Delta t}-\left(\frac{\partial^2m}{\partial x^2}\right)^n=0$$ which is solving a boundary value problem in each time step: $$ m(x)^{n+1}=m(x)^n + \left(\frac{\partial^2m}{\partial x^2}\right)^n(x)\quad s.t.\quad m(0) = m_0 \quad m(L) = m_L$$

  • $\begingroup$ Thanks for the answer, this isn't quite what I was getting at though. I originally tried this approach and it is very hard to generalise for problems where the parameters $\beta$, $\lambda_{sf}$, $\lambda_{phi}$, $D$ etc... depend on x as these add more terms to the equation thanks to the product rule! The approach I was describing where you solve for $\vec{m}(x,t)$ then use that to solve for $\vec{j}_m$ is the one I was after. I asked the question to see if I was using the correct method of solving a first order PDE. $\endgroup$
    – Matt Ellis
    Aug 25 '17 at 10:47
  • $\begingroup$ @MichaelPortobello, it doesn't matter how you implement it, as long as $j_m$ is calculated from $m^n$ you're still solving a diffusive term using an explicit time stepping method. This approach isn't usually stable with centred spatial derivatives for a general hyperbolic equation, and gives an additional criterion for parabolic problems. See e.g. en.wikipedia.org/wiki/FTCS_scheme $\endgroup$
    – origimbo
    Aug 25 '17 at 10:57
  • $\begingroup$ @MichaelPortobello: The point is that its is not a first order PDE, actually it is a second order one and you must treat it as what it is. In any case,apply a the numerical second derivative to that term: $$(ku')'_i = \frac{k_{i+1/2}(u_{i+1}-u_i)-k_{i-1/2}(u_i-u_{i-1})}{\Delta x^2}$$ $\endgroup$
    – HBR
    Aug 25 '17 at 11:00
  • $\begingroup$ @origimbo This equation is parabolic and not hyperbolic. The spatial discretisation is then stable for all centred schemes. It is clear then that stability issues arise from the time scheme. Therefore if the OP wants to solve easily without any application of an iterative scheme it must be explicit as it did. If s/he doesn't then s/he must put the term within brackets as $(\partial^2_x m)^{n+1}$ $\endgroup$
    – HBR
    Aug 25 '17 at 11:07

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.