Consider the PDE

$$\nabla \cdot ( - \color{blue}{\texttt{c}} \;\nabla u - \color{blue}{\texttt{alpha}} \; u) = 0 \tag{std}\label{std} $$


c     = {{1, 0}, {0, 1}};
alpha = {1, 0};

We use the helper function from FEM Usage Tips for extracting parsed coefficients:

<< NDSolve`FEM`
getcoeffs[eqn_] :=
        DirichletCondition[u[x, y] == 0, True]
      ], u, Element[{x, y}, Disk[]]

PDE specified with minus sign outside Inactive[Times][...]:

out =
    -c . Inactive[Grad][u[x, y], {x, y}]
    - Inactive[Times][alpha, u[x, y]]
 (* ^ here *)
  , {x, y}] == 0;

PDE specified with minus sign inside Inactive[Times][...]:

in =
    -c . Inactive[Grad][u[x, y], {x, y}]
    + Inactive[Times][-alpha, u[x, y]]
                   (* ^ here *)
  , {x, y}] == 0;

Intuitively one would expect these to represent the same PDE, but it turns out that they are parsed differently:

getcoeffs[out]["ConservativeConvectionCoefficients"] (* {{{{1}, {0}}}}  *)
getcoeffs[in]["ConservativeConvectionCoefficients"]  (* {{{{-1}, {0}}}} *)

Given this, I would say that the minus sign should be placed outside to be consistent with the standard form $\eqref{std}$.

However, I am confused by the example in FEM Usage Tips from In[93] onwards (Version 11.0). The intended PDE is

$$\nabla \cdot ( - \color{blue}{c} \;\nabla u + \color{blue}{\alpha} \; u) = 0 $$

where $\color{blue}{\alpha} = \{ -x, -y \}$ (see In[85]). But that example effectively places the minus sign inside Inactive[Times][...]:

α    = {-x, -y};
ipde =
    -c . Inactive[Grad][u[x, y], {x, y}]
    + Inactive[Times][α, u[x, y]]
  , {x, y}] == 0;

We get

getcoeffs[ipde]["ConservativeConvectionCoefficients"] (* {{{{-x}, {-y}}}} *)

meaning the actual (i.e. parsed) PDE is

\begin{align*} \nabla \cdot (-\color{blue}{c} \;\nabla u - \{ -x, -y \} \; u) &= 0 \\ \nabla \cdot (-\color{blue}{c} \;\nabla u - \color{blue}{\alpha} \; u) &= 0 \end{align*}

in light of the standard form $\eqref{std}$.

TLDR; I think I should put the minus sign outside Inactive[Times][...]. Is this correct?


There are a few issues here. First, the (minus) signs in the standard form have to be specified. If c=1 and you want to model:

$$\nabla \cdot ( - \color{blue}{\texttt{c}} \;\nabla u) = 0 $$

the input is:

Inactive[Div][ -c . Inactive[Grad][u[x, y], {x, y}], {x, y}] == 0

In other words the minus sign needs to specified. The same is true for alpha.

Now, the fact that

getcoeffs[out]["ConservativeConvectionCoefficients"] (* {{{{1}, {0}}}}  *)

is a bug that is fixed in the upcoming V12.0. The correct result is:

(* {{{{-1}, {0}}}}  *)

For now you have to use the minus sign inside (close to the coefficient). I'll also clarify that inconsistency in the tips tutorial. Sorry for the confusion.

Summary: if you see a minus sign in the standard equation you need to specify that sign. That is the case for both c and alpha where the minus sign in front of them needs to be part of your input. Otherwise you model

$$\nabla \cdot ( \color{blue}{\texttt{c}} \;\nabla u + \color{blue}{\texttt{alpha}} \; u) = 0 $$

The the corresponding `NeumannValue will also change it's signs.

Yet another way to put it: Everything you see in the standard equation has to be input by you, including the minus signs should your PDE model requite them.

|improve this answer|||||
  • $\begingroup$ Am I interpreting this correctly: in v11, the PDE in will correctly parse as the standard form $\eqref{std}$, and the bug lies in NDSolve`ProcessEquations (as called by getcoeffs) identifying alpha as the ConservativeConvectionCoefficient rather than -alpha? $\endgroup$ – for Monica Apr 1 '19 at 15:09
  • 1
    $\begingroup$ @lastresort, the parser of NDSolve is broken in the out case. The out case should and will in V12 return the same as the in case. $\endgroup$ – user21 Apr 1 '19 at 18:13
  • $\begingroup$ @lastresort, does that help? $\endgroup$ – user21 Apr 2 '19 at 6:46
  • $\begingroup$ I'm trying to reconcile this with $\eqref{std}$. In v12, does this mean that ConservativeConvectionCoefficient is $-\color{blue}{\texttt{alpha}}$ rather than $+\color{blue}{\texttt{alpha}}$ in the same way that DiffusionCoefficient is $-\color{blue}{\texttt{c}}$ rather than $+\color{blue}{\texttt{c}}$? $\endgroup$ – for Monica Apr 2 '19 at 7:31
  • 1
    $\begingroup$ @lastresort, yes, the ConservativeConvectionCoefficient behaves in the same manner as the DiffusionCoefficient. $\endgroup$ – user21 Apr 2 '19 at 10:33

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.