forked from pseudotensor/grmonty
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathinit_geometry.c
114 lines (77 loc) · 3.36 KB
/
init_geometry.c
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
/***********************************************************************************
Copyright 2013 Joshua C. Dolence, Charles F. Gammie, Monika Mo\'scibrodzka,
and Po Kin Leung
GRMONTY version 1.0 (released February 1, 2013)
This file is part of GRMONTY. GRMONTY v1.0 is a program that calculates the
emergent spectrum from a model using a Monte Carlo technique.
This version of GRMONTY is configured to use input files from the HARM code
available on the same site. It assumes that the source is a plasma near a
black hole described by Kerr-Schild coordinates that radiates via thermal
synchrotron and inverse compton scattering.
You are morally obligated to cite the following paper in any
scientific literature that results from use of any part of GRMONTY:
Dolence, J.C., Gammie, C.F., Mo\'scibrodzka, M., \& Leung, P.-K. 2009,
Astrophysical Journal Supplement, 184, 387
Further, we strongly encourage you to obtain the latest version of
GRMONTY directly from our distribution website:
http://rainman.astro.illinois.edu/codelib/
GRMONTY is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
GRMONTY is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GRMONTY; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
***********************************************************************************/
#include "decs.h"
/*
set up the metric (indicies both up and down), and the
connection coefficients on a grid, based
on a HARM simulation grid.
In principle the geometry could be sampled on a finer or
coarser grid than the simulation grid.
These routines are taken directly out of HARM.
They require the code be compiled against the
Gnu scientific library (GSL).
CFG 21 July 06
*/
gsl_matrix *gsl_gcov, *gsl_gcon;
gsl_permutation *perm;
#pragma omp threadprivate (gsl_gcov, gsl_gcon, perm)
/* assumes gcov has been set first; returns determinant */
double gdet_func(double gcov[][NDIM])
{
double d;
int k, l, signum;
if (gsl_gcov == NULL) {
gsl_gcov = gsl_matrix_alloc(NDIM, NDIM);
gsl_gcon = gsl_matrix_alloc(NDIM, NDIM);
perm = gsl_permutation_alloc(NDIM);
}
DLOOP gsl_matrix_set(gsl_gcov, k, l, gcov[k][l]);
gsl_linalg_LU_decomp(gsl_gcov, perm, &signum);
d = gsl_linalg_LU_det(gsl_gcov, signum);
return (sqrt(fabs(d)));
}
/* invert gcov to get gcon */
/*
void gcon_func(double gcov[][NDIM], double gcon[][NDIM])
{
int k, l, signum;
if (gsl_gcov == NULL) {
gsl_gcov = gsl_matrix_alloc(NDIM, NDIM);
gsl_gcon = gsl_matrix_alloc(NDIM, NDIM);
perm = gsl_permutation_alloc(NDIM);
}
DLOOP gsl_matrix_set(gsl_gcov, k, l, gcov[k][l]);
gsl_linalg_LU_decomp(gsl_gcov, perm, &signum);
gsl_linalg_LU_invert(gsl_gcov, perm, gsl_gcon);
DLOOP gcon[k][l] = gsl_matrix_get(gsl_gcon, k, l);
// done!
}
*/
#undef DELTA