aboutsummaryrefslogtreecommitdiff
path: root/src/Misner_standard.c
blob: a5badbc6eff2637ed933d2338ea32ee6ce780416 (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
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
 /*@@
   @file      Misner_standard.c
   @date      March 1997
   @author    Joan Masso
   @desc 
      Set up initial data for two Misner black holes
   @enddesc 
   @history
   @hdate Sun Oct 17 11:05:48 1999 @hauthor Tom Goodale
   @hdesc Converted to C
   @endhistory
 @@*/

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

#include "cctk.h"
#include "cctk_Arguments.h"
#include "cctk_Parameters.h"

#include "CactusEinstein/Einstein/src/Einstein.h"

#define SQR(a) ((a)*(a))

 /*@@
   @routine    Misner_standard
   @date       
   @author     Joan Masso, Ed Seidel
   @desc 
            Initialize the metric with a time symmetrical 
            black hole spacetime containing
            two axially symmetric misner black holes with a 
            mass/length parameter mu. The mass is computed.
            The spacetime line element has the form:
                 $$ ds^2 = -dt^2 + \Psi^4 (dx^2+dy^2+dz^2) $$
            and only $\Psi$ differs.
            (Conformal factor from Karen Camarda)
   @enddesc 
   @calls     
   @history 
 
   @endhistory 

   @par      mu
   @pdesc    Misner parameter. 
   @ptype    real
   @pcomment Values less than 1.8 do not really correspond to two 
            black holes, as there is an initial single event horizon 
            surrounding the throats. So, with low values of mu we also
            have distorted single black holes.
   @endpar
 
   @par      nmax
   @pdesc    Summation limit for the misner series in the 'twobh' case.
   @ptype    integer
   @endpar

@@*/
void Misner_standard(CCTK_CARGUMENTS)
{
  DECLARE_CCTK_CARGUMENTS
  DECLARE_CCTK_PARAMETERS

  int i,j,k;
  int n;
  char *message;
  CCTK_REAL zero, one, three;
  CCTK_REAL csch, coth, r1, r2;
  CCTK_REAL x_squared, y_squared;
  CCTK_REAL r1_cubed, r2_cubed;
  CCTK_REAL r1_5, r2_5;
  CCTK_INT powfac;

  int nx,ny,nz;
  int index;
  nx = cctk_lsh[0];
  ny = cctk_lsh[1];
  nz = cctk_lsh[2];


  zero  = 0.0;
  one   = 1.0;
  three = 3.0;

  /*     Initialize so we can accumulate
   *     ------------------------------- 
   */
  for(k=0; k < nz; k++)
  {
    for(j=0; j < ny; j++)
    {
      for(i=0; i < nx; i++)
      {
        index = CCTK_GFINDEX3D(cctkGH, i,j,k);
        
        psi[index] = one;
      }
    }
  }

  if (use_conformal_derivs == 1)
  {
    for(k=0; k < nz; k++)
    {
      for(j=0; j < ny; j++)
      {
        for(i=0; i < nx; i++)
        {
          index = CCTK_GFINDEX3D(cctkGH, i,j,k);
          
          psix[index]  = zero;
          psiy[index]  = zero;
          psiz[index]  = zero;
          psixx[index] = zero;
          psixy[index] = zero;
          psixz[index] = zero;
          psiyy[index] = zero;
          psiyz[index] = zero;
          psizz[index] = zero;
        }
      }
    }
  }

  for(n = nmax; n >= 1; n--)
  {
    csch = one/sinh(mu*n);
    coth = one/tanh(mu*n);
    
    for(k=0; k < nz; k++)
    {
      for(j=0; j < ny; j++)
      {
        for(i=0; i < nx; i++)
        {
          index = CCTK_GFINDEX3D(cctkGH, i,j,k);
          
          x_squared = SQR(x[index]);
          y_squared = SQR(y[index]);
          r1 = sqrt(x_squared+y_squared+SQR(z[index]+coth));
          r2 = sqrt(x_squared+y_squared+SQR(z[index]-coth));
          
          psi[index] += csch*(one/r1 + one/r2);
          
          if (use_conformal_derivs == 1)
          {
            r1_cubed = r1*r1*r1;
            r2_cubed = r2*r2*r2;
            r1_5     = pow(r1, 5);
            r2_5     = pow(r2, 5);
            psix[index]  +=  (-(x[index]/r2_cubed)-x[index]/r1_cubed)*csch;
            psiy[index]  +=  (-(y[index]/r2_cubed)-y[index]/r1_cubed)*csch;
            psiz[index]  +=  (-((z[index]-coth)/r2_cubed)-(z[index] + coth)/r1_cubed)*csch;
            psixx[index] +=  ((three*x_squared)/r2_5-one/r2_cubed
                              +(three*x_squared)/r1_5-one/r1_cubed)*csch;
            psixy[index] +=  ((three*x[index]*y[index])/r2_5
                              +(three*x[index]*y[index])/r1_5)*csch;
            psixz[index] +=  ((three*x[index]*(z[index]-coth))/r2_5 
                              +(three*x[index]*(z[index]+coth))/r1_5)*csch;
            psiyy[index] +=  ((three*y_squared)/r2_5-one/r2_cubed 
                              +(three*y_squared)/r1_5-one/r1_cubed)*csch;
            psiyz[index] +=  ((three*y[index]*(z[index]-coth))/r2_5
                              +(three*y[index]*(z[index]+coth))/r1_5)*csch;
            psizz[index] += (-one/r2_cubed+(three*SQR(z[index]-coth))/r2_5+
                             (three*SQR(z[index]+coth))/r1_5-one/r1_cubed)*csch;
          }
        }
      }
    }
  }

  /*     Cactus convention
   *     -----------------
   */

  if (use_conformal_derivs == 1)
  {
    for(k=0; k < nz; k++)
    {
      for(j=0; j < ny; j++)
      {
        for(i=0; i < nx; i++)
        {
          index = CCTK_GFINDEX3D(cctkGH, i,j,k);
          
          psix[index]  /= psi[index];
          psiy[index]  /= psi[index];
          psiz[index]  /= psi[index];
          psixx[index] /= psi[index];
          psixy[index] /= psi[index];
          psixz[index] /= psi[index];
          psiyy[index] /= psi[index];
          psiyz[index] /= psi[index];
          psizz[index] /= psi[index];
        }
      }
    }
  }
  
  /*     compute the ADM mass
   *     -------------------- 
   */
  mass = zero;
  
  for(n = 1; n <= nmax; n++)
  {
    mass += 4./sinh(n*mu);
  }

  message = (char *)malloc(200*sizeof(char));
  sprintf(message,"ADM mass is %f",mass);
  CCTK_INFO(message);
  free(message);
  
  /*     Should initialize lapse to Cadez value if possible
   *     --------------------------------------------------
   */

  if (CCTK_Equals(initial_lapse,"cadez") )
  { 
    CCTK_INFO("Initialise with cadez lapse");
    
    for(k=0; k < nz; k++)
    {
      for(j=0; j < ny; j++)
      {
        for(i=0; i < nx; i++)
        {
          index = CCTK_GFINDEX3D(cctkGH, i,j,k);
          
          x_squared = SQR(x[index]);
          y_squared = SQR(y[index]);
            
          alp[index] = one;

          powfac = 1;

          for(n = 1; n <= nmax; n++)
          {
            coth = one/tanh(mu*n);
            r1 = sqrt(x_squared+y_squared+SQR(z[index]+coth));
            r2 = sqrt(x_squared+y_squared+SQR(z[index]-coth));
            powfac *= -1;

            alp[index] += powfac * one/sinh(mu*n)*(one/r1 + one/r2);
          }
          
          alp[index] /= psi[index];
        }
      }
    }
  }
  
  /*     Metric depends on conformal state
   *     ---------------------------------
   */

  if (*conformal_state == CONFORMAL_METRIC)
  {
    for(k=0; k < nz; k++)
    {
      for(j=0; j < ny; j++)
      {
        for(i=0; i < nx; i++)
        {
          index = CCTK_GFINDEX3D(cctkGH, i,j,k);
          

          gxx[index] = one;
          gyy[index] = one;
          gzz[index] = one;
          gxy[index] = zero;
          gxz[index] = zero;
          gyz[index] = zero;
        }
      }
    }
  }
  else 
  {
    for(k=0; k < nz; k++)
    {
      for(j=0; j < ny; j++)
      {
        for(i=0; i < nx; i++)
        {
          index = CCTK_GFINDEX3D(cctkGH, i,j,k);
          
          gxx[index] = pow(psi[index],4);
          gyy[index] = gxx[index];
          gzz[index] = gxx[index];
          gxy[index] = zero;
          gxz[index] = zero;
          gyz[index] = zero;
        }
      }
    }
  }

  /*     Time-symmetric data
   *     -------------------
   */

  for(k=0; k < nz; k++)
  {
    for(j=0; j < ny; j++)
    {
      for(i=0; i < nx; i++)
      {
        index = CCTK_GFINDEX3D(cctkGH, i,j,k);
          
        kxx[index] = zero;
        kyy[index] = zero;
        kzz[index] = zero;
        kxy[index] = zero;
        kxz[index] = zero;
        kyz[index] = zero;
      }
    }
  }

  return;

  
  

}