def _dummy_metric(self): """Make a dummy metric""" cs = coords.toroidal_coords(dim=2) dt, dr = cs.base_oneforms() a, b = symbols('a b') form = a * tpow(dt, 2) + b * tpow(dr, 2) return metric.Metric(twoform=form, components=(a, b))
def test_from_twoform(self): """Test from twoform""" cs = coords.toroidal_coords(dim=2) dt, dr = cs.base_oneforms() a, b = symbols('a b') form = a * tpow(dt, 2) + b * tpow(dr, 2) cs_p = coords.CoordSystem.from_twoform(form) assert cs == cs_p
def 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). """ cs = coords.cartesian_coords() dt, dx, dy, dz = cs.base_oneforms() form = -tpow(dt, 2) + tpow(dx, 2) + tpow(dy, 2) + tpow(dz, 2) return Metric(twoform=form)
def friedmann_lemaitre_roberston_walker(curvature_constant: Symbol = symbols.k, cartesian: bool = False): """Utility for constructing the FLRW metric in terms of a unit lapse and general scale function `a`. Args: 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). """ a = Function('a')(symbols.t) if cartesian: cs = coords.cartesian_coords() dt, dx, dy, dz = cs.base_oneforms() form = -c**2 * tpow( dt, 2) + a**2 * (tpow(dx, 2) + tpow(dy, 2) + tpow(dz, 2)) else: cs = coords.toroidal_coords() _, r, theta, _ = cs.base_symbols() dt, dr, dtheta, dphi = cs.base_oneforms() form = -c**2 * tpow(dt, 2) + a**2 * ( 1 / (1 - curvature_constant * r**2) * tpow(dr, 2) + r**2 * (tpow(dtheta, 2) + sin(theta)**2 * tpow(dphi, 2))) return Metric(twoform=form, components=(a, ))
def test_simplify_deriv_notation(self): """Test simplify deriv notation""" cs = coords.cartesian_coords() t, x, *_ = cs.base_symbols() dt, dx, *_ = cs.base_oneforms() F = Function('F')(t) G = Function('G')(t, x) form = F ** 2 * tpow(dt, 2) + G ** 2 * tpow(dx, 2) g = metric.Metric(twoform=form, components=(F, G)) # Check First-Order Terms assert str(metric.simplify_deriv_notation(D(F, t), g, max_order=1)) == "F'(t)" assert str(metric.simplify_deriv_notation(D(F, t), g, max_order=1, use_dots=True)) == r"\dot{F}(t)" # Check Second-Order Pure Terms assert str(metric.simplify_deriv_notation(D(D(F, t), t), g, max_order=2)) == "F''(t)" assert str(metric.simplify_deriv_notation(D(D(F, t), t), g, max_order=2, use_dots=True)) == r"\ddot{F}(t)" # Check Second-Order Mixed Terms assert str(metric.simplify_deriv_notation(D(D(G, t), t), g, max_order=2)) == "G_{t t}(t, x)" assert str(metric.simplify_deriv_notation(D(D(G, t), x), g, max_order=2)) == "G_{t x}(t, x)"
def 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 """ cs = coords.toroidal_coords() t, r, theta, _ = cs.base_symbols() dt, dr, dtheta, dphi = cs.base_oneforms() # Create generic isotropic metric component functions M = Function('M')(t, r) N = Function('N')(t, r) L = Function('L')(t, r) S = Function('S')(t, r) form = - c ** 2 * N ** 2 * tpow(dt, 2) + \ L ** 2 * tpow(dr + c * M * dt, 2) + \ S ** 2 * (tpow(dtheta, 2) + sin(theta) ** 2 * tpow(dphi, 2)) if use_natural_units: form = constants.subs_natural(form) return Metric(twoform=form, components=(M, N, L, S))