Skip to content
This repository was archived by the owner on Jan 30, 2023. It is now read-only.

Commit b78d8a2

Browse files
committed
#30362: fix merge conflict
2 parents c5af195 + 8ca1724 commit b78d8a2

18 files changed

+1839
-73
lines changed

src/doc/en/reference/manifolds/index.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ More documentation (in particular example worksheets) can be found
1919

2020
riem_manifold
2121

22+
poisson_manifold
23+
2224
sage/manifolds/utilities
2325

2426
sage/manifolds/catalog
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Poisson Manifolds
2+
=================
3+
4+
.. toctree::
5+
:maxdepth: 3
6+
7+
sage/manifolds/differentiable/poisson_tensor
8+
9+
sage/manifolds/differentiable/symplectic_form
10+
11+
sage/manifolds/differentiable/examples/symplectic_space

src/doc/en/reference/references/index.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,9 @@ REFERENCES:
216216
.. [AM1969] \M. F. Atiyah and I. G. Macdonald, "Introduction to commutative
217217
algebra", Addison-Wesley, 1969.
218218
219+
.. [AM1990] \R. Abraham and J. E. Marsden, "Foundations of Mechanics",
220+
Addison-Wesley, 1980.
221+
219222
.. [AM1974] \J. F. Adams and H. R. Margolis, "Sub-Hopf-algebras of the
220223
Steenrod algebra," Proc. Cambridge Philos. Soc. 76 (1974),
221224
45-52.
@@ -4949,6 +4952,9 @@ REFERENCES:
49494952
.. [RSS] :wikipedia:`Residual_sum_of_squares`, accessed 13th
49504953
October 2009.
49514954
4955+
.. [RS2012] G. Rudolph and M. Schmidt, "Differential Geometry and Mathematical Physics.
4956+
Part I. Manifolds, Lie Groups and Hamiltonian Systems", Springer, 2012.
4957+
49524958
.. [RSW2011] Victor Reiner, Franco Saliola, Volkmar Welker.
49534959
*Spectra of Symmetrized Shuffling Operators*.
49544960
:arxiv:`1102.2460v2`.

src/sage/manifolds/catalog.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@
3636
_lazy_import('sage.manifolds.differentiable.examples.real_line', 'RealLine')
3737
_lazy_import('sage.manifolds.differentiable.examples.euclidean', 'EuclideanSpace')
3838
_lazy_import('sage.manifolds.differentiable.examples.sphere', 'Sphere')
39+
_lazy_import(
40+
"sage.manifolds.differentiable.examples.symplectic_space", "StandardSymplecticSpace"
41+
)
42+
3943

