sagemath / sage

Main repository of SageMath
https://www.sagemath.org
Other
1.43k stars 479 forks source link

Introduce periodic coordinates on manifolds #27548

Closed egourgoulhon closed 5 years ago

egourgoulhon commented 5 years ago

This ticket introduces periodic coordinates on manifolds for more flexibility. In particular, this fixes an issue with the azimuthal angle phi being limited to the interval (0,2*pi). For instance, the numerical computation of a geodesic that is winding around the center in Schwarzschild spacetime fails:

sage: M = Manifold(4, 'M', structure='Lorentzian')
sage: X.<t,r,th,ph> = M.chart(r't r:(0,+oo) th:(0,pi):\theta ph:(0,2*pi):\phi')
sage: g = M.metric()
sage: g[0,0], g[1,1] = -(1-2/r), 1/(1-2/r)
sage: g[2,2], g[3,3] = r^2, (r*sin(th))^2
sage: p0 = M((0, 8, pi/2, pi))  # initial point
sage: v0 = M.tangent_space(p0)((1.297, 0, 0, 0.064))  # initial tangent vector
sage: s = var('s')
sage: geod = M.integrated_geodesic(g, (s, 0, 1500), v0)
sage: geod.solve() # numerical integration
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
...
ValueError: the 7th point (initial point being the '0th' point) of the 
numerical solution (obtained for a curve parameter equal to 105.0) is 
out of the chart domain

This is because phi reaches 2*pi at some point in the integration.

With the branch in this ticket, it suffices to declare phi to be a periodic coordinate, by adding the keyword periodic in the chart definition

sage: X.<t,r,th,ph> = M.chart(r't r:(0,+oo) th:(0,pi):\theta ph:(0,2*pi):periodic:\phi')

to allow for the full integration of the geodesic.

The periodicity of the coordinate is taken into account in point comparisons:

sage: M((0, 8, pi/2, pi)) == M((0, 8, pi/2, 3*pi))
True
sage: M((0, 8, pi/2, pi)) == M((0, 8, pi/2, -pi))
True

CC: @tscrim

Component: geometry

Keywords: coordinate chart

Author: Eric Gourgoulhon

Branch/Commit: 1718b1d

Reviewer: Travis Scrimshaw

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

egourgoulhon commented 5 years ago

Branch: public/manifolds/periodic_coords

egourgoulhon commented 5 years ago

Commit: 1d658e0

egourgoulhon commented 5 years ago

New commits:

d27d464Add periodic coordinates in manifold charts
2e2543eTreatment of periodic coordinates in point comparison; add periodic azimuthal coordinate in Euclidean spaces
1d658e0Correct typo in error message in IntegratedCurve.solve()
egourgoulhon commented 5 years ago

Description changed:

--- 
+++ 
@@ -1,5 +1,5 @@
 This ticket introduces periodic coordinates on manifolds for more flexibility. 
-In particular, this fixes an issue with the azimuthal angle phi being limited limited to the interval (0,2*pi). For instance, the numerical computation of a geodesic that is winding around the center in Schwarzschild spacetime fails:
+In particular, this fixes an issue with the azimuthal angle phi being limited to the interval (0,2*pi). For instance, the numerical computation of a geodesic that is winding around the center in Schwarzschild spacetime fails:

sage: M = Manifold(4, 'M', structure='Lorentzian') @@ -28,7 +28,7 @@

 to allow for the full integration of the geodesic.

-The periodicity of the coordinate is taken into account in the point comparison:
+The periodicity of the coordinate is taken into account in point comparisons:

sage: M((0, 8, pi/2, pi)) == M((0, 8, pi/2, 3*pi))

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 5 years ago

Changed commit from 1d658e0 to 1718b1d

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 5 years ago

Branch pushed to git repo; I updated commit sha1. New commits:

1718b1dFix two pyflakes errors in src/sage/manifolds/differentiable
tscrim commented 5 years ago

Reviewer: Travis Scrimshaw

tscrim commented 5 years ago
comment:4

LGTM.

egourgoulhon commented 5 years ago
comment:5

Thanks for the review!

vbraun commented 5 years ago

Changed branch from public/manifolds/periodic_coords to 1718b1d