CosmoGRaPH v0.0
bardeen.h
Go to the documentation of this file.
1 
6 #ifndef COSMO_BARDEEN
7 #define COSMO_BARDEEN
8 
9 #include "../../cosmo_includes.h"
10 #include "../../cosmo_macros.h"
11 #include "../../cosmo_types.h"
12 #include "../../utils/Fourier.h"
13 #include "bssn.h"
14 
15 #define NUM_BARDEEN_VIOLS 17
16 
17 namespace cosmo
18 {
19 
25 class Bardeen
26 {
27  BSSN * bssn;
28  Fourier * fourier;
29 
31  real_t Omega_L_I;
32 
33 public:
34  // perturbed metric & time derivatives
35  arr_t h11, h12, h13, h22, h23, h33;
36  arr_t dt_h11, dt_h12, dt_h13, dt_h22, dt_h23, dt_h33;
37  arr_t d2t_h11, d2t_h12, d2t_h13, d2t_h22, d2t_h23, d2t_h33;
38  arr_t h01, h02, h03;
39  arr_t dt_h01, dt_h02, dt_h03;
40 
41  // storage for intermediate metric calc's
42  arr_t dt_g11, dt_g12, dt_g13,
43  dt_g22, dt_g23, dt_g33;
44  arr_t d2t_g11, d2t_g12, d2t_g13,
45  d2t_g22, d2t_g23, d2t_g33;
46  arr_t dt_beta1, dt_beta2, dt_beta3;
47  arr_t dt_phi, d2t_phi;
48 
49  // metric scalar potentials
50  arr_t A, dt_A, d2t_A;
51  arr_t B, dt_B, d2t_B;
52  arr_t F, dt_F, // higher-order time derivs. of these
53  E; // aren't needed (for now).
54 
55  // Vector potentials
56  arr_t G1, G2, G3;
57  arr_t C1, C2, C3;
58  arr_t dt_C1, dt_C2, dt_C3;
59  arr_t Vmag;
60 
61  // Tensor
62  arr_t D11, D12, D13, D22, D23, D33;
63 
64  // Bardeen potentials
65  arr_t Phi, Psi;
66 
67  // constraint violation
68  arr_t lin_viol, lin_viol_mag, lin_viol_der_mag, lin_viol_der;
69 
70  real_t * viols;
71 
72  Bardeen(BSSN * bssn_in, Fourier * fourier_in)
73  {
74  bssn = bssn_in;
75  fourier = fourier_in;
76 
77  use_mL_scale_factor = false;
78  Omega_L_I = 0;
79 
80  h11.init(NX, NY, NZ); h12.init(NX, NY, NZ); h13.init(NX, NY, NZ);
81  h22.init(NX, NY, NZ); h23.init(NX, NY, NZ); h33.init(NX, NY, NZ);
82  dt_h11.init(NX, NY, NZ); dt_h12.init(NX, NY, NZ); dt_h13.init(NX, NY, NZ);
83  dt_h22.init(NX, NY, NZ); dt_h23.init(NX, NY, NZ); dt_h33.init(NX, NY, NZ);
84  d2t_h11.init(NX, NY, NZ); d2t_h12.init(NX, NY, NZ); d2t_h13.init(NX, NY, NZ);
85  d2t_h22.init(NX, NY, NZ); d2t_h23.init(NX, NY, NZ); d2t_h33.init(NX, NY, NZ);
86 
87  h01.init(NX, NY, NZ); h02.init(NX, NY, NZ); h03.init(NX, NY, NZ);
88  dt_h01.init(NX, NY, NZ); dt_h02.init(NX, NY, NZ); dt_h03.init(NX, NY, NZ);
89 
90  dt_g11.init(NX, NY, NZ); dt_g12.init(NX, NY, NZ); dt_g13.init(NX, NY, NZ);
91  dt_g22.init(NX, NY, NZ); dt_g23.init(NX, NY, NZ); dt_g33.init(NX, NY, NZ);
92  d2t_g11.init(NX, NY, NZ); d2t_g12.init(NX, NY, NZ); d2t_g13.init(NX, NY, NZ);
93  d2t_g22.init(NX, NY, NZ); d2t_g23.init(NX, NY, NZ); d2t_g33.init(NX, NY, NZ);
94  dt_beta1.init(NX, NY, NZ); dt_beta2.init(NX, NY, NZ); dt_beta3.init(NX, NY, NZ);
95  dt_phi.init(NX, NY, NZ); d2t_phi.init(NX, NY, NZ);
96 
97  A.init(NX, NY, NZ); dt_A.init(NX, NY, NZ); d2t_A.init(NX, NY, NZ);
98  B.init(NX, NY, NZ); dt_B.init(NX, NY, NZ); d2t_B.init(NX, NY, NZ);
99  F.init(NX, NY, NZ); dt_F.init(NX, NY, NZ);
100  E.init(NX, NY, NZ);
101 
102  G1.init(NX, NY, NZ); G2.init(NX, NY, NZ); G3.init(NX, NY, NZ);
103  C1.init(NX, NY, NZ); C2.init(NX, NY, NZ); C3.init(NX, NY, NZ);
104  dt_C1.init(NX, NY, NZ); dt_C2.init(NX, NY, NZ); dt_C3.init(NX, NY, NZ);
105  Vmag.init(NX, NY, NZ);
106 
107  D11.init(NX, NY, NZ);
108  D12.init(NX, NY, NZ);
109  D13.init(NX, NY, NZ);
110  D22.init(NX, NY, NZ);
111  D23.init(NX, NY, NZ);
112  D33.init(NX, NY, NZ);
113 
114  Phi.init(NX, NY, NZ); Psi.init(NX, NY, NZ);
115 
116  lin_viol.init(NX, NY, NZ);
117  lin_viol_mag.init(NX, NY, NZ);
118  lin_viol_der_mag.init(NX, NY, NZ);
119  lin_viol_der.init(NX, NY, NZ);
120 
121  viols = new real_t[NUM_BARDEEN_VIOLS];
122  for(int i=0; i<NUM_BARDEEN_VIOLS; ++i)
123  viols[0] = 0;
124 
125  // add Bardeen potentials to BSSN fields map
126  bssn->fields["Bardeen_Phi"] = & Phi;
127  bssn->fields["Bardeen_Psi"] = & Psi;
128  bssn->fields["Bardeen_A"] = & A;
129  bssn->fields["Bardeen_dt_A"] = & dt_A;
130  bssn->fields["Bardeen_d2t_A"] = & d2t_A;
131  bssn->fields["Bardeen_B"] = & B;
132  bssn->fields["Bardeen_dt_B"] = & dt_B;
133  bssn->fields["Bardeen_d2t_B"] = & d2t_B;
134 
135  bssn->fields["Bardeen_E"] = & E;
136  bssn->fields["Bardeen_F"] = & F;
137 
138  bssn->fields["Bardeen_G1"] = & G1;
139  bssn->fields["Bardeen_G2"] = & G2;
140  bssn->fields["Bardeen_G3"] = & G3;
141  bssn->fields["Bardeen_C1"] = & C1;
142  bssn->fields["Bardeen_C2"] = & C2;
143  bssn->fields["Bardeen_C3"] = & C3;
144  bssn->fields["Bardeen_dt_C1"] = & dt_C1;
145  bssn->fields["Bardeen_dt_C2"] = & dt_C2;
146  bssn->fields["Bardeen_dt_C3"] = & dt_C3;
147  bssn->fields["Bardeen_Vmag"] = & Vmag;
148 
149  bssn->fields["Bardeen_D11"] = & D11;
150  bssn->fields["Bardeen_D12"] = & D12;
151  bssn->fields["Bardeen_D13"] = & D13;
152  bssn->fields["Bardeen_D22"] = & D22;
153  bssn->fields["Bardeen_D23"] = & D23;
154  bssn->fields["Bardeen_D33"] = & D33;
155  }
156 
157  ~Bardeen()
158  {
159  // anything to do?
160  }
161 
162 
163  void useMLScaleFactor(real_t Omega_L_I_in)
164  {
165  if(Omega_L_I_in < 0 || Omega_L_I_in > 1)
166  {
167  std::cout << "Invalid Omega_Lambda specified." << std::endl;
168  throw -1;
169  }
170 
171  Omega_L_I = Omega_L_I_in;
172  }
173 
174  void setUseMLScaleFactor(bool use)
175  {
176  use_mL_scale_factor = use;
177  }
178 
184  {
185  if(Omega_L_I == 0)
186  {
187  return 2.0/3.0;
188  }
189  else
190  {
191  real_t sqrt_Omega_L_I = std::sqrt(Omega_L_I);
192  return std::log1p(
193  2.0/(1.0 - sqrt_Omega_L_I) * sqrt_Omega_L_I
194  ) / (3.0*sqrt_Omega_L_I);
195  }
196  }
197 
198  real_t getMLScaleFactor(real_t elapsed_sim_time)
199  {
200  if(Omega_L_I == 0)
201  {
202  real_t tI = getMLInitialTime();
203  real_t t = tI + elapsed_sim_time;
204  return std::pow(t/tI, 2.0/3.0);
205  }
206  else
207  {
208  return std::pow(
209  std::cosh(3.0*std::sqrt(Omega_L_I) * elapsed_sim_time / 2.0 )
210  + (std::sinh(3.0*std::sqrt(Omega_L_I) * elapsed_sim_time / 2.0 ) / std::sqrt(Omega_L_I))
211  , 2.0/3.0);
212  }
213  }
214 
215  real_t getMLHubbleFactor(real_t elapsed_sim_time)
216  {
217  real_t a = getMLScaleFactor(elapsed_sim_time);
218  return std::sqrt( (1 - Omega_L_I)*std::pow(a, -3.0) + Omega_L_I );
219  }
220 
221  real_t getMLd2adt2Factor(real_t elapsed_sim_time)
222  {
223  real_t a = getMLScaleFactor(elapsed_sim_time);
224  real_t H = getMLHubbleFactor(elapsed_sim_time);
225  return a*H*H - (1.0 - Omega_L_I)*3.0/2.0/a/a;
226  }
227 
228  void setPotentials(real_t elapsed_sim_time);
229 
230  void getSVTViolations(real_t * viols_copyto);
231 
232 }; // Bardeen class
233 
234 }
235 
236 #endif
Definition: bardeen.cc:5
Definition: bardeen.h:25
bool use_mL_scale_factor
Use FLRW matter+Lambda scale factor?
Definition: bardeen.h:30
Definition: Fourier.h:21
BSSN Class: evolves BSSN metric fields, computes derived quantities.
Definition: bssn.h:24
map_t fields
Public map from names to internal arrays.
Definition: bssn.h:38
real_t Omega_L_I
Initial Omega_Lambda.
Definition: bardeen.h:31
void setPotentials(real_t elapsed_sim_time)
Compute Bardeen & vector potentials. Assumes no reference solultion is used (this should be checked i...
Definition: bardeen.cc:23
real_t getMLInitialTime()
Gets the matter+Lambda universe initial time. Assumes units H_I = 1, a_I = 1.
Definition: bardeen.h:183