differential_geometry.dense_ops.dense_vector_divergence_covariant_full#
- differential_geometry.dense_ops.dense_vector_divergence_covariant_full(vector_field: ndarray, Dterm_field: ndarray, inverse_metric_field: ndarray, *varargs, field_axes: Sequence[int] | None = None, derivative_axes: Sequence[int] | None = None, edge_order: Literal[1, 2] = 2, out: ndarray | None = None, **kwargs) ndarray [source]#
Compute the divergence of a covariant vector field in a general coordinate system using a full inverse metric tensor.
This function converts the covariant vector field to its contravariant form by contracting with the inverse metric, and then computes the divergence using:
\[\nabla_i V^i = D_i V^i + \partial_i V^i\]where:
\(V^i = g^{ij} V_j\) is the contravariant form of the input covariant field.
\(D_i = (\partial_i \rho) / \rho\) is the logarithmic derivative of the volume density.
\(\nabla_i V^i\) is the full covariant divergence in curved space.
- Parameters:
vector_field (
numpy.ndarray
) – Contravariant vector field with shape(F_1, ..., F_M, ndim)
, where the final axis corresponds to coordinate directions. The firstm
axes are spatial grid axes. Must be broadcast-compatible with Dterm_field.Dterm_field (
numpy.ndarray
) – D-term array of shape(..., ndim)
, where the last axis matches the number of coordinate directions. Must broadcast with the spatial axes of vector_field.inverse_metric_field (
numpy.ndarray
) – Inverse metric tensor with shape (…, N, N). This is used to raise the index of the covariant field.*varargs –
Grid spacing for each axis. Follows the same format as
numpy.gradient()
, and can be:A single scalar (applied to all spatial axes),
A list of scalars (one per axis),
A list of coordinate arrays (one per axis),
A mix of scalars and arrays (broadcast-compatible).
If derivative_axes is provided, then varargs must match its shape. Otherwise, there must be
M
elements in varargs.field_axes (
list
ofint
, optional) – Maps each grid axis (0 tom-1
) to a corresponding component index in the vector field. Defaults to identity mapping[0, 1, ..., m-1]
.derivative_axes (
list
ofint
, optional) – Grid axes along which to compute partial derivatives. If not specified, all spatial axes listed in field_axes are used.edge_order (
{1, 2}
, default2
) – Accuracy order of finite differences used in derivative computation.out (
numpy.ndarray
, optional) –Optional output buffer into which the result is placed. Specifying out can help to conserve memory.
out should be specified so that it is the broadcast shape of vector_field and Dterm_field excluding the final (component) dimension of each. Thus, if vector_field is
(A,B,1,3)
and Dterm_field is(1,B,C,3)
, out should be(A,B,C)
.**kwargs – Additional keyword arguments passed to the metric contraction routine.
- Returns:
Divergence of the covariant vector field, with shape vector_field.shape[:-1].
- Return type:
See also
dense_vector_divergence_contravariant
Performs divergence on contravariant fields.
dense_contract_with_metric
Raises the index of the vector field via contraction.