| 1 |
/* |
| 2 |
* Test code for the classe Metconf and the associated covariant |
| 3 |
* derivatives, using Schwarzschild metric. |
| 4 |
* |
| 5 |
*/ |
| 6 |
|
| 7 |
/* |
| 8 |
* Copyright (c) 2002 Jerome Novak |
| 9 |
* |
| 10 |
* This file is part of LORENE. |
| 11 |
* |
| 12 |
* LORENE is free software; you can redistribute it and/or modify |
| 13 |
* it under the terms of the GNU General Public License version 2 |
| 14 |
* as published by the Free Software Foundation. |
| 15 |
* |
| 16 |
* LORENE is distributed in the hope that it will be useful, |
| 17 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 18 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 19 |
* GNU General Public License for more details. |
| 20 |
* |
| 21 |
* You should have received a copy of the GNU General Public License |
| 22 |
* along with LORENE; if not, write to the Free Software |
| 23 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 24 |
* |
| 25 |
*/ |
| 26 |
|
| 27 |
char metconf_derive_C[] = "$Header: /cvsroot/Lorene/Codes/Test/Metrique/test_metconf_derive.C,v 1.5 2014/10/13 08:54:01 j_novak Exp $" ; |
| 28 |
|
| 29 |
/* |
| 30 |
* $Id: test_metconf_derive.C,v 1.5 2014/10/13 08:54:01 j_novak Exp $ |
| 31 |
* $Log: test_metconf_derive.C,v $ |
| 32 |
* Revision 1.5 2014/10/13 08:54:01 j_novak |
| 33 |
* Lorene classes and functions now belong to the namespace Lorene. |
| 34 |
* |
| 35 |
* Revision 1.4 2014/10/06 15:12:53 j_novak |
| 36 |
* Modified #include directives to use c++ syntax. |
| 37 |
* |
| 38 |
* Revision 1.3 2002/10/16 14:37:18 j_novak |
| 39 |
* Reorganization of #include instructions of standard C++, in order to |
| 40 |
* use experimental version 3 of gcc. |
| 41 |
* |
| 42 |
* Revision 1.2 2002/09/10 14:16:14 j_novak |
| 43 |
* Modif commentaires |
| 44 |
* |
| 45 |
* |
| 46 |
* $Header: /cvsroot/Lorene/Codes/Test/Metrique/test_metconf_derive.C,v 1.5 2014/10/13 08:54:01 j_novak Exp $ |
| 47 |
* |
| 48 |
*/ |
| 49 |
|
| 50 |
//standard |
| 51 |
#include <cmath> |
| 52 |
|
| 53 |
// Headers Lorene : |
| 54 |
#include "utilitaires.h" |
| 55 |
#include "param.h" |
| 56 |
#include "metconf.h" |
| 57 |
#include "graphique.h" |
| 58 |
#include "proto.h" |
| 59 |
#include "nbr_spx.h" |
| 60 |
|
| 61 |
using namespace Lorene ; |
| 62 |
|
| 63 |
int main() { |
| 64 |
|
| 65 |
int nz = 2 ; |
| 66 |
double R = 3. ; |
| 67 |
|
| 68 |
// Nombre points en r |
| 69 |
int nr = 21 ; |
| 70 |
|
| 71 |
// echantillonnage en phi : |
| 72 |
int* np = new int [nz] ; |
| 73 |
for (int l=0 ; l<nz ; l++) |
| 74 |
np[l] = 4 ; |
| 75 |
int type_p = SYM ; |
| 76 |
|
| 77 |
// echantillonnage en theta : |
| 78 |
int* nt = new int [nz] ; |
| 79 |
for (int l=0 ; l<nz ; l++) |
| 80 |
nt[l] = 5 ; |
| 81 |
int type_t = SYM ; |
| 82 |
|
| 83 |
int* type_r = new int[nz] ; |
| 84 |
type_r[0] = FIN ; |
| 85 |
for (int l=1 ; l<nz ; l++) |
| 86 |
type_r[l] = FIN ; |
| 87 |
type_r[nz-1] = UNSURR ; |
| 88 |
|
| 89 |
// Construction de la grille |
| 90 |
|
| 91 |
// echantillonage en r : |
| 92 |
int* nr0 = new int [nz] ; |
| 93 |
for (int l=0 ; l<nz ; l++) |
| 94 |
nr0[l] = nr ; |
| 95 |
|
| 96 |
Mg3d grille (nz, nr0, type_r, nt, type_t, np, type_p) ; |
| 97 |
cout << grille ; |
| 98 |
|
| 99 |
//Construction du mapping : |
| 100 |
double* bornes = new double[nz+1] ; |
| 101 |
for (int i=0 ; i<nz ; i++) |
| 102 |
bornes[i] = R*double(i+nz)/double(nz) ; |
| 103 |
bornes[nz] = __infinity ; |
| 104 |
Map_af mapping(grille, bornes) ; |
| 105 |
|
| 106 |
Coord& r = mapping.r ; |
| 107 |
Cmp source(mapping) ; |
| 108 |
source = 1. - 2/r ; //Schwarzschild avec M = 1 |
| 109 |
|
| 110 |
Tenseur_sym gspher(mapping, 2, COV, mapping.get_bvect_spher() ) ; |
| 111 |
gspher.set_etat_qcq() ; |
| 112 |
for (int i=0; i<3; i++) |
| 113 |
for (int j=0; j<i; j++) |
| 114 |
gspher.set(i,j) = 0 ; |
| 115 |
gspher.set(0,0) = 1./source ; |
| 116 |
gspher.set(1,1) = 1. ; |
| 117 |
gspher.set(2,2) = 1. ; |
| 118 |
gspher.set_std_base() ; |
| 119 |
|
| 120 |
Tenseur_sym gcart(gspher) ; |
| 121 |
gcart.change_triad(mapping.get_bvect_cart() ) ; |
| 122 |
gcart.set_std_base() ; |
| 123 |
|
| 124 |
Metrique gij(gcart) ; |
| 125 |
cout << "----------------------------------------------------" << endl ; |
| 126 |
cout << "Norme du scalaire de courbure de la 3-metrique gij: " << endl ; |
| 127 |
cout << "----------------------------------------------------" << endl ; |
| 128 |
Cmp courb(gij.ricci_scal()()) ; |
| 129 |
courb.dec2_dzpuis() ; |
| 130 |
courb.dec_dzpuis() ; |
| 131 |
cout << norme(courb) ; |
| 132 |
arrete() ; |
| 133 |
|
| 134 |
Tenseur_sym plat(mapping, 2, COV, mapping.get_bvect_cart() ) ; |
| 135 |
plat.set_etat_qcq() ; |
| 136 |
for (int i=0; i<3; i++) { |
| 137 |
for (int j=0; j<i; j++) |
| 138 |
plat.set(i,j) = 0 ; |
| 139 |
plat.set(i,i) = 1 ; |
| 140 |
} |
| 141 |
plat.set_std_base() ; |
| 142 |
|
| 143 |
Metrique fij(plat, true) ; |
| 144 |
Metconf gtilde(pow(gij.determinant(),(-1./3.))*gcart, fij) ; |
| 145 |
|
| 146 |
cout << "--------------------" << endl ; |
| 147 |
cout << "Norme de D_k g~_ij: " << endl ; |
| 148 |
cout << "--------------------" << endl ; |
| 149 |
for (int i=0; i<3; i++) |
| 150 |
for (int j=0; j<3; j++) |
| 151 |
for (int k=j; k<3; k++) { |
| 152 |
cout << "k, i, j : " << i << ", " << j << ", " << k << endl ; |
| 153 |
cout << norme(gtilde.cov().derive_cov(gij)(i,j,k)) ; |
| 154 |
} |
| 155 |
arrete() ; |
| 156 |
|
| 157 |
cout << "---------------------" << endl ; |
| 158 |
cout << "Norme de D~_k g~_ij: " << endl ; |
| 159 |
cout << "---------------------" << endl ; |
| 160 |
for (int i=0; i<3; i++) |
| 161 |
for (int j=0; j<3; j++) |
| 162 |
for (int k=j; k<3; k++) { |
| 163 |
cout << "k, i, j : " << i << ", " << j << ", " << k << endl ; |
| 164 |
cout << norme(gtilde.cov().derive_cov(gtilde)(i,j,k)) ; |
| 165 |
} |
| 166 |
arrete() ; |
| 167 |
|
| 168 |
cout << "------------" << endl ; |
| 169 |
cout << "Delta^k_ik: " << endl ; |
| 170 |
cout << "------------" << endl ; |
| 171 |
Tenseur beta(contract(gtilde.delta(),0,1)) ; |
| 172 |
for (int i=0; i<3; i++) { |
| 173 |
cout << "i: " << i << endl ; |
| 174 |
cout << norme(beta(i)) ; |
| 175 |
} |
| 176 |
arrete() ; |
| 177 |
|
| 178 |
cout << "---------------------------------------------------------" |
| 179 |
<< endl ; |
| 180 |
cout << "Erreur relative sur C~ - gamma + gamma~ [formule (169)]: " |
| 181 |
<< endl ; |
| 182 |
cout << "---------------------------------------------------------" |
| 183 |
<< endl ; |
| 184 |
Tenseur T1(contract(gij.con(),1,gij.cov().derive_cov(gtilde),1)) ; |
| 185 |
Tenseur T2(contract(gij.con(),1,gij.cov().derive_cov(gtilde),0)) ; |
| 186 |
Tenseur_sym ctilde(gij.gamma()) ; |
| 187 |
for (int k=0; k<3; k++) |
| 188 |
for (int i=0; i<3; i++) |
| 189 |
for (int j=0; j<3; j++) { |
| 190 |
ctilde.set(k,i,j) = 0.5*(T1(k,i,j) + T1(k,j,i) - T2(k,i,j)) ; |
| 191 |
} |
| 192 |
|
| 193 |
Tenseur diff(ctilde - gij.gamma() + gtilde.gamma()) ; |
| 194 |
for (int i=0; i<3; i++) |
| 195 |
for (int j=0; j<3; j++) |
| 196 |
for (int k=j; k<3; k++) { |
| 197 |
cout << "k, i, j : " << i << ", " << j << ", " << k << endl ; |
| 198 |
cout << norme(diff(i,j,k))/norme(ctilde(i,j,k)) ; |
| 199 |
} |
| 200 |
arrete() ; |
| 201 |
|
| 202 |
cout << "----------------------------------------------------" << endl ; |
| 203 |
cout << "Verification de la relation entre Rij et R~ij (178):" << endl ; |
| 204 |
cout << "----------------------------------------------------" << endl ; |
| 205 |
Tenseur lnh(log(gij.determinant())) ; |
| 206 |
lnh.set_std_base() ; |
| 207 |
Tenseur gradh(lnh.gradient()) ; |
| 208 |
Tenseur gradh2(gradh) ; |
| 209 |
gradh2.dec2_dzpuis() ; |
| 210 |
Tenseur_sym ggh(gradh2.derive_cov(gtilde)) ; |
| 211 |
ggh.inc_dzpuis() ; |
| 212 |
|
| 213 |
Tenseur_sym R1(fij.cov()) ; |
| 214 |
for(int i=0; i<3; i++) |
| 215 |
for (int j=i; j<3; j++) |
| 216 |
R1.set(i,j) = gradh(i)*gradh(j)/6. ; |
| 217 |
R1.dec_dzpuis() ; |
| 218 |
Tenseur Raux(contract(gtilde.con(),0,ggh+R1,0)) ; |
| 219 |
Tenseur_sym R2(contract(Raux,0,1)*gtilde.cov()) ; |
| 220 |
Tenseur_sym Rij(gij.ricci() - gtilde.ricci() + (ggh - R1 + R2)/6.) ; |
| 221 |
for(int i=0; i<3; i++) |
| 222 |
for (int j=i; j<3; j++) { |
| 223 |
cout << "Erreur relative/composante: " << i << ", " << j << endl ; |
| 224 |
cout << norme(Rij(i,j))/norme(gij.ricci()(i,j)) ;} |
| 225 |
arrete() ; |
| 226 |
|
| 227 |
cout << "------------------------------------------------" << endl ; |
| 228 |
cout << "Verification de la relation entre R et R~ (182):" << endl ; |
| 229 |
cout << "------------------------------------------------" << endl ; |
| 230 |
Raux = contract(gij.con(), 0,(ggh - R1 + R2)/6., 0) ; |
| 231 |
Tenseur R3(contract(Raux,0,1)) ; |
| 232 |
Tenseur R4(gtilde.ricci_scal()) ; |
| 233 |
if (gtilde.dirac_gauge()) R4.dec_dzpuis() ; |
| 234 |
Tenseur RR(gij.ricci_scal() - pow(gij.determinant(), -1./3.)*R4 + R3) ; |
| 235 |
cout << norme(RR())/norme(gtilde.ricci_scal()()) ; |
| 236 |
arrete() ; |
| 237 |
|
| 238 |
cout << "--------------------------------------------" << endl ; |
| 239 |
cout << "Verification de la formule (199) pour R~_ij:" << endl ; |
| 240 |
cout << "--------------------------------------------" << endl ; |
| 241 |
Tenseur_sym L1(contract(contract(gtilde.delta(),0, gtilde.delta(),2), |
| 242 |
1,2) ); |
| 243 |
L1.dec_dzpuis() ; |
| 244 |
Tenseur_sym del2(gtilde.delta()) ; |
| 245 |
del2.dec2_dzpuis() ; |
| 246 |
Tenseur_sym L2(contract(del2.derive_cov(fij), 0, 1)) ; |
| 247 |
L2.inc_dzpuis() ; |
| 248 |
|
| 249 |
Tenseur_sym fin(gtilde.ricci() - L2 + L1) ; |
| 250 |
for (int i=0; i<3; i++) |
| 251 |
for (int j=i; j<3; j++) { |
| 252 |
cout << "i, j: " << i << ", " << j << endl ; |
| 253 |
cout << norme(fin(i,j))/norme(gtilde.ricci()(i,j)) ; |
| 254 |
} |
| 255 |
|
| 256 |
delete [] np ; |
| 257 |
delete [] nt ; |
| 258 |
delete [] nr0 ; |
| 259 |
delete [] type_r ; |
| 260 |
delete [] bornes ; |
| 261 |
return EXIT_SUCCESS ; |
| 262 |
} |
| 263 |
|
| 264 |
|
| 265 |
|
| 266 |
|
| 267 |
|
| 268 |
|