coordinates.coordinate_systems.CylindricalCoordinateSystem.get_expression#

CylindricalCoordinateSystem.get_expression(expression_name: str) Symbol | Expr | MutableDenseMatrix | MutableDenseNDimArray | ImmutableDenseMatrix | ImmutableDenseNDimArray#

Retrieve an instance-specific symbolic expression.

Unlike get_class_expression(), this method returns an expression where parameter values have been substituted. The returned expression retains symbolic representations of coordinate axes but replaces any parameter symbols with their numerical values assigned at instantiation.

Parameters:

expression_name (str) – The name of the symbolic expression to retrieve.

Return type:

The symbolic expression with parameters substituted.

Raises:

ValueError – If the expression is not found at either the instance or class level.

Notes

  • This method allows retrieving instance-specific symbolic expressions where numerical parameter values have been applied.

  • If an expression has not been previously computed for the instance, it is derived from the class-level expression and stored in self.__expressions__.

Example

class CylindricalCoordinateSystem(CoordinateSystemBase):
    __AXES__ = ['r', 'theta', 'z']
    __PARAMETERS__ = {'scale': 2}

    @staticmethod
    def __construct_metric_tensor_symbol__(*args, **kwargs):
        return sp.Matrix([[1, 0, 0], [0, args[0]**2, 0], [0, 0, 1]])

coords = CylindricalCoordinateSystem(scale=3)
expr = coords.get_expression('metric_tensor')
print(expr)
Matrix([
    [1, 0, 0],
    [0, r**2, 0],
    [0, 0, 1]
])