TransWikia.com

Inactive[Grad] is lost when NDSolve parses PDE

Mathematica Asked on June 9, 2021

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} *)

One Answer

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.

Correct answer by user21 on June 9, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP