Skip to content

Fix check of orientation in volume form #30519

@egourgoulhon

Description

@egourgoulhon

After the introduction of manifold orientation in #30178, attempting
to get the volume form of a metric on a manifold without any predefined orientation yields a weird error message:

sage: M = Manifold(2, 'M', structure='Riemannian')  # the 2-sphere
sage: U = M.open_subset('U'); V = M.open_subset('V')
sage: M.declare_union(U, V)
sage: c_xy.<x,y> = U.chart() # stereographic coord. from the North pole
sage: c_uv.<u,v> = V.chart() # stereographic coord. from the South pole
sage: xy_to_uv = c_xy.transition_map(c_uv, (x/(x^2+y^2), y/(x^2+y^2)),
....:                intersection_name='W', restrictions1= x^2+y^2!=0,
....:                restrictions2= u^2+v^2!=0)
sage: uv_to_xy = xy_to_uv.inverse()
sage: eU = c_xy.frame(); eV = c_uv.frame()
sage: g = M.metric()
sage: g[eU,0,0], g[eU,1,1] = 4/(1+x^2+y^2)^2, 4/(1+x^2+y^2)^2
sage: g.add_comp_by_continuation(eV, U.intersection(V), chart=c_uv)
sage: g.volume_form()
Traceback (most recent call last):
...
IndexError: list index out of range

This surprising error message (which list index?) is due to a bad check for an orientation in PseudoRiemannianMetric.volume_form(); the fix is

-        if orient is None:
+        if not orient:

Indeed, the attribute _orientation of manifolds is initialized as [], not as None. With the fix, the error message is more expressive:

ValueError: 2-dimensional Riemannian manifold M must admit an orientation

In addition to the above fix, with a new doctest checking it, this ticket corrects some mistake in the documentation illustrating the choice of an orientation on the 2-sphere in the docstring of class PseudoRiemannianMetric:

sage: M.set_orientation([c_xy, c_uv])

does not define a valid orientation because the stereographic frames from the North and South poles have opposite orientations, the Jacobian of the transition map c_xy --> c_uv being negative. It is replaced here by

sage: f = U.vector_frame('f', (eU[2], eU[1]))
sage: M.set_orientation([eV, f])

CC: @mjungmath @tscrim

Component: manifolds

Keywords: orientation, volume_form

Author: Eric Gourgoulhon

Branch/Commit: e7c9d04

Reviewer: Michael Jung

Issue created by migration from https://trac.sagemath.org/ticket/30519

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions