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:
- Returns:
The D-term components.
- Return type:
See also
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]