Rename *ll* and *ul* to ll and ul in easy-subs
[maxima.git] / share / tensor / rtest_itensor.mac
blobaac86d113e950596c308c4728f7785e8cba12e9e
1 /* Load itensor */
2 (if get('itensor,'version)=false then load(itensor),done);
3 done;
4 /* Set up a metric */
5 imetric(g);
6 done;
7 /* Symmetries */
8 decsym(s,2,0,[sym(all)],[]);
9 done;
10 canform(s([i,j],[])-s([j,i],[]));
12 decsym(a,2,0,[anti(all)],[]);
13 done;
14 canform(a([i,j],[])+a([j,i],[]));
16 allsym:true;
17 true;
18 canform(a([i,j],[])-a([j,i],[]));
20 allsym:false;
21 false;
22 rename(a([i,j1],[])*b([],[j1,k])+a([i,j2],[])*b([],[j2,k]));
23 2*a([i,%1],[])*b([],[%1,k]);
24 /* Components */
25 (kill(h),remcomps(h));
26 done;
27 components(h([],[i,j]),e([],[i,j])/p([],[]));
28 done;
29 h([],[a,b]);
30 e([],[a,b])/p([],[]);
31 (kill(h),remcomps(h));
32 done;
33 /* Contractions */
34 defcon(e,f,g);
35 done;
36 contract(e([a],[b])*f([b],[c]));
37 g([a],[c]);
38 dim:3;
40 contract(kdelta([a],[b])*kdelta([b],[a]));
41 'kdelta([],[]);
42 %,kdelta;
44 contract(g([i,j],[])*g([],[j,k]));
45 kdelta([i],[k]);
46 /* Curvature and covariant derivatives */
47 (flipflag:false,rename(icurvature([s,u,n],[y])));
48 ichr2([s,u],[y],n)-ichr2([s,n],[y],u)+ichr2([%1,n],[y])*ichr2([s,u],[%1])-ichr2([%1,u],[y])*ichr2([s,n],[%1]);
49 canform(icurvature([l,j,k],[i])+icurvature([k,l,j],[i])+icurvature([j,k,l],[i]));
51 canform(covdiff(icurvature([j,m,k],[i]),l)+covdiff(icurvature([j,l,m],[i]),k)+covdiff(icurvature([j,k,l],[i]),m));
53 contract(expand(kdels([i,j,k],[l,m,n])*kdelta([l,m,n],[i1,i2,i3])));
55 /* Special tensors */
56 levi_civita([i,j,j],[]);
57 kdelta([i,j,j],[1,2,3]);
58 %,kdelta;
60 contract(expand(lc2kdt('levi_civita([i,j,k],[])*a([],[j])*'levi_civita([],[k,l,n])*b([l],[])*c([n],[]))));
61 a([],[n])*b([i],[])*c([n],[])-a([],[l])*c([i],[])*b([l],[]);
62 contract(expand(lc2kdt('levi_civita([i,j,k],[])*a([],[j])*b([],[k])*'levi_civita([],[i,l,n])*c([l],[])*u([n],[]))));
63 a([],[l])*b([],[n])*c([l],[])*u([n],[])-b([],[l])*a([],[n])*c([l],[])*u([n],[]);
64 canform(contract(expand(applyb1('levi_civita([],[i,j,k])*a([j])*a([k]),lc_l,lc_u))));
66 /* Frames, derivatives */
67 idiff(f([],[]),k);
68 f([],[],k);
69 idiff(idiff(v([i],[]),k),l)-idiff(idiff(v([i],[]),l),k);
71 iframe_flag:true;
72 true;
73 idiff(idiff(v([i],[]),k),l)-idiff(idiff(v([i],[]),l),k);
74 v([i],[],k,l)-v([i],[],l,k);
75 iframe_flag:false;
76 false;
77 undiff(v([i],[],k));
78 'idiff(v([i],[]),k,1);
79 ichr1([i,j,k]);
80 (g([j,k],[],i)+g([i,k],[],j)-g([i,j],[],k))/2;
81 rename(ichr2([i,j],[k]));
82 g([],[k,%1])*(g([j,%1],[],i)-g([i,j],[],%1)+g([i,%1],[],j))/2;
83 (remove(a,constant),rename(covdiff(a([j,k],[i]),i)));
84 a([j,k],[%1],%1)+a([j,k],[%2])*ichr2([%2,%1],[%1])-a([j,%2],[%1])*ichr2([k,%1],[%2])-a([%2,k],[%1])*ichr2([j,%1],[%2]);
85 canform(factor(canform(covdiff(v([],[i]),k,l)-covdiff(v([],[i]),l,k)))-v([],[j])*icurvature([j,k,l],[i]));
87 /* TODO: flush & relatives, lorentz, conmetderiv */
88 /* Exterior algebra */
89 a([i])~b([j]);
90 (a([i],[])*b([j],[])-a([j],[])*b([i],[]))/2;
91 decsym(p,2,0,[anti(all)],[]);
92 done;
93 factor(canform(extdiff(p([j,k]),i)));
94 (p([j,k],[],i)-p([i,k],[],j)+p([i,j],[],k))/3;
95 extdiff(a([j])~b([k]),k);
97 factor(a([i1])~b([i2])|a+a([i2])~b([i1])|a);
99 canform(liediff(v,extdiff(a([i1]),i2))-extdiff(liediff(v,a([i1])),i2));
101 decsym(g,2,0,[sym(all)],[]);
102 done;
103 decsym(g,0,2,[],[sym(all)]);
104 done;
105 canform(g([a,d],[])*g([b,e],[])*g([],[b,a],c));
106 g([%1,e],[])*g([%2,d],[])*g([],[%1,%2],c);
107 canform(g([],[a,d])*g([],[b,e])*g([b,a],[]));
108 g([],[%1,e])*g([],[%2,d])*g([%1,%2],[]);
109 canform(g([],[a,b])*A([a],[],c)*A([b],[],d));
110 g([],[%1,%2])*A([%1],[],d)*A([%2],[],c);
111 canform(g([],[a,b])*A([a],[],d)*A([b],[],c));
112 g([],[%1,%2])*A([%1],[],d)*A([%2],[],c);
113 decsym(a,0,2,[],[anti(all)]);
114 done;
115 canform(a([A,B],[])*a([],[B,C]));
116 -a([],[%1,C])*a([%1,A],[]);
117 canform(a([A,B],[])*a([],[C,B]));
118 a([],[%1,C])*a([%1,A],[]);
119 det(H):=block([idx1:makelist(idummy(),i,1,dim),idx2:makelist(idummy(),i,1,dim)],'kdelta(idx1,idx2)*product(H([idx2[i]],[idx1[i]]),i,1,dim)/dim!);
120 det(H):=block([idx1:makelist(idummy(),i,1,dim),idx2:makelist(idummy(),i,1,dim)],'kdelta(idx1,idx2)*product(H([idx2[i]],[idx1[i]]),i,1,dim)/dim!);
121 components(H([],[]),H([i],[i]));
122 done;
123 defcon(H,H,kdelta);
124 done;
125 apply(ev,[contract(apply(ev,[contract(apply(ev,[det(H),nouns,expand])),nouns])),nouns]);
127 /* ic_convert: In recent versions, this test 'fails' with the correct result */
128 /*ic_convert(f([a],[b])=g([],[b,c])*(B([a],[],c)-C([],[d])*g([a,d],[],c)));
129 for a thru dim do (for b thru dim do f[a,b]:sum(ug[b,c]*diff(B[a],ct_coords[c]),c,1,dim)-sum(sum(ug[b,c]*C[d]*diff(lg[a,d],ct_coords[c]),c,1,dim),d,1,dim));*/
130 /* TODO: torsion, nonmetricity tensors, connection coeffs */