I am currently looking into a way of being able to easily non-dimensionalise differential equations (such as the Navier-Stokes equation) in Mathematica, so that I can then seek an asymptotic expansion as a solution and derive leading-order equations.

I have found, through here, some code that displays anything involving partial derivatives in a much more natural way, akin to how we would write it down on paper. I have had some success with this, and gotten it to work with some things. The version of the code I have has been modified (not by me, as I am relatively new to Mathematica) in an attempt to suppress arguments of functions not attached to partial derivatives.

pdConv[expr_] := 
  fns = DeleteDuplicates[
    Cases[expr, Derivative[__][g__][__] :> g, Infinity]];
   expr /. {Derivative[inds__][g_][vars__] :> 
      Apply[Defer[D[g, ##]] &, 
       Transpose[{{vars}, {inds}}] /. {{var_, 0} :> 
          Sequence[], {var_, 1} :> {var}}], 
     a_[__] :> a /; MemberQ[fns, a]}]]

By running the following code, in an attempt to non-dimensionalise an equation which looks like the Navier-Stokes equation (bar some constants), and nondimensionalising it:

enter image description here

I am converting the equation from dimensional variables (subscripted with "d") to dimensionless variables (no subscript). Whilst the desirable algebraic procedure has been carried out, it is infuriating to see that the variables with respect to which the derivatives are being carried out are not fully simplified.

This happens for very simple expressions as well: enter image description here

The 2 should be outside, but it shouldn't be inside the partial derivative at the bottom.

Can anyone suggest a simple remedy for this, so that (a) either the chain rule is applied, or (b) the partial derivatives are formatted correctly once they are computed?

  • $\begingroup$ Have you tried DChange? $\endgroup$ – xzczd Dec 3 '19 at 5:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy