et_magnetisation_comp.C
/*
* Computational functions for magnetized rotating equilibrium
*
* (see file et_rot_mag.h for documentation)
*
*/
/*
* Copyright (c) 2013 Debarati Chatterjee, Jerome Novak
*
* This file is part of LORENE.
*
* LORENE 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.
*
* LORENE 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 LORENE; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
char et_magnetisation_comp_C[] = "$Header: /cvsroot/Lorene/C++/Source/Etoile/et_magnetisation_comp.C,v 1.14 2016/11/01 09:12:59 j_novak Exp $" ;
/*
* $Id: et_magnetisation_comp.C,v 1.14 2016/11/01 09:12:59 j_novak Exp $
* $Log: et_magnetisation_comp.C,v $
* Revision 1.14 2016/11/01 09:12:59 j_novak
* Correction of a missing '-' in mom_quad_old().
*
* Revision 1.13 2015/06/12 12:38:25 j_novak
* Implementation of the corrected formula for the quadrupole momentum.
*
* Revision 1.12 2014/10/21 09:23:54 j_novak
* Addition of global functions mass_g(), angu_mom(), grv2/3() and mom_quad().
*
* Revision 1.11 2014/10/13 08:52:57 j_novak
* Lorene classes and functions now belong to the namespace Lorene.
*
* Revision 1.10 2014/07/04 12:08:02 j_novak
* Added some filtering.
*
* Revision 1.9 2014/05/14 15:19:05 j_novak
* The magnetisation field is now filtered.
*
* Revision 1.8 2014/05/13 15:37:12 j_novak
* Updated to new magnetic units.
*
* Revision 1.7 2014/05/01 13:07:16 j_novak
* Fixed two bugs: in the computation of F31,F32 and the triad of U_up.
*
* Revision 1.6 2014/04/29 13:46:07 j_novak
* Addition of switches 'use_B_in_eos' and 'include_magnetisation' to control the model.
*
* Revision 1.5 2014/04/28 14:53:29 j_novak
* Minor modif.
*
* Revision 1.4 2014/04/28 12:48:13 j_novak
* Minor modifications.
*
* Revision 1.2 2013/12/19 17:05:40 j_novak
* Corrected a dzpuis problem.
*
* Revision 1.1 2013/12/13 16:36:51 j_novak
* Addition and computation of magnetisation terms in the Einstein equations.
*
*
*
* $Header: /cvsroot/Lorene/C++/Source/Etoile/et_magnetisation_comp.C,v 1.14 2016/11/01 09:12:59 j_novak Exp $
*
*/
// Headers C
#include <cstdlib>
#include <cmath>
// Headers Lorene
#include "et_rot_mag.h"
#include "metric.h"
#include "utilitaires.h"
#include "param.h"
#include "proto_f77.h"
#include "unites.h"
namespace Lorene {
using namespace Unites_mag ;
// Algo du papier de 1995
void Et_magnetisation::magnet_comput(const int adapt_flag,
Cmp (*f_j)(const Cmp&, const double),
Param& par_poisson_At,
Param& par_poisson_Avect){
double relax_mag = 0.5 ;
int Z = mp.get_mg()->get_nzone();
bool adapt(adapt_flag) ;
/****************************************************************
* Assertion that all zones have same number of points in theta
****************************************************************/
int nt = mp.get_mg()->get_nt(nzet-1) ;
for (int l=0; l<Z; l++) assert(mp.get_mg()->get_nt(l) == nt) ;
Tbl Rsurf(nt) ;
Rsurf.set_etat_qcq() ;
mp.r.fait() ;
mp.tet.fait() ;
Mtbl* theta = mp.tet.c ;
const Map_radial* mpr = dynamic_cast<const Map_radial*>(&mp) ;
assert (mpr != 0x0) ;
for (int j=0; j<nt; j++)
Rsurf.set(j) = mpr->val_r_jk(l_surf()(0,j), xi_surf()(0,j), j, 0) ;
// Calcul de A_0t dans l'etoile (conducteur parfait)
Cmp A_0t(- omega * A_phi) ;
A_0t.annule(nzet,Z-1) ;
Tenseur ATTENS(A_t) ;
Tenseur APTENS(A_phi) ;
Tenseur BMN(-logn) ;
BMN = BMN + log(bbb) ;
BMN.set_std_base() ;
Cmp grad1(flat_scalar_prod_desal(ATTENS.gradient_spher(),
nphi.gradient_spher())());
Cmp grad2(flat_scalar_prod_desal(APTENS.gradient_spher(),
nphi.gradient_spher())()) ;
Cmp grad3(flat_scalar_prod_desal(ATTENS.gradient_spher(),
BMN.gradient_spher())()
+ 2*nphi()*flat_scalar_prod_desal(APTENS.gradient_spher(),
BMN.gradient_spher())()) ;
Cmp ATANT(A_phi.srdsdt()); // Constrction par copie pour mapping
ATANT.va = ATANT.va.mult_ct().ssint() ;
Cmp ttnphi(tnphi()) ;
ttnphi.mult_rsint() ;
Cmp BLAH(- b_car()/(nnn()*nnn())*ttnphi*grad1) ;
BLAH -= (1+b_car()/(nnn()*nnn())*tnphi()*tnphi())*grad2 ;
Cmp nphisr(nphi()) ;
nphisr.div_r() ;
Cmp npgrada(2*nphisr*(A_phi.dsdr()+ATANT )) ;
npgrada.inc2_dzpuis() ;
BLAH -= grad3 + npgrada ;
Cmp gtt(-nnn()*nnn()+b_car()*tnphi()*tnphi()) ;
Cmp gtphi( - b_car()*ttnphi) ;
// Computation of j_t thanks to Maxwell-Gauss
// modified to include Magnetisation
// components of F
Cmp F01 = 1/(a_car()*nnn()*nnn())*A_0t.dsdr()
+ 1/(a_car()*nnn()*nnn())*nphi()*A_phi.dsdr() ;
Cmp F02 = 1/(a_car()*nnn()*nnn())*A_0t.srdsdt()
+ 1/(a_car()*nnn()*nnn())*nphi()*A_phi.srdsdt() ;
Cmp tmp = A_phi.dsdr() / (bbb() * bbb() * a_car() );
tmp.div_rsint() ;
tmp.div_rsint() ;
Cmp F31 = 1/(a_car()*nnn()*nnn())*nphi()*nphi()*A_phi.dsdr()
+ 1/(a_car()*nnn()*nnn())*nphi()*A_0t.dsdr()
+ tmp ;
tmp = A_phi.srdsdt() / (bbb() * bbb() * a_car() );
tmp.div_rsint() ;
tmp.div_rsint() ;
Cmp F32 = 1/(a_car()*nnn()*nnn())*nphi()*nphi()*A_phi.srdsdt()
+ 1/(a_car()*nnn()*nnn())*nphi()*A_0t.srdsdt()
+ tmp ;
Cmp x = get_magnetisation();
Cmp one_minus_x = 1 - x ;
one_minus_x.std_base_scal() ;
tmp = ((BLAH - A_0t.laplacien())*one_minus_x/a_car()
- gtphi*j_phi
- gtt*(F01*x.dsdr()+F02*x.srdsdt())
- gtphi*(F31*x.dsdr()+F32*x.srdsdt()) ) / gtt ;
tmp.annule(nzet, Z-1) ;
if (adapt) {
j_t = tmp ;
}
else {
j_t.allocate_all() ;
for (int j=0; j<nt; j++)
for (int l=0; l<nzet; l++)
for (int i=0; i<mp.get_mg()->get_nr(l); i++)
j_t.set(l,0,j,i) = ( (*mp.r.c)(l,0,j,i) > Rsurf(j) ?
0. : tmp(l,0,j,i) ) ;
j_t.annule(nzet,Z-1) ;
}
j_t.std_base_scal() ;
// Calcul du courant j_phi
j_phi = omega * j_t + (ener() + press())*f_j(A_phi, a_j) ;
j_phi.std_base_scal() ;
// Resolution de Maxwell Ampere (-> A_phi)
// Calcul des termes sources avec A-t du pas precedent.
Cmp grad4(flat_scalar_prod_desal(APTENS.gradient_spher(),
BMN.gradient_spher())());
Tenseur source_tAphi(mp, 1, CON, mp.get_bvect_spher()) ;
source_tAphi.set_etat_qcq() ;
Cmp tjphi(j_phi) ;
tjphi.mult_rsint() ;
Cmp tgrad1(grad1) ;
tgrad1.mult_rsint() ;
Cmp d_grad4(grad4) ;
d_grad4.div_rsint() ;
source_tAphi.set(0)=0 ;
source_tAphi.set(1)=0 ;
// modified to include Magnetisation
Cmp phifac = (F31-nphi()*F01)*x.dsdr()
+ (F32-nphi()*F02)*x.srdsdt() ;
phifac.mult_rsint();
source_tAphi.set(2)= -b_car()*a_car()/one_minus_x
*(tjphi-tnphi()*j_t + phifac)
+ b_car()/(nnn()*nnn())*(tgrad1+tnphi()*grad2)
+ d_grad4 ;
source_tAphi.change_triad(mp.get_bvect_cart());
// Filtering
for (int i=0; i<3; i++) {
Scalar tmp_filter = source_tAphi(i) ;
tmp_filter.exponential_filter_r(0, 2, 1) ;
tmp_filter.exponential_filter_ylm(0, 2, 1) ;
source_tAphi.set(i) = tmp_filter ;
}
Tenseur WORK_VECT(mp, 1, CON, mp.get_bvect_cart()) ;
WORK_VECT.set_etat_qcq() ;
for (int i=0; i<3; i++) {
WORK_VECT.set(i) = 0 ;
}
Tenseur WORK_SCAL(mp) ;
WORK_SCAL.set_etat_qcq() ;
WORK_SCAL.set() = 0 ;
double lambda_mag = 0. ; // No 3D version !
Tenseur AVECT(source_tAphi) ;
if (source_tAphi.get_etat() != ETATZERO) {
for (int i=0; i<3; i++) {
if(source_tAphi(i).dz_nonzero()) {
assert( source_tAphi(i).get_dzpuis() == 4 ) ;
}
else{
(source_tAphi.set(i)).set_dzpuis(4) ;
}
}
}
source_tAphi.poisson_vect(lambda_mag, par_poisson_Avect, AVECT, WORK_VECT,
WORK_SCAL) ;
AVECT.change_triad(mp.get_bvect_spher());
Cmp A_phi_n(AVECT(2));
A_phi_n.mult_rsint() ;
// Solution to Maxwell-Ampere : A_1
// modified to include Magnetisation
Cmp source_A_1t(-a_car()*( j_t*gtt + j_phi*gtphi
+ gtt*(F01*x.dsdr()+F02*x.srdsdt())
+ gtphi*(F31*x.dsdr()+F32*x.srdsdt()) )/one_minus_x
+ BLAH);
Scalar tmp_filter = source_A_1t ;
tmp_filter.exponential_filter_r(0, 2, 1) ;
tmp_filter.exponential_filter_ylm(0, 2, 1) ;
source_A_1t = tmp_filter ;
Cmp A_1t(mp);
A_1t = 0 ;
source_A_1t.poisson(par_poisson_At, A_1t) ;
int L = mp.get_mg()->get_nt(0);
Tbl MAT(L,L) ;
Tbl MAT_PHI(L,L);
Tbl VEC(L) ;
MAT.set_etat_qcq() ;
VEC.set_etat_qcq() ;
MAT_PHI.set_etat_qcq() ;
Tbl leg(L,2*L) ;
leg.set_etat_qcq() ;
Cmp psi(mp);
Cmp psi2(mp);
psi.allocate_all() ;
psi2.allocate_all() ;
for (int p=0; p<mp.get_mg()->get_np(0); p++) {
// leg[k,l] : legendre_l(cos(theta_k))
// Construction par recurrence de degre 2
for(int k=0;k<L;k++){
for(int l=0;l<2*L;l++){
if(l==0) leg.set(k,l)=1. ;
if(l==1) leg.set(k,l)=cos((*theta)(l_surf()(p,k),p,k,0)) ;
if(l>=2) leg.set(k,l) = double(2*l-1)/double(l)
* cos((*theta)(l_surf()(p,k),p,k,0))
* leg(k,l-1)-double(l-1)/double(l)*leg(k,l-2) ;
}
}
for(int k=0;k<L;k++){
// Valeurs a la surface trouvees via va.val_point_jk(l,xisurf,k,p)
VEC.set(k) = A_0t.va.val_point_jk(l_surf()(p,k), xi_surf()(p,k), k, p)
-A_1t.va.val_point_jk(l_surf()(p,k), xi_surf()(p,k), k, p);
for(int l=0;l<L;l++) MAT.set(l,k) = leg(k,2*l)/pow(Rsurf(k),2*l+1);
}
// appel fortran :
int* IPIV=new int[L] ;
int INFO ;
Tbl MAT_SAVE(MAT) ;
Tbl VEC2(L) ;
VEC2.set_etat_qcq() ;
int un = 1 ;
F77_dgesv(&L, &un, MAT.t, &L, IPIV, VEC.t, &L, &INFO) ;
// coeffs a_l dans VEC
for(int k=0;k<L;k++) {VEC2.set(k)=1. ; }
F77_dgesv(&L, &un, MAT_SAVE.t, &L, IPIV, VEC2.t, &L, &INFO) ;
delete [] IPIV ;
for(int nz=0;nz < Z; nz++){
for(int i=0;i< mp.get_mg()->get_nr(nz);i++){
for(int k=0;k<L;k++){
psi.set(nz,p,k,i) = 0. ;
psi2.set(nz,p,k,i) = 0. ;
for(int l=0;l<L;l++){
psi.set(nz,p,k,i) += VEC(l)*leg(k,2*l) /
pow((*mp.r.c)(nz,p,k,i),2*l+1);
psi2.set(nz,p,k,i) += VEC2(l)*leg(k,2*l)/
pow((*mp.r.c)(nz, p, k,i),2*l+1);
}
}
}
}
}
psi.std_base_scal() ;
psi2.std_base_scal() ;
assert(psi.get_dzpuis() == 0) ;
int dif = A_1t.get_dzpuis() ;
if (dif > 0) {
for (int d=0; d<dif; d++) A_1t.dec_dzpuis() ;
}
if (adapt) {
Cmp A_t_ext(A_1t + psi) ;
A_t_ext.annule(0,nzet-1) ;
A_0t += A_t_ext ;
}
else {
tmp = A_0t ;
A_0t.allocate_all() ;
for (int j=0; j<nt; j++)
for (int l=0; l<Z; l++)
for (int i=0; i<mp.get_mg()->get_nr(l); i++)
A_0t.set(l,0,j,i) = ( (*mp.r.c)(l,0,j,i) > Rsurf(j) ?
A_1t(l,0,j,i) + psi(l,0,j,i) : tmp(l,0,j,i) ) ;
}
A_0t.std_base_scal() ;
tmp_filter = A_0t ;
tmp_filter.exponential_filter_r(0, 2, 1) ;
tmp_filter.exponential_filter_ylm(0, 2, 1) ;
A_0t = tmp_filter ;
Valeur** asymp = A_0t.asymptot(1) ;
double Q_0 = -4*M_PI*(*asymp[1])(Z-1,0,0,0) ; // utilise A_0t plutot que E
delete asymp[0] ;
delete asymp[1] ;
delete [] asymp ;
asymp = psi2.asymptot(1) ;
double Q_2 = -4*M_PI*(*asymp[1])(Z-1,0,0,0) ; // A_2t = psi2 a l'infini
delete asymp[0] ;
delete asymp[1] ;
delete [] asymp ;
// solution definitive de A_t:
double C = (Q-Q_0)/Q_2 ;
assert(psi2.get_dzpuis() == 0) ;
dif = A_0t.get_dzpuis() ;
if (dif > 0) {
for (int d=0; d<dif; d++) A_0t.dec_dzpuis() ;
}
Cmp A_t_n(mp) ;
if (adapt) {
A_t_n = A_0t + C ;
Cmp A_t_ext(A_0t + C*psi2) ;
A_t_ext.annule(0,nzet-1) ;
A_t_n.annule(nzet,Z-1) ;
A_t_n += A_t_ext ;
}
else {
A_t_n.allocate_all() ;
for (int j=0; j<nt; j++)
for (int l=0; l<Z; l++)
for (int i=0; i<mp.get_mg()->get_nr(l); i++)
A_t_n.set(l,0,j,i) = ( (*mp.r.c)(l,0,j,i) > Rsurf(j) ?
A_0t(l,0,j,i) + C*psi2(l,0,j,i) :
A_0t(l,0,j,i) + C ) ;
}
A_t_n.std_base_scal() ;
tmp_filter = A_t_n ;
tmp_filter.exponential_filter_r(0, 2, 1) ;
tmp_filter.exponential_filter_ylm(0, 2, 1) ;
A_t_n = tmp_filter ;
asymp = A_t_n.asymptot(1) ;
delete asymp[0] ;
delete asymp[1] ;
delete [] asymp ;
A_t = relax_mag*A_t_n + (1.-relax_mag)*A_t ;
A_phi = relax_mag*A_phi_n + (1. - relax_mag)*A_phi ;
}
void Et_magnetisation::MHD_comput() {
// Computes the E-M terms of the stress-energy tensor...
Tenseur ATTENS(A_t) ;
Tenseur APTENS(A_phi) ;
Tenseur ApAp ( flat_scalar_prod_desal(APTENS.gradient_spher(),
APTENS.gradient_spher())() );
Tenseur ApAt ( flat_scalar_prod_desal(APTENS.gradient_spher(),
ATTENS.gradient_spher())() );
Tenseur AtAt ( flat_scalar_prod_desal(ATTENS.gradient_spher(),
ATTENS.gradient_spher())() );
if (ApAp.get_etat() != ETATZERO) {
ApAp.set().div_rsint() ;
ApAp.set().div_rsint() ;
}
if (ApAt.get_etat() != ETATZERO)
ApAt.set().div_rsint() ;
E_em = 0.5*mu0 * ( 1/(a_car*nnn*nnn) * (AtAt + 2*tnphi*ApAt)
+ ( (tnphi*tnphi/(a_car*nnn*nnn)) + 1/(a_car*b_car) )*ApAp );
Jp_em = -mu0 * (ApAt + tnphi*ApAp) /(a_car*nnn) ;
if (Jp_em.get_etat() != ETATZERO) Jp_em.set().mult_rsint() ;
Srr_em = 0 ;
// Stt_em = -Srr_em
Spp_em = E_em ;
// ... and those corresponding to the magnetization.
Tenseur Efield = Elec() ;
Tenseur Bfield = Magn() ;
Scalar EiEi ( flat_scalar_prod(Efield, Efield)() ) ;
Scalar BiBi ( flat_scalar_prod(Bfield, Bfield)() ) ;
Vector U_up(mp, CON, mp.get_bvect_cart()) ;
for (int i=1; i<=3; i++)
U_up.set(i) = u_euler(i-1) ;
U_up.change_triad(mp.get_bvect_spher()) ;
Sym_tensor gamij(mp, COV, mp.get_bvect_spher()) ;
for (int i=1; i<=3; i++)
for (int j=1; j<i; j++) {
gamij.set(i,j) = 0 ;
}
gamij.set(1,1) = a_car() ;
gamij.set(2,2) = a_car() ;
gamij.set(3,3) = b_car() ;
Metric met(gamij) ;
Vector Ui = U_up.down(0, met) ;
Scalar fac = sqrt(a_car()) ;
Vector B_up(mp, CON, mp.get_bvect_spher()) ;
B_up.set(1) = Scalar(Bfield(0)) / fac ;
B_up.set(2) = Scalar(Bfield(1)) / fac ;
B_up.set(3) = 0 ;
Vector Bi = B_up.down(0, met) ;
fac = Scalar(gam_euler()*gam_euler()) ;
E_I = get_magnetisation() * EiEi / mu0 ;
J_I = get_magnetisation() * BiBi * Ui / mu0 ;
Sij_I = get_magnetisation()
* ( (BiBi / fac) * gamij + BiBi*Ui*Ui - Bi*Bi / fac ) / mu0 ;
for (int i=1; i<=3; i++)
for (int j=i; j<=3; j++)
Sij_I.set(i,j).set_dzpuis(0) ;
}
//----------------------------//
// Gravitational mass //
//----------------------------//
double Et_magnetisation::mass_g() const {
if (p_mass_g == 0x0) { // a new computation is required
if (relativistic) {
// Magnetisation: S_{rr} + S_{\theta\theta}
Tenseur SrrplusStt( Cmp(Sij_I(1, 1) + Sij_I(2, 2)) ) ;
SrrplusStt = SrrplusStt / a_car ; // S^r_r + S^\theta_\theta
Tenseur Spp (Cmp(Sij_I(3, 3))) ; // Magnetisation: S_{\phi\phi}
Spp = Spp / b_car ; // S^\phi_\phi
Cmp temp(E_I) ;
Tenseur E_i (temp) ;
Tenseur J_i (Cmp(J_I(3))) ;
Tenseur source = nnn * (ener_euler + E_em + E_i
+ s_euler + Spp_em + SrrplusStt + Spp) +
nphi * (Jp_em + J_i)
+ 2 * bbb * (ener_euler + press) * tnphi * uuu ;
source = a_car * bbb * source ;
source.set_std_base() ;
p_mass_g = new double( source().integrale() ) ;
}
else{ // Newtonian case
p_mass_g = new double( mass_b() ) ; // in the Newtonian case
// M_g = M_b
}
}
return *p_mass_g ;
}
//----------------------------//
// Angular momentum //
//----------------------------//
double Et_magnetisation::angu_mom() const {
if (p_angu_mom == 0x0) { // a new computation is required
Cmp dens = uuu() ;
dens.mult_r() ; // Multiplication by
dens.va = (dens.va).mult_st() ; // r sin(theta)
if (relativistic) {
dens = a_car() * (b_car() * (ener_euler() + press())
* dens + bbb() * (Jp_em() + Cmp(J_I(3)) ) ) ;
}
else { // Newtonian case
dens = nbar() * dens ;
}
dens.std_base_scal() ;
p_angu_mom = new double( dens.integrale() ) ;
}
return *p_angu_mom ;
}
//----------------------------//
// GRV2 //
//----------------------------//
double Et_magnetisation::grv2() const {
if (p_grv2 == 0x0) { // a new computation is required
// To get qpig:
using namespace Unites ;
Tenseur Spp (Cmp(Sij_I(3, 3))) ; //S_{\phi\phi}
Spp = Spp / b_car ; // S^\phi_\phi
Tenseur sou_m = 2 * qpig * a_car * (press + (ener_euler+press)
* uuu*uuu + Spp) ;
Tenseur sou_q = 2 * qpig * a_car * Spp_em + 1.5 * ak_car
- flat_scalar_prod(logn.gradient_spher(), logn.gradient_spher() ) ;
p_grv2 = new double( double(1) - lambda_grv2(sou_m(), sou_q()) ) ;
}
return *p_grv2 ;
}
//----------------------------//
// GRV3 //
//----------------------------//
double Et_magnetisation::grv3(ostream* ost) const {
if (p_grv3 == 0x0) { // a new computation is required
// To get qpig:
using namespace Unites ;
Tenseur source(mp) ;
// Gravitational term [cf. Eq. (43) of Gourgoulhon & Bonazzola
// ------------------ Class. Quantum Grav. 11, 443 (1994)]
if (relativistic) {
Tenseur alpha = dzeta - logn ;
Tenseur beta = log( bbb ) ;
beta.set_std_base() ;
source = 0.75 * ak_car
- flat_scalar_prod(logn.gradient_spher(),
logn.gradient_spher() )
+ 0.5 * flat_scalar_prod(alpha.gradient_spher(),
beta.gradient_spher() ) ;
Cmp aa = alpha() - 0.5 * beta() ;
Cmp daadt = aa.srdsdt() ; // 1/r d/dth
// What follows is valid only for a mapping of class Map_radial :
const Map_radial* mpr = dynamic_cast<const Map_radial*>(&mp) ;
if (mpr == 0x0) {
cout << "Etoile_rot::grv3: the mapping does not belong"
<< " to the class Map_radial !" << endl ;
abort() ;
}
// Computation of 1/tan(theta) * 1/r daa/dtheta
if (daadt.get_etat() == ETATQCQ) {
Valeur& vdaadt = daadt.va ;
vdaadt = vdaadt.ssint() ; // division by sin(theta)
vdaadt = vdaadt.mult_ct() ; // multiplication by cos(theta)
}
Cmp temp = aa.dsdr() + daadt ;
temp = ( bbb() - a_car()/bbb() ) * temp ;
temp.std_base_scal() ;
// Division by r
Valeur& vtemp = temp.va ;
vtemp = vtemp.sx() ; // division by xi in the nucleus
// Id in the shells
// division by xi-1 in the ZEC
vtemp = (mpr->xsr) * vtemp ; // multiplication by xi/r in the nucleus
// by 1/r in the shells
// by r(xi-1) in the ZEC
// In the ZEC, a multiplication by r has been performed instead
// of the division:
temp.set_dzpuis( temp.get_dzpuis() + 2 ) ;
source = bbb() * source() + 0.5 * temp ;
}
else{
source = - 0.5 * flat_scalar_prod(logn.gradient_spher(),
logn.gradient_spher() ) ;
}
source.set_std_base() ;
double int_grav = source().integrale() ;
// Matter term
// -----------
if (relativistic) {
// S_{rr} + S_{\theta\theta}
Tenseur SrrplusStt( Cmp(Sij_I(1, 1) + Sij_I(2, 2)) ) ;
SrrplusStt = SrrplusStt / a_car ; // S^r_r + S^\theta_\theta
Tenseur Spp (Cmp(Sij_I(3, 3))) ; //S_{\phi\phi}
Spp = Spp / b_car ; // S^\phi_\phi
source = qpig * a_car * bbb * ( s_euler + Spp_em + SrrplusStt + Spp ) ;
}
else{
source = qpig * ( 3 * press + nbar * uuu * uuu ) ;
}
source.set_std_base() ;
double int_mat = source().integrale() ;
// Virial error
// ------------
if (ost != 0x0) {
*ost << "Et_magnetisation::grv3 : gravitational term : " << int_grav
<< endl ;
*ost << "Et_magnetisation::grv3 : matter term : " << int_mat
<< endl ;
}
p_grv3 = new double( (int_grav + int_mat) / int_mat ) ;
}
return *p_grv3 ;
}
//----------------------------//
// Quadrupole moment //
//----------------------------//
double Et_magnetisation::mom_quad_old() const {
if (p_mom_quad_old == 0x0) { // a new computation is required
// To get qpig:
using namespace Unites ;
// Source for of the Poisson equation for nu
// -----------------------------------------
Tenseur source(mp) ;
if (relativistic) {
// S_{rr} + S_{\theta\theta}
Tenseur SrrplusStt( Cmp(Sij_I(1, 1) + Sij_I(2, 2)) ) ;
SrrplusStt = SrrplusStt / a_car ; // S^r_r + S^\theta_\theta
Tenseur Spp (Cmp(Sij_I(3, 3))) ; //S_{\phi\phi}
Spp = Spp / b_car ; // S^\phi_\phi
Cmp temp(E_I) ;
Tenseur E_i(temp) ;
Tenseur beta = log(bbb) ;
beta.set_std_base() ;
source = qpig * a_car *( ener_euler + E_em + E_i
+ s_euler + Spp_em + SrrplusStt + Spp)
+ ak_car - flat_scalar_prod(logn.gradient_spher(),
logn.gradient_spher() + beta.gradient_spher()) ;
}
else {
source = qpig * nbar ;
}
source.set_std_base() ;
// Multiplication by -r^2 P_2(cos(theta))
// [cf Eq.(7) of Salgado et al. Astron. Astrophys. 291, 155 (1994) ]
// ------------------------------------------------------------------
// Multiplication by r^2 :
// ----------------------
Cmp& csource = source.set() ;
csource.mult_r() ;
csource.mult_r() ;
if (csource.check_dzpuis(2)) {
csource.inc2_dzpuis() ;
}
// Muliplication by cos^2(theta) :
// -----------------------------
Cmp temp = csource ;
// What follows is valid only for a mapping of class Map_radial :
assert( dynamic_cast<const Map_radial*>(&mp) != 0x0 ) ;
if (temp.get_etat() == ETATQCQ) {
Valeur& vtemp = temp.va ;
vtemp = vtemp.mult_ct() ; // multiplication by cos(theta)
vtemp = vtemp.mult_ct() ; // multiplication by cos(theta)
}
// Muliplication by -P_2(cos(theta)) :
// ----------------------------------
source = 0.5 * source() - 1.5 * temp ;
// Final result
// ------------
p_mom_quad_old = new double( - source().integrale() / qpig ) ;
}
return *p_mom_quad_old ;
}
double Et_magnetisation::mom_quad_Bo() const {
using namespace Unites ;
if (p_mom_quad_Bo == 0x0) { // a new computation is required
// S_{rr} + S_{\theta\theta} = A^2*(S^r_r + S^\theta_\theta)
Tenseur SrrplusStt( Cmp(Sij_I(1, 1) + Sij_I(2, 2)) ) ;
Cmp dens = a_car() * press() ;
dens = bbb() * nnn() * (SrrplusStt() + 2*dens) ;
dens.mult_rsint() ;
dens.std_base_scal() ;
p_mom_quad_Bo = new double( - 16. * dens.integrale() / qpig ) ;
}
return *p_mom_quad_Bo ;
}
}
Lorene::Cmp
Component of a tensorial field *** DEPRECATED : use class Scalar instead ***.
Definition cmp.h:446
Lorene::Cmp::mult_rsint
void mult_rsint()
Multiplication by .
Definition cmp_r_manip.C:116
Lorene::Cmp::allocate_all
void allocate_all()
Sets the logical state to ETATQCQ (ordinary state) and performs the memory allocation of all the elem...
Definition cmp.C:323
Lorene::Cmp::div_r
void div_r()
Division by r everywhere.
Definition cmp_r_manip.C:78
Lorene::Cmp::dec_dzpuis
void dec_dzpuis()
Decreases by 1 the value of dzpuis and changes accordingly the values of the Cmp in the external comp...
Definition cmp_r_manip.C:154
Lorene::Cmp::get_etat
int get_etat() const
Returns the logical state.
Definition cmp.h:899
Lorene::Cmp::va
Valeur va
The numerical value of the Cmp.
Definition cmp.h:464
Lorene::Cmp::std_base_scal
void std_base_scal()
Sets the spectral bases of the Valeur va to the standard ones for a scalar.
Definition cmp.C:644
Lorene::Cmp::annule
void annule(int l)
Sets the Cmp to zero in a given domain.
Definition cmp.C:348
Lorene::Cmp::laplacien
const Cmp & laplacien(int zec_mult_r=4) const
Returns the Laplacian of *this.
Definition cmp_deriv.C:242
Lorene::Cmp::get_dzpuis
int get_dzpuis() const
Returns dzpuis.
Definition cmp.h:903
Lorene::Cmp::mult_r
void mult_r()
Multiplication by r everywhere.
Definition cmp_r_manip.C:91
Lorene::Cmp::inc2_dzpuis
void inc2_dzpuis()
Increases by 2 the value of dzpuis and changes accordingly the values of the Cmp in the external comp...
Definition cmp_r_manip.C:192
Lorene::Cmp::set
Tbl & set(int l)
Read/write of the value in a given domain.
Definition cmp.h:724
Lorene::Cmp::set_dzpuis
void set_dzpuis(int)
Set a value to dzpuis.
Definition cmp.C:654
Lorene::Cmp::integrale
double integrale() const
Computes the integral over all space of *this .
Definition cmp_integ.C:55
Lorene::Cmp::srdsdt
const Cmp & srdsdt() const
Returns of *this .
Definition cmp_deriv.C:105
Lorene::Cmp::check_dzpuis
bool check_dzpuis(int dzi) const
Returns false if the last domain is compactified and *this is not zero in this domain and dzpuis is n...
Definition cmp.C:715
Lorene::Cmp::asymptot
Valeur ** asymptot(int n, const int flag=0) const
Asymptotic expansion at r = infinity.
Definition cmp_asymptot.C:71
Lorene::Cmp::div_rsint
void div_rsint()
Division by .
Definition cmp_r_manip.C:141
Lorene::Cmp::poisson
Cmp poisson() const
Solves the scalar Poisson equation with *this as a source.
Definition cmp_pde.C:94
Lorene::Cmp::dsdr
const Cmp & dsdr() const
Returns of *this .
Definition cmp_deriv.C:84
Lorene::Et_magnetisation::magnet_comput
virtual void magnet_comput(const int adapt_flag, Cmp(*f_j)(const Cmp &x, const double), Param &par_poisson_At, Param &par_poisson_Avect)
Computes the electromagnetic quantities solving the Maxwell equations (6) and (7) of [Bocquet,...
Definition et_magnetisation_comp.C:97
Lorene::Et_magnetisation::grv3
virtual double grv3(ostream *ost=0x0) const
Error on the virial identity GRV3.
Definition et_magnetisation_comp.C:642
Lorene::Et_magnetisation::Sij_I
Sym_tensor Sij_I
Interaction stress 3-tensor.
Definition et_rot_mag.h:630
Lorene::Et_magnetisation::J_I
Vector J_I
Interaction momentum density 3-vector.
Definition et_rot_mag.h:627
Lorene::Et_magnetisation::mom_quad_Bo
virtual double mom_quad_Bo() const
Part of the quadrupole moment.
Definition et_magnetisation_comp.C:828
Lorene::Et_magnetisation::grv2
virtual double grv2() const
Error on the virial identity GRV2.
Definition et_magnetisation_comp.C:613
Lorene::Et_magnetisation::mom_quad_old
virtual double mom_quad_old() const
Part of the quadrupole moment.
Definition et_magnetisation_comp.C:755
Lorene::Et_magnetisation::get_magnetisation
const Scalar & get_magnetisation() const
Accessor to the magnetisation scalar field.
Definition et_rot_mag.h:677
Lorene::Et_magnetisation::MHD_comput
virtual void MHD_comput()
Computes the electromagnetic part of the stress-energy tensor.
Definition et_magnetisation_comp.C:461
Lorene::Et_magnetisation::angu_mom
virtual double angu_mom() const
Angular momentum.
Definition et_magnetisation_comp.C:582
Lorene::Et_magnetisation::E_I
Scalar E_I
Interaction (magnetisation) energy density.
Definition et_rot_mag.h:624
Lorene::Et_magnetisation::mass_g
virtual double mass_g() const
Gravitational mass.
Definition et_magnetisation_comp.C:538
Lorene::Et_rot_mag::Srr_em
Tenseur Srr_em
rr component of the electromagnetic stress 3-tensor, as measured in the Eulerian frame....
Definition et_rot_mag.h:170
Lorene::Et_rot_mag::j_phi
Cmp j_phi
-component of the current 4-vector
Definition et_rot_mag.h:159
Lorene::Et_rot_mag::A_phi
Cmp A_phi
-component of the electromagnetic potential 1-form divided by .
Definition et_rot_mag.h:155
Lorene::Et_rot_mag::a_j
double a_j
Amplitude of the curent/charge function.
Definition et_rot_mag.h:180
Lorene::Et_rot_mag::Spp_em
Tenseur Spp_em
component of the electromagnetic stress 3-tensor, as measured in the Eulerian frame.
Definition et_rot_mag.h:173
Lorene::Et_rot_mag::A_t
Cmp A_t
t-component of the elecctromagnetic potential 1-form, divided by .
Definition et_rot_mag.h:150
Lorene::Et_rot_mag::j_t
Cmp j_t
t-component of the current 4-vector
Definition et_rot_mag.h:158
Lorene::Et_rot_mag::E_em
Tenseur E_em
electromagnetic energy density in the Eulerian frame
Definition et_rot_mag.h:161
Lorene::Et_rot_mag::Jp_em
Tenseur Jp_em
component of the electromagnetic momentum density 3-vector, as measured in the Eulerian frame.
Definition et_rot_mag.h:167
Lorene::Et_rot_mag::Q
double Q
In the case of a perfect conductor, the requated baryonic charge.
Definition et_rot_mag.h:179
Lorene::Et_rot_mag::Elec
Tenseur Elec() const
Computes the electric field spherical components in Lorene's units.
Definition et_rot_mag_global.C:151
Lorene::Et_rot_mag::Magn
Tenseur Magn() const
Computes the magnetic field spherical components in Lorene's units.
Definition et_rot_mag_global.C:170
Lorene::Etoile_rot::uuu
Tenseur uuu
Norm of u_euler.
Definition etoile.h:1518
Lorene::Etoile_rot::omega
double omega
Rotation angular velocity ([f_unit] ).
Definition etoile.h:1501
Lorene::Etoile_rot::logn
Tenseur & logn
Metric potential = logn_auto.
Definition etoile.h:1521
Lorene::Etoile_rot::l_surf
virtual const Itbl & l_surf() const
Description of the stellar surface: returns a 2-D Itbl containing the values of the domain index l on...
Definition et_rot_global.C:95
Lorene::Etoile_rot::p_mom_quad_old
double * p_mom_quad_old
Part of the quadrupole moment.
Definition etoile.h:1642
Lorene::Etoile_rot::nphi
Tenseur nphi
Metric coefficient .
Definition etoile.h:1510
Lorene::Etoile_rot::mass_b
virtual double mass_b() const
Baryon mass.
Definition et_rot_global.C:125
Lorene::Etoile_rot::lambda_grv2
static double lambda_grv2(const Cmp &sou_m, const Cmp &sou_q)
Computes the coefficient which ensures that the GRV2 virial identity is satisfied.
Definition et_rot_lambda_grv2.C:79
Lorene::Etoile_rot::bbb
Tenseur bbb
Metric factor B.
Definition etoile.h:1504
Lorene::Etoile_rot::ak_car
Tenseur ak_car
Scalar .
Definition etoile.h:1586
Lorene::Etoile_rot::dzeta
Tenseur & dzeta
Metric potential = beta_auto.
Definition etoile.h:1534
Lorene::Etoile_rot::p_grv3
double * p_grv3
Error on the virial identity GRV3.
Definition etoile.h:1634
Lorene::Etoile_rot::p_grv2
double * p_grv2
Error on the virial identity GRV2.
Definition etoile.h:1633
Lorene::Etoile_rot::p_mom_quad_Bo
double * p_mom_quad_Bo
Part of the quadrupole moment.
Definition etoile.h:1643
Lorene::Etoile_rot::p_angu_mom
double * p_angu_mom
Angular momentum.
Definition etoile.h:1631
Lorene::Etoile_rot::b_car
Tenseur b_car
Square of the metric factor B.
Definition etoile.h:1507
Lorene::Etoile_rot::tnphi
Tenseur tnphi
Component of the shift vector.
Definition etoile.h:1515
Lorene::Etoile::nzet
int nzet
Number of domains of *mp occupied by the star.
Definition etoile.h:432
Lorene::Etoile::p_mass_g
double * p_mass_g
Gravitational mass.
Definition etoile.h:548
Lorene::Etoile::nnn
Tenseur nnn
Total lapse function.
Definition etoile.h:509
Lorene::Etoile::nbar
Tenseur nbar
Baryon density in the fluid frame.
Definition etoile.h:459
Lorene::Etoile::u_euler
Tenseur u_euler
Fluid 3-velocity with respect to the Eulerian observer.
Definition etoile.h:474
Lorene::Etoile::gam_euler
Tenseur gam_euler
Lorentz factor between the fluid and Eulerian observers.
Definition etoile.h:471
Lorene::Etoile::mp
Map & mp
Mapping associated with the star.
Definition etoile.h:429
Lorene::Etoile::ener
Tenseur ener
Total energy density in the fluid frame.
Definition etoile.h:460
Lorene::Etoile::press
Tenseur press
Fluid pressure.
Definition etoile.h:461
Lorene::Etoile::relativistic
bool relativistic
Indicator of relativity: true for a relativistic star, false for a Newtonian one.
Definition etoile.h:437
Lorene::Etoile::ener_euler
Tenseur ener_euler
Total energy density in the Eulerian frame.
Definition etoile.h:465
Lorene::Etoile::s_euler
Tenseur s_euler
Trace of the stress tensor in the Eulerian frame.
Definition etoile.h:468
Lorene::Etoile::xi_surf
const Tbl & xi_surf() const
Description of the stellar surface: returns a 2-D Tbl containing the values of the radial coordinat...
Definition etoile_global.C:101
Lorene::Etoile::a_car
Tenseur a_car
Total conformal factor .
Definition etoile.h:515
Lorene::Map_radial
Base class for pure radial mappings.
Definition map.h:1536
Lorene::Map_radial::xsr
Coord xsr
in the nucleus; \ 1/R in the non-compactified shells; \ in the compactified outer domain.
Definition map.h:1549
Lorene::Map_radial::val_r_jk
virtual double val_r_jk(int l, double xi, int j, int k) const =0
Returns the value of the radial coordinate r for a given and a given collocation point in in a give...
Lorene::Metric
Metric for tensor calculation.
Definition metric.h:90
Lorene::Mtbl
Multi-domain array.
Definition mtbl.h:118
Lorene::Param
Parameter storage.
Definition param.h:125
Lorene::Scalar
Tensor field of valence 0 (or component of a tensorial field).
Definition scalar.h:387
Lorene::Scalar::exponential_filter_ylm
virtual void exponential_filter_ylm(int lzmin, int lzmax, int p, double alpha=-16.)
Applies an exponential filter to the spectral coefficients in the angular directions.
Definition scalar_exp_filter.C:142
Lorene::Scalar::exponential_filter_r
virtual void exponential_filter_r(int lzmin, int lzmax, int p, double alpha=-16.)
Applies an exponential filter to the spectral coefficients in the radial direction.
Definition scalar_exp_filter.C:60
Lorene::Sym_tensor
Class intended to describe valence-2 symmetric tensors.
Definition sym_tensor.h:223
Lorene::Tbl
Basic array class.
Definition tbl.h:161
Lorene::Tbl::set_etat_qcq
void set_etat_qcq()
Sets the logical state to ETATQCQ (ordinary state).
Definition tbl.C:361
Lorene::Tbl::set
double & set(int i)
Read/write of a particular element (index i) (1D case).
Definition tbl.h:281
Lorene::Tbl::t
double * t
The array of double.
Definition tbl.h:173
Lorene::Tenseur
Tensor handling *** DEPRECATED : use class Tensor instead ***.
Definition tenseur.h:301
Lorene::Tenseur::set
Cmp & set()
Read/write for a scalar (see also operator=(const Cmp&) ).
Definition tenseur.C:824
Lorene::Tenseur::set_etat_qcq
void set_etat_qcq()
Sets the logical state to ETATQCQ (ordinary state).
Definition tenseur.C:636
Lorene::Tenseur::set_std_base
void set_std_base()
Set the standard spectal basis of decomposition for each component.
Definition tenseur.C:1170
Lorene::Tenseur::gradient_spher
const Tenseur & gradient_spher() const
Returns the gradient of *this (Spherical coordinates) (scalar field only).
Definition tenseur.C:1548
Lorene::Tenseur::change_triad
void change_triad(const Base_vect &new_triad)
Sets a new vectorial basis (triad) of decomposition and modifies the components accordingly.
Definition tenseur.C:668
Lorene::Tenseur::poisson_vect
void poisson_vect(double lambda, Param &par, Tenseur &shift, Tenseur &vect, Tenseur &scal) const
Solves the vectorial Poisson equation : .
Definition tenseur_pde.C:118
Lorene::Tenseur::get_etat
int get_etat() const
Returns the logical state.
Definition tenseur.h:707
Lorene::Valeur
Values and coefficients of a (real-value) function.
Definition valeur.h:287
Lorene::Valeur::mult_ct
const Valeur & mult_ct() const
Returns applied to *this.
Definition valeur_mult_ct.C:98
Lorene::Valeur::val_point_jk
double val_point_jk(int l, double x, int j, int k) const
Computes the value of the field represented by *this at an arbitrary point in , but collocation point...
Definition valeur.C:900
Lorene::Valeur::sx
const Valeur & sx() const
Returns (r -sampling = RARE ) \ Id (r sampling = FIN ) \ (r -sampling = UNSURR ).
Definition valeur_sx.C:110
Lorene::Valeur::ssint
const Valeur & ssint() const
Returns of *this.
Definition valeur_ssint.C:112
Lorene::Vector
Tensor field of valence 1.
Definition vector.h:188
Lorene::Vector::change_triad
virtual void change_triad(const Base_vect &)
Sets a new vectorial basis (triad) of decomposition and modifies the components accordingly.
Definition vector_change_triad.C:75
Lorene::Vector::set
Scalar & set(int)
Read/write access to a component.
Definition vector.C:296
Lorene::sqrt
Cmp sqrt(const Cmp &)
Square root.
Definition cmp_math.C:220
Lorene::pow
Cmp pow(const Cmp &, int)
Power .
Definition cmp_math.C:348
Lorene::cos
Cmp cos(const Cmp &)
Cosine.
Definition cmp_math.C:94
Lorene::log
Cmp log(const Cmp &)
Neperian logarithm.
Definition cmp_math.C:296
Lorene::Tensor::down
Tensor down(int ind, const Metric &gam) const
Computes a new tensor by lowering an index of *this.
Definition tensor_calculus.C:265
Lorene::Tensor::set
Scalar & set(const Itbl &ind)
Returns the value of a component (read/write version).
Definition tensor.C:654
Lorene::flat_scalar_prod
Tenseur flat_scalar_prod(const Tenseur &t1, const Tenseur &t2)
Scalar product of two Tenseur when the metric is : performs the contraction of the last index of t1 w...
Definition tenseur_operateur.C:653
Lorene::flat_scalar_prod_desal
Tenseur flat_scalar_prod_desal(const Tenseur &t1, const Tenseur &t2)
Same as flat_scalar_prod but with desaliasing.
Definition tenseur_operateur.C:735
Lorene
Lorene prototypes.
Definition app_hor.h:64
Lorene::adapt
virtual void adapt(const Cmp &ent, const Param &par, int nbr=0)=0
Adaptation of the mapping to a given scalar field.
Lorene::integrale
virtual Tbl * integrale(const Cmp &) const =0
Computes the integral over all space of a Cmp .
Lorene::x
Coord x
x coordinate centered on the grid
Definition map.h:726
Unites
Standard units of space, time and mass.