-
Notifications
You must be signed in to change notification settings - Fork 0
/
TensorDerivative.m
50 lines (36 loc) · 1.25 KB
/
TensorDerivative.m
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
(* ::Package:: *)
Begin["IndexNotation`Private`"];
With[
{
KD = KroneckerDelta,
IT = IndexNotation`IndexTensor,
TI = IndexNotation`TensorIndex,
ScD = IndexNotation`Scope`UniqueDummyIndex,
ScU = IndexNotation`Scope`UniqueIndex,
ScT = IndexNotation`Scope`Transform,
indexfunc = IndexNotation`DummyIndex,
TD = IndexNotation`TensorDerivative
},
TD[ Subscript[s_, h_[_, _]], {_, n1___}, {_, n2___} ] @ x_
:= Module[
{
tmp1 = ScD @ $ModuleNumber ++,
tmp2 = ScD @ $ModuleNumber ++
},
ScT[indexfunc] @ If[
(* In order to keep up symmetry of {tmp1, tmp2} with {k1, k2} *)
MemberQ[ Attributes[h], Orderless ],
x /. Subscript[ Verbatim[s], Verbatim[h][k1_, k2_] ] :>
IT[
( KD[k1, tmp1] KD[k2, tmp2] + KD[k2, tmp1] KD[k1, tmp2] ) / 2,
{tmp1, n1}, {tmp2, n2}
],
x /. Subscript[ Verbatim[s], Verbatim[h][k1_, k2_] ] :>
IT[
KD[k1, tmp1] KD[k2, tmp2],
{tmp1, n1}, {tmp2, n2}
]
]
];
]
End[];