DenseDependenceObject#

class differential_geometry.dependence.DenseDependenceObject(coordinate_system: _CoordinateSystemBase, shape: Sequence[int], /, *, dependent_axes: str | Sequence[str] | None = None)[source]#

Represents a dense symbolic dependence on coordinate axes within a coordinate system.

This class models a scalar or tensor field where every component shares the same symbolic dependence on one or more coordinate axes. In a dense dependence object, the entire field is treated uniformly: all components are assumed to depend on the same subset of coordinate axes (e.g., [“r”, “theta”]). This contrasts with sparse or component-wise symbolic representations where each component could depend on different variables.

DenseDependenceObject supports: - Uniform shape and rank definitions for the symbolic field. - Construction of full symbolic proxies (scalars or tensors). - Element-wise symbolic operations and differential operators. - Dependence introspection and shape-level comparison.

It builds on the abstract DependenceObject base class by adding tensor shape and axis metadata, and it mixes in OperatorsMixin to enable symbolic arithmetic and differential operations.

Notes

The symbolic proxy is lazily constructed using SymPy. For tensor fields, a MutableDenseNDimArray of symbolic functions is used, with each component named based on its index.

Examples

>>> from pymetric.coordinates import SphericalCoordinateSystem
>>> from pymetric.utilities.logging import pg_log
>>> pg_log.disabled = True
>>>
>>> u = SphericalCoordinateSystem() 
>>>
>>> # Construct the dependence
>>> # object.
>>> obj = DenseDependenceObject(u, (3,), dependent_axes=["r", "theta"])
>>> obj.shape
(3,)
>>> obj.depends_on("r")
True
>>> obj.symbolic_proxy  # Returns a symbolic vector field
[T_r(r, theta), T_theta(r, theta), T_phi(r, theta)]

Methods

__init__(coordinate_system, shape, /, *[, ...])

Initialize a dense dependence object with shape and dependent axes.

depends_on(axis)

Check whether this object symbolically depends on a given coordinate axis.

element_wise_gradient(*[, basis, as_field])

Compute the component-wise gradient of the field.

element_wise_laplacian(*[, as_field])

Compute the component-wise Laplacian of the field.

from_symbolic_proxy(coordinate_system, ...)

Reconstruct a DenseDependenceObject from a symbolic proxy expression.

to_symbolic_proxy()

Construct a symbolic proxy representing this tensor or scalar field.

Attributes

axes_symbols

The symbolic representations of the dependent coordinate axes.

coordinate_system

The coordinate system associated with this dependence object.

coordinates_ndim

Number of coordinate dimensions in the associated coordinate system.

dependent_axes

The list of coordinate axis names this field depends on.

is_scalar

Whether this object represents a scalar field (i.e., rank 0).

rank

The tensor rank [number of indices] of this field.

shape

The tensor shape of this symbolic field.

symbolic_proxy

A symbolic proxy field or tensor that represents coordinate dependence.