2
$\begingroup$

I want to write Navier-Stokes equations in generalised orthogonal frame of reference in Mathematica. I therefore want to expand gradient and other vector calculus operations using metric factors such that Grad[ϕ[x1, x2, x3], {x1, x2, x3}] expands as

$$\nabla \phi = \frac{1}{h_1} \frac{\partial \phi}{\partial x_1} \mathbf i_1 + \frac{1}{h_2} \frac{\partial \phi}{\partial x_2} \mathbf i_2 + \frac{1}{h_3} \frac{\partial \phi}{\partial x_3} \mathbf i_3,$$

where h1, h2 and h3 are maintained in the Mathematica's output so I can express the equations, after simplifying the expansions, in a desired reference frame. I do not really know how to make Mathematica use the metrics h.

Could you provide me with some methodology for this?

$\endgroup$
4
  • $\begingroup$ Mathematica already supports several basis, see Grad for examples. $\endgroup$ Commented Jan 29 at 14:36
  • $\begingroup$ That's true but doesn't really do the trick. I want to have a general expression such that I can define my own, body-fitted, reference frames through the metrics. $\endgroup$
    – dylewiczk
    Commented Jan 29 at 14:44
  • $\begingroup$ Why do you not define your own Gradient, Laplacian.... E.g.` grad= {1/h1 D[#,x1], 1/h2 D[#,x2],1/h3 D[#,x3]}&`. $\endgroup$ Commented Jan 29 at 18:09
  • $\begingroup$ Thanks Daniel, that's a fairly obvious solution that did not cross my mind. Works well! $\endgroup$
    – dylewiczk
    Commented Feb 5 at 8:44

1 Answer 1

2
$\begingroup$

It is possible to define your own coordinate chart according to Is there a way to add my own coordinate chart? In your case

patch = SymbolicTensors`ScaleFactorGeometryPatch[{h1, h2, h3}, {x1, x2, x3}];
Grad[f[x1, x2, x3], {x1, x2, x3}, patch]

It is important to note that h1, h2, h3 will be treated as constants unless you define them as functions of coordinates. Also, you may need to specify $Assumptions = h1 > 0 && h2 > 0 && h3 > 0 to avoid expressions like $\sqrt{h_i^2}$. You can compute Div and Curl the same way by substituting patch in place of chart.

$\endgroup$

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.