aboutsummaryrefslogtreecommitdiff
path: root/m/grhydro.m
blob: a71a28b81e0d584415fe927d8455854c58a15909 (plain)
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
Get["KrancThorn`"];

(*SetDebugLevel[InfoFull];*)

SetEnhancedTimes[False];
SetSourceLanguage["C"];

(****************************************************************************
 Derivatives
****************************************************************************)

derivatives =
{
 PDstandard2nd[i_] -> StandardCenteredDifferenceOperator[1,1,i],
 PDstandard2nd[i_, i_] -> StandardCenteredDifferenceOperator[2,1,i],
 PDstandard2nd[i_, j_] -> StandardCenteredDifferenceOperator[1,1,i] *
   StandardCenteredDifferenceOperator[1,1,j],

 PDstandard4th[i_] -> StandardCenteredDifferenceOperator[1,2,i],
 PDstandard4th[i_, i_] -> StandardCenteredDifferenceOperator[2,2,i],
 PDstandard4th[i_, j_] -> StandardCenteredDifferenceOperator[1,2,i] *
   StandardCenteredDifferenceOperator[1,2,j],

 PDplus[i_] -> DPlus[i],
 PDminus[i_] -> DMinus[i],
 PDplus[i_,j_] -> DPlus[i] DPlus[j],

 PDonesided2nd[1] -> dir[1] (-shift[1]^(2 dir[1]) + 4 shift[1]^dir[1] - 3 )/
   (2 spacing[1]),
 PDonesided2nd[2] -> dir[2] (-shift[2]^(2 dir[2]) + 4 shift[2]^dir[2] - 3 )/
   (2 spacing[2]),
 PDonesided2nd[3] -> dir[3] (-shift[3]^(2 dir[3]) + 4 shift[3]^dir[3] - 3 )/
   (2 spacing[3])
};

(*PD = PDstandard2nd;*)

(****************************************************************************
 Tensors 
****************************************************************************)

(* Register all the tensors that will be used with TensorTools *)
Map[DefineTensor, 
{
  rho, vel, eps, press,
  dens, mom, tau
}];

(* Register the TensorTools symmetries (this is very simplistic) *)
Map[AssertSymmetricDecreasing, 
{
}];

(* Determinants of the metrics in terms of their components
  (Mathematica symbolic expressions) *)
gDet = Det[MatrixOfComponents[g[la,lb]]];

(****************************************************************************
 Groups
****************************************************************************)

SetGroupTimelevels[g_,tl_] = Join[g, {Timelevels -> tl}];

evolvedGroups =
  {CreateGroupFromTensor [dens   ],             (* mass density *)
   CreateGroupFromTensor [mom[la]],             (* momentum density *)
   CreateGroupFromTensor [tau    ]};            (* energy density *)
evaluatedGroups =
  {CreateGroupFromTensor [rho    ],             (* mass density *)
   CreateGroupFromTensor [vel[ua]],             (* velocity *)
   CreateGroupFromTensor [eps    ],             (* specific internal energy *)
   CreateGroupFromTensor [press  ]};            (* pressure *)

declaredGroups = Join [evolvedGroups, evaluatedGroups];
declaredGroupNames = Map [First, declaredGroups];

groups = Join[declaredGroups];

(******************************************************************************)
(* Initial data *)
(******************************************************************************)

initialCalc =
{
  Name -> BSSN <> "_vacuum",
  Schedule -> {"IN ADMBase_InitialData"},
  ConditionalOnKeyword -> {"my_initial_data", "vacuum"},
  Equations -> 
  {
    rho     -> 0,
    vel[ua] -> 0,
    eps     -> 0
  }
};

(******************************************************************************)
(* Convert from primitive to conserved variables *)
(******************************************************************************)

prim2conCalc =
{
  Name -> BSSN <> "_con2prim",
  Schedule -> {"AT initial AFTER ADMBase_PostInitial"},
  Equations -> 
  {
    dens    -> rho,
    mom[la] -> rho vel[ua],
    tau     -> (1/2) rho vel[ua] vel[la] + rho eps
  }
};

(******************************************************************************)
(* Convert from conserved to primitive variables *)
(******************************************************************************)

con2primCalc =
{
  Name -> BSSN <> "_con2prim",
  Schedule -> {"IN " <> BSSN <>"_con2primGroup"},
  Equations -> 
  {
    rho     -> dens,
    vel[ua] -> mom[la] / dens,
    eps     -> tau / dens - (1/2) vel[ua] vel[la],
    
    press   -> Gamma rho eps +
               alpha PD[vel[ua],la]
  }
};

(******************************************************************************)
(* Evolution equations *)
(******************************************************************************)

evolCalc =
{
  Name -> BSSN <> "_RHS",
  Schedule -> {"IN " <> BSSN <>"_evolCalcGroup"},
  Shorthands -> {rhov[ua], momv[la,ub], tauv[ua]},
  Equations -> 
  {
    (* dt rho + div rho v = 0 *)
    rhov[ua]  -> mom[la],
    dot[dens] -> - PD[rhov[ua],la],
    
    (* dt pi + div (pi v + P) = 0 *)
    momv[la,ub]  -> mom[la] vel[ub] + KD[la,ub] press,
    dot[mom[la]] -> - PD[momv[la,ub],lb],
    
    (* dt tau + div (tauv + P) = 0 *)
    tauv[ua] -> tau vel[ua] + press vel[ua],
    dot[tau] -> - PD[tauv[ua],la]
  }
};