Skip to content

Commit 66e7f60

Browse files
committed
Fix docs, start relativity package.
1 parent 3b8ea53 commit 66e7f60

File tree

6 files changed

+173
-21
lines changed

6 files changed

+173
-21
lines changed

core/DataCell.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ std::string cadabra::latex_to_html(const std::string& str)
7979
std::regex discretionary(R"(\\discretionary\{\}\{\}\{\})");
8080
std::regex subsection(R"(\\subsection\*\{([^\}]*)\})");
8181
std::regex subsubsection(R"(\\subsubsection\*\{([^\}]*)\})");
82+
std::regex emph(R"(\\emph\{([^\}]*)\})");
8283
std::regex verb(R"(\\verb\|([^\|]*)\|)");
8384
std::regex url(R"(\\url\{([^\}]*)\})");
8485
std::regex href(R"(\\href\{([^\}]*)\}\{([^\}]*)\})");
@@ -120,6 +121,7 @@ std::string cadabra::latex_to_html(const std::string& str)
120121
res = std::regex_replace(res, section, "<h1>$1</h1>");
121122
res = std::regex_replace(res, subsection, "<h2>$1</h2>");
122123
res = std::regex_replace(res, subsubsection, "<h3>$1</h3>");
124+
res = std::regex_replace(res, emph, "<i>$1</i>");
123125
res = std::regex_replace(res, author, "<div class='author'>$1</div>");
124126
res = std::regex_replace(res, email, "<div class='email'>$1</div>");
125127
res = std::regex_replace(res, verb, "<code>$1</code>");

core/packages/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ set(PACKAGES
2929
core/solve
3030
utils/node
3131
sympy/solvers
32+
relativity/abstract
3233
relativity/schwarzschild
3334
)
3435

Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
{
2+
"cell_id" : 10246630462622169684,
3+
"cells" :
4+
[
5+
{
6+
"cell_id" : 3324461703110413508,
7+
"cell_origin" : "client",
8+
"cell_type" : "latex",
9+
"cells" :
10+
[
11+
{
12+
"cell_id" : 14419213666533296135,
13+
"cell_origin" : "client",
14+
"cell_type" : "latex_view",
15+
"source" : "\\package{cdb.relativity.abstract}{Core general relativity package, mainly a library of various standard expressions.}\n\nImporting this library will make \\verb|\\partial| a partial derivative and will also declare the\ngreek indices to be space-time indices."
16+
}
17+
],
18+
"hidden" : true,
19+
"source" : "\\package{cdb.relativity.abstract}{Core general relativity package, mainly a library of various standard expressions.}\n\nImporting this library will make \\verb|\\partial| a partial derivative and will also declare the\ngreek indices to be space-time indices."
20+
},
21+
{
22+
"cell_id" : 12613540530229412949,
23+
"cell_origin" : "client",
24+
"cell_type" : "input",
25+
"cells" :
26+
[
27+
{
28+
"cell_id" : 9223372036854775835,
29+
"cell_origin" : "server",
30+
"cell_type" : "latex_view",
31+
"source" : "\\begin{dmath*}{}\\text{Attached property PartialDerivative to~}\\partial{\\#}.\\end{dmath*}"
32+
},
33+
{
34+
"cell_id" : 9223372036854775836,
35+
"cell_origin" : "server",
36+
"cell_type" : "latex_view",
37+
"source" : "\\begin{dmath*}{}\\text{Attached property Indices(position=fixed) to~}\\left[\\mu,~\\discretionary{}{}{} \\nu,~\\discretionary{}{}{} \\rho,~\\discretionary{}{}{} \\sigma,~\\discretionary{}{}{} \\kappa,~\\discretionary{}{}{} \\gamma,~\\discretionary{}{}{} \\lambda\\right].\\end{dmath*}"
38+
}
39+
],
40+
"source" : "\\partial{#}::PartialDerivative;\n{\\mu,\\nu,\\rho,\\sigma,\\kappa,\\gamma,\\lambda}::Indices(spacetime, position=fixed);"
41+
},
42+
{
43+
"cell_id" : 11955494087904535027,
44+
"cell_origin" : "client",
45+
"cell_type" : "latex",
46+
"cells" :
47+
[
48+
{
49+
"cell_id" : 15119378517043388215,
50+
"cell_origin" : "client",
51+
"cell_type" : "latex_view",
52+
"source" : "\\algorithm{riemann_from_christoffel(R: Ex, c: Ex) -> Ex}{Generates an equality which determines the Riemann tensor in terms of the Christoffel symbols.}"
53+
}
54+
],
55+
"hidden" : true,
56+
"source" : "\\algorithm{riemann_from_christoffel(R: Ex, c: Ex) -> Ex}{Generates an equality which determines the Riemann tensor in terms of the Christoffel symbols.}"
57+
},
58+
{
59+
"cell_id" : 14094191732391016476,
60+
"cell_origin" : "client",
61+
"cell_type" : "input",
62+
"source" : "def riemann_from_christoffel(R=$R$, c=$\\Gamma$):\n ex:= @(R)^{\\rho}_{\\sigma\\mu\\nu} = \\partial_{\\mu}{@(c)^{\\rho}_{\\nu\\sigma}} \n -\\partial_{\\nu}{@(c)^{\\rho}_{\\mu\\sigma}} \n + @(c)^{\\rho}_{\\mu\\lambda} @(c)^{\\lambda}_{\\nu\\sigma} \n - @(c)^{\\rho}_{\\nu\\lambda} @(c)^{\\lambda}_{\\mu\\sigma}:\n return ex"
63+
},
64+
{
65+
"cell_id" : 17711059759552177114,
66+
"cell_origin" : "client",
67+
"cell_type" : "latex",
68+
"cells" :
69+
[
70+
{
71+
"cell_id" : 2943028165866679465,
72+
"cell_origin" : "client",
73+
"cell_type" : "latex_view",
74+
"source" : "\\algorithm{christoffel_from_metric(c: Ex, g: Ex) -> Ex}{Generates an equality which determines the Christoffel symbols in terms of the metric.}"
75+
}
76+
],
77+
"hidden" : true,
78+
"source" : "\\algorithm{christoffel_from_metric(c: Ex, g: Ex) -> Ex}{Generates an equality which determines the Christoffel symbols in terms of the metric.}"
79+
},
80+
{
81+
"cell_id" : 16328687583199300518,
82+
"cell_origin" : "client",
83+
"cell_type" : "input",
84+
"source" : "def christoffel_from_metric(c=$\\Gamma$, g=$g$):\n ex:= @(c)^{\\lambda}_{\\mu\\nu} = 1/2 g^{\\lambda\\kappa} ( \\partial_{\\mu}{ g_{\\kappa\\nu} }\n + \\partial_{\\nu}{ g_{\\kappa\\mu} } - \\partial_{\\kappa}{ g_{\\mu\\nu} } ).\n return ex\n"
85+
},
86+
{
87+
"cell_id" : 17531443358799556997,
88+
"cell_origin" : "client",
89+
"cell_type" : "latex",
90+
"cells" :
91+
[
92+
{
93+
"cell_id" : 16528097175233509746,
94+
"cell_origin" : "client",
95+
"cell_type" : "latex_view",
96+
"source" : "\\algorithm{riemann_to_ricci}{Convert contractions of Riemann tensors to Ricci tensors or scalars.}"
97+
}
98+
],
99+
"hidden" : true,
100+
"source" : "\\algorithm{riemann_to_ricci}{Convert contractions of Riemann tensors to Ricci tensors or scalars.}"
101+
},
102+
{
103+
"cell_id" : 6890929525873944922,
104+
"cell_origin" : "client",
105+
"cell_type" : "input",
106+
"source" : "def riemann_to_ricci(ex, R=$R$):\n rl1:= @(R)^{a?}_{b? a? c?} = @(R)_{b? c?}, @(R)^{a?}_{b? c? a?} = -@(R)_{b? c?}.\n rl2:= @(R)_{a?}_{b?}^{a?}_{c?} = @(R)_{b? c?}, @(R)_{a?}_{b? c?}^{a?} = -@(R)_{b? c?}.\n rl3:= @(R)_{b?}^{a?}_{c? a?} = @(R)_{b? c?}, @(R)_{b?}^{a?}_{a? c?} = -@(R)_{b? c?}.\n rl4:= @(R)_{b?}_{a?}^{c? a?} = @(R)_{b?}^{c?}.\n rl5:= @(R)^{a?}_{a?} = @(R), @(R)_{a?}^{a?} = @(R).\n rl6:= @(R)^{a?}_{a? b? c?} = R_{\n\n substitute(ex, rl1+rl2+rl3+rl4+rl5, repeat=True)\n return ex"
107+
},
108+
{
109+
"cell_id" : 3773496488914727547,
110+
"cell_origin" : "client",
111+
"cell_type" : "input",
112+
"cells" :
113+
[
114+
{
115+
"cell_id" : 9223372036854775849,
116+
"cell_origin" : "server",
117+
"cell_type" : "latex_view",
118+
"cells" :
119+
[
120+
{
121+
"cell_id" : 9223372036854775850,
122+
"cell_origin" : "server",
123+
"cell_type" : "input_form",
124+
"source" : "R^{a}_{b c a}-R^{a}_{b a c}"
125+
}
126+
],
127+
"source" : "\\begin{dmath*}{}R^{a}\\,_{b c a}-R^{a}\\,_{b a c}\\end{dmath*}"
128+
}
129+
],
130+
"source" : "ex:= R^{a}_{b c a} - R^{a}_{b a c};"
131+
},
132+
{
133+
"cell_id" : 2143829647108705411,
134+
"cell_origin" : "client",
135+
"cell_type" : "input",
136+
"cells" :
137+
[
138+
{
139+
"cell_id" : 9223372036854775852,
140+
"cell_origin" : "server",
141+
"cell_type" : "latex_view",
142+
"cells" :
143+
[
144+
{
145+
"cell_id" : 9223372036854775853,
146+
"cell_origin" : "server",
147+
"cell_type" : "input_form",
148+
"source" : "-2R_{b c}"
149+
}
150+
],
151+
"source" : "\\begin{dmath*}{}-2R_{b c}\\end{dmath*}"
152+
}
153+
],
154+
"source" : "riemann_to_ricci(ex);"
155+
},
156+
{
157+
"cell_id" : 8133262252432645091,
158+
"cell_origin" : "client",
159+
"cell_type" : "input",
160+
"source" : ""
161+
}
162+
],
163+
"description" : "Cadabra JSON notebook format",
164+
"version" : 1
165+
}

core/packages/cdb/relativity/schwarzschild.cnb

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"cell_id" : 7004405290148921668,
2+
"cell_id" : 11589016112009228246,
33
"cells" :
44
[
55
{
@@ -8,24 +8,6 @@
88
"cell_type" : "input",
99
"cells" :
1010
[
11-
{
12-
"cell_id" : 9223372036854775809,
13-
"cell_origin" : "server",
14-
"cell_type" : "latex_view",
15-
"source" : "\\begin{dmath*}{}\\text{Attached property Coordinate to~}\\left[t,~\\discretionary{}{}{} r,~\\discretionary{}{}{} \\phi,~\\discretionary{}{}{} \\theta\\right].\\end{dmath*}"
16-
},
17-
{
18-
"cell_id" : 9223372036854775810,
19-
"cell_origin" : "server",
20-
"cell_type" : "latex_view",
21-
"source" : "\\begin{dmath*}{}\\text{Attached property Indices(position=free) to~}\\left[\\mu,~\\discretionary{}{}{} \\nu,~\\discretionary{}{}{} \\rho,~\\discretionary{}{}{} \\sigma,~\\discretionary{}{}{} \\kappa\\right].\\end{dmath*}"
22-
},
23-
{
24-
"cell_id" : 9223372036854775811,
25-
"cell_origin" : "server",
26-
"cell_type" : "latex_view",
27-
"source" : "\\begin{dmath*}{}\\text{Attached property Metric to~}g_{\\mu \\nu}.\\end{dmath*}"
28-
},
2911
{
3012
"cell_id" : 9223372036854775812,
3113
"cell_origin" : "server",
@@ -42,7 +24,7 @@
4224
"source" : "def metric():\n ret := { g_{t t} = -(1-2 M/r), \n g_{r r} = 1/(1-2 M/r), \n g_{\\theta \\theta} = r**2,\n g_{\\phi \\phi} = r**2 \\sin(\\theta)**2 \n };\n return ret"
4325
},
4426
{
45-
"cell_id" : 6301629692701616073,
27+
"cell_id" : 17548331014027880039,
4628
"cell_origin" : "client",
4729
"cell_type" : "input",
4830
"source" : ""

tests/packages.cdb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
import cdb.relativity as rel
2+
import cdb.relativity.abstract as rel
33

44
def test01():
55
__cdbkernel__=create_scope()

web2/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,8 @@ set(PACKAGES
149149
cdb/core/manip
150150
cdb/core/component
151151
cdb/sympy/solvers
152+
cdb/relativity/abstract
153+
cdb/relativity/schwarzschild
152154
)
153155

154156
# Table of contents

0 commit comments

Comments
 (0)