-
Notifications
You must be signed in to change notification settings - Fork 2
/
xSVT.wl
166 lines (114 loc) · 4.23 KB
/
xSVT.wl
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
(* ::Package:: *)
(* ::Title:: *)
(*xSVT*)
(* ::Section:: *)
(*Initialise*)
(* ::Subsection::Closed:: *)
(*Preliminary checks*)
(****
Check that the code can be properly initialised.
Preliminary global variables should be defined here in "list", together
with a function that checks that their value has the expected type.
****)
list = Map[Unevaluated, Unevaluated@{
{$CodeDirectory, StringQ},
{$EquationsDirectory, StringQ},
{$Theory, StringQ},
{$Metric, StringQ},
{$ScalarPertsQ, BooleanQ},
{$VectorPertsQ, BooleanQ},
{$TensorPertsQ, BooleanQ},
{$ImportDecompositionRules, StringQ},
{$ToClass, BooleanQ}
}, {2}];
listvar = #[[1]] & /@list;
listtype = #[[2]] & /@list;
exit = False;
If[Not[ValueQ[#]],
Print["The variable "<>ToString[#]<>" has not been defined, but it is necessary!"];
exit = True;
] & /@ listvar;
MapThread[
If[Not[#1@#2],
Print["The variable "<>ToString[Unevaluated[#2]]<>" is not of the correct type ("<>ToString[#1]<>" needed)."];
exit = True;
] &, {listtype, listvar}];
If[exit, Print["Exiting..."]; Exit[]];
Clear[list, listvar, listtype, exit];
(* ::Subsection::Closed:: *)
(*Main xAct call and global settings*)
(** These variables help to manage long expressions **)
$RecursionLimit = 32768;
$IterationLimit = 32768;
(** This is the main call to xAct and subpackages **)
<< xAct`xTensor`
<< xAct`xPert`
<< xAct`xTras`
<< xAct`TexAct`
(** Correct known bug with 1D manifolds **)
xAct`xTensor`Private`Symmetry1D[sym_StrongGenSet, inds_] := sym;
(** Use Prefix or Postfix notation for covariant derivatives **)
$CovDFormat = "Prefix";
(** Suppress verbose **)
$DefInfoQ = False;
SetOptions[AutomaticRules, Verbose -> False];
SetOptions[MakeRule, ContractMetrics -> False, MetricOn -> None];
(** Color in red the perturbation index **)
Unprotect[IndexForm];
IndexForm[LI[x_]] := ColorString[ToString[x], RGBColor[1, 0, 0]];
Protect[IndexForm];
(* ::Section:: *)
(*xSVT pipeline*)
(****
Initialise global variables containing the
list of tensors defined in xSVT.
****)
$ListBackground = List[];
$ListScalarPerts = List[];
$ListVectorPerts = List[];
$ListTensorPerts = List[];
(****
Usage and Definitions.
These modules group together definition and usage
of xSVT functions and variables.
****)
Import[FileNameJoin[{$CodeDirectory,"Core","function_usage.wl"}]]
Import[FileNameJoin[{$CodeDirectory,"Core","function_definitions.wl"}]]
(****
Try to import DecompositionRules, a global variable
filled with all the expansion rules.
****)
If[FileExistsQ[$ImportDecompositionRules],
$SVTDecompositionRules = Import[$ImportDecompositionRules];
fill = False;
Print["Using rules from "<>$ImportDecompositionRules<>"."];
Print[Column[{"Basic decomposition rules", ScreenDollarIndices[$SVTDecompositionRules[[1]]]}]];
Print[Column[{"Derived decomposition rules", ScreenDollarIndices[$SVTDecompositionRules[[2]]]}]];,
$SVTDecompositionRules = {{},{}};
fill = True;
Print["Using default rules."];
];
(****
Theory.
Each of these modules contains the necessary definitions and rules to
run xSVT: manifolds, metrics, tensors, ...
The main module focuses on the tensors of General Relativity plus matter
(treated as a fluid with density, pressure, velocity and shear). The
additional modules introduce theory specific ingredients.
****)
(** Basic definitions: GR and matter **)
Import[FileNameJoin[{$CodeDirectory,"Core","theory_GR_matter.wl"}]]
(** Additional definitions: ST **)
If[$Theory=="ST" || $Theory=="STfast" || $Theory=="ALL", Import[FileNameJoin[{$CodeDirectory,"Core","theory_ST.wl"}]]];
Clear[fill]
(**** Some global option ****)
SetOptions[ToCanonical, UseMetricOnVBundle->{TangentM4}];
Off[VBundleOfIndex::unknown]
Off[Attributes::ssle]
$Assumptions = {scale[]>0, hubbleC[]>0, hubbleP[]>0, primescalar[]!=0};
(**** Lagrangian ****)
Import[FileNameJoin[{$CodeDirectory,"Core","lagrangian_matter.wl"}]];
If[$Theory=="GR", Import[FileNameJoin[{$CodeDirectory,"Core","lagrangian_GR.wl"}]]];
If[$Theory=="ST" || $Theory=="STfast", Import[FileNameJoin[{$CodeDirectory,"Core","lagrangian_ST.wl"}]]];
(**** ToClass ****)
If[$ToClass, Import[FileNameJoin[{$CodeDirectory,"Core","to_class.wl"}]]];