pystein.metric module

Utilities for constructing a metric

class pystein.metric.Metric(twoform: Optional[sympy.core.expr.Expr] = None, matrix: Optional[sympy.tensor.array.dense_ndim_array.ImmutableDenseNDimArray] = None, coord_system: Optional[pystein.coords.CoordSystem] = None, components: Optional[Tuple[sympy.core.expr.Expr, ...]] = None)

Bases: object

Metric represents a twoform on a manifold that is symmetric. This class is capable of being created from and converted to both twoform notation and matrix notation given a coordinate system.

angle(vec1, vec2)
inner_product(vec1: List[sympy.core.expr.Expr], vec2: List[sympy.core.expr.Expr])
property inverse

Compute the inverse metric (if possible) and return new Metric instance

property matrix

Safe accessor for matrix

norm(vec: List[sympy.core.expr.Expr])
subs(*args, **kwargs)

Pass thru to twoform substitution

property twoform

Safe accessor for twoform

pystein.metric.flrw(curvature_constant: sympy.core.symbol.Symbol = k, cartesian: bool = False)

Utility for constructing the FLRW metric in terms of a unit lapse and general scale function a.

Parameters
  • curvature_constant – Symbol, default “k”, the curvature parameter in reduced polar coordinates

  • cartesian – bool, default False. If true create a cartesian FLRW and ignore curvature_constant argument

Returns

Metric, the FLRW metric

References

[1] S. Weinberg, Cosmology (Oxford University Press, Oxford ; New York, 2008).

pystein.metric.friedmann_lemaitre_roberston_walker(curvature_constant: sympy.core.symbol.Symbol = k, cartesian: bool = False)

Utility for constructing the FLRW metric in terms of a unit lapse and general scale function a.

Parameters
  • curvature_constant – Symbol, default “k”, the curvature parameter in reduced polar coordinates

  • cartesian – bool, default False. If true create a cartesian FLRW and ignore curvature_constant argument

Returns

Metric, the FLRW metric

References

[1] S. Weinberg, Cosmology (Oxford University Press, Oxford ; New York, 2008).

pystein.metric.general_inhomogeneous_isotropic(use_natural_units: bool = True)

Utility for constructing a general inhomogeneous, but still isotropic, metric (GIIM). The metric components M, N, L, S all depend on time and radius, but not theta or phi (hence isotropy).

Returns

Metric, the GIIM metric

pystein.metric.gii(use_natural_units: bool = True)

Utility for constructing a general inhomogeneous, but still isotropic, metric (GIIM). The metric components M, N, L, S all depend on time and radius, but not theta or phi (hence isotropy).

Returns

Metric, the GIIM metric

pystein.metric.minkowski()

Utility for constructing the Minkowski metric

Returns

Metric, the Minkowski metric for flat space

References

[1] S. Weinberg, Cosmology (Oxford University Press, Oxford ; New York, 2008).

pystein.metric.simplify_deriv_notation(expr: sympy.core.expr.Expr, metric: pystein.metric.Metric, max_order: int = 2, use_dots: bool = False)

Utility for Simplifying LaTeX representation of a sympy Expression via substitutions. Note that this function simplifies the LaTeX output of the Expr at the cost of the Expr semantics, only use this after all operations on the Expr (including simplification) have been performed.

Parameters
  • expr – Expr, the sympy expression

  • metric – Metric, the metric containing components whose derivatives will be simplified

  • max_order – int, default 2, the max derivative order to replace

  • use_dots – bool, default False. If True use dot notation for derivatives of single-variable functions

Returns

Expr, the modified expression. Recall this is only useful for LaTeX conversion, not semantically valid in sympy.