differential_geometry.symbolic.compute_Dterm#

differential_geometry.symbolic.compute_Dterm(metric_density: Basic, axes: Sequence[Symbol]) ImmutableDenseNDimArray[source]#

Compute the D-term components for a particular coordinate system from the metric density function.

In a general, curvilinear coordinate system, the divergence is

\[\nabla \cdot {\bf F} = \frac{1}{\rho} \partial_\mu(\rho F^\mu) = D_\mu F^\mu + \partial_\mu F^\mu,\]

where

\[D_\mu = \frac{1}{\rho} \partial_\mu \rho.\]

This function therefore computes each of the \(D_\mu\) components.

Parameters:
  • metric_density (Basic) – The metric density function \(\sqrt{{\rm Det} \; g}\).

  • axes (list of Symbol) – The coordinate axes symbols on which to compute the D-terms. There will be len(axes) resulting elements in the output array each corresponding to the \(D_{x^i}\) component of the D-terms.

Returns:

The D-term components.

Return type:

MutableDenseNDimArray

Examples

To compute the \(D_\mu\) components for a spherical coordinate system, we can do the following:

>>> from pymetric.differential_geometry.symbolic import compute_Dterm
>>> import sympy as sp
>>> r,theta,phi = sp.symbols('r,theta,phi')
>>> metric_density = r**2 * sp.sin(theta)
>>> print(compute_Dterm(metric_density, axes=[r,theta,phi]))
[2/r, 1/tan(theta), 0]