4044
def Minkowski(positive_spacelike=True, names=None):
4145
"""

src/sage/manifolds/differentiable/diff_form.py

Lines changed: 64 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,17 @@
4444
# https://www.gnu.org/licenses/
4545
# *****************************************************************************
4646

47+
from __future__ import annotations
48+
from typing import Union, TYPE_CHECKING
4749
from sage.misc.cachefunc import cached_method
4850
from sage.tensor.modules.free_module_alt_form import FreeModuleAltForm
4951
from sage.manifolds.differentiable.tensorfield import TensorField
5052
from sage.manifolds.differentiable.tensorfield_paral import TensorFieldParal
5153

54+
if TYPE_CHECKING:
55+
from sage.manifolds.differentiable.metric import PseudoRiemannianMetric
56+
from sage.manifolds.differentiable.symplectic_form import SymplecticForm
57+
5258

5359
class DiffForm(TensorField):
5460
r"""
@@ -441,21 +447,25 @@ def exterior_derivative(self):
441447
True
442448
443449
"""
444-
from sage.tensor.modules.format_utilities import (format_unop_txt,
445-
format_unop_latex)
450+
from sage.tensor.modules.format_utilities import (
451+
format_unop_txt,
452+
format_unop_latex,
453+
)
454+
446455
vmodule = self._vmodule # shortcut
447-
rname = format_unop_txt('d', self._name)
448-
rlname = format_unop_latex(r'\mathrm{d}', self._latex_name)
449-
resu = vmodule.alternating_form(self._tensor_rank + 1, name=rname,
450-
latex_name=rlname)
456+
rname = format_unop_txt("d", self._name)
457+
rlname = format_unop_latex(r"\mathrm{d}", self._latex_name)
458+
resu = vmodule.alternating_form(
459+
self._tensor_rank + 1, name=rname, latex_name=rlname
460+
)
451461
for dom, rst in self._restrictions.items():
452462
resu._restrictions[dom] = rst.exterior_derivative()
453463
return resu
454464

455465
derivative = exterior_derivative # allows one to use functional notation,
456466
# e.g. diff(a) for a.exterior_derivative()
457467

458-
def wedge(self, other):
468+
def wedge(self, other: DiffForm) -> DiffForm:
459469
r"""
460470
Exterior product with another differential form.
461471
@@ -603,13 +613,16 @@ def degree(self):
603613
"""
604614
return self._tensor_rank
605615

606-
def hodge_dual(self, metric=None):
616+
def hodge_dual(
617+
self,
618+
nondegenerate_tensor: Union[PseudoRiemannianMetric, SymplecticForm, None] = None,
619+
) -> DiffForm:
607620
r"""
608-
Compute the Hodge dual of the differential form with respect to some
609-
metric.
621+
Compute the Hodge dual of the differential form with respect to some non-degenerate
622+
bilinear form (Riemannian metric or symplectic form).
610623
611624
If the differential form is a `p`-form `A`, its *Hodge dual* with
612-
respect to a pseudo-Riemannian metric `g` is the
625+
respect to the non-degenerate form `g` is the
613626
`(n-p)`-form `*A` defined by
614627
615628
.. MATH::
@@ -624,9 +637,10 @@ def hodge_dual(self, metric=None):
624637
625638
INPUT:
626639
627-
- ``metric``: a pseudo-Riemannian metric defined on the same manifold
640+
- ``nondegenerate_tensor``: a non-degenerate bilinear form defined on the same manifold
628641
as the current differential form; must be an instance of
629-
:class:`~sage.manifolds.differentiable.metric.PseudoRiemannianMetric`.
642+
:class:`~sage.manifolds.differentiable.metric.PseudoRiemannianMetric` or
643+
:class:`~sage.manifolds.differentiable.symplectic_form.SymplecticForm`.
630644
If none is provided, the ambient domain of ``self`` is supposed to be endowed
631645
with a default metric and this metric is then used.
632646
@@ -731,10 +745,43 @@ def hodge_dual(self, metric=None):
731745
See the documentation of
732746
:meth:`~sage.manifolds.differentiable.metric.PseudoRiemannianMetric.hodge_star`
733747
for more examples.
748+
749+
TESTS:
750+
Fall back to use (ambient) metric::
751+
752+
sage: M = Manifold(3, 'M', start_index=1, structure='Riemannian')
753+
sage: X.<x,y,z> = M.chart()
754+
sage: g = M.metric()
755+
sage: g[1,1], g[2,2], g[3,3] = 1, 1, 1
756+
sage: var('Ax Ay Az')
757+
(Ax, Ay, Az)
758+
sage: a = M.one_form(Ax, Ay, Az, name='A')
759+
sage: a.hodge_dual().display()
760+
*A = Az dx∧dy - Ay dx∧dz + Ax dy∧dz
734761
"""
735-
if metric is None:
736-
metric = self._vmodule._ambient_domain.metric()
737-
return metric.hodge_star(self)
762+
from sage.functions.other import factorial
763+
from sage.tensor.modules.format_utilities import (
764+
format_unop_txt,
765+
format_unop_latex,
766+
)
767+
768+
if nondegenerate_tensor is None:
769+
nondegenerate_tensor = self._vmodule._ambient_domain.metric()
770+
771+
p = self.tensor_type()[1]
772+
eps = nondegenerate_tensor.volume_form(p)
773+
if p == 0:
774+
common_domain = nondegenerate_tensor.domain().intersection(self.domain())
775+
result = self.restrict(common_domain) * eps.restrict(common_domain)
776+
else:
777+
result = self.contract(*range(p), eps, *range(p))
778+
if p > 1:
779+
result = result / factorial(p)
780+
result.set_name(
781+
name=format_unop_txt("*", self._name),
782+
latex_name=format_unop_latex(r"\star ", self._latex_name),
783+
)
784+
return result
738785

739786
def interior_product(self, qvect):
740787
r"""
@@ -1506,6 +1553,7 @@ def wedge(self, other):
15061553
other_r = other.restrict(dom_resu)
15071554
return FreeModuleAltForm.wedge(self_r, other_r)
15081555

