3
$\begingroup$

I encountered this when trying to solve the PDE mentioned here. I've transformed the equation to the following:

With[{u = u[x, t]}, 
 neweq = D[u, t] == Inactive[Div][{{u^2}}.Inactive[Grad][u, {x}], {x}] + 
                    {1}.Inactive[Grad][Sign[x] u, {x}]]

This is the formal PDE for FiniteElement method as far as I can tell, but it doesn't lead to the correct solution. After checking with GetInactivePDE, I found the Inactive[Grad][Sign[x] u, {x}]] term is simply lost in parsing stage:

(* Definition of GetInactivePDE isn't included in this post,
   please find it in the link above. *)
showFormalPDE[a__] := 
  Module[{state}, {state} = NDSolve`ProcessEquations[a];
   GetInactivePDE[state["FiniteElementData"]@"PDECoefficientData", 
      state@"VariableData"] == 0 // Thread];

{bc, ic} = {{u[-7, t] == 0, u[7, t] == 0}, u[x, 0] == Exp[-x^2]};
showFormalPDE[{neweq, ic, bc}, u, {t, 0, 2}, {x, -7, 7}]
(* {Inactive[Div][-{{u[x]^2}} . Inactive[Grad][u[t, x], {x}], {x}] + 
    Derivative[1, 0][u][t, x] == 0} *)

Is this a bug? Or separate Inactive[Grad][……] term in PDE is not allowed at the moment?

Tested on v12.1.1.


Just a simpler sample reflecting the underlying issue:

eq = D[u[x, t], t] == Inactive[Grad][aaaa[x], {x}];
ic = u[x, 0] == 0;
showFormalPDE[{eq, ic}, u, {x, 0, 1}, {t, 0, 2}]
(* {Derivative[1, 0][u][t, x] == 0} *)
$\endgroup$
1
  • $\begingroup$ There is no right definition of inactive form of equation for FEM. This is the problem. $\endgroup$ Commented Sep 23, 2020 at 14:02

1 Answer 1

2
$\begingroup$

No, this is not a bug. You can not have Inactive[Grad][Sign[x] u[x], {x}] you can only have Inactive[Grad][u[x], {x}] the rest needs to go into some coefficient.

$\endgroup$
12
  • $\begingroup$ Oh, I see… but I'd argue that a warning should be generated in this case. $\endgroup$
    – xzczd
    Commented Sep 23, 2020 at 6:09
  • 2
    $\begingroup$ Yes, a warning probably would be good. The problem is when I first wrote that parser I wrote it in a way that would look at the entire equation and then extract the components it recognizes. However, it does not 'subtract' what it recognizes from the argument given and in the end I have no knowledge of what did not get parsed. Trust me I would not do it this way again, but re-writing the parser would be quite a thing. Maybe something in the future. Sorry about that. $\endgroup$
    – user21
    Commented Sep 23, 2020 at 6:14
  • $\begingroup$ It is not clear why we need inactive form of equation for FEM. And also we don't know what is inactive form in every case. $\endgroup$ Commented Sep 23, 2020 at 14:06
  • $\begingroup$ @AlexTrounev Have a look at the documentation. The main point of Inactive is to prevent premature evaluation - that's necessary for a variety of reasons, have a look here, here and here. $\endgroup$
    – user21
    Commented Sep 23, 2020 at 15:26
  • $\begingroup$ @user21 I read documentation during last several years, but I don't understand why we need inactive form at all. Is it connected with some algorithm implemented in NDSolve? $\endgroup$ Commented Sep 23, 2020 at 15:34

Your Answer

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

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