00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 char et_rot_mag_C[] = "$Header: /cvsroot/Lorene/C++/Source/Etoile/et_rot_mag.C,v 1.18 2011/10/06 14:55:36 j_novak Exp $" ;
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096 #include "math.h"
00097
00098
00099 #include "et_rot_mag.h"
00100 #include "utilitaires.h"
00101 #include "unites.h"
00102 #include "param.h"
00103 #include "eos.h"
00104
00105
00106
00107
00108
00109
00110
00111
00112 Et_rot_mag::Et_rot_mag(Map& mp_i, int nzet_i, bool relat, const Eos& eos_i,
00113 const int cond)
00114 : Etoile_rot(mp_i, nzet_i, relat, eos_i),
00115 A_t(mp_i),
00116 A_phi(mp_i),
00117 j_t(mp_i),
00118 j_phi(mp_i),
00119 E_em(mp_i),
00120 Jp_em(mp_i),
00121 Srr_em(mp_i),
00122 Spp_em(mp_i)
00123
00124 {
00125
00126 A_t = 0;
00127 A_phi = 0;
00128 j_t = 0 ;
00129 j_phi = 0 ;
00130
00131 Q = 0 ;
00132 a_j = 0 ;
00133 conduc = cond ;
00134
00135 set_der_0x0() ;
00136 }
00137
00138
00139
00140 Et_rot_mag::Et_rot_mag(Map& mp_i, const Eos& eos_i, FILE* fich)
00141 : Etoile_rot(mp_i, eos_i, fich),
00142 A_t(mp_i),
00143 A_phi(mp_i),
00144 j_t(mp_i),
00145 j_phi(mp_i),
00146 E_em(mp_i),
00147 Jp_em(mp_i),
00148 Srr_em(mp_i),
00149 Spp_em(mp_i)
00150
00151 {
00152
00153
00154
00155
00156 fread_be(&conduc, sizeof(int), 1, fich) ;
00157 fread_be(&Q, sizeof(double), 1, fich) ;
00158 fread_be(&a_j, sizeof(double), 1, fich) ;
00159
00160
00161
00162
00163 Cmp A_t_file(mp, *mp.get_mg(), fich) ;
00164 A_t = A_t_file ;
00165
00166 Cmp A_phi_file(mp, *mp.get_mg(), fich) ;
00167 A_phi = A_phi_file ;
00168
00169 Cmp j_t_file(mp, *mp.get_mg(), fich) ;
00170 j_t = j_t_file ;
00171
00172 Cmp j_phi_file(mp, *mp.get_mg(), fich) ;
00173 j_phi = j_phi_file ;
00174
00175 Tenseur E_em_file(mp, fich) ;
00176 E_em = E_em_file ;
00177
00178 Tenseur Jp_em_file(mp, fich) ;
00179 Jp_em = Jp_em_file ;
00180
00181 Tenseur Srr_em_file(mp, fich) ;
00182 Srr_em = Srr_em_file ;
00183
00184 Tenseur Spp_em_file(mp, fich) ;
00185 Spp_em = Spp_em_file ;
00186
00187
00188
00189 set_der_0x0() ;
00190
00191 }
00192
00193
00194
00195
00196
00197 Et_rot_mag::Et_rot_mag(const Et_rot_mag& et)
00198 : Etoile_rot(et),
00199 A_t(et.A_t),
00200 A_phi(et.A_phi),
00201 j_t(et.j_t),
00202 j_phi(et.j_phi),
00203 E_em(et.E_em),
00204 Jp_em(et.Jp_em),
00205 Srr_em(et.Srr_em),
00206 Spp_em(et.Spp_em)
00207
00208 {
00209 Q = et.Q ;
00210 a_j = et.a_j ;
00211 conduc = et.conduc ;
00212 set_der_0x0() ;
00213 }
00214
00215
00216
00217
00218
00219
00220 Et_rot_mag::~Et_rot_mag(){
00221 del_deriv() ;
00222 }
00223
00224
00225
00226
00227
00228
00229 void Et_rot_mag::del_deriv() const {
00230
00231 Etoile_rot::del_deriv() ;
00232
00233 set_der_0x0() ;
00234
00235 }
00236
00237
00238 void Et_rot_mag::set_der_0x0() const {
00239 Etoile_rot::set_der_0x0() ;
00240
00241 }
00242
00243
00244 void Et_rot_mag::del_hydro_euler() {
00245 Etoile_rot::del_hydro_euler() ;
00246
00247 del_deriv() ;
00248 }
00249
00250
00251
00252
00253
00254 void Et_rot_mag::operator=(const Et_rot_mag& et) {
00255
00256
00257 Etoile_rot::operator=(et) ;
00258 A_t = et.A_t ;
00259 A_phi = et.A_phi ;
00260 j_t = et.j_t ;
00261 j_phi = et.j_phi ;
00262 E_em = et.E_em ;
00263 Jp_em = et.Jp_em ;
00264 Srr_em = et.Srr_em ;
00265 Spp_em = et.Spp_em ;
00266 Q = et.Q ;
00267 a_j = et.a_j ;
00268 conduc = et.conduc ;
00269
00270 del_deriv() ;
00271
00272 }
00273
00274
00275 void Et_rot_mag::equation_of_state() {
00276
00277 Cmp ent_eos = ent() ;
00278
00279
00280
00281
00282
00283
00284 double epsilon = 1.e-12 ;
00285
00286 const Mg3d* mg = mp.get_mg() ;
00287 int nz = mg->get_nzone() ;
00288
00289 Mtbl xi(mg) ;
00290 xi.set_etat_qcq() ;
00291 for (int l=0; l<nz; l++) {
00292 xi.t[l]->set_etat_qcq() ;
00293 for (int k=0; k<mg->get_np(l); k++) {
00294 for (int j=0; j<mg->get_nt(l); j++) {
00295 for (int i=0; i<mg->get_nr(l); i++) {
00296 xi.set(l,k,j,i) =
00297 mg->get_grille3d(l)->x[i] ;
00298 }
00299 }
00300 }
00301
00302 }
00303
00304 Cmp fact_ent(mp) ;
00305 fact_ent.allocate_all() ;
00306
00307 fact_ent.set(0) = 1 + epsilon * xi(0) * xi(0) ;
00308 fact_ent.set(1) = 1 - 0.25 * epsilon * (xi(1) - 1) * (xi(1) - 1) ;
00309
00310 for (int l=nzet; l<nz; l++) {
00311 fact_ent.set(l) = 1 ;
00312 }
00313
00314 if (nzet > 1) {
00315
00316 if (nzet > 2) {
00317
00318 cout << "Etoile::equation_of_state: not ready yet for nzet > 2 !"
00319 << endl ;
00320 }
00321
00322 ent_eos = fact_ent * ent_eos ;
00323 ent_eos.std_base_scal() ;
00324 }
00325
00326
00327
00328 if ( dynamic_cast<const Eos_mag*>(&eos) != 0x0) {
00329
00330
00331 Tenseur Bmag = Magn() ;
00332 Cmp norm_B = sqrt(a_car() * ( Bmag(0)*Bmag(0) + Bmag(1)*Bmag(1) )) ;
00333 norm_B.std_base_scal() ;
00334 Param par ;
00335 double magB0 ;
00336 par.add_double_mod(magB0) ;
00337
00338 nbar.set_etat_qcq() ; nbar.set().set_etat_qcq() ;
00339 nbar.set().va.set_etat_c_qcq() ; nbar.set().va.c->set_etat_qcq() ;
00340 ener.set_etat_qcq() ; ener.set().set_etat_qcq() ;
00341 ener.set().va.set_etat_c_qcq() ; ener.set().va.c->set_etat_qcq() ;
00342 press.set_etat_qcq() ; press.set().set_etat_qcq() ;
00343 press.set().va.set_etat_c_qcq() ; press.set().va.c->set_etat_qcq() ;
00344
00345 for (int l=0; l< nz; l++) {
00346 Tbl* tent = ent_eos.va.c->t[l] ;
00347 if (tent->get_etat() == ETATZERO) {
00348 nbar.set().set(l).set_etat_zero() ;
00349 ener.set().set(l).set_etat_zero() ;
00350 press.set().set(l).set_etat_zero() ;
00351 }
00352 else {
00353 nbar.set().set(l).annule_hard() ;
00354 ener.set().set(l).annule_hard() ;
00355 press.set().set(l).annule_hard() ;
00356 for (int k=0; k < mg->get_np(l); k++) {
00357 for (int j=0; j < mg->get_nt(l); j++) {
00358 for (int i=0; i < mg->get_nr(l); i++) {
00359 magB0 = norm_B(l, k, j, i) ;
00360 double ent0 = ent_eos(l, k, j, i) ;
00361 nbar.set().set(l, k, j, i) = eos.nbar_ent_p(ent0, &par) ;
00362 ener.set().set(l, k, j, i) = eos.ener_ent_p(ent0, &par) ;
00363 press.set().set(l, k, j, i) = eos.press_ent_p(ent0, &par) ;
00364 }
00365 }
00366 }
00367 }
00368 }
00369 }
00370
00371 else {
00372
00373
00374
00375 Cmp tempo(mp) ;
00376
00377 nbar.set_etat_qcq() ;
00378 nbar.set() = 0 ;
00379 for (int l=0; l<nzet; l++) {
00380
00381 Param par ;
00382 par.add_int(l) ;
00383
00384 tempo = eos.nbar_ent(ent_eos, 1, l, &par) ;
00385
00386 nbar = nbar() + tempo ;
00387
00388 }
00389
00390 ener.set_etat_qcq() ;
00391 ener.set() = 0 ;
00392 for (int l=0; l<nzet; l++) {
00393
00394 Param par ;
00395 par.add_int(l) ;
00396
00397 tempo = eos.ener_ent(ent_eos, 1, l, &par) ;
00398
00399 ener = ener() + tempo ;
00400
00401 }
00402
00403 press.set_etat_qcq() ;
00404 press.set() = 0 ;
00405 for (int l=0; l<nzet; l++) {
00406
00407 Param par ;
00408 par.add_int(l) ;
00409
00410 tempo = eos.press_ent(ent_eos, 1, l, &par) ;
00411
00412 press = press() + tempo ;
00413
00414 }
00415 }
00416
00417
00418 nbar.set_std_base() ;
00419 ener.set_std_base() ;
00420 press.set_std_base() ;
00421
00422
00423 del_deriv() ;
00424
00425 }
00426
00427
00428
00429
00430
00431
00432
00433
00434
00435 void Et_rot_mag::sauve(FILE* fich) const {
00436
00437 Etoile_rot::sauve(fich) ;
00438
00439 fwrite_be(&conduc, sizeof(int), 1, fich) ;
00440 fwrite_be(&Q, sizeof(double), 1, fich) ;
00441 fwrite_be(&a_j, sizeof(double), 1, fich) ;
00442
00443 A_t.sauve(fich) ;
00444 A_phi.sauve(fich) ;
00445 j_t.sauve(fich) ;
00446 j_phi.sauve(fich) ;
00447 E_em.sauve(fich) ;
00448 Jp_em.sauve(fich) ;
00449 Srr_em.sauve(fich) ;
00450 Spp_em.sauve(fich) ;
00451
00452 }
00453
00454
00455
00456
00457
00458
00459 ostream& Et_rot_mag::operator>>(ostream& ost) const {
00460
00461 using namespace Unites_mag ;
00462
00463 Etoile_rot::operator>>(ost) ;
00464 int theta_eq = mp.get_mg()->get_nt(nzet-1)-1 ;
00465 ost << endl ;
00466 ost << "Electromagnetic quantities" << endl ;
00467 ost << "----------------------" << endl ;
00468 ost << endl ;
00469 if (is_conduct()) {
00470 ost << "***************************" << endl ;
00471 ost << "**** perfect conductor ****" << endl ;
00472 ost << "***************************" << endl ;
00473 ost << "Prescribed charge : " << Q*j_unit*pow(r_unit,3)/v_unit
00474 << " [C]" << endl;
00475 }
00476 else {
00477 ost << "***************************" << endl ;
00478 ost << "**** isolator ****" << endl ;
00479 ost << "***************************" << endl ;
00480 }
00481 ost << "Prescribed current amplitude : " << a_j*j_unit
00482 << " [A/m2]" << endl ;
00483 ost << "Magnetic Momentum : " << MagMom()/1.e32
00484 << " [10^32 Am^2]" << endl ;
00485 ost << "Radial magnetic field polar value : " <<
00486 Magn()(0).va.val_point(l_surf()(0,0),xi_surf()(0,0),0.,0.)
00487 << " [GT]" << endl;
00488
00489 ost << "Tangent magnetic field equatorial value : " <<
00490 Magn()(1).va.val_point(l_surf()(0,theta_eq),xi_surf()(0,theta_eq),M_PI_2,0.)
00491 << " [GT]" << endl;
00492
00493 ost << "Central magnetic field values : " <<
00494 Magn()(0)(0,0,0,0)
00495 << " [GT]" << endl;
00496
00497 ost << "Radial electric field polar value : " <<
00498 Elec()(0).va.val_point(l_surf()(0,0),xi_surf()(0,0),0.,0.)
00499 << " [TV]" << endl;
00500
00501 ost << "Radial electric field equatorial value : " <<
00502 Elec()(0).va.val_point(l_surf()(0,theta_eq),xi_surf()(0,theta_eq),M_PI_2,0.)
00503 << " [TV]" << endl;
00504
00505 ost << "Magnetic/fluid pressure : "
00506 << 1/(2*mu_si)*(pow(Magn()(0)(0,0,0,0),2) +
00507 pow(Magn()(1)(0,0,0,0),2) +
00508 pow(Magn()(2)(0,0,0,0),2))*1.e18
00509 / (press()(0,0,0,0)*rho_unit*pow(v_unit,2)) << endl ;
00510 ost << "Computed charge : " << Q_comput() << " [C]" << endl ;
00511 ost << "Interior charge : " << Q_int() << " [C]" << endl ;
00512 ost << "Q^2/M^2 :" << mu_si*c_si*c_si*Q_comput()*Q_comput()/(4*M_PI*g_si*mass_g()*mass_g()*m_unit*m_unit)
00513 << endl ;
00514 ost << "Gyromagnetic ratio : " << GyroMag() << endl ;
00515
00516 return ost ;
00517 }
00518
00519
00520
00521
00522
00523
00524
00525
00526
00527
00528
00529
00530
00531
00532
00533