1556+
15091557
def interior_product(self, qvect):
15101558
r"""
15111559
Interior product with a multivector field.
Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
r"""
2+
Symplectic vector spaces
3+
4+
AUTHORS:
5+
6+
- Tobias Diez (2021): initial version
7+
8+
"""
9+
10+
# *****************************************************************************
11+
# Copyright (C) 2020 Tobias Diez
12+
#
13+
# Distributed under the terms of the GNU General Public License (GPL)
14+
# as published by the Free Software Foundation; either version 2 of
15+
# the License, or (at your option) any later version.
16+
# https://www.gnu.org/licenses/
17+
# *****************************************************************************
18+
from __future__ import annotations
19+
20+
from typing import Optional, Tuple
21+
22+
from sage.categories.manifolds import Manifolds
23+
from sage.manifolds.differentiable.examples.euclidean import EuclideanSpace
24+
from sage.manifolds.differentiable.symplectic_form import (SymplecticForm,
25+
SymplecticFormParal)
26+
from sage.rings.real_mpfr import RR
27+
28+
29+
class StandardSymplecticSpace(EuclideanSpace):
30+
r"""
31+
The vector space `\RR^{2n}` equipped with its standard symplectic form.
32+
"""
33+
34+
_symplectic_form: SymplecticForm
35+
36+
def __init__(
37+
self,
38+
dimension: int,
39+
name: Optional[str] = None,
40+
latex_name: Optional[str] = None,
41+
coordinates: str = "Cartesian",
42+
symbols: Optional[str] = None,
43+
symplectic_name: Optional[str] = "omega",
44+
symplectic_latex_name: Optional[str] = None,
45+
start_index: int = 1,
46+
base_manifold: Optional[StandardSymplecticSpace] = None,
47+
names: Optional[Tuple[str]] = None,
48+
):
49+
r"""
50+
INPUT:
51+
52+
- ``dimension`` -- dimension of the space over the real field (has to be even)
53+
- ``name`` -- name (symbol) given to the underlying vector space;
54+
if ``None``, the name will be set to ``'Rn'``, where ``n`` is the ``dimension``
55+
- ``latex_name`` -- LaTeX symbol to denote the underlying vector space; if ``None``, it is set to ``name``
56+
- ``coordinates`` -- (default: ``'Cartesian'``) the
57+
type of coordinates to be initialized at the Euclidean space
58+
creation; allowed values are
59+
60+
- ``'Cartesian'`` (canonical coordinates on `\RR^{2n}`)
61+
- ``'polar'`` for ``dimension=2`` only (see
62+
:meth:`~sage.manifolds.differentiable.examples.euclidean.EuclideanPlane.polar_coordinates`)
63+
64+
- ``symbols`` -- the coordinate text symbols and LaTeX symbols, with the same conventions as the
65+
argument ``coordinates`` in :class:`~sage.manifolds.differentiable.chart.RealDiffChart`, namely
66+
``symbols`` is a string of coordinate fields separated by a blank
67+
space, where each field contains the coordinate's text symbol and
68+
possibly the coordinate's LaTeX symbol (when the latter is different
69+
from the text symbol), both symbols being separated by a colon
70+
(``:``); if ``None``, the symbols will be automatically generated
71+
according to the value of ``coordinates``
72+
- ``symplectic_name`` -- name (symbol) given to the symplectic form
73+
- ``symplectic_latex_name`` -- LaTeX symbol to denote the symplectic form;
74+
if none is provided, it is set to ``symplectic_name``
75+
- ``start_index`` -- lower value of the range of
76+
indices used for "indexed objects" in the vector space, e.g.
77+
coordinates of a chart
78+
- ``base_manifold`` -- if not ``None``, the created object is then an open subset
79+
of ``base_manifold``
80+
- ``names`` -- (default: ``None``) unused argument, except if
81+
``symbols`` is not provided; it must then be a tuple containing
82+
the coordinate symbols (this is guaranteed if the shortcut operator
83+
``<,>`` is used)
84+
If ``names`` is specified, then ``dimension`` does not have to be specified.
85+
86+
EXAMPLES:
87+
88+
Standard symplectic form on `\RR^2`::
89+
90+
sage: M.<q, p> = manifolds.StandardSymplecticSpace(2, symplectic_name='omega')
91+
sage: omega = M.symplectic_form()
92+
sage: omega.display()
93+
omega = -dq∧dp
94+
"""
95+
# Check that manifold is even dimensional
96+
if dimension % 2 == 1:
97+
raise ValueError(
98+
f"the dimension of the manifold must be even but it is {dimension}"
99+
)
100+
dim_half = dimension // 2
101+
102+
if names is not None and symbols is None:
103+
symbols = " ".join(names)
104+
105+
if symbols is None:
106+
if dim_half == 1:
107+
symbols = r"q:q p:p"
108+
else:
109+
symbols_list = [
110+
f"q{i}:q^{i} p{i}:p_{i}" for i in range(1, dim_half + 1)
111+
]
112+
symbols = " ".join(symbols_list)
113+
114+
if name is None:
115+
name = f"R{dimension}"
116+
117+
category = Manifolds(RR).Smooth()
118+
119+
EuclideanSpace.__init__(
120+
self,
121+
dimension,
122+
name,
123+
latex_name=latex_name,
124+
coordinates=coordinates,
125+
symbols=symbols,
126+
start_index=start_index,
127+
base_manifold=base_manifold,
128+
category=category,
129+
init_coord_methods=None,
130+
)
131+
132+
self._symplectic_form = SymplecticFormParal(
133+
self, symplectic_name, symplectic_latex_name
134+
)
135+
for i in range(0, dim_half):
136+
q_index = 2 * i + 1
137+
self._symplectic_form.set_comp()[q_index, q_index + 1] = -1
138+
139+
def _repr_(self):
140+
r"""
141+
Return a string representation of ``self``.
142+
143+
EXAMPLES::
144+
145+
sage: V.<q, p> = manifolds.StandardSymplecticSpace(2, symplectic_name='omega'); V
146+
Standard symplectic space R2
147+
"""
148+
return f"Standard symplectic space {self._name}"
149+
150+
def symplectic_form(self) -> SymplecticForm:
151+
r"""
152+
Return the symplectic form.
153+
154+
EXAMPLES:
155+
156+
Standard symplectic form on `\RR^2`::
157+
158+
sage: M.<q, p> = manifolds.StandardSymplecticSpace(2, symplectic_name='omega')
159+
sage: omega = M.symplectic_form()
160+
sage: omega.display()
161+
omega = -dq∧dp
162+
"""
163+
return self._symplectic_form
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import sage.all
2+
from sage.manifolds.differentiable.symplectic_form import SymplecticForm
3+
from sage.manifolds.differentiable.examples.symplectic_space import (
4+
StandardSymplecticSpace,
5+
)
6+
import pytest
7+
8+
9+
class TestR2VectorSpace:
10+
@pytest.fixture
11+
def M(self):
12+
return StandardSymplecticSpace(2, "R2", symplectic_name="omega")
13+
14+
@pytest.fixture
15+
def omega(self, M: StandardSymplecticSpace):
16+
return M.symplectic_form()
17+
18+
def test_repr(self, M: StandardSymplecticSpace):
19+
assert str(M) == "Standard symplectic space R2"
20+
21+
def test_display(self, omega: SymplecticForm):
22+
assert str(omega.display()) == r"omega = -dq∧dp"
23+
24+
25+
class TestR4VectorSpace:
26+
@pytest.fixture
27+
def M(self):
28+
return StandardSymplecticSpace(4, "R4", symplectic_name="omega")
29+
30+
@pytest.fixture
31+
def omega(self, M: StandardSymplecticSpace):
32+
return M.symplectic_form()
33+
34+
def test_repr(self, M: StandardSymplecticSpace):
35+
assert str(M) == "Standard symplectic space R4"
36+
37+
def test_display(self, omega: SymplecticForm):
38+
assert str(omega.display()) == r"omega = -dq1∧dp1 - dq2∧dp2"

0 commit comments

Comments
 (0)