sagemath / sage

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

Characteristic Classes - MixedAlgebra #27584

Closed b220a61f-8dcb-4d62-9a53-d56a2b1bfc8f closed 5 years ago

b220a61f-8dcb-4d62-9a53-d56a2b1bfc8f commented 5 years ago

This project is my master thesis. I want to implement a computation of characteristic classes of vector bundles out of their curvature matrices. The algorithm is based on this short script.

In this first step, the graded algebra of "mixed" differential forms of a manifold will be introduced so one can use the matrix framework of sage in the following steps.

A demo notebook is provided at https://github.com/DeRhamSource/MixedFormNotebook

CC: @egourgoulhon @tscrim

Component: geometry

Keywords: characteristic classes

Author: Michael Jung

Branch/Commit: cdfaf6d

Reviewer: Eric Gourgoulhon, Travis Scrimshaw

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

egourgoulhon commented 5 years ago
comment:41

Regarding the documentation: you have added doctests in the Python sources but the documentation is not generated since there is no entry to it in the sources of the reference manual. You shall modify/add files in src/doc/en/reference/manifolds, for instance in a way similar to what is done for differential forms, i.e. create a file mixed_diff_form.rst and add a pointer to it in diff_manifold.rst. To generate the documentation in a fast way, i.e. without having Sage process the whole reference manual, run

sage -docbuild reference/manifolds html
egourgoulhon commented 5 years ago
comment:42

Side remark: the bug that you've reported in https://groups.google.com/d/msg/sage-devel/EfLYpAxl_jU/ShlCS9L4BgAJ is fixed in Sage 8.8.beta1 (since #25576 has been merged in it).

b220a61f-8dcb-4d62-9a53-d56a2b1bfc8f commented 5 years ago
comment:43

Replying to @egourgoulhon:

Regarding the documentation: you have added doctests in the Python sources but the documentation is not generated since there is no entry to it in the sources of the reference manual. You shall modify/add files in src/doc/en/reference/manifolds, for instance in a way similar to what is done for differential forms, i.e. create a file mixed_diff_form.rst and add a pointer to it in diff_manifold.rst. To generate the documentation in a fast way, i.e. without having Sage process the whole reference manual, run

sage -docbuild reference/manifolds html

Unfortunately, I get some errors:

[manifolds] /home/michi/GitProjects/sage/src/sage_setup/docbuild/ext/sage_autodoc.py:1170: RemovedInSphinx20Warning: formatargspec() is now deprecated.  Please use sphinx.util.inspect.Signature instead.
[manifolds]   return formatargspec(initmeth, *argspec)
[manifolds] /home/michi/GitProjects/sage/src/sage_setup/docbuild/ext/sage_autodoc.py:1406: RemovedInSphinx20Warning: formatargspec() is now deprecated.  Please use sphinx.util.inspect.Signature instead.
[manifolds]   args = formatargspec(self.object, *argspec)
[manifolds] /home/michi/GitProjects/sage/src/sage_setup/docbuild/ext/sage_autodoc.py:1072: RemovedInSphinx20Warning: formatargspec() is now deprecated.  Please use sphinx.util.inspect.Signature instead.
[manifolds]   args = formatargspec(self.object, *argspec)
...
OSError: /home/michi/GitProjects/sage/src/doc/en/reference/manifolds/index.rst:4: WARNING: undefined label: tensors-on-free-modules (if the link has no caption the label must precede a section header)

However, what comes next?

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

Changed commit from 506ef37 to 970ccce

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

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

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

Changed commit from 970ccce to 9516d69

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

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

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

Changed commit from 9516d69 to 3a731b6

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

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

3a731b6Damn! :D
tscrim commented 5 years ago
comment:47

Some debugging will be needed (if you haven't fixed them already). Also you should rebase this (and force push) to have more professional commit messages. ;)

b220a61f-8dcb-4d62-9a53-d56a2b1bfc8f commented 5 years ago
comment:48

What should be debugged? I mean, the error above does not seem to have to do something with my implementation. Or does it?

Long story short: There is no error occuring anymore regarding the mixed algebra while building the doc.

egourgoulhon commented 5 years ago
comment:49

Replying to @DeRhamSource:

What should be debugged? I mean, the error above does not seem to have to do something with my implementation. Or does it?

Long story short: There is no error occuring anymore regarding the mixed algebra while building the doc.

Yes but some parts of the documentation require some debugging:

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

Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:

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

Changed commit from 3a731b6 to 177cfff

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

Changed commit from 177cfff to 4d9967a

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

Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:

38b36edMinor fixes
4d9967aMinor doc fixes
b220a61f-8dcb-4d62-9a53-d56a2b1bfc8f commented 5 years ago
comment:52

My apologies for these confusing commits. I'm quite new to it.

However, I fixed the aforementioned issues.

tscrim commented 5 years ago
comment:53

I have a couple more comments, most of them are fairly minor:

In _richcmp_:

        from sage.structure.richcmp import richcmp

        # Compare all elements separately:
        for j in range(0, self._max_deg + 1):

move the import statement to the top-level (this is for speed reasons) and make range(0, foo) -> range(foo).

Make _mul_ = wedge and maybe combine or reduce the doctests.

degree $k$ along `\varphi` replace & with `.

Instead of using self.__class__, I have been told it is better to use type(self).

Instead of \, my understanding is it is better to use () as that is guaranteed to generate an error if misused (as opposed to possibly a strange bug). For example

-                error_msg = "input must be a " \
-                            "differential form of degree {}".format(deg)
+                error_msg = ("input must be a "
+                             "differential form of degree {}".format(deg))

Typo: datailed -> detailed

I don't think you need the self._populate_coercion_lists_().

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

Changed commit from 4d9967a to cebde90

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

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

cebde90Typos and Minor Issues Fixed
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 5 years ago

Changed commit from cebde90 to b78c7a9

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

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

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

Changed commit from b78c7a9 to 407505d

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

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

407505dComponents from scratch
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 5 years ago

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

f03d4a0Minor: Whitespace + Comment
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 5 years ago

Changed commit from 407505d to f03d4a0

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

Changed commit from f03d4a0 to b4a9219

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

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

b4a9219Error Message obsolete
b220a61f-8dcb-4d62-9a53-d56a2b1bfc8f commented 5 years ago
comment:59

Thanks for your patience so far. Again, I changed a lot. Please check.

However, I noticed another error message that should not occur:

sage: M = Manifold(2, 'M')
sage: X.<x,y> = M.chart()
sage: f = M.scalar_field(x, name='f')
sage: f in M.diff_form_module(1)
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-38-9654b754d2bc> in <module>()
      2 X = M.chart(names=('x', 'y',)); (x, y,) = X._first_ngens(2)
      3 f = M.scalar_field(x, name='f')
----> 4 f in M.diff_form_module(Integer(1))

/home/michi/GitProjects/sage/local/lib/python2.7/site-packages/sage/structure/parent.pyx in sage.structure.parent.Parent.__contains__ (build/cythonized/sage/structure/parent.c:9885)()
   1090             return True
   1091         try:
-> 1092             x2 = self(x)
   1093             EQ = (x2 == x)
   1094             if EQ is True:

/home/michi/GitProjects/sage/local/lib/python2.7/site-packages/sage/structure/parent.pyx in sage.structure.parent.Parent.__call__ (build/cythonized/sage/structure/parent.c:9219)()
    898         if mor is not None:
    899             if no_extra_args:
--> 900                 return mor._call_(x)
    901             else:
    902                 return mor._call_with_args(x, args, kwds)

/home/michi/GitProjects/sage/local/lib/python2.7/site-packages/sage/structure/coerce_maps.pyx in sage.structure.coerce_maps.DefaultConvertMap_unique._call_ (build/cythonized/sage/structure/coerce_maps.c:4551)()
    160                 print(type(C), C)
    161                 print(type(C._element_constructor), C._element_constructor)
--> 162             raise
    163 
    164     cpdef Element _call_with_args(self, x, args=(), kwds={}):

/home/michi/GitProjects/sage/local/lib/python2.7/site-packages/sage/structure/coerce_maps.pyx in sage.structure.coerce_maps.DefaultConvertMap_unique._call_ (build/cythonized/sage/structure/coerce_maps.c:4443)()
    155         cdef Parent C = self._codomain
    156         try:
--> 157             return C._element_constructor(x)
    158         except Exception:
    159             if print_warnings:

/home/michi/GitProjects/sage/local/lib/python2.7/site-packages/sage/manifolds/differentiable/diff_form_module.pyc in _element_constructor_(self, comp, frame, name, latex_name)
    818         resu = self.element_class(self._fmodule, self._degree, name=name,
    819                                   latex_name=latex_name)
--> 820         if comp != []:
    821             resu.set_comp(frame)[:] = comp
    822         return resu

/home/michi/GitProjects/sage/local/lib/python2.7/site-packages/sage/manifolds/scalarfield.pyc in __ne__(self, other)
   1285 
   1286         """
-> 1287         return not (self == other)
   1288 
   1289     ####### End of required methods for an algebra element (beside arithmetic) #######

/home/michi/GitProjects/sage/local/lib/python2.7/site-packages/sage/manifolds/scalarfield.pyc in __eq__(self, other)
   1244                 return False
   1245             try:
-> 1246                 other = self.parent()(other)  # conversion to a scalar field
   1247             except TypeError:
   1248                 return False

/home/michi/GitProjects/sage/local/lib/python2.7/site-packages/sage/structure/parent.pyx in sage.structure.parent.Parent.__call__ (build/cythonized/sage/structure/parent.c:9219)()
    898         if mor is not None:
    899             if no_extra_args:
--> 900                 return mor._call_(x)
    901             else:
    902                 return mor._call_with_args(x, args, kwds)

/home/michi/GitProjects/sage/local/lib/python2.7/site-packages/sage/structure/coerce_maps.pyx in sage.structure.coerce_maps.DefaultConvertMap_unique._call_ (build/cythonized/sage/structure/coerce_maps.c:4551)()
    160                 print(type(C), C)
    161                 print(type(C._element_constructor), C._element_constructor)
--> 162             raise
    163 
    164     cpdef Element _call_with_args(self, x, args=(), kwds={}):

/home/michi/GitProjects/sage/local/lib/python2.7/site-packages/sage/structure/coerce_maps.pyx in sage.structure.coerce_maps.DefaultConvertMap_unique._call_ (build/cythonized/sage/structure/coerce_maps.c:4443)()
    155         cdef Parent C = self._codomain
    156         try:
--> 157             return C._element_constructor(x)
    158         except Exception:
    159             if print_warnings:

/home/michi/GitProjects/sage/local/lib/python2.7/site-packages/sage/manifolds/scalarfield_algebra.pyc in _element_constructor_(self, coord_expression, chart, name, latex_name)
    470                                       coord_expression=coord_expression,
    471                                       name=name, latex_name=latex_name,
--> 472                                       chart=chart)
    473         return resu
    474 

/home/michi/GitProjects/sage/local/lib/python2.7/site-packages/sage/manifolds/differentiable/scalarfield.pyc in __init__(self, parent, coord_expression, chart, name, latex_name)
    630         """
    631         ScalarField.__init__(self, parent, coord_expression=coord_expression,
--> 632                              chart=chart, name=name, latex_name=latex_name)
    633         self._tensor_type = (0,0)
    634 

/home/michi/GitProjects/sage/local/lib/python2.7/site-packages/sage/manifolds/scalarfield.pyc in __init__(self, parent, coord_expression, chart, name, latex_name)
   1101                         self._express[ch] = ch.function(coord_expression)
   1102                 else:
-> 1103                     self._express[chart] = chart.function(coord_expression)
   1104         self._init_derived()   # initialization of derived quantities
   1105 

/home/michi/GitProjects/sage/local/lib/python2.7/site-packages/sage/manifolds/chart.pyc in function(self, expression, calc_method, expansion_symbol, order)
   1087         return parent.element_class(parent, expression, calc_method=calc_method,
   1088                                     expansion_symbol=expansion_symbol,
-> 1089                                     order=order)
   1090 
   1091     def zero_function(self):

/home/michi/GitProjects/sage/local/lib/python2.7/site-packages/sage/manifolds/chart_func.pyc in __init__(self, parent, expression, calc_method, expansion_symbol, order)
    360                 calc_method = self._calc_method._current
    361             self._express[calc_method] = self._calc_method._tranf[calc_method](
--> 362                                                                     expression)
    363         # Derived quantities:
    364         self._der = None  # list of partial derivatives (to be set by diff()

/home/michi/GitProjects/sage/local/lib/python2.7/site-packages/sage/manifolds/calculus_method.pyc in _Sympy_to_SR(expression)
    106         # If SR cannot transform a sympy expression this is because it is a
    107         # sympy abstract function
--> 108         a = expression._sage_()
    109         # As all sage objects have a ._sage_ operator, they have to be
    110         # catched

AttributeError: 'list' object has no attribute '_sage_'
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 5 years ago

Changed commit from b4a9219 to 8036fb0

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

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

8036fb0Components from scratch - Fixes
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 5 years ago

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

6d1c88cTiny doc typos fixed
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 5 years ago

Changed commit from 8036fb0 to 6d1c88c

tscrim commented 5 years ago
comment:62

Does that second to last commit fix the issue in comment:59?

b220a61f-8dcb-4d62-9a53-d56a2b1bfc8f commented 5 years ago
comment:63

Replying to @tscrim:

Does that second to last commit fix the issue in comment:59?

No. But now, I guess this has nothing to do with the mixed algebra. I already reported it in sage-devel.

egourgoulhon commented 5 years ago
comment:64

Replying to @DeRhamSource:

Replying to @tscrim:

Does that second to last commit fix the issue in comment:59?

No. But now, I guess this has nothing to do with the mixed algebra. I already reported it in sage-devel.

I confirm the error. I've opened #27658 for it.

egourgoulhon commented 5 years ago
comment:65

Replying to @egourgoulhon:

Replying to @DeRhamSource:

Replying to @tscrim:

Does that second to last commit fix the issue in comment:59?

No. But now, I guess this has nothing to do with the mixed algebra. I already reported it in sage-devel.

I confirm the error. I've opened #27658 for it.

While this is definitely a bug, you can get rid of it by replacing

f in M.diff_form_module(n)

by

f.domain() is M and f.degree() == n

for any integer n. Moreover the second form is must faster.

b220a61f-8dcb-4d62-9a53-d56a2b1bfc8f commented 5 years ago
comment:66

Fortunately, this issue is not directly relevant for my code anymore (since the error message was deleted). I've encountered the problem while debugging. :)

egourgoulhon commented 5 years ago
comment:67

Replying to @DeRhamSource:

Fortunately, this issue is not directly relevant for my code anymore (since the error message was deleted). I've encountered the problem while debugging. :)

Good!

b220a61f-8dcb-4d62-9a53-d56a2b1bfc8f commented 5 years ago
comment:68

Patchbot says no. :(

Though, there is no obvious error. So, what's the matter?

Any further suggestions?

tscrim commented 5 years ago
comment:69

That error from the patchbot looks unrelated, so I would treat the patchbot as coming back green.

Sorry, one more nitpick for readability:

-            return self._domain.is_subset(
-                S._domain) and self._ambient_domain.is_subset(S._ambient_domain)
+            return (self._domain.is_subset(S._domain)
+                    and self._ambient_domain.is_subset(S._ambient_domain))

Eric, any other comments?

egourgoulhon commented 5 years ago
comment:70

Replying to @tscrim:

Eric, any other comments?

Yes, there is a doctest error with Python3-built Sage:

sage -t --long --warn-long 48.2 src/sage/manifolds/differentiable/mixed_form.py
**********************************************************************
File "src/sage/manifolds/differentiable/mixed_form.py", line 479, in sage.manifolds.differentiable.mixed_form.MixedForm.set_name
Failed example:
    F.set_name(name='fancy', latex_name='\eta'); F
Expected:
    Mixed differential form fancy on the 4-dimensional differentiable
     manifold M
Got:
    doctest:warning
    ...
    DeprecationWarning: invalid escape sequence \e
    Mixed differential form fancy on the 4-dimensional differentiable manifold M
**********************************************************************

You should replace '\eta' by r'\eta'.

Apart from this, everything is OK for me.

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

Changed commit from 6d1c88c to cdfaf6d

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

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

cdfaf6dDoctest fix + Readability
b220a61f-8dcb-4d62-9a53-d56a2b1bfc8f commented 5 years ago
comment:72

Anything else? :)

Otherwise I'd start programming the next part - namely characteristic classes.

egourgoulhon commented 5 years ago
comment:73

Replying to @DeRhamSource:

Anything else? :)

Otherwise I'd start programming the next part - namely characteristic classes.

Thanks for the update and your work on this. I am OK for the positive review. Travis, do you agree?

tscrim commented 5 years ago
comment:74

I concur.

vbraun commented 5 years ago

Changed branch from public/manifolds/mixed_differential_forms to cdfaf6d