Skip to content

Commit 9ece45d

Browse files
committed
Fixed bug in handling of products of differential forms, added tutorial.
1 parent 82fb96a commit 9ece45d

File tree

8 files changed

+75
-34
lines changed

8 files changed

+75
-34
lines changed

core/Cleanup.cc

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include "properties/SelfAntiCommuting.hh"
77
#include "properties/Diagonal.hh"
88
#include "properties/ExteriorDerivative.hh"
9+
#include "properties/DifferentialForm.hh"
910
#include "properties/KroneckerDelta.hh"
1011
#include "properties/NumericalFlat.hh"
1112
#include "properties/PartialDerivative.hh"
@@ -158,17 +159,29 @@ bool cleanup_productlike(const Kernel& k, Ex&tr, Ex::iterator& it)
158159
}
159160
}
160161

161-
// Turn wedge products containing two identical siblings to zero.
162+
// Turn wedge products containing two identical siblings of odd degree to zero.
162163
if(nm=="\\wedge") {
163164
auto s1=tr.begin(it);
164165
auto s2=s1;
165166
++s2;
166167
while(s2!=tr.end(it)) {
167168
if(subtree_compare(0, s1, s2)==0) {
168-
tr.erase_children(it);
169-
zero(it->multiplier);
170-
ret=true;
171-
break;
169+
auto df1 = k.properties.get<DifferentialForm>(s1);
170+
auto df2 = k.properties.get<DifferentialForm>(s2);
171+
if(df1 && df2) {
172+
auto degree1 = df1->degree(k.properties, s1);
173+
auto degree2 = df2->degree(k.properties, s2);
174+
if(degree1.is_rational() && degree2.is_rational()) {
175+
long d1 = to_long(degree1.to_rational());
176+
long d2 = to_long(degree2.to_rational());
177+
if(d1==d2 && d1%2==1) {
178+
tr.erase_children(it);
179+
zero(it->multiplier);
180+
ret=true;
181+
break;
182+
}
183+
}
184+
}
172185
}
173186
++s2;
174187
++s1;

core/Compare.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1247,8 +1247,9 @@ int Ex_comparator::can_swap(Ex::iterator one, Ex::iterator two, match_t subtree_
12471247
return 1;
12481248
else {
12491249
if(Ex::is_head(one) || *(Ex::parent(one)->name)=="\\wedge") {
1250-
// if(df1->degree.is_rational()==false || df2->degree.is_rational()==false)
1251-
// throw NotYetImplemented("Cannot yet order forms with non-numerical degrees");
1250+
if(df1->degree(properties, one).is_rational()==false ||
1251+
df2->degree(properties, two).is_rational()==false)
1252+
return 0; // Cannot yet order forms with non-numerical degrees.
12521253
long d1 = to_long(df1->degree(properties, one).to_rational());
12531254
long d2 = to_long(df2->degree(properties, two).to_rational());
12541255
if( (d1*d2) % 2 == 1) return -1;

examples/exterior.cnb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@
110110
{
111111
"cell_origin" : "server",
112112
"cell_type" : "latex_view",
113-
"source" : "\\begin{dmath*}{}\\text{Attached property ExteriorDerivative to~}{\\rm d}{\\#}.\\end{dmath*}"
113+
"source" : "\\begin{dmath*}{}\\text{Attached property ExteriorDerivative to~}d{\\#}.\\end{dmath*}"
114114
}
115115
],
116116
"source" : "d{#}::ExteriorDerivative;\nd{#}::LaTeXForm(\"{\\rm d}\")."
@@ -266,7 +266,7 @@
266266
{
267267
"cell_origin" : "server",
268268
"cell_type" : "latex_view",
269-
"source" : "\\begin{dmath*}{}\\text{Attached property Indices(position=free) to~}\\left\\{a, \\linebreak[0] b, \\linebreak[0] c\\right\\}.\\end{dmath*}"
269+
"source" : "\\begin{dmath*}{}\\text{Attached property Indices(position=free) to~}\\left[a,~\\discretionary{}{}{} b,~\\discretionary{}{}{} c\\right].\\end{dmath*}"
270270
},
271271
{
272272
"cell_origin" : "server",
@@ -346,11 +346,11 @@
346346
{
347347
"cell_origin" : "client",
348348
"cell_type" : "latex_view",
349-
"source" : "Some more random assorted ramblings below, not finished yet."
349+
"source" : "Some more random assorted ramblings below, not finished yet!!!"
350350
}
351351
],
352352
"hidden" : true,
353-
"source" : "Some more random assorted ramblings below, not finished yet."
353+
"source" : "Some more random assorted ramblings below, not finished yet!!!"
354354
},
355355
{
356356
"cell_origin" : "client",

tests/derivative.cdb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -644,3 +644,17 @@ def test38():
644644
print("Test 38 passed")
645645

646646
test38()
647+
648+
def test39():
649+
__cdbkernel__=create_scope()
650+
A0::DifferentialForm(degree=0).
651+
A1::DifferentialForm(degree=1).
652+
A2::DifferentialForm(degree=2).
653+
A3::DifferentialForm(degree=3).
654+
ex:= A3 ^ A1 - A1 ^ A3 + A2 ^ A2 ^ A0;
655+
sort_product(_);
656+
tst:= - 2 A1 ^ A3 + A0 ^ A2 ^ A2 - @(ex);
657+
assert(tst==0)
658+
print("Test 39 passed")
659+
660+
test39()

web2/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ set(TUTORIALS
2121
string_states
2222
bianchi_identities
2323
schwarzschild
24+
exterior
2425
kaluza_klein
2526
plotting
2627
scalar_manipulations

web2/cadabra2/source/download.html

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -23,47 +23,50 @@ <h2>Linux</h2>
2323
</p>
2424

2525
<table class="packages">
26-
<tr><th>distribution</th><th>package</th></tr>
26+
<tr><th>distribution</th></tr>
2727
<tr>
28-
<td class="system">&bullet; Ubuntu Trusty Tahr 14.04</td>
29-
<td><a href="/packages/ubuntu1404">download folder</a></td>
28+
<td class="system">&bullet; <a href="/packages/ubuntu1404">Ubuntu Trusty Tahr 14.04</a></td>
3029
</tr>
3130
<tr>
32-
<td class="system">&bullet; Ubuntu Xenial Xerus 16.04</td>
33-
<td><a href="/packages/ubuntu1604">download folder</a></td>
31+
<td class="system">&bullet; <a href="/packages/ubuntu1604">Ubuntu Xenial Xerus 16.04</a></td>
3432
</tr>
3533
<tr>
36-
<td class="system">&bullet; Ubuntu Artful Aardvark 17.10</td>
37-
<td><a href="/packages/ubuntu1710">download folder</a></td>
34+
<td class="system">&bullet; <a href="/packages/ubuntu1610">Ubuntu Artful Aardvark 17.10</a></td>
3835
</tr>
3936
<tr>
40-
<td class="system">&bullet; Fedora 24</td>
41-
<td><a href="/packages/fedora24">download folder</a></td>
37+
<td class="system">&bullet; <a href="/packages/fedora24">Fedora 24</a></td>
4238
</tr>
4339
<tr>
44-
<td class="system">&bullet; Fedora 26</td>
45-
<td><a href="/packages/fedora26">download folder</a></td>
40+
<td class="system">&bullet; <a href="/packages/fedora26">Fedora 26</a></td>
4641
</tr>
4742
<tr>
48-
<td class="system">&bullet; Mint Sarah 18</td>
49-
<td><a href="/packages/mint18">download folder</a></td>
43+
<td class="system">&bullet; <a href="/packages/mint18">Mint Sarah 18</a></td>
5044
</tr>
5145
<tr>
52-
<td class="system">&bullet; CentOS 7 / Scientific Linux 7</td>
53-
<td><a href="/packages/centos7">download folder</a></td>
46+
<td class="system">&bullet; <a href="/packages/centos7">CentOS 7</a></td>
5447
</tr>
5548
<tr>
5649
<td colspan=2 class="instructions">
5750
After installation you also need to run<br/>
58-
<code>sudo yum install epel-release</code><br/><code>sudo yum
59-
install python-pip</code><br/><code>sudo pip install
60-
sympy</code><br/>
51+
<code>sudo yum install epel-release; sudo yum
52+
install python-pip; sudo pip install sympy</code><br/>
6153
in order to enable component computations.
6254
</td>
6355
</tr>
6456
<tr>
65-
<td class="system">&bullet; OpenSUSE Leap 42.1</td>
66-
<td><a href="/packages/opensuse421">download folder</a></td>
57+
<td class="system">&bullet; <a href="/packages/scientific7x">Scientific
58+
Linux 7x</a></td>
59+
</tr>
60+
<tr>
61+
<td colspan=2 class="instructions">
62+
After installation you also need to run<br/>
63+
<code>sudo yum install epel-release; sudo yum
64+
install python-pip; sudo pip install sympy</code><br/>
65+
in order to enable component computations.
66+
</td>
67+
</tr>
68+
<tr>
69+
<td class="system">&bullet; <a href="/packages/opensuse421">OpenSUSE Leap 42.1</a></td>
6770
</tr>
6871
<tr>
6972
<td colspan=2 class="instructions">
@@ -75,8 +78,7 @@ <h2>Linux</h2>
7578
</td>
7679
</tr>
7780
<tr>
78-
<td class="system">&bullet; Debian Jessie 8.6</td>
79-
<td><a href="/packages/debian86">download folder</a></td>
81+
<td class="system">&bullet; <a href="/packages/debian86">Debian Jessie 8.6</a></td>
8082
</tr>
8183

8284
</table>

web2/cadabra2/source/static/styles/cadabra-web.css

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,8 @@ table.packages tr {
398398
table.packages code {
399399
font-size: 12px;
400400
margin-left: 10px;
401+
margin-top: 0px;
402+
margin-bottom:0px;
401403
}
402404

403405
/* Young tableaux */

web2/cadabra2/source/tutorials.html

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ <h2>Quantum mechanics, groups and algebras</h2>
120120
<a href="notebooks/string_states.cnb">download notebook</a>
121121
</div>
122122

123-
<h2>Abstract general relativity</h2>
123+
<h2>Abstract general relativity and differential geometry</h2>
124124
<p>
125125
Cadabra was originally written in order to facilitate computations
126126
in extensions of general relativity. The following example shows how
@@ -132,6 +132,14 @@ <h2>Abstract general relativity</h2>
132132
<a href="notebooks/bianchi_identities.html">read online</a>
133133
<a href="notebooks/bianchi_identities.cnb">download notebook</a>
134134
</div>
135+
<p>
136+
You can also do computations with abstract differential forms and
137+
the exterior derivative, as in the example below.
138+
<div class="view_options">
139+
<span>Differential forms:</span>
140+
<a href="notebooks/exterior.html">read online</a>
141+
<a href="notebooks/exterior.cnb">download notebook</a>
142+
</div>
135143
</p>
136144

137145
<h2>Component computations</h2>

0 commit comments

Comments
 (0)