Symbolic Field

class mechpy.core.symbolic.field.SymbolicField(coord_system, data, field_params=None, symbols_validation=True)

Bases: object

Represents a symbolic field in a given coordinate system.

Parameters:
  • coord_system (SymbolicCoordSystem) – The coordinate system for the field.

  • data (sp.NDimArray) – The field data.

  • field_params (dict, optional) – Additional field parameters. Defaults to {}.

  • symbols_validation (bool) – If True, validate symbols in the field data. Defaults to True.

Raises:

ValueError – If coord_system is not a SymbolicCoordSystem, data is not a NDimArray, or if field parameters overlap with coordinate system basis symbols.

get_invalid_symbols() set

Get symbols in the field data that are not in the basis or field parameters.

Returns:

A set of invalid symbols.

Return type:

set

subs_field_params(param_values)

Substitute the provided field parameters with specific values, and remove them from self.field_params.

Parameters:

param_values (dict) – A dictionary mapping parameters to their values.

Raises:
  • TypeError – If param_values is not a dictionary.

  • ValueError – If a parameter in param_values is not in self.field_params.

Returns:

None. The method updates self.data and self.field_params in place.

to_cartesian()

Converts the scalar field from its current coordinate system (cylindrical or spherical) to the Cartesian coordinate system.

Raises:

ValueError – If the current coordinate system is not cylindrical or spherical.

Returns:

A new SymbolicField in the Cartesian coordinate system.

Return type:

SymbolicField

to_cylindrical()

Converts the scalar field from its current coordinate system (Cartesian) to the cylindrical coordinate system.

Raises:

NotImplementedError – If the current coordinate system is not Cartesian.

Returns:

A new SymbolicField in the cylindrical coordinate system.

Return type:

SymbolicField

to_spherical()

Converts the scalar field from its current coordinate system (Cartesian) to the spherical coordinate system.

Raises:

NotImplementedError – If the current coordinate system is not Cartesian.

Returns:

A new SymbolicField in the spherical coordinate system.

Return type:

SymbolicField

subs(subs_dict, keys=False)

Deprecated method for substituting values. Raises a warning.

Raises:

DeprecationWarning – This method is deprecated.

class mechpy.core.symbolic.field.SymbolicSpatialField(coord_system, data, field_params=None, symbols_validation=True)

Bases: SymbolicField

lambdify()

Converts the symbolic field data into a lambda function for numerical evaluation. If the field is not in Cartesian coordinates, it first converts it to Cartesian.

class mechpy.core.symbolic.field.SymbolicScalarField(coord_system, data, field_params=None, symbols_validation=True)

Bases: SymbolicSpatialField

shape = (1,)
classmethod create(coord_system=None, data=None, field_params=None)
classmethod create_linear(coord_system=None, data=None, field_params=None)
plot(x_range=(-10, 10), y_range=(-10, 10), z_range=(-10, 10), num_points=20)
class mechpy.core.symbolic.field.SymbolicVectorField(coord_system, data, field_params=None, symbols_validation=True)

Bases: SymbolicSpatialField

shape = (3,)
classmethod create(coord_system=None, data=None, field_params=None, symbols_validation=True)
classmethod create_linear(coord_system=None, data=None, field_params=None)
plot()
class mechpy.core.symbolic.field.SymbolicTensorField(coord_system, data, field_params=None, symbols_validation=True)

Bases: SymbolicSpatialField

shape = (3, 3)
classmethod create_linear(coord_system=None, data=None, field_params=None)