Opened 23 months ago
Last modified 19 months ago
#24623 closed enhancement
Euclidean spaces and vector calculus — at Version 27
Reported by:  egourgoulhon  Owned by:  

Priority:  major  Milestone:  sage8.3 
Component:  geometry  Keywords:  Euclidean space, vector calculus, gradient, divergence, curl, Laplacian 
Cc:  tmonteil  Merged in:  
Authors:  Eric Gourgoulhon  Reviewers:  
Report Upstream:  N/A  Work issues:  
Branch:  public/manifolds/Euclidean_spaces (Commits)  Commit:  de74bb734f9f531bb6d991b14af20e58e6ebd683 
Dependencies:  #24622, #24792  Stopgaps: 
Description (last modified by )
This ticket implements Euclidean spaces as Riemannian manifolds diffeomorphic to R^{n} and equipped with a flat metric, which defines the Euclidean dot product. Using the operators introduced in #24622, this provides the standard operators of vector calculus: dot product, norm, cross product, gradient, divergence, curl and Laplacian, along with the standard coordinate systems (Cartesian, spherical, cylindrical, etc.).
See this ask.sagemath question for a motivation.
The implementation is performed via the parent class EuclideanSpaceGeneric
, which inherits from PseudoRiemannianManifold
(introduced in #24622). Two subclasses are devoted to specific cases:
EuclideanPlane
for n=2Euclidean3dimSpace
for n=3
The user interface for constructing an Euclidean space relies on a single function: EuclideanSpace
.
The implementation through the manifold framework allows for an easy use of various coordinate systems, along with the related transformations. However, the user interface does not assume any knowledge of Riemannian geometry. In particular, no direct manipulation of the metric tensor is required.
A minimal example is
sage: E.<x,y,z> = EuclideanSpace(3) sage: v = E.vector_field(y, x, 0) sage: v.display() y e_x + x e_y sage: v[:] [y, x, 0] sage: w = v.curl() sage: w.display() 2 e_z sage: w[:] [0, 0, 2]
The transformation to spherical coordinates:
sage: spherical.<r,th,ph> = E.spherical_coordinates() sage: spherical_frame = E.spherical_frame() # orthonormal frame (e_r, e_th, e_ph) sage: v.display(spherical_frame) sqrt(x^2 + y^2) e_ph sage: v.display(spherical_frame, spherical) r*sin(th) e_ph sage: v[spherical_frame, :, spherical] [0, 0, r*sin(th)] sage: w.display(spherical_frame, spherical) 2*cos(th) e_r  2*sin(th) e_th sage: w[spherical_frame, :, spherical] [2*cos(th), 2*sin(th), 0]
More detailed examples are in the following Jupyter notebooks:
 vector calculus in Cartesian coordinates
 vector calculus in spherical coordinates
 vector calculus in cylindrical coordinates
 changing coordinates in the Euclidean 3space
 Advanced aspects: Euclidean spaces as Riemannian manifolds
 the Euclidean plane
This work is part of the SageManifolds project, see #18528 for an overview.
Change History (27)
comment:1 Changed 23 months ago by
 Description modified (diff)
comment:2 Changed 23 months ago by
 Description modified (diff)
comment:3 Changed 23 months ago by
 Cc tmonteil added
comment:4 Changed 22 months ago by
 Branch set to public/manifolds/Euclidean_spaces
 Commit set to 4bf802027ddd8178ab17efa692bda2d877e0f8d6
comment:5 Changed 22 months ago by
 Dependencies changed from #24622 to #24622, #24792
#24792 introduces more flexibility in naming the elements of vector frames, for instance using (e_x, e_y, e_z)
for a coordinate frame instead of (d/dx, d/dy, d/dz)
. The current ticket will therefore be build on it for a better user interface.
comment:6 Changed 22 months ago by
 Commit changed from 4bf802027ddd8178ab17efa692bda2d877e0f8d6 to f24a5f96a25d12b75c9d98a1b6749513673b4faa
Branch pushed to git repo; I updated commit sha1. New commits:
a527e8e  First draft adding more flexibility in symbols of free module bases and vector frames

2d43a23  More refactoring in vector frames

0840d54  More work on vector frames

01681b8  Add documentation for new options of vector frames

f24a5f9  Merge branch 'public/manifolds/Euclidean_spaces' of git://trac.sagemath.org/sage into public/manifolds/more_basis_flexibility (branch of #24792)

comment:7 Changed 22 months ago by
 Commit changed from f24a5f96a25d12b75c9d98a1b6749513673b4faa to d9302b65668e7f62b54306c4e4c916c73c72dc31
Branch pushed to git repo; I updated commit sha1. New commits:
d9302b6  Add documentation and doctests for Euclidean spaces

comment:8 followups: ↓ 9 ↓ 26 Changed 22 months ago by
I wonder whether some of this (in terms of the div/grad/curl) could be exposed in the symbolic calculus places, at least with some wellplaced and wellformed examples that would be understandable to someone teaching Calc III to engineers (in the US framework) who may not be a differential geometer.
comment:9 in reply to: ↑ 8 Changed 22 months ago by
Replying to kcrisman:
I wonder whether some of this (in terms of the div/grad/curl) could be exposed in the symbolic calculus places, at least with some wellplaced and wellformed examples that would be understandable to someone teaching Calc III to engineers (in the US framework) who may not be a differential geometer.
Indeed, the aim here is to provide some interface which does not require any knowledge of differential geometry on manifolds. The class EuclideanSpaceGeneric
does inherit from PseudoRiemannianManifold
, but the end user has not to know it if he is not interested by this aspect and prefers to focus on vector calculus. Regarding examples, I plan to prepare some Jupyter notebooks and will expose them here, when the ticket is ready for review. Already, you can have a glimpse of the div/grad/curl capabilities introduced in the dependency #24622 in this notebook.
comment:10 followup: ↓ 11 Changed 22 months ago by
That's great! The reason I brought it up is because folders like sage/calculus
and sage/symbolic
might benefit from some good examples that are easy to find.
Is there a way to use something like (say) vector([x^2+y,y^2+z,z^2+x])
as "vector field" immediately, without much (or any) of the formalism necessary in that notebook? I think that is how most end users I've talked to about this issue would want it. See e.g. https://ask.sagemath.org/question/10104/gradientdivergencecurlandvectorproducts/ and ticket:3021 for one version already in Sage  maybe these should be combined somehow, if possible.
comment:11 in reply to: ↑ 10 Changed 22 months ago by
Replying to kcrisman:
Is there a way to use something like (say)
vector([x^2+y,y^2+z,z^2+x])
as "vector field" immediately, without much (or any) of the formalism necessary in that notebook?
Yes, this is precisely the aim of the current ticket. The above notebook is still at the level of semiRiemannian manifolds (i.e. it illustrates only ticket #24622), while the user interface of the current ticket will be much simpler. It should also provide an easy way to change from Cartesian coordinates to e.g. polar or cylindrical ones.
See e.g. https://ask.sagemath.org/question/10104/gradientdivergencecurlandvectorproducts/ and ticket:3021 for one version already in Sage  maybe these should be combined somehow, if possible.
Thanks for pointing this version; I was not aware of it.
comment:12 Changed 22 months ago by
 Commit changed from d9302b65668e7f62b54306c4e4c916c73c72dc31 to 56a1a4a37f60f8f61ba8da18ece1e281c6c07aa9
Branch pushed to git repo; I updated commit sha1. New commits:
9ddc467  Add method set_name to classes VectorFrame and CoFrame

82c37b4  Cut long lines in src/sage/manifolds/differentiable/vectorframe.py

95b2736  Merge branch 'public/manifolds/more_basis_flexibility' of git://trac.sagemath.org/sage into Euclidean (to get latest version of the dependency #24792)

56a1a4a  Add method vector_field to Euclidean spaces + internal changes regarding charts and frames

comment:13 Changed 22 months ago by
 Commit changed from 56a1a4a37f60f8f61ba8da18ece1e281c6c07aa9 to 70a2a749c2d5c07a85182c0d51fdc9f16d050b01
Branch pushed to git repo; I updated commit sha1. New commits:
799066b  List entries of VectorFrame processed by __classcall_private__

da06d12  Small improvement in treatment of symbol attributes of free module bases

244c1f4  Merge branch 'public/manifolds/more_basis_flexibility' into 'public/manifolds/Euclidean_spaces' to get the latest version of dependency #24792 in #24623.

70a2a74  Vector fields on Euclidean spaces can be initialized from a vector of symbolic expressions

comment:14 Changed 22 months ago by
 Description modified (diff)
comment:15 Changed 22 months ago by
Here is some status update: functionalities regarding the 2dimensional case are almost complete, as you can see in this demo worksheet (any feedback is of course appreciated). The 3dimensional case is under preparation. The generic ndimensional case, with n=1 or n>=4 is ready, since only Cartesian coordinates will be introduced (by default) in this case.
Regarding a question raised in comment:10, it is now possible to construct a vector field on an Euclidean space from a vector
of symbolic expressions like this:
v = E.vector_field(vector([y,x]))
where E
is the underlying Euclidean space.
comment:16 Changed 21 months ago by
 Commit changed from 70a2a749c2d5c07a85182c0d51fdc9f16d050b01 to 6e9fce6b191d1d1fcf84153ea90478c444687703
Branch pushed to git repo; I updated commit sha1. New commits:
18b63a6  Differential operators are no longer imported in the global namespace by PseudoRiemannianManifold.__init__

8367232  Merge branch 'public/manifolds/pseudoRiemannian' of git://trac.sagemath.org/sage into 'public/manifolds/Euclidean_spaces' to get the latest version of the dependency #24622 in #24623.

6e9fce6  First draft of Euclidean 3spaces, with the Cartesian, spherical and cylindrical coordinate systems

comment:17 Changed 21 months ago by
 Commit changed from 6e9fce6b191d1d1fcf84153ea90478c444687703 to 825ba7831fc3774455fd23b4c3b78dee3ee1fa0c
Branch pushed to git repo; I updated commit sha1. New commits:
825ba78  Add doctests to Euclidean spaces

comment:18 Changed 21 months ago by
 Commit changed from 825ba7831fc3774455fd23b4c3b78dee3ee1fa0c to 88f12ed85714bfa068c0a4e8f911681771ca4f20
Branch pushed to git repo; I updated commit sha1. New commits:
185e438  Improve documentation of pseudoRiemannian manifolds

52b10ee  Merge branch 'public/manifolds/pseudoRiemannian' of git://trac.sagemath.org/sage into 'public/manifolds/Euclidean_spaces' to get the final version of the dependency #24622 in #24623.

88f12ed  Improve documentation of Euclidean spaces

comment:19 Changed 21 months ago by
 Commit changed from 88f12ed85714bfa068c0a4e8f911681771ca4f20 to 371e05ee9f2d118c8f4b1d13376668a85b6fa639
Branch pushed to git repo; I updated commit sha1. New commits:
371e05e  Improve treatment of changes of frames in Euclidean spaces + documentation added

comment:20 Changed 21 months ago by
 Commit changed from 371e05ee9f2d118c8f4b1d13376668a85b6fa639 to 8a87f70a8efbf5e5f57f682459fe984a8df92338
Branch pushed to git repo; I updated commit sha1. New commits:
8a87f70  Add scalar triple product in Euclidean spaces

comment:21 Changed 21 months ago by
 Commit changed from 8a87f70a8efbf5e5f57f682459fe984a8df92338 to dd1951f87df19bdab818ded912e38579ad8f2fc5
Branch pushed to git repo; I updated commit sha1. New commits:
dd1951f  Improve documentation of Euclidean spaces, especially of vector operators

comment:22 Changed 21 months ago by
 Commit changed from dd1951f87df19bdab818ded912e38579ad8f2fc5 to d8b748baf218baf6d35b767d358553619a9045cb
comment:23 Changed 21 months ago by
 Commit changed from d8b748baf218baf6d35b767d358553619a9045cb to de74bb734f9f531bb6d991b14af20e58e6ebd683
Branch pushed to git repo; I updated commit sha1. New commits:
de74bb7  Slight reorganization of the documentation of Euclidean spaces

comment:24 Changed 21 months ago by
 Description modified (diff)
comment:25 Changed 21 months ago by
 Status changed from new to needs_review
The documentation has been completed in the above commits and new Jupyter notebook examples have been added. This is now ready for review.
comment:26 in reply to: ↑ 8 Changed 21 months ago by
Replying to kcrisman:
I wonder whether some of this (in terms of the div/grad/curl) could be exposed in the symbolic calculus places, at least with some wellplaced and wellformed examples that would be understandable to someone teaching Calc III to engineers (in the US framework) who may not be a differential geometer.
I have added an entry "Vector Calculus" to src/doc/en/reference/calculus/index.rst
. I have also added some SEEALSO
sections in the definitions of curl
and div
in src/sage/modules/free_module_element.pyx
, as well as in the definition of gradient
in src/sage/symbolic/expression.pyx
.
comment:27 Changed 21 months ago by
 Description modified (diff)
This is a first sketch (not ready yet).
Last 10 new commits:
Improve documentation of pseudoRiemannian manifolds
Remove method set_metric and improve doc of pseudoRiemannian manifolds
Add operators Laplacian, d'Alembertian and curl on pseudoRiemannian manifolds
Add dot product and cross product of vector fields
Add norm of vector fields.
Add method volume_form() to class PseudoRiemannianManifold
Add global functions grad, div, curl, etc. for vector/tensor operators on pseudoRiemannian manifolds
Improve documentation for operators on pseudoRiemannian manifolds
Merge branch 'public/manifolds/pseudoRiemannian' of git://trac.sagemath.org/sage into Sage 8.2.beta5
First draft of Euclidean spaces as Riemannian manifolds