6
$\begingroup$

Consider the PDE

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

where

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_] :=
  First[
    NDSolve`ProcessEquations[
      List[
        eqn,
        DirichletCondition[u[x, y] == 0, True]
      ], u, Element[{x, y}, Disk[]]
    ]
  ]["FiniteElementData"]["PDECoefficientData"];

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

out =
  Inactive[Div][
    -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 =
  Inactive[Div][
    -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 =
  Inactive[Div][
    -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?

$\endgroup$

1 Answer 1

4
$\begingroup$

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.

$\endgroup$
8
  • $\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$
    – user40265
    Commented Apr 1, 2019 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
    Commented Apr 1, 2019 at 18:13
  • $\begingroup$ @lastresort, does that help? $\endgroup$
    – user21
    Commented Apr 2, 2019 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$
    – user40265
    Commented Apr 2, 2019 at 7:31
  • 1
    $\begingroup$ @lastresort, yes, the ConservativeConvectionCoefficient behaves in the same manner as the DiffusionCoefficient. $\endgroup$
    – user21
    Commented Apr 2, 2019 at 10:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.