OrthogonalCoordinateSystem#
- class coordinates.core.OrthogonalCoordinateSystem(**kwargs)[source]#
Base class for orthogonal curvilinear coordinate systems.
This class provides the foundational symbolic and numerical machinery for defining and working with orthogonal coordinate systems—those in which the metric tensor is diagonal and basis vectors are mutually perpendicular. It supports automatic symbolic generation of differential geometry operators such as the gradient, divergence, and Laplacian, as well as index manipulation utilities for raising and lowering tensor components.
Subclasses should define the coordinate axes and parameter set via the
__AXES__
and__PARAMETERS__
class attributes, and must implement the__construct_metric_tensor_symbol__
method to specify the diagonal components of the metric tensor symbolically.Coordinate systems may be initialized lazily (at instance creation) or eagerly (at import time) depending on the
__setup_point__
class attribute. Most systems should use lazy setup for performance.Features#
Symbolic and numeric computation of metric, inverse metric, and metric density
Raising and lowering of tensor indices using orthogonal metric contractions
Computation of gradient, divergence, and Laplacian in both covariant and contravariant bases
Automatic handling of coordinate slices via fixed_axes
Support for symbolic dependence analysis for field operations
Notes
This class assumes that the metric tensor is diagonal, as is true for all orthogonal systems. Mixed metric components (i.e., \(g_{ij}\) for \(i \\ne j\)) are assumed to be zero.
Methods
__init__
(**kwargs)Initialize a coordinate system instance with specific parameter values.
adjust_dense_tensor_signature
(tensor_field, ...)Raise and/or lower multiple tensor slots in one call.
axes_complement
(axes)Return all axes in the coordinate system that are not present in axes.
build_axes_mask
(axes)Construct a boolean mask array indicating which axes are in
axes
.compute_expression
(expression, coordinates)Evaluate a named symbolic expression over mixed coordinate inputs.
compute_expression_from_coordinates
(...[, ...])Evaluate a named expression over 1D coordinate arrays with optional fixed axes.
compute_function_from_coordinates
(func, ...)Evaluate a function over 1D coordinate arrays with optional fixed axes.
convert_axes_to_indices
(axes)Convert axis name(s) to their corresponding index or indices.
convert_indices_to_axes
(axes_indices)Convert axis index or indices to their corresponding axis name(s).
convert_to
(target_system, *native_coords)Convert coordinates from this system to another coordinate system via Cartesian intermediate.
coordinate_meshgrid
(*coordinate_arrays[, ...])Construct a coordinate-aligned meshgrid from 1D coordinate arrays.
create_coordinate_list
(coordinate_arrays, /)Assemble a list of coordinate components (arrays or scalars) in canonical axis order.
from_cartesian
(*coords)Convert Cartesian coordinates to native coordinates in this system.
from_hdf5
(filename[, group_name, registry])Save this coordinate system to HDF5.
get_axes_from_mask
(mask)Convert a boolean axis mask into a list of axis names.
get_axes_latex
(axes)Return the LaTeX representation(s) of one or more axis names.
get_axes_order
(src_axes, dst_axes)Compute the reordering indices that will reorder src_axes into the order of dst_axes.
get_axes_permutation
(src_axes, dst_axes)Compute the permutation needed to reorder src_axes into dst_axes.
get_axes_units
(unit_system)Resolve the physical units for each axis in a given unit system.
get_canonical_axes_order
(src_axes)Compute the permutation indices to reorder src_axes into sorted alphabetical order.
Compute the permutation needed to reorder axes into the canonical order defined by the coordinate system.
get_class_expression
(expression_name)Retrieve a derived expression for this coordinate system by name.
get_conversion_transform
(other)Construct a coordinate transformation function that maps native coordinates from this coordinate system to the target coordinate system.
get_expression
(expression_name)Retrieve an instance-specific symbolic expression.
get_free_fixed
([axes, fixed_axes])Split a list of coordinate axes into fixed and free components.
get_indices_from_mask
(mask)Convert a boolean mask of length
ndim
back to numeric indices.get_mask_from_axes
(axes)Return a boolean mask of shape
(ndim,)
with True on the positions corresponding toaxes
.get_mask_from_indices
(indices)Boolean mask that is True at the supplied numeric indices.
get_numeric_expression
(expression_name)Retrieve a numerically evaluable version of a coordinate system expression given the expression name.
has_class_expression
(expression_name)Check if the coordinate system has a specific expression registered to it.
has_expression
(expression_name)Check if a symbolic expression is registered at the instance level.
in_axes_order
(iterable, src_axes, dst_axes)Reorder a sequence of values from src_axes order to dst_axes order.
in_canonical_order
(iterable, src_axes)Reorder a sequence of values from src_axes order to canonical axis order.
insert_fixed_axes
(iterable, src_axes[, ...])Insert fixed axis values into an iterable of values according to canonical axis order.
is_axes_subset
(axes_a, axes_b)Check if axes_a is a subset of axes_b.
is_axes_superset
(axes_a, axes_b)Check if axes_a is a superset of axes_b.
is_axis
(axis)Check whether the given axis name(s) exist in this coordinate system.
lambdify_expression
(expression)Convert a symbolic expression into a callable function.
List the available coordinate system expressions.
List the available instance-level expressions.
lower_index_dense
(tensor_field, index, rank, ...)Lower a single tensor index using \(g_{ab}\).
order_axes
(src_axes, dst_axes)Reorder src_axes into the order defined by dst_axes.
order_axes_canonical
(src_axes)Reorder a list of axis names into the canonical order of this coordinate system.
pprint
()Print a detailed description of the coordinate system, including its axes, parameters, and expressions.
raise_index_dense
(tensor_field, index, rank, ...)Raise a single tensor index using \(g^{ab}\).
requires_expression
(value, expression, ...)Return value if not None; otherwise evaluate compute_expression.
requires_expression_from_coordinates
(value, ...)Return value if not None; otherwise evaluate compute_expression_from_coordinates.
resolve_axes
([axes, require_subset, ...])Normalize and validate a user-supplied list of axis names.
set_expression
(expression_name, expression)Set a symbolic expression at the instance level.
substitute_expression
(expression)Replace symbolic parameters with numerical values in an expression.
to_cartesian
(*coords)Convert native coordinates to Cartesian coordinates.
to_hdf5
(filename[, group_name, overwrite])Save this coordinate system to HDF5.
Attributes
The axes names present in this coordinate system.
Return the symbolic physical dimensions associated with each axis.
The symbols representing each of the coordinate axes in this coordinate system.
Returns the callable function for the inverse metric tensor of the coordinate system.
The symbolic inverse metric tensor for this coordinate system instance.
Returns the callable function for the metric tensor of the coordinate system.
The symbolic array representing the metric tensor.
The number of dimensions spanned by this coordinate system.
Get the symbolic representations of the coordinate system parameters.
The parameters of this coordinate system.