differential_geometry.dependence.DenseTensorDependence.divergence#
- DenseTensorDependence.divergence(*, basis: Literal['covariant', 'contravariant'] = 'contravariant', as_field: bool = False)#
Compute the divergence of a rank-1 tensor field.
This is a true tensorial divergence that contracts the covariant derivative with the appropriate metric volume form and raises indices if needed.
- Parameters:
basis (
{"covariant", "contravariant"}
, optional) – Basis in which to compute the divergence.as_field (
bool
, optional) – Whether to return the raw symbolic result or wrap it as a dependence object.
- Returns:
The divergence expression or new dependence object.
- Return type:
_GenericFieldType
or_DepT
- Raises:
ValueError – If the tensor rank is not 1 (i.e., not a vector field).