File: dummies.cdb

package info (click to toggle)
cadabra2 2.4.3.2-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 78,796 kB
  • sloc: ansic: 133,450; cpp: 92,064; python: 1,530; javascript: 203; sh: 184; xml: 182; objc: 53; makefile: 51
file content (87 lines) | stat: -rw-r--r-- 2,389 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87

# rename_dummies tests

def test01():
   __cdbkernel__=create_scope()
   {m,n,p,q}::Indices("one").
   {a,b,c,d}::Indices("two").
   ex:= A_{m} A^{m} + B_{m} C^{m} + A_{n} A^{n} + Q_{c d} R^{d c}.
   rename_dummies(ex, "one", "two")
   tst:= 2 A_{a} A^{a} + B_{a} C^{a} + Q_{c d} R^{d c} - @(ex).
   assert tst == 0, tst
   print("Test 01 passed")

test01()

def test02a():
   __cdbkernel__=create_scope()
   {n,p,q}::Indices("one").
   {m,n,p,q,r,s,t}::Indices("two").
   ex:= A_{r} = A_{m r} A^{m} + A_{n r} A^{n} + A_{s r} A^{s}.
   rename_dummies(ex, "two", "one")
   assert ex == $A_{r} = 3A_{n r} A^{n}$, ex
   print("Test 02a passed")

test02a()

def test02b():
   __cdbkernel__ = create_scope()
   {a, b, c, d, e, f}::Indices("one").
   {\alpha, \beta, \gamma, \delta}::Indices("two")
   ex1 := A_{a a \alpha \alpha};
   rename_dummies(ex1, "two", "one")
   assert ex1 == $A_{a a b b}$
   ex2 := A_{a a \alpha \alpha};
   rename_dummies(ex2, "one", "two")
   assert ex2 == $A_{\beta \beta \alpha \alpha}$
   print("Test 02b passed")

test02b()

# expand_dummies tests

def test03():
   __cdbkernel__ = create_scope()
   {t, x}::Coordinate.
   {\mu, \nu, \rho}::Indices(vector, values={t, x}).
   ex := A_{\mu} A^{\mu}.
   expand_dummies(ex)
   assert ex == $A_{t}A^{t} + A_{x}A^{x}$, ex
   print("Test 03 passed")

test03()

def test04():
   __cdbkernel__ = create_scope()
   {t, x}::Coordinate.
   {\mu, \nu, \rho}::Indices(vector, values={t, x}).
   ex := g^{\mu \nu} A_{\nu}.
   expand_dummies(ex)
   assert ex == $g^{\mu t} A_{t} + g^{\mu x} A_{x}$, ex
   print("Test 04 passed")

test04()

def test05():
   __cdbkernel__ = create_scope()
   {t, x, y, z}::Coordinate.
   {\mu, \nu, \rho, \lambda}::Indices(vector, values={t, x, y, z}).
   mink := g_{t t} = -1, g_{x x} = 1, g_{y y} = 1, g_{z z} = 1.
   ex := g_{\mu \rho} g_{\mu \lambda} k^{\rho} k^{\lambda}.
   expand_dummies(ex, mink)
   assert ex == $k^{t}k^{t} + k^{x}k^{x} + k^{y}k^{y} + k^{z}k^{z}$, ex
   print("Test 05 passed")

test05()

def test06():
   __cdbkernel__ = create_scope()
   {t, x}::Coordinate.
   {\mu, \nu, \rho, \lambda}::Indices(vector, values={t, x}).
   components := A_{t t} = a1, A_{x x} = a2, B_{x t} = b.
   ex := A_{\mu \nu}B_{\mu \nu}.
   expand_dummies(ex, components, False)
   assert ex == $a1 B_{t t} + A_{x t} b + A_{t x} B_{t x} + a2 B_{x x}$, ex
   print("Test 06 passed")

test06()