| 1 |
/* |
| 2 |
* Main code for testing the classes Qmetrique and Qtenseur. |
| 3 |
*/ |
| 4 |
|
| 5 |
/* |
| 6 |
* Copyright (c) 2002 Jerome Novak |
| 7 |
* |
| 8 |
* This file is part of LORENE. |
| 9 |
* |
| 10 |
* LORENE is free software; you can redistribute it and/or modify |
| 11 |
* it under the terms of the GNU General Public License as published by |
| 12 |
* the Free Software Foundation; either version 2 of the License, or |
| 13 |
* (at your option) any later version. |
| 14 |
* |
| 15 |
* LORENE is distributed in the hope that it will be useful, |
| 16 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 18 |
* GNU General Public License for more details. |
| 19 |
* |
| 20 |
* You should have received a copy of the GNU General Public License |
| 21 |
* along with LORENE; if not, write to the Free Software |
| 22 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 23 |
* |
| 24 |
*/ |
| 25 |
|
| 26 |
char test_qmetrique_C[] = "$Header: /cvsroot/Lorene/Codes/Test/QuadriD/test_qmetrique.C,v 1.4 2014/10/13 08:54:02 j_novak Exp $" ; |
| 27 |
|
| 28 |
/* |
| 29 |
* $Id: test_qmetrique.C,v 1.4 2014/10/13 08:54:02 j_novak Exp $ |
| 30 |
* $Log: test_qmetrique.C,v $ |
| 31 |
* Revision 1.4 2014/10/13 08:54:02 j_novak |
| 32 |
* Lorene classes and functions now belong to the namespace Lorene. |
| 33 |
* |
| 34 |
* Revision 1.3 2014/10/06 15:12:55 j_novak |
| 35 |
* Modified #include directives to use c++ syntax. |
| 36 |
* |
| 37 |
* Revision 1.2 2003/01/09 11:07:59 j_novak |
| 38 |
* headcpp.h is now compliant with C++ norm. |
| 39 |
* The include files have been ordered, as well as the local_settings_linux |
| 40 |
* |
| 41 |
* Revision 1.1 2002/09/19 11:41:29 j_novak |
| 42 |
* Added main program for testing the classes Qmetrique and Qtenseur |
| 43 |
* |
| 44 |
* |
| 45 |
* $Header: /cvsroot/Lorene/Codes/Test/QuadriD/test_qmetrique.C,v 1.4 2014/10/13 08:54:02 j_novak Exp $ |
| 46 |
* |
| 47 |
*/ |
| 48 |
|
| 49 |
//standard |
| 50 |
#include <cmath> |
| 51 |
|
| 52 |
// Headers Lorene : |
| 53 |
#include "qmetrique.h" |
| 54 |
#include "nbr_spx.h" |
| 55 |
|
| 56 |
using namespace Lorene ; |
| 57 |
|
| 58 |
int main() { |
| 59 |
|
| 60 |
double M = 1. ; |
| 61 |
double a = 0.99 ; |
| 62 |
|
| 63 |
int nz = 2 ; |
| 64 |
double R = 2*M ; |
| 65 |
|
| 66 |
// Nombre points en r |
| 67 |
int nr = 21 ; |
| 68 |
|
| 69 |
// echantillonnage en phi : |
| 70 |
int* np = new int [nz] ; |
| 71 |
for (int l=0 ; l<nz ; l++) |
| 72 |
np[l] = 4 ; |
| 73 |
int type_p = SYM ; |
| 74 |
|
| 75 |
// echantillonnage en theta : |
| 76 |
int* nt = new int [nz] ; |
| 77 |
for (int l=0 ; l<nz ; l++) |
| 78 |
nt[l] = 9 ; |
| 79 |
int type_t = SYM ; |
| 80 |
|
| 81 |
int* type_r = new int[nz] ; |
| 82 |
type_r[0] = FIN ; |
| 83 |
for (int l=1 ; l<nz ; l++) |
| 84 |
type_r[l] = FIN ; |
| 85 |
type_r[nz-1] = UNSURR ; |
| 86 |
|
| 87 |
// Construction de la grille |
| 88 |
|
| 89 |
// echantillonage en r : |
| 90 |
int* nr0 = new int [nz] ; |
| 91 |
for (int l=0 ; l<nz ; l++) |
| 92 |
nr0[l] = nr ; |
| 93 |
|
| 94 |
Mg3d grille (nz, nr0, type_r, nt, type_t, np, type_p) ; |
| 95 |
cout << grille ; |
| 96 |
|
| 97 |
//Construction du mapping : |
| 98 |
double* bornes = new double[nz+1] ; |
| 99 |
bornes[0] = R ; |
| 100 |
for (int i=1 ; i<nz ; i++) |
| 101 |
bornes[i] = R*double(i+nz)/double(nz) ; |
| 102 |
bornes[nz] = __infinity ; |
| 103 |
Map_af mapping(grille, bornes) ; |
| 104 |
|
| 105 |
Coord& r = mapping.r ; |
| 106 |
Coord& sint = mapping.sint ; |
| 107 |
Coord& cost = mapping.cost ; |
| 108 |
Mtbl erre(1.+M/r + (M*M - a*a)/(4*r*r)) ; |
| 109 |
Mtbl rs(r + M + (M*M - a*a)/(4*r)) ; |
| 110 |
Mtbl sigmasr(rs + (a*a*cost*cost)/rs) ; |
| 111 |
Cmp adeux(mapping) ; Cmp bdeux(mapping) ; |
| 112 |
adeux = erre*erre + (a*a*cost*cost)/(r*r) ; //Kerr dans la jauge quasi- |
| 113 |
bdeux = erre*erre + a*a/(r*r) + 2*a*a*sint*sint*M/(sigmasr*r*r) ; //isotrope |
| 114 |
|
| 115 |
Tenseur_sym gspher(mapping, 2, COV, mapping.get_bvect_spher() ) ; |
| 116 |
gspher.set_etat_qcq() ; |
| 117 |
for (int i=0; i<3; i++) |
| 118 |
for (int j=0; j<i; j++) |
| 119 |
gspher.set(i,j) = 0 ; |
| 120 |
gspher.set(0,0) = adeux ; |
| 121 |
gspher.set(1,1) = adeux ; |
| 122 |
gspher.set(2,2) = bdeux ; |
| 123 |
gspher.set_std_base() ; |
| 124 |
|
| 125 |
Tenseur shift(mapping, 1, CON, mapping.get_bvect_spher() ) ; |
| 126 |
shift.set_etat_qcq() ; |
| 127 |
shift.set(0) = 0 ; |
| 128 |
shift.set(1) = 0 ; |
| 129 |
Cmp bphi(mapping) ; |
| 130 |
bphi = 2*a*M*sint/(sigmasr*(rs*erre + a*a/r) + 2*a*a*M*sint*sint/r) ; |
| 131 |
shift.set(2) = bphi ; |
| 132 |
shift.set_std_base() ; |
| 133 |
|
| 134 |
shift.change_triad(mapping.get_bvect_cart()) ; |
| 135 |
shift.set_std_base() ; |
| 136 |
|
| 137 |
Tenseur lapse(mapping) ; |
| 138 |
lapse.set_etat_qcq() ; |
| 139 |
Cmp enne2(mapping) ; |
| 140 |
enne2 = 1 - 2*M/sigmasr + |
| 141 |
1./(sigmasr*sigmasr*(rs*rs + a*a)/(4*a*a*M*M*sint*sint) |
| 142 |
+ sigmasr/(2*M)) ; |
| 143 |
lapse.set() = sqrt(enne2 ) ; |
| 144 |
lapse.set_std_base() ; |
| 145 |
|
| 146 |
Tenseur_sym gcart(gspher) ; |
| 147 |
gcart.change_triad(mapping.get_bvect_cart() ) ; |
| 148 |
gcart.set_std_base() ; |
| 149 |
|
| 150 |
Metrique gij(gcart) ; |
| 151 |
double dt = 0.1 ; |
| 152 |
Param para ; |
| 153 |
para.add_double(dt) ; |
| 154 |
Qmetrique kerr(lapse, shift, gij) ; |
| 155 |
cout << "---------------------------------" << endl ; |
| 156 |
cout << "4-Ricci tensor of the Kerr metric" << endl ; |
| 157 |
cout << "---------------------------------" << endl ; |
| 158 |
kerr.avance_temps(lapse, shift, gij, dt) ; |
| 159 |
kerr.avance_temps(lapse, shift, gij, dt) ; |
| 160 |
kerr.avance_temps(lapse, shift, gij, dt) ; |
| 161 |
for (int i=0; i<4; i++) |
| 162 |
for (int j=i; j<4; j++) { |
| 163 |
cout << "i, j " << i << ", " << j << endl ; |
| 164 |
cout << max(abs(kerr.ricci(dt)(i,j))) ; |
| 165 |
} |
| 166 |
|
| 167 |
delete [] np ; |
| 168 |
delete [] nt ; |
| 169 |
delete [] nr0 ; |
| 170 |
delete [] type_r ; |
| 171 |
delete [] bornes ; |
| 172 |
return EXIT_SUCCESS ; |
| 173 |
} |
| 174 |
|
| 175 |
|
| 176 |
|
| 177 |
|
| 178 |
|
| 179 |
|