forked from satfra/TensorBases
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTensorBases.m
More file actions
3020 lines (2438 loc) · 116 KB
/
TensorBases.m
File metadata and controls
3020 lines (2438 loc) · 116 KB
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
(* ::Package:: *)
(************************************************************************)
(* This file was generated automatically by the Mathematica front end. *)
(* It contains Initialization cells from a Notebook file, which *)
(* typically will have the same name as this file except ending in *)
(* ".nb" instead of ".m". *)
(* *)
(* This file is intended to be loaded into the Mathematica kernel using *)
(* the package loading commands Get or Needs. Doing so is equivalent *)
(* to using the Evaluate Initialization Cells menu command in the front *)
(* end. *)
(* *)
(* DO NOT EDIT THIS FILE. This entire file is regenerated *)
(* automatically each time the parent Notebook file is saved in the *)
(* Mathematica front end. Any changes you make to this file will be *)
(* overwritten. *)
(************************************************************************)
If["AllowInternetUse" /. SystemInformation["Network"],
Module[{TBCurPacletAddr,TBCurPaclet,TBCurVersion,
TBInstalledPaclet,TBInstalledVersion},
TBCurPacletAddr="https://github.com/satfra/TensorBases/raw/refs/heads/main/PacletInfo.m";
TBCurPaclet=(List@@Import[TBCurPacletAddr])[[1]];
TBCurVersion=TBCurPaclet["Version"];
TBInstalledPaclet=(List@@Import[FileNameJoin[{$UserBaseDirectory,"Applications","TensorBases","PacletInfo.m"}]])[[1]];
TBInstalledVersion=TBInstalledPaclet["Version"];
If[TBCurVersion=!=TBInstalledVersion,
If[ChoiceDialog[
TemplateApply["There is a newer TensorBases version on the internet.
The installed version is `a`, whereas `b` is available. Do you want to install it?",<|"a"->TBInstalledVersion,"b"->TBCurVersion|>]
,WindowTitle->"Update TensorBases",WindowSize->{Medium,All}],
Import["https://raw.githubusercontent.com/satfra/TensorBases/main/TensorBasesInstaller.m"];
Echo["Please restart your Kernel."];Exit[],
Print["Consider updating the TensorBases package for bugfixes and new features!"];
];
];
];
];
Print["Mathematica package \!\(\*
StyleBox[\"TensorBases\",\nFontWeight->\"Bold\"]\)\!\(\*
StyleBox[\" \",\nFontWeight->\"Bold\"]\)loaded
\!\(\*
StyleBox[\"Authors\",\nFontWeight->\"Bold\"]\): Andreas Gei\[SZ]el, Franz Richard Sattler
\!\(\*
StyleBox[\"Version\",\nFontWeight->\"Bold\"]\): 1.0
\!\(\*
StyleBox[\"Year\",\nFontWeight->\"Bold\"]\): 2025
For a list of available bases, call \!\(\*
StyleBox[\"TBInfo\",\nFontColor->RGBColor[1, 0.5, 0]]\)[]. For further information on a particular basis, call \!\(\*
StyleBox[\"TBInfo\",\nFontColor->RGBColor[1, 0.5, 0]]\)[\"\!\(\*
StyleBox[\"BasisName\",\nFontColor->GrayLevel[0.5]]\)\"].
This package provides the methods \!\(\*
StyleBox[\"TBGetBasisElement\",\nFontColor->RGBColor[1, 0.5, 0]]\), \!\(\*
StyleBox[\"TBGetInnerProduct\",\nFontColor->RGBColor[1, 0.5, 0]]\), \!\(\*
StyleBox[\"TBGetMetric\",\nFontColor->RGBColor[1, 0.5, 0]]\), \!\(\*
StyleBox[\"TBGetInverseMetric\",\nFontColor->RGBColor[1, 0.5, 0]]\), \!\(\*
StyleBox[\"TBGetProjector\",\nFontColor->RGBColor[1, 0.5, 0]]\) for every tensor basis available.
For closer explanations, please call their usage messages, e.g. \!\(\*
StyleBox[\"TBGetProjector\",\nFontColor->RGBColor[1, 0.5, 0]]\)::\!\(\*
StyleBox[\"usage\",\nFontColor->RGBColor[0, 0, 1]]\).
Other useful tools include \!\(\*
StyleBox[\"TBBasisTransformation\",\nFontColor->RGBColor[1, 0.5, 0]]\), \!\(\*
StyleBox[\"TBVertexTransformation\",\nFontColor->RGBColor[1, 0.5, 0]]\), \!\(\*
StyleBox[\"TBGetIdentityMatrix\",\nFontColor->RGBColor[1, 0.5, 0]]\), \!\(\*
StyleBox[\"TBGetBasisSize\",\nFontColor->RGBColor[1, 0.5, 0]]\),\!\(\*
StyleBox[\" \",\nFontColor->RGBColor[1, 0.5, 0]]\)\!\(\*
StyleBox[\"TBGetIndexSet\",\nFontColor->RGBColor[1, 0.5, 0]]\),\!\(\*
StyleBox[\" \",\nFontColor->RGBColor[1, 0.5, 0]]\)\!\(\*
StyleBox[\"TBMakePropagator\",\nFontColor->RGBColor[1, 0.5, 0]]\).
To build or manipulate bases, please call \!\(\*
StyleBox[\"TBInfo\",\nFontColor->RGBColor[1, 0.5, 0]]\)[\"BaseBuilder\"].
To show information on the used notation, call \!\(\*
StyleBox[\"TBInfo\",\nFontColor->RGBColor[1, 0.5, 0]]\)[\"Notation\"].
"]
FormTracerLoaded[]:=(Length[Select[$Packages,#=="FormTracer`"&]]>0);
FormTracerInstalled[]:=Module[{FTDirectory},
FTDirectory=SelectFirst[
Join[
{
FileNameJoin[{$UserBaseDirectory,"Applications","FormTracer"}],
FileNameJoin[{$BaseDirectory,"Applications","FormTracer"}],
FileNameJoin[{$InstallationDirectory,"AddOns","Applications","FormTracer"}],
FileNameJoin[{$InstallationDirectory,"AddOns","Packages","FormTracer"}],
FileNameJoin[{$InstallationDirectory,"AddOns","ExtraPackages","FormTracer"}]
},
Select[$Path,StringContainsQ[#,"FormTracer"]&]
],
DirectoryQ[#]&
]<>"/"//Quiet;
If[Head[FTDirectory]=!=String,Return[False]];
Return[True];
];
If[Not@FormTracerInstalled[],
If[ChoiceDialog["FormTracer does not seem to be installed. Do you want to install it?",WindowTitle->"Install FormTracer",WindowSize->{Medium,All}],
Import["https://raw.githubusercontent.com/FormTracer/FormTracer/master/src/FormTracerInstaller.m"],
Print["The \!\(\*
StyleBox[\"TensorBases\",\nFontWeight->\"Bold\"]\) package requires \!\(\*
StyleBox[\"FormTracer\",\nFontWeight->\"Bold\"]\) to run."];Abort[];
];
];
If[Not@FormTracerLoaded[],
Block[{Print},Get["FormTracer`"]];
If[FormTracerLoaded[],
Print["\!\(\*
StyleBox[\"FormTracer\",\nFontWeight->\"Bold\"]\) package loaded. "];,
Print["Error: Could not load \!\(\*
StyleBox[\"FormTracer\",\nFontWeight->\"Bold\"]\)\!\(\*
StyleBox[\" \",\nFontWeight->\"Bold\"]\)package."];Abort[];
],
Print["\!\(\*
StyleBox[\"FormTracer\",\nFontWeight->\"Bold\"]\) package already loaded. "];
Print["Clearing all extra variables for compatibility!\n"];
FormTracer`DefineExtraVars[];
];
Block[{Print},FiniteT[True];]
Block[{Print},FastGamma5Trace[True];]
If[Head[$DistributedContexts]=!=List,$DistributedContexts={}];
$DistributedContexts=$DistributedContexts\[Union]{$Context,"TensorBases`Private`","TensorBases`","FormTracer`","FormTracer`Private`"}
Print["To see all (user-defined and package-defined) FormTracer definitions, call \!\(\*
StyleBox[\"TBInfo\",\nFontColor->RGBColor[1, 0.5, 0]]\)[\"FormTracer\"].
Furthermore, \!\(\*
StyleBox[\"TensorBases\",\nFontWeight->\"Bold\"]\)\!\(\*
StyleBox[\" \",\nFontWeight->\"Bold\"]\)extends \!\(\*
StyleBox[\"FormTracer\",\nFontWeight->\"Bold\"]\). To see all extensions, call \!\(\*
StyleBox[\"TBInfo\",\nFontColor->RGBColor[1, 0.5, 0]]\)[\"Extensions\"]"];
Print["\nTo see all momentum transformations that can be performed by \!\(\*
StyleBox[\"TensorBases\",\nFontWeight->\"Bold\"]\), call \!\(\*
StyleBox[\"TBInfo\",\nFontColor->RGBColor[1, 0.5, 0]]\)[\"Momenta\"].\n"];
GetFormTracerGroups::usage="GetFormTracerGroups[]";
FormTracerGroupExistsQ::usage="GetFormTracerGroupList[name_Symbol]";
GetFormTracerGroupList::usage="GetFormTracerGroupList[name_Symbol]";
AddGroupTensors::usage="AddGroupTensors[groupDef_List]";
GetFormTracerGroupConstants::usage="GetFormTracerGroupConstants[]";
GetFormTracerGroupConstant::usage="GetFormTracerGroupConstant[name_Symbol]";
AddFormTracerGroup::usage="AddFormTracerGroup[{ingroupName_Symbol,inkind_Symbol,inconstant_}]";
UseLorentzLinearitySP::usage="";
UseLorentzLinearityVec::usage="";
UseLorentzLinearity::usage="";
TBInsertCombinedLorentzTensors::usage="";
ShowFormTracerExtensions[]:=Module[{},
Print["\!\(\*
StyleBox[\"TensorBases\",\nFontWeight->\"Bold\"]\) defines the following functions in extension to \!\(\*
StyleBox[\"FormTracer\",\nFontWeight->\"Bold\"]\) functionality.
In order to get detailed information on each of those, please call their usage messages, e.g. \!\(\*
StyleBox[\"GetFormTracerGroups\",\nFontColor->RGBColor[1, 0.5, 0]]\)::\!\(\*
StyleBox[\"usage\",\nFontColor->RGBColor[0, 0, 1]]\).
\!\(\*
StyleBox[\"GetFormTracerGroups\",\nFontColor->RGBColor[1, 0.5, 0]]\),
\!\(\*
StyleBox[\"FormTracerGroupExists\",\nFontColor->RGBColor[1, 0.5, 0]]\),
\!\(\*
StyleBox[\"GetFormTracerGroupList\",\nFontColor->RGBColor[1, 0.5, 0]]\),
\!\(\*
StyleBox[\"AddGroupTensors\",\nFontColor->RGBColor[1, 0.5, 0]]\),
\!\(\*
StyleBox[\"AddFormTracerGroup\",\nFontColor->RGBColor[1, 0.5, 0]]\),
\!\(\*
StyleBox[\"GetFormTracerGroupConstants\",\nFontColor->RGBColor[1, 0.5, 0]]\),
\!\(\*
StyleBox[\"GetFormTracerGroupConstant\",\nFontColor->RGBColor[1, 0.5, 0]]\),
\!\(\*
StyleBox[\"UseLorentzLinearitySP\",\nFontColor->RGBColor[1, 0.5, 0]]\),
\!\(\*
StyleBox[\"UseLorentzLinearityVec\",\nFontColor->RGBColor[1, 0.5, 0]]\),
\!\(\*
StyleBox[\"UseLorentzLinearity\",\nFontColor->RGBColor[1, 0.5, 0]]\),
\!\(\*
StyleBox[\"TBInsertCombinedLorentzTensors\",\nFontColor->RGBColor[1, 0.5, 0]]\)"];
];
GetFormTracerGroups[]:=FormTracer`Private`groupNames;
FormTracerGroupExistsQ[name_Symbol]:=Module[{},
If[Not@MemberQ[GetFormTracerGroups[],name],
Return[False];,
Return[True];
];
];
GetFormTracerGroupTypes[]:=FormTracer`Private`groupTypes;
GetFormTracerGroupNamesAndTypes[]:=Transpose[{FormTracer`Private`groupNames,FormTracer`Private`groupTypes}]
GetFormTracerGroupList[name_Symbol]:=Module[{idx,type,constant,mRules,funcs},
If[Not@FormTracerGroupExistsQ[name],
Print["Logic error: "~~ToString[name]~~" is not an already defined group"];
Abort[];
];
idx=Flatten[Position[FormTracer`Private`groupNames,name]][[1]];
type=FormTracer`Private`groupTypes[[idx]];
constant=FormTracer`Private`groupConstantsTable[[idx]][[1]];
mRules=Select[Normal[FormTracer`Private`groupTensorReplacementRulesOutput],MemberQ[#,name,Infinity]&];
funcs=mRules//.(a_:>b_):>b//.a_[b___,FormTracer`Private`a$]->a[b,i,j,k];
Join[{type, {name, constant}},funcs]
];
AddGroupTensors[groupDef_List]:=Module[{alreadyPresent},
alreadyPresent=Map[GetFormTracerGroupList,FormTracer`Private`groupNames];
DefineGroupTensors[Join[
alreadyPresent,
{groupDef}
]]
]
RemoveGroupTensor[name_]:=Module[{alreadyPresent,obj},
alreadyPresent=Map[GetFormTracerGroupList,FormTracer`Private`groupNames];
obj=Select[alreadyPresent,MemberQ[#,name,Infinity]&];
If[Length[obj]===0,Print["No group called "<>ToString[name]<>" present!"];Abort[]];
DefineGroupTensors[
DeleteCases[alreadyPresent,obj[[1]]]
]
];
SetNf[3]:=Module[{},
RemoveGroupTensor[flavor];
Unprotect[Nf];
ClearAll[Nf];
Nf=3;
Protect[Nf];
AddGroupTensors[{FormTracer`SU3fundexplicit, {flavor,3}, deltaAdjFlav[a, b], FFlav[a, b, c], deltaFundFlav[a, b], TFlav[a, b, c], epsAdjFlav[a, b, c],epsFundFlav[a, b, c]}];
]
SetNf[2]:=Module[{},
RemoveGroupTensor[flavor];
Unprotect[Nf];
ClearAll[Nf];
Nf=2;
Protect[Nf];
AddGroupTensors[{FormTracer`SU2fundexplicit, {flavor,2}, deltaAdjFlav[a, b], FFlav[a, b, c], deltaFundFlav[a, b], TFlav[a, b, c], epsAdjFlav[a, b, c],epsFundFlav[a, b, c]}];
]
SetNf[]:=Module[{},
RemoveGroupTensor[flavor];
Unprotect[Nf];
ClearAll[Nf];
AddFormTracerGroup[{flavor,SUNfund,Nf}];
]
SetNf[i_]:=Print["Can only set flavor group number to 2 or 3; to set it to Nf, use SetNf[]"]
SetNc[3]:=Module[{},
RemoveGroupTensor[color];
Unprotect[Nc];
ClearAll[Nc];
Nc=3;
Protect[Nc];
AddGroupTensors[{FormTracer`SU3fundexplicit, {color,3}, deltaAdjCol[a, b], FCol[a, b, c], deltaFundCol[a, b], TCol[a, b, c],epsAdjCol[a, b, c], epsFundCol[a, b, c]}];
]
SetNc[2]:=Module[{},
RemoveGroupTensor[color];
Unprotect[Nc];
ClearAll[Nc];
Nc=2;
Protect[Nc];
AddGroupTensors[{FormTracer`SU2fundexplicit, {color,2}, deltaAdjCol[a, b], FCol[a, b, c], deltaFundCol[a, b], TCol[a, b, c],epsAdjCol[a, b, c], epsFundCol[a, b, c]}];
]
SetNc[]:=Module[{},
RemoveGroupTensor[color];
Unprotect[Nc];
ClearAll[Nc];
Protect[Nc];
AddFormTracerGroup[{color,SUNfund,Nc}];
]
SetNc[i_]:=Print["Can only set color group number to 2 or 3; to set it to Nc, use SetNc[]"]
GetFormTracerGroupConstants[]:=Module[{},
Return[FormTracer`Private`groupConstantsTable[[All,1]]];
];
GetFormTracerGroupConstant[name_Symbol]:=Module[{idx},
idx=Position[GetFormTracerGroups[],name][[1,1]];
Return[GetFormTracerGroupConstants[][[idx]]]
]
MakeConstant[name_Symbol]:=Module[{stripped},
Return[Symbol[SymbolName[name]]];
]
MakeConstant[number_Integer]:=number;
AddFormTracerGroup[{ingroupName_Symbol,inkind_Symbol,inconstant_}]:=Module[
{
groupName,kind,constant,args,
a,b,c
},
groupName=Symbol[SymbolName[ingroupName]];
kind=Symbol["FormTracer`"~~SymbolName[inkind]];
constant=Evaluate[Global`MakeConstant[inconstant]];
If[groupName===color,
Unprotect[color,Nc];
If[Not@FormTracerGroupExistsQ[color],
ClearAll[color];
Print["\!\(\*
StyleBox[\"Group\",\nFontSize->10]\)\!\(\*
StyleBox[\" \",\nFontSize->10]\)\!\(\*
StyleBox[\"with\",\nFontSize->10]\)\!\(\*
StyleBox[\" \",\nFontSize->10]\)\!\(\*
StyleBox[\"name\",\nFontSize->10]\)\!\(\*
StyleBox[\" \",\nFontSize->10]\)\!\(\*
StyleBox[\"color\",\nFontSize->10,\nFontColor->RGBColor[0.5, 0, 0.5]]\)\!\(\*
StyleBox[\" \",\nFontSize->10]\)\!\(\*
StyleBox[\"undefined\",\nFontSize->10]\)\!\(\*
StyleBox[\",\",\nFontSize->10]\)\!\(\*
StyleBox[\" \",\nFontSize->10]\)\!\(\*
StyleBox[\"using\",\nFontSize->10]\)\!\(\*
StyleBox[\" \",\nFontSize->10]\)\!\(\*
StyleBox[\"default\",\nFontSize->10]\)\!\(\*
StyleBox[\" \",\nFontSize->10]\)\!\(\*
StyleBox[\"names\",\nFontSize->10]\)\!\(\*
StyleBox[\".\",\nFontSize->10]\)"];
If[IntegerQ[Nc]&&2<=Nc<=3,Print["Nc is set to ", Nc],
ClearAll[Nc]];
AddGroupTensors[{FormTracer`SUNfund, {color,Global`Nc}, deltaAdjCol[a, b], FCol[a, b, c], deltaFundCol[a, b], TCol[a, b, c],epsAdjCol[a, b, c], epsFundCol[a, b, c]}];
];
Protect[color,Nc];
Return[];
];
If[groupName===flavor,
Unprotect[flavor,Nf];
If[Not@FormTracerGroupExistsQ[flavor],
ClearAll[flavor];
Print["\!\(\*
StyleBox[\"Group\",\nFontSize->10]\)\!\(\*
StyleBox[\" \",\nFontSize->10]\)\!\(\*
StyleBox[\"with\",\nFontSize->10]\)\!\(\*
StyleBox[\" \",\nFontSize->10]\)\!\(\*
StyleBox[\"name\",\nFontSize->10]\)\!\(\*
StyleBox[\" \",\nFontSize->10]\)\!\(\*
StyleBox[\"flavor\",\nFontSize->10,\nFontColor->RGBColor[0.5, 0, 0.5]]\)\!\(\*
StyleBox[\" \",\nFontSize->10]\)\!\(\*
StyleBox[\"undefined\",\nFontSize->10]\)\!\(\*
StyleBox[\",\",\nFontSize->10]\)\!\(\*
StyleBox[\" \",\nFontSize->10]\)\!\(\*
StyleBox[\"using\",\nFontSize->10]\)\!\(\*
StyleBox[\" \",\nFontSize->10]\)\!\(\*
StyleBox[\"default\",\nFontSize->10]\)\!\(\*
StyleBox[\" \",\nFontSize->10]\)\!\(\*
StyleBox[\"names\",\nFontSize->10]\)\!\(\*
StyleBox[\".\",\nFontSize->10]\)"];
If[IntegerQ[Nf]&&2<=Nf<=3,Print["Nc is set to ", Nc],
ClearAll[Nf]];
AddGroupTensors[{FormTracer`SUNfund, {flavor,Global`Nf}, deltaAdjFlav[a, b], FFlav[a, b, c], deltaFundFlav[a, b], TFlav[a, b, c], epsAdjFlav[a, b, c],epsFundFlav[a, b, c]}];
];
Protect[flavor,Nf];
Return[];
];
Unprotect[Evaluate[groupName]];
If[Not@FormTracerGroupExistsQ[groupName],
ClearAll[Evaluate[groupName]];
Print["\!\(\*
StyleBox[\"Group\",\nFontSize->10]\)\!\(\*
StyleBox[\" \",\nFontSize->10]\)\!\(\*
StyleBox[\"with\",\nFontSize->10]\)\!\(\*
StyleBox[\" \",\nFontSize->10]\)\!\(\*
StyleBox[\"name\",\nFontSize->10]\)\!\(\*
StyleBox[\" \",\nFontSize->10]\)"~~ToString[Style[ToString[groupName],Purple]]~~"\!\(\*
StyleBox[\" \",\nFontSize->10]\)\!\(\*
StyleBox[\"undefined\",\nFontSize->10]\)\!\(\*
StyleBox[\",\",\nFontSize->10]\)\!\(\*
StyleBox[\" \",\nFontSize->10]\)\!\(\*
StyleBox[\"using\",\nFontSize->10]\)\!\(\*
StyleBox[\" \",\nFontSize->10]\)\!\(\*
StyleBox[\"default\",\nFontSize->10]\)\!\(\*
StyleBox[\" \",\nFontSize->10]\)\!\(\*
StyleBox[\"names\",\nFontSize->10]\)\!\(\*
StyleBox[\".\",\nFontSize->10]\)"];
If[IntegerQ[constant]&&2<=constant<=3,Print["Group constant is set to ", constant],
Unprotect[Evaluate[constant]];ClearAll[Evaluate[constant]]];
args={kind, {groupName,constant}, deltaAdj[groupName,a, b], F[groupName,a, b, c], deltaFund[groupName,a, b], T[groupName,a, b, c],epsAdj[groupName,a, b, c], epsFund[groupName,a, b, c]};
AddGroupTensors@args;
];
If[Not@IntegerQ[constant],Protect[constant]];
Protect[Evaluate[groupName]];
];
If[Length[Normal[FormTracer`Private`lorentzTensorReplacementRulesInput]]==0,
Print["\!\(\*
StyleBox[\"Lorentz\",\nFontSize->10,\nFontColor->RGBColor[0.5, 0, 0.5]]\)\!\(\*
StyleBox[\" \",\nFontSize->10]\)\!\(\*
StyleBox[\"group\",\nFontSize->10]\)\!\(\*
StyleBox[\" \",\nFontSize->10]\)\!\(\*
StyleBox[\"undefined\",\nFontSize->10]\)\!\(\*
StyleBox[\",\",\nFontSize->10]\)\!\(\*
StyleBox[\" \",\nFontSize->10]\)\!\(\*
StyleBox[\"using\",\nFontSize->10]\)\!\(\*
StyleBox[\" \",\nFontSize->10]\)\!\(\*
StyleBox[\"default\",\nFontSize->10]\)\!\(\*
StyleBox[\" \",\nFontSize->10]\)\!\(\*
StyleBox[\"names\",\nFontSize->10]\)\!\(\*
StyleBox[\".\",\nFontSize->10]\)"];
DefineLorentzTensors[deltaLorentz[mu, nu], vec[p, mu], sp[p, q], epsLorentz[i, j, k], deltaDirac[i, j], gamma[mu, i, j], gamma5[i, j], vecs[p, mu], sps[p, q]];
];
TBInsertOutputNaming[expr_]:=Module[
{outputRulesLorentzTensors,outputRulesGroupTensors,outputRules},
outputRulesLorentzTensors=Normal[FormTracer`Private`lorentzTensorReplacementRulesOutput]/.{(a_[c___]:>b_):>(Symbol["Global`TB"~~StringSplit[ToString[a],"FTx"][[-1]]][c]:>b)};
outputRulesGroupTensors=Normal[FormTracer`Private`groupTensorReplacementRulesOutput]/.{(a_[c___]:>b_):>(Symbol["Global`TB"~~StringSplit[ToString[a],"FTx"][[-1]]][c]:>b)};
outputRules=Join[outputRulesLorentzTensors,outputRulesGroupTensors];
Return[expr//.outputRules];
];
TBInsertLorentzNames[expr_]:=Module[
{outputNameRulesLorentzTensors},
outputNameRulesLorentzTensors=Normal[FormTracer`Private`lorentzTensorReplacementRulesOutput]/.{(a_[c___]:>b_[d___]):>(Symbol["Global`TB"~~StringSplit[ToString[a],"FTx"][[-1]]]:>b)};
Return[Evaluate[expr//.outputNameRulesLorentzTensors]];
]
Unprotect[UseLorentzLinearity,UseLorentzLinearitySP,UseLorentzLinearityVec];
UseLorentzLinearitySP[expr_]:=Module[{eval,conv=TBInsertLorentzNames},
SetAttributes[Evaluate[conv[TBsps]],Orderless];
SetAttributes[Evaluate[conv[TBsp]],Orderless];
conv[TBsp][0,a_]=0;
conv[TBsp][a_,0]=0;
conv[TBsp][0,0]=0;
conv[TBsps][0,a_]=0;
conv[TBsps][a_,0]=0;
conv[TBsps][0,0]=0;
conv[TBsp][a_,b_+c_]:= conv[TBsp][a,b]+conv[TBsp][a,c];
conv[TBsp][a_,-1b_]:= -conv[TBsp][a,b];
conv[TBsp][b_,a_?NumericQ c_]:= a conv[TBsp][b,c];
conv[TBsps][a_,b_+c_]:= conv[TBsps][a,b]+conv[TBsps][a,c];
conv[TBsps][a_,-1b_]:= -conv[TBsps][a,b];
conv[TBsps][b_,a_?NumericQ c_]:= a conv[TBsps][b,c];
eval=Evaluate[expr];
ClearAll[
Evaluate[conv[TBsps]],
Evaluate[conv[TBsp]]
];
Return[eval];
];
UseLorentzLinearityVec[expr_]:=Module[{eval,conv=TBInsertLorentzNames},
conv[TBvec][0,mu_]=0;
conv[TBvecs][0,mu_]=0;
conv[TBvecs][p_,0]=0;
conv[TBvec][p_+q_,mu_]:=conv[TBvec][p,mu]+conv[TBvec][q,mu];
conv[TBvec][-1 p_,mu_]:= -conv[TBvec][p,mu];
conv[TBvec][n_?NumericQ a_,mu_]:=n conv[TBvec][a,mu];
conv[TBvecs][p_+q_,mu_]:=conv[TBvecs][p,mu]+conv[TBvecs][q,mu];
conv[TBvecs][-1 p_,mu_]:= -conv[TBvecs][p,mu];
conv[TBvecs][n_?NumericQ a_,mu_]:=n conv[TBvecs][a,mu];
eval=Evaluate[expr];
ClearAll[
Evaluate[conv[TBvec]],
Evaluate[conv[TBvecs]]
];
Return[eval];
];
UseLorentzLinearity[expr_]:=UseLorentzLinearitySP[UseLorentzLinearityVec[expr]];
Protect[UseLorentzLinearity,UseLorentzLinearitySP,UseLorentzLinearityVec];
Unprotect[sigma,pdash,psdash];
sigma[v1_,v2_,d1_,d2_]:=Module[{dint1,dint2},TBInsertOutputNaming[I/2 (TBgamma[v1,d1,dint1]TBgamma[v2,dint1,d2]-TBgamma[v2,d1,dint2]TBgamma[v1,dint2,d2])]];pdash[p_,i_,j_]:=Module[{mu},TBInsertOutputNaming[TBgamma[mu,i,j]TBvec[p,mu]]];
psdash[p_,i_,j_]:=Module[{mu},TBInsertOutputNaming[TBgamma[mu,i,j]TBvecs[p,mu]]];
Protect[sigma,pdash,psdash];
TensorBases`Private`LTCache=
FormTracer`Private`combinedLorentzTensorInputCache;
removeObj[expr_]:=Module[{pos},
pos=FirstPosition[TensorBases`Private`LTCache,expr][[1]];
If[IntegerQ[pos],
TensorBases`Private`LTCache=Delete[TensorBases`Private`LTCache,pos]
];
];
removeObj/@{transProj[_,_,_],transProj[_,_,_,_],longProj[_,_,_],transProjMagnetic[_,_,_],transProjElectric[_,_,_]};
ClearAll[removeObj];
DefineCombinedLorentzTensors[
TBInsertOutputNaming[Union[
TensorBases`Private`LTCache,
{
(*zero temperature*)
{
transProj[p,mu,nu],
TBdeltaLorentz[mu,nu]-TBvec[p,mu]TBvec[p,nu]/TBsp[p,p]
},
{
transProj[p,q,mu,nu],
TBdeltaLorentz[mu,nu]-TBvec[p,mu]TBvec[q,nu]/TBsp[p,q]
},
{
longProj[p,mu,nu],
TBvec[p,mu]TBvec[p,nu]/TBsp[p,p]
},
(*finite temperature*)
{
transProjMagnetic[p,mu,nu],
TBdeltaLorentz[mu,nu]-(TBvecs[p,mu]TBvecs[p,nu])/TBsps[p,p]-TBdeltaLorentz[mu,0]*TBdeltaLorentz[nu,0]
},
{
transProjElectric[p,mu,nu],
TBdeltaLorentz[mu,0] TBdeltaLorentz[nu,0]-(TBvec[p,mu] TBvec[p,nu])/TBsp[p,p]+(TBvecs[p,mu] TBvecs[p,nu])/TBsps[p,p]
}
}
]]
];
TensorBases`Private`LTCache=
FormTracer`Private`lorentzTensorIdentitiesInputCache;
removeObj[expr_]:=Module[{pos},
pos=FirstPosition[TensorBases`Private`LTCache,expr][[1]];
If[IntegerQ[pos],
TensorBases`Private`LTCache=Delete[TensorBases`Private`LTCache,pos]
];
];
removeObj/@{transProj[_,_,_],transProj[_,_,_,_],longProj[_,_,_],transProjMagnetic[_,_,_],transProjElectric[_,_,_]};
ClearAll[removeObj];
DefineLorentzTensorIdentities[Union[TensorBases`Private`LTCache,{
(*zero temperature*)
{transProj[p,mu,rho]transProj[p,rho,nu],transProj[p,mu,nu]},
{transProj[p,mu,rho]transProj[p,nu,rho],transProj[p,mu,nu]},
{transProj[p,rho,mu]transProj[p,rho,nu],transProj[p,mu,nu]},
{longProj[p,mu,rho]longProj[p,rho,nu],longProj[p,mu,nu]},
{longProj[p,mu,rho]longProj[p,nu,rho],longProj[p,mu,nu]},
{longProj[p,rho,mu]longProj[p,rho,nu],longProj[p,mu,nu]},
{transProj[p,mu,rho]longProj[p,rho,nu],0},
{transProj[p,rho,mu]longProj[p,rho,nu],0},
{transProj[p,mu,rho]longProj[p,nu,rho],0},
(*finite temperature*)
{transProjMagnetic[p,mu,rho]transProjMagnetic[p,rho,nu],transProjMagnetic[p,mu,nu]},
{transProjMagnetic[p,mu,rho]transProjMagnetic[p,nu,rho],transProjMagnetic[p,mu,nu]},
{transProjMagnetic[p,rho,mu]transProjMagnetic[p,rho,nu],transProjMagnetic[p,mu,nu]},
{transProjElectric[p,mu,rho]transProjElectric[p,rho,nu],transProjElectric[p,mu,nu]},
{transProjElectric[p,mu,rho]transProjElectric[p,nu,rho],transProjElectric[p,mu,nu]},
{transProjElectric[p,rho,mu]transProjElectric[p,rho,nu],transProjElectric[p,mu,nu]},
{transProjMagnetic[p,mu,rho]transProjElectric[p,rho,nu],0},
{transProjMagnetic[p,mu,rho]transProjElectric[p,nu,rho],0},
{transProjMagnetic[p,rho,mu]transProjElectric[p,rho,nu],0},
{transProjMagnetic[p,mu,rho]longProj[p,rho,nu],0},
{transProjMagnetic[p,mu,rho]longProj[p,nu,rho],0},
{transProjMagnetic[p,rho,mu]longProj[p,rho,nu],0},
{transProjElectric[p,mu,rho]longProj[p,rho,nu],0},
{transProjElectric[p,mu,rho]longProj[p,nu,rho],0},
{transProjElectric[p,rho,mu]longProj[p,rho,nu],0}
}]
];
TBReplacementsLorentzTensors=Flatten[{
(*zero temperature*)
{transProj[p_,mu_,rho_]transProj[p_,rho_,nu_]:>transProj[p,mu,nu]},
{transProj[p_,mu_,rho_]transProj[p_,nu_,rho_]:>transProj[p,mu,nu]},
{transProj[p_,rho_,mu_]transProj[p_,rho_,nu_]:>transProj[p,mu,nu]},
{longProj[p_,mu_,rho_]longProj[p_,rho_,nu_]:>longProj[p,mu,nu]},
{longProj[p_,mu_,rho_]longProj[p_,nu_,rho_]:>longProj[p,mu,nu]},
{longProj[p_,rho_,mu_]longProj[p_,rho_,nu_]:>longProj[p,mu,nu]},
{transProj[p_,mu_,rho_]longProj[p_,rho_,nu_]:>0},
{transProj[p_,rho_,mu_]longProj[p_,rho_,nu_]:>0},
{transProj[p_,mu_,rho_]longProj[p_,nu_,rho_]:>0}
}];
TBCombinedLorentzTensorsList={
transProj[p_,mu_,nu_]:>TBInsertOutputNaming[TBdeltaLorentz[mu,nu]-TBvec[p,mu]TBvec[p,nu]/TBsp[p,p]],
transProj[p_,q_,mu_,nu_]:>TBInsertOutputNaming[TBdeltaLorentz[mu,nu]-TBvec[p,mu]TBvec[q,nu]/TBsp[p,q]],
longProj[p_,mu_,nu_]:>TBInsertOutputNaming[TBvec[p,mu]TBvec[p,nu]/TBsp[p,p]],
(*finite temperature*)
transProjMagnetic[p_,mu_,nu_]:>TBInsertOutputNaming[TBdeltaLorentz[mu,nu]-(TBvecs[p,mu]TBvecs[p,nu])/TBsps[p,p]-TBdeltaLorentz[mu,0]*TBdeltaLorentz[nu,0]],
transProjElectric[p_,mu_,nu_]:>TBInsertOutputNaming[TBdeltaLorentz[mu,0] TBdeltaLorentz[nu,0]-(TBvec[p,mu] TBvec[p,nu])/TBsp[p,p]+(TBvecs[p,mu] TBvecs[p,nu])/TBsps[p,p]]
};
TBInsertCombinedLorentzTensors[expr_]:=expr//.TBReplacementsLorentzTensors//.TBCombinedLorentzTensorsList;
ShowFormTracerDefinitions[]:=Module[{els},
Print["FormTracer Names: ",TableForm[Join[
{
{"\!\(\*SubscriptBox[\(\[Delta]\), \(ij\)]\) in Lorentz group",TBdeltaLorentz[i,j]},
{"\!\(\*SubscriptBox[\(p\), \(\[Mu]\)]\) Lorentz vector",TBvec[p,\[Mu]]},
{"\!\(\*SubscriptBox[\(p\), \(i\)]\) spatial Lorentz vector",TBvecs[p,i]},
{"\!\(\*SubscriptBox[\(p\), \(\[Mu]\)]\)\!\(\*SubscriptBox[\(q\), \(\[Mu]\)]\) scalar product",TBsp[p,q]},
{"\!\(\*SubscriptBox[\(p\), \(i\)]\)\!\(\*SubscriptBox[\(q\), \(i\)]\) spatial calar product ",TBsps[p,q]},
{"",""},
{"\!\(\*SubscriptBox[\(\[Delta]\), \(ij\)]\) in Spinor group",TBdeltaDirac[i,j]},
{"\!\(\*SubscriptBox[\(\[Gamma]\), \(\[Mu]\)]\)",TBgamma[\[Mu],d1,d2]},
{"\!\(\*SubscriptBox[\(\[Gamma]\), \(5\)]\)",TBgamma5[d1,d2]},
{"\!\(\*SubscriptBox[\(\[Epsilon]\), \(\[Mu]\[Nu]\[Rho]\)]\)",TBepsLorentz[\[Mu],\[Nu],\[Rho]]},
{"",""}
},
Flatten[Map[{
{"adjoint \!\(\*SubscriptBox[\(\[Delta]\), \(ab\)]\)",TBdeltaAdj[#,a,b]},
{"fundamental \!\(\*SubscriptBox[\(\[Delta]\), \(AB\)]\)",TBdeltaFund[#,A,B]},
{"\!\(\*FractionBox[SubscriptBox[\(f\), \(abc\)], \(2\)]\)",TBF[#,a, b, c]},
{"(\!\(\*SubscriptBox[\(t\), \(a\)]\)\!\(\*SubscriptBox[\()\), \(BC\)]\)",TBT[#,a, B, C]},
{"\!\(\*SubscriptBox[\(\[Epsilon]\), \(abc\)]\)",TBepsAdj[#,a, b, c]},
{"\!\(\*SubscriptBox[\(\[Epsilon]\), \(ABC\)]\)",TBepsFund[#,A, B, C]},
{"group constant",GetFormTracerGroupConstant[#]},
{"",""}}&,GetFormTracerGroups[]],1]
]//TBInsertOutputNaming
,TableHeadings->{Join[
{"Lorentz","","","","","",
"spinor","","","",""},
Flatten[Map[{#,"","","","","","",""}&,
Map[ToString[#[[1]]]<>"("<>ToString[#[[2]]]<>")"&,GetFormTracerGroupNamesAndTypes[]]
],1]
]
, {"object","name"}},TableSpacing->{3, 3}]];
els=Transpose[{
TBCombinedLorentzTensorsList//.(a_[b___]:>f_):>a@@ToExpression[StringReplace[ToString[{b}],"_"->""]],
TBCombinedLorentzTensorsList//.(a_[b___]:>f_):>f
}];
Print["\nCombined Lorentz tensors: ",TableForm[Transpose[{els[[All,2]]}],TableHeadings->{els[[All,1]],{"replacement","name"}},TableSpacing->{3, 5}]];
Print["\nThese can be explicitly evaluated by using e.g. \!\(\*
StyleBox[\"TBInsertCombinedLorentzTensors\",\nFontColor->RGBColor[1, 0.5, 0]]\)[transProj[p,\[Mu],\[Nu]]]"];
Print["\n
TensorBases defines additionally the following Lorentz tensors:
sigma[\[Mu],\[Nu],\!\(\*SubscriptBox[\(d\), \(1\)]\),\!\(\*SubscriptBox[\(d\), \(2\)]\)] : \!\(\*FractionBox[\(\[ImaginaryI]\), \(2\)]\)[\!\(\*SubscriptBox[\(\[Gamma]\), \(\[Mu]\)]\),\!\(\*SubscriptBox[\(\[Gamma]\), \(\[Nu]\)]\)\!\(\*SubscriptBox[\(]\), \(\*SubscriptBox[\(d\), \(1\)] \*SubscriptBox[\(d\), \(2\)]\)]\)
pdash[p,\!\(\*SubscriptBox[\(d\), \(1\)]\),\!\(\*SubscriptBox[\(d\), \(2\)]\)] : (\!\(\*SubscriptBox[\(\[Gamma]\), \(\[Mu]\)]\)\!\(\*SubscriptBox[\(p\), \(\[Mu]\)]\)\!\(\*SubscriptBox[\()\), \(\*SubscriptBox[\(d\), \(1\)] \*SubscriptBox[\(d\), \(2\)]\)]\)
psdash[p,\!\(\*SubscriptBox[\(d\), \(1\)]\),\!\(\*SubscriptBox[\(d\), \(2\)]\)] : (\!\(\*SubscriptBox[\(\[Gamma]\), \(i\)]\)\!\(\*SubscriptBox[\(p\), \(i\)]\)\!\(\*SubscriptBox[\()\), \(\*SubscriptBox[\(d\), \(1\)] \*SubscriptBox[\(d\), \(2\)]\)]\)
Further useful functions defined by TensorBases:
\!\(\*
StyleBox[\"UseLorentzLinearity\",\nFontColor->RGBColor[1, 0.5, 0]]\)[expr] expands all scalar products and vectors in expr (e.g. sp[p1,p2-p3] -> sp[p1,p2]-sp[p1,p3])
\!\(\*
StyleBox[\"AddFormTracerGroup\",\nFontColor->RGBColor[1, 0.5, 0]]\)[{name,kind,constant}] adds a group to FormTracer where name is an identifier, kind is one of {SUNfund, SONfund, SU3fundexplicit, SU2fundexplicit,SPNfund} (see also FormTracer`ShowGroupTemplates[]) and constant is the identifier for the group constant.
\!\(\*
StyleBox[\"RemoveFormTracerGroup\",\nFontColor->RGBColor[1, 0.5, 0]]\)[name] removes a group from FormTracer where name is an identifier.
\!\(\*
StyleBox[\"SetNf\",\nFontColor->RGBColor[1, 0.5, 0]]\)[3],\!\(\*
StyleBox[\"SetNf\",\nFontColor->RGBColor[1, 0.5, 0]]\)[2],\!\(\*
StyleBox[\"SetNf\",\nFontColor->RGBColor[1, 0.5, 0]]\)[] sets the flavor number to 3, 2 or the general Nf.
\!\(\*
StyleBox[\"SetNc\",\nFontColor->RGBColor[1, 0.5, 0]]\)[3],\!\(\*
StyleBox[\"SetNc\",\nFontColor->RGBColor[1, 0.5, 0]]\)[2],\!\(\*
StyleBox[\"SetNc\",\nFontColor->RGBColor[1, 0.5, 0]]\)[] sets the color number to 3, 2 or the general Nc.
"];
];
BeginPackage["TensorBases`"];
Unprotect["TensorBases`*"];
Unprotect["TensorBases`Private`*"];
ClearAll["TensorBases`*"];
ClearAll["TensorBases`Private`*"];
If[Head[$DistributedContexts]=!=List,$DistributedContexts={}];
$DistributedContexts=$DistributedContexts\[Union]{$Context,"TensorBases`Private`","TensorBases`","FormTracer`","FormTracer`Private`"}
Tensor::usage="Symbol used by TensorBases to express vertex structures";
Tensor1::usage="Symbol used by TensorBases to express inner & canonical products";
Tensor2::usage="Symbol used by TensorBases to express inner & canonical products";
TBGetBasisElement::usage = "TBGetBasisElement[BasisName_String,n_Integer,indices___]
Obtains the n-th element of the specified basis. The given indices must match the ones specified by the basis, see TBInfo[].
If no indices are given, the standard indices specified by the basis are used.
TBGetBasisElement[BasisName_String,All,indices___]
Returns a list with all elements of the specified basis. The given indices must match the ones specified by the basis, see TBInfo[].
If no indices are given, the standard indices specified by the basis are used.";
TBGetVertex::usage = "TBGetVertex[BasisName_String,n_Integer,indices___]
Obtains the n-th vertex of the specified basis. The given indices must match the ones specified by the basis, see TBInfo[].
If no indices are given, the standard indices specified by the basis are used.
TBGetVertex[BasisName_String,All,indices___]
Returns a list with all vertices of the specified basis. The given indices must match the ones specified by the basis, see TBInfo[].
If no indices are given, the standard indices specified by the basis are used.";
TBGetInnerProduct::usage = "TBGetInnerProduct[BasisName_String]
Returns the bilinear operator \[ScriptCapitalO] that represents the inner product of the specified basis.
It can be called as \[ScriptCapitalO][Tensor1, n, Tensor2, m], where Tensor1 and Tensor2 are functions with signatures Tensor[BasisName_String, n_Integer, indices___].
For example, \[ScriptCapitalO][TBGetBasisElement, 2, TBGetBasisElement, 1] returns <\!\(\*SubscriptBox[\(e\), \(2\)]\),\!\(\*SubscriptBox[\(e\), \(1\)]\)>.";
TBGetCanonicalProduct::usage = "TBGetCanonicalProduct[BasisName_String]
Returns the bilinear operator \[ScriptCapitalO] that represents the canonical product (i.e. the euclidean inner product) of the specified basis.
It can be called as \[ScriptCapitalO][Tensor1, n, Tensor2, m], where Tensor1 and Tensor2 are functions with signatures Tensor[BasisName_String, n_Integer, indices___].
For example, \[ScriptCapitalO][TBGetBasisElement, 2, TBGetBasisElement, 1] returns <\!\(\*SubscriptBox[\(e\), \(2\)]\),\!\(\*SubscriptBox[\(e\), \(1\)]\)\!\(\*SubscriptBox[\(>\), \(can\)]\).";
TBGetMetric::usage = "TBGetMetric[BasisName_String]
Returns the metric of the specified basis, i.e. the matrix \!\(\*SubscriptBox[\(g\), \(ij\)]\) = <\!\(\*SubscriptBox[\(e\), \(i\)]\),\!\(\*SubscriptBox[\(e\), \(j\)]\)>, where the \!\(\*SubscriptBox[\(e\), \(i\)]\) are the basis elements of the basis.";
TBGetInverseMetric::usage = "TBGetInverseMetric[BasisName_String]
Returns the inverse of the metric of the specified basis, i.e. the matrix \!\(\*SuperscriptBox[SubscriptBox[\(g\), \(ij\)], \(-1\)]\) = (<\!\(\*SubscriptBox[\(e\), \(i\)]\),\!\(\*SubscriptBox[\(e\), \(j\)]\)>\!\(\*SuperscriptBox[\()\), \(-1\)]\), where the \!\(\*SubscriptBox[\(e\), \(i\)]\) are the basis elements of the basis.";
TBGetBasisFields::usage = "TBGetBasisFields[BasisName_String]
Returns the field content in the order as used for the indices of the basis.";
TBGetProjector::usage = "TBGetBasisProjector[BasisName_String,n_Integer,indices___]
Returns the n-th projector, which is defined by \!\(\*SuperscriptBox[SubscriptBox[\(g\), \(nj\)], \(-1\)]\)\!\(\*SubscriptBox[\(e\), \(j\)]\). The given indices must match the ones specified by the basis, see TBInfo[].
If no indices are given, the standard indices specified by the basis are used.
TBGetVertex[BasisName_String,All,indices___]
Returns a list with all projectors of the specified basis, defined by \!\(\*SuperscriptBox[SubscriptBox[\(g\), \(nj\)], \(-1\)]\)\!\(\*SubscriptBox[\(e\), \(j\)]\). The given indices must match the ones specified by the basis, see TBInfo[].
If no indices are given, the standard indices specified by the basis are used.";
TBInfo::usage = "TBInfo[_String]
Return information on a given object.
TBInfo[] prints all available bases with some usage information.
TBInfo[BasisName] prints detailed information provided by this basis.
TBInfo[\"FormTracer\"] prints all defined groups and identites which FormTracer currently knows.
TBInfo[\"Extensions\"] prints all extensions to FormTracer, defined by the TensorBases package.
TBInfo[\"Momenta\"] prints all momentum transformations that can be performed by the TensorBases package.";
TBImportBasis::usage = "TBImportBasis[BasisDefinitionFile_String,CacheDirectory_String:\"./TBCache\"]
Import a custom basis definition file. The optional argument CacheDirectory can be set to choose a specific location where the intermediate files from processing the basis are stored.";
TBExportBasis::usage = "TBExportBasis[BasisName_String,folder_String:\"./\"]
Export a basis definition file. The basis with the name BasisName has to be loaded in memory. If the optional argument folder is given, this will be the location where the exported basis definition will be placed.";
TBRestrictBasis::usage = "TBRestrictBasis[inBasisName_String, outBasisName_String, {indices__Integer}, CacheDirectory_String:\"./TBCache\"]
Restrict an existing basis. The new basis will be called outBasisName and only contain the basis elements specified by the given indices.";
TBConstructBasis::usage = "TBConstructBasis[options...]
Construct a new basis from a given set of Tensors.
Example call:
TBConstructBasis[\[IndentingNewLine]\"Name\"->\"FourFermionBasis\",\[IndentingNewLine]\"Vertex\"->{psibar,psi,psibar,psi},\[IndentingNewLine]\"VertexStructure\"->2(Tensor[1,2,3,4]-Tensor[1,4,3,2]),\[IndentingNewLine]\"InnerProduct\"->2Tensor1[1,2,3,4](Tensor2[2,1,4,3]-Tensor2[4,1,2,3]),\[IndentingNewLine]\"Indices\"->{{p1,d1},{p2,d2},{p3,d3},{p4,d4}},\[IndentingNewLine]\"Tensors\"->{{deltaDirac[d1,d2]deltaDirac[d3,d4],gamma[mu,d1,d2]gamma[mu,d3,d4],gamma5[d1,d2]gamma5[d3,d4],gamma[mu,d1,dint1]gamma5[dint1,d2]gamma[mu,d3,d3int]gamma5[d3int,d4],sigma[mu,nu,d1,d2]sigma[mu,nu,d3,d4]\[IndentingNewLine]}}\[IndentingNewLine]]
For all possible options, see Options[TBConstructBasis]
";
TBConstructVertexBasis::usage = "TBConstructVertexBasis[options...]
Construct a new vertex basis from a given set of Tensors.
Example call:
TBConstructBasis[\[IndentingNewLine]\"Name\"->\"FourFermionBasis\",\[IndentingNewLine]\"Vertex\"->{psibar,psi,psibar,psi},\[IndentingNewLine]\"VertexStructure\"->2(Tensor[1,2,3,4]-Tensor[1,4,3,2]),\[IndentingNewLine]\"Indices\"->{{p1,d1},{p2,d2},{p3,d3},{p4,d4}},\[IndentingNewLine]\"Tensors\"->{{deltaDirac[d1,d2]deltaDirac[d3,d4],gamma[mu,d1,d2]gamma[mu,d3,d4],gamma5[d1,d2]gamma5[d3,d4],gamma[mu,d1,dint1]gamma5[dint1,d2]gamma[mu,d3,d3int]gamma5[d3int,d4],sigma[mu,nu,d1,d2]sigma[mu,nu,d3,d4]\[IndentingNewLine]}}\[IndentingNewLine]]
For all possible options, see Options[TBConstructBasis]
";
TBExportCache::usage = "TBExportCache[BasisName_String,CacheFolder_String:\"./TBCache\"]
Exports everything in memory of the Basis BasisName onto disk in the folder CacheFolder.";
TBUnregister::usage = "TBUnregister[BasisName_String]
Remove an existing basis from internal memory. This does not delete or change any files on disk.";
TBBasisExists::usage = "TBBasisExists[BasisName_String]
Returns True or False, depending if the given Basis exists in memory.";
TBList::usage = "TBList[]
Returns as a list all basis names in memory.";
TBBasisTransformation::usage = "TBBasisTransformation[toBasis_String,fromBasis_String]
Returns a matrix for the transformation of coordinates (i.e. dressings) from the basis \"fromBasis\" to the basis \"toBasis\".
I.e. given a set of dressings dress = {d1,d2,d3...} in \"fromBasis\", we get the set of dressings dressbar = {db1,db2,db3,...} in \"toBasis\" from dressbar = TBBasisTransformation[toBasis,fromBasis].dress";
TBVertexTransformation::usage = "TBVertexTransformation[toBasis_String,fromBasis_String]
Returns a matrix for the transformation of coordinates (i.e. (!) vertex dressings) from the basis \"fromBasis\" to the basis \"toBasis\".
I.e. given a set of (!) vertex dressings dress = {d1,d2,d3...} in \"fromBasis\", we get the set of dressings dressbar = {db1,db2,db3,...} in \"toBasis\" from dressbar = TBBasisTransformation[toBasis,fromBasis].dress";
TBGetIdentityMatrix::usage = "TBGetIdentityMatrix[BasisName_String,indices___]
Returns an identity matrix for the given two-point function BasisName. Works only for two-point functions.
If no indices are given, the standard indices specified by the basis are used.";
TBGetBasisSize::usage = "TBGetBasisSize[BasisName_String]
Get the size of a basis of with name \"BasisName\".";
TBGetIndexSet::usage = "TBGetIndexSet[BasisName_String,id_Integer,p_Symbol]
Get a unique index set for particle id in the Basis \"BasisName\" with momentum p.
TBGetIndexSet[set_List,p_]
Change the momentum of an index set to p.
";
TBGetBasis::usage= "TBGetBasis[BasisName_String,indices___]
Returns a list with all basis elements.
If no indices are given, the standard indices specified by the basis are used.";
TBMakePropagator::usage = "TBMakePropagator[BasisName_String,InvProp_List]
For a two-point basis \"BasisName\", obtain a propagator for a given inverse propagator.
InvProp should be a list of basis element coefficients making up the inverse propagator.
For example, {\[ImaginaryI], Mq[p]} for the Basis \"qbq\" for the standard quark propagator in vacuum.
TBMakePropagator[BasisName_String,InvProp_List,p]
Uses the momentum p in the output.";
TB3PToS0S1SPhi::usage="TB3PToS0S1SPhi[p1_Symbol,p2_Symbol,p3_Symbol,S0_Symbol,S1_Symbol,SPhi_Symbol]
Given three momenta p1,p2,p3, obtain a function which transforms these to the representation in terms of S0,S1 and SPhi.
Returns a function which takes one argument, the expression to be transformed.
TB3PToS0S1SPhi[p1_Symbol,p2_Symbol,p3_Symbol,q_Symbol,S0_Symbol,S1_Symbol,SPhi_Symbol]
If an additional momentum q is supplied, it is included in the transformation. Currently this assumes that q is a four-dimensional vector and is described by
q={cos1,\!\(\*SqrtBox[\(1 - \*SuperscriptBox[\(cos2\), \(2\)]\)]\)cos1,\!\(\*SqrtBox[\(1 - \*SuperscriptBox[\(cos1\), \(2\)]\)]\)\!\(\*SqrtBox[\(1 - \*SuperscriptBox[\(cos2\), \(2\)]\)]\)Cos[phi],\!\(\*SqrtBox[\(1 - \*SuperscriptBox[\(cos1\), \(2\)]\)]\)\!\(\*SqrtBox[\(1 - \*SuperscriptBox[\(cos2\), \(2\)]\)]\)Sin[phi]}
";
TB3PFromS0S1SPhi::usage="TB3PFromS0S1SPhi[p1_Symbol,p2_Symbol,p3_Symbol,S0_Symbol,S1_Symbol,SPhi_Symbol]
Given three momenta p1,p2,p3, obtain a function which transforms from the representation in terms of S0,S1 and SPhi back to the momenta p1,p2,p3.
Returns a function which takes one argument, the expression to be transformed.
";
TB3PToS0S1SPhiQk::usage="TB3PToS0S1SPhi[Q_Symbol,k_Symbol,S0_Symbol,S1_Symbol,SPhi_Symbol]
Given two momenta Q,k obtain a function which transforms these to the representation in terms of S0,S1 and SPhi.
Returns a function which takes one argument, the expression to be transformed.
TB3PToS0S1SPhi[Q_Symbol,k_Symbol,q_Symbol,S0_Symbol,S1_Symbol,SPhi_Symbol]
If an additional momentum q is supplied, it is included in the transformation. Currently this assumes that q is a four-dimensional vector and is described by
q={cos1,\!\(\*SqrtBox[\(1 - \*SuperscriptBox[\(cos2\), \(2\)]\)]\)cos1,\!\(\*SqrtBox[\(1 - \*SuperscriptBox[\(cos1\), \(2\)]\)]\)\!\(\*SqrtBox[\(1 - \*SuperscriptBox[\(cos2\), \(2\)]\)]\)Cos[phi],\!\(\*SqrtBox[\(1 - \*SuperscriptBox[\(cos1\), \(2\)]\)]\)\!\(\*SqrtBox[\(1 - \*SuperscriptBox[\(cos2\), \(2\)]\)]\)Sin[phi]}
";
TB3PFromS0S1SPhiQk::usage="TB3PFromS0S1SPhi[Q_Symbol,k_Symbol,S0_Symbol,S1_Symbol,SPhi_Symbol]
Given two momenta Q,k, obtain a function which transforms from the representation in terms of S0,S1 and SPhi back to the momenta Q,k.
Returns a function which takes one argument, the expression to be transformed.
";
TB3PToS0as::usage="TB3PToS0as[p1_Symbol,p2_Symbol,p3_Symbol,S0_Symbol,a_Symbol,s_Symbol]
Given three momenta p1,p2,p3, obtain a function which transforms these to the representation in terms of S0, a and s.
Returns a function which takes one argument, the expression to be transformed.
TB3PToS0as[p1_Symbol,p2_Symbol,p3_Symbol,q_Symbol,S0_Symbol,a_Symbol,s_Symbol]
If an additional momentum q is supplied, it is included in the transformation. Currently this assumes that q is a four-dimensional vector and is described by
q={cos1,\!\(\*SqrtBox[\(1 - \*SuperscriptBox[\(cos2\), \(2\)]\)]\)cos1,\!\(\*SqrtBox[\(1 - \*SuperscriptBox[\(cos1\), \(2\)]\)]\)\!\(\*SqrtBox[\(1 - \*SuperscriptBox[\(cos2\), \(2\)]\)]\)Cos[phi],\!\(\*SqrtBox[\(1 - \*SuperscriptBox[\(cos1\), \(2\)]\)]\)\!\(\*SqrtBox[\(1 - \*SuperscriptBox[\(cos2\), \(2\)]\)]\)Sin[phi]}
";
TB3PFromS0as::usage="TB3PFromS0as[p1_Symbol,p2_Symbol,p3_Symbol,S0_Symbol,a_Symbol,s_Symbol]
Given three momenta p1,p2,p3, obtain a function which transforms from the representation in terms of S0, a and s back to the momenta p1,p2,p3.
Returns a function which takes one argument, the expression to be transformed.
";
TBProjectToSymmetricPoint::usage="TBProjectToSymmetricPoint[expr_,q_Symbol,p_Symbol,momenta___Symbol]
Project an expression with internal loop momentum q to the symmetric point with average momentum p. The last arguments should be all involved momenta.
According to their number, the correct symmetric-point configuration is chosen.
";
TBProjectToSymmetricPointSpatial::usage="TBProjectToSymmetricPointSpatial[expr_,q_Symbol,p_Symbol,momenta___Symbol]
Project an expression with internal loop momentum q to the symmetric point in the d-1 dimensional subspace with average momentum p.
This is useful for applications at finite temperature, where the 0th component is discrete.
The last arguments should be all involved momenta. According to their number, the correct symmetric-point configuration is chosen.
";
TBInfo["FormTracer"]:=Global`ShowFormTracerDefinitions[];
TBInfo["Extensions"]:=Global`ShowFormTracerExtensions[];
TBInfo["BaseBuilder"]:=Print@"TensorBases provides facilities for exporting and importing bases:
\nTBImportBasis and TBExportBasis allow for importing user-written basis definition files and automatic export of bases in memory to such definition files.
\nTBExportCache writes any basis data in memory to disk at a specified location.
\nTBUnregister allows to remove basis names from the registry, which allows one to overwrite bases by custom imports.
\nTBRestrictBasis creates a new basis from an old one by simple restriction.
\nTBConstructBasis creates a new basis from a set of primitive tensors. The method automatically takes tensor products of multiple given tensor spaces and reduces any overcomplete set using a given inner product to a minimal basis (a maximal linearly independent set).
\nTBConstructVertexBasis creates a new vertex basis from a set of primitive tensors.
\nFor usage help with the aforementioned functions, please call their usage messages, e.g. TBConstructBasis::usage.
";
TBInfo["Notation"]:=Print@"\!\(\*
StyleBox[\"TensorBases\",\nFontWeight->\"Bold\"]\) uses the following conventions and notation:
For a given group, \!\(\*SuperscriptBox[\(T\), \(a\)]\) denotes the generators of the group in the fundamental representation, \!\(\*SuperscriptBox[\(t\), \(a\)]\) denotes the generators in the adjoint representation.
\!\(\*SubscriptBox[\(\[Epsilon]\), \(abc\)]\) is the fully anti-symmetric Levi-Civita symbol.
The \!\(\*SuperscriptBox[\(T\), \(a\)]\) are normalised as
tr[\!\(\*SuperscriptBox[\(T\), \(a\)]\)\!\(\*SuperscriptBox[\(T\), \(b\)]\)] = \!\(\*FractionBox[\(1\), \(2\)]\)\!\(\*SubscriptBox[\(\[Delta]\), \(ab\)]\).
The \!\(\*SubscriptBox[\(\[Gamma]\), \(\(\[Mu]\)\(\\\ \)\)]\)denote Euclidean gamma matrices and accordingly \!\(\*SubscriptBox[\(\[Gamma]\), \(\(5\)\(\\\ \)\)]\)= \!\(\*SubscriptBox[\(\[Gamma]\), \(0\)]\)\!\(\*SubscriptBox[\(\[Gamma]\), \(1\)]\)\!\(\*SubscriptBox[\(\[Gamma]\), \(2\)]\)\!\(\*SubscriptBox[\(\[Gamma]\), \(3\)]\)
";
Begin["`Private`"];
If[Head[$DistributedContexts]=!=List,$DistributedContexts={}];
$DistributedContexts=$DistributedContexts\[Union]{$Context,"TensorBases`Private`","TensorBases`","FormTracer`","FormTracer`Private`"}
GlobalContext[expr_]:=Module[{$ContextOld,result},
$ContextOld=$Context;
$Context="Global`";
result=ReleaseHold[expr];
$Context=$ContextOld;
Return[result];
];
SetAttributes[GlobalContext,HoldAll]
WithinContext[context_String,expr_]:=Module[{$ContextOld,result},
$ContextOld=$Context;
$Context=context;
Begin[context];
Print["Changed to context", $Context];
result=ReleaseHold[expr];
End[];
$Context=$ContextOld;
Return[result];
];
SetAttributes[WithinContext,HoldRest]
FormTracerNaming[]:=Module[
{outputRulesLorentzTensors,outputRulesGroupTensors,outputRules,
privateOutputRulesLorentzTensors,privateOutputRulesGroupTensors,privateOutputRules},
outputRulesLorentzTensors=Normal[FormTracer`Private`lorentzTensorReplacementRulesOutput]/.{(a_[c___]:>b_):>(Symbol["TB"~~StringSplit[ToString[a],"FTx"][[-1]]][c])};
outputRulesGroupTensors=Normal[FormTracer`Private`groupTensorRep:qlacementRulesOutput]/.{(a_[c___]:>b_):>(Symbol["TB"~~StringSplit[ToString[a],"FTx"][[-1]]][c])};
outputRules=Join[outputRulesLorentzTensors,outputRulesGroupTensors];
Print["Lorentz group: ",outputRulesLorentzTensors//TableForm];
Print[""];
Print["color group: ",Select[outputRulesGroupTensors,MemberQ[#,color,Infinity]&]//TableForm];
Print[""];
Print["flavor group: ",Select[outputRulesGroupTensors,MemberQ[#,flavor,Infinity]&]//TableForm];
];
InsertOutputNaming[expr_]:=Module[
{
groups,
outputRulesLorentzTensors,outputRulesGroupTensors,outputRules,
privateOutputRulesLorentzTensors,privateOutputRulesGroupTensors,privateOutputRules,
otherRules
},
outputRulesLorentzTensors=Normal[FormTracer`Private`lorentzTensorReplacementRulesOutput]/.{(a_[c___]:>b_):>(Symbol["TB"~~StringSplit[ToString[a],"FTx"][[-1]]][c]:>b)};
outputRulesGroupTensors=Normal[FormTracer`Private`groupTensorReplacementRulesOutput]/.{(a_[c___]:>b_):>(Symbol["TB"~~StringSplit[ToString[a],"FTx"][[-1]]][c]:>b)};
outputRules=Join[outputRulesLorentzTensors,outputRulesGroupTensors];
privateOutputRulesLorentzTensors=Normal[FormTracer`Private`lorentzTensorReplacementRulesOutput]/.{(a_[c___]:>b_):>(Symbol["TensorBases`Private`TB"~~StringSplit[ToString[a],"FTx"][[-1]]][c]:>b)};
privateOutputRulesGroupTensors=Normal[FormTracer`Private`groupTensorReplacementRulesOutput]/.{(a_[c___]:>b_):>(Symbol["TensorBases`Private`TB"~~StringSplit[ToString[a],"FTx"][[-1]]][c]:>b)};
privateOutputRules=Join[privateOutputRulesLorentzTensors,privateOutputRulesGroupTensors];
groups={
TensorBases`Private`flavor->Global`flavor,
TensorBases`Private`color->Global`color
};
otherRules={
TensorBases`Private`sigma:>Global`sigma,
TensorBases`Private`pdash:>Global`pdash,
TensorBases`Private`psdash:>Global`psdash,
TensorBases`Private`transProj:>Global`transProj,
TensorBases`Private`longProj:>Global`longProj,
TensorBases`Private`transProjMagnetic:>Global`transProjMagnetic,
TensorBases`Private`transProjElectric:>Global`transProjElectric