/* * Method of class Binary_xcts to compute the orbital angular velocity * {\tt omega} and the position of the rotation axis {\tt x_axe}. * (See file binary_xcts.h for documentation) */ /* * Copyright (c) 2010 Michal Bejger * * 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 version 2 * as published by the Free Software Foundation. * * 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 binary_orbit_xcts_C[] = "$Header: /cvsroot/Lorene/C++/Source/Binary_xcts/binary_orbit_xcts.C,v 1.14 2014/10/24 14:10:24 j_novak Exp $" ; /* * $Id: binary_orbit_xcts.C,v 1.14 2014/10/24 14:10:24 j_novak Exp $ * $Log: binary_orbit_xcts.C,v $ * Revision 1.14 2014/10/24 14:10:24 j_novak * Minor change to prevent weird error from g++-4.8... * * Revision 1.13 2014/10/13 08:52:45 j_novak * Lorene classes and functions now belong to the namespace Lorene. * * Revision 1.12 2014/10/06 15:12:59 j_novak * Modified #include directives to use c++ syntax. * * Revision 1.11 2011/03/30 13:14:27 m_bejger * Psi and chi rewritten using auto and comp parts to improve the convergence (in all the remaining fields, not only logn) * * Revision 1.10 2011/03/28 17:13:37 m_bejger * logn in dnulg stated using Psi1,2 and chi1,2 * * Revision 1.9 2011/03/27 16:41:19 e_gourgoulhon * -- Corrected sign of ny and dny for star no. 2 * -- Added output via new function save_profile for graphics * * Revision 1.8 2011/03/27 14:58:48 m_bejger * dnulg by means of dsdx(); rearrangements to use primary variables * * Revision 1.7 2011/03/25 16:28:36 e_gourgoulhon * Still in progress * * Revision 1.6 2010/12/09 10:41:20 m_bejger * For testing; not sure if working properly * * Revision 1.5 2010/10/26 19:45:45 m_bejger * Cleanup * * Revision 1.4 2010/07/16 16:27:19 m_bejger * This version is basically a copy of the one used by Binaire (binaire_orbite.C) * * Revision 1.3 2010/06/17 14:15:41 m_bejger * Using method get_Psi() * * Revision 1.2 2010/06/15 07:57:30 m_bejger * Minor corrections * * Revision 1.1 2010/05/04 07:35:54 m_bejger * Initial version * * $Header: /cvsroot/Lorene/C++/Source/Binary_xcts/binary_orbit_xcts.C,v 1.14 2014/10/24 14:10:24 j_novak Exp $ * */ // Headers C #include // Headers Lorene #include "binary_xcts.h" #include "eos.h" #include "param.h" #include "utilitaires.h" #include "unites.h" #include "graphique.h" namespace Lorene { double fonc_binary_xcts_axe(double , const Param& ) ; double fonc_binary_xcts_orbit(double , const Param& ) ; //****************************************************************************** void Binary_xcts::orbit(double fact_omeg_min, double fact_omeg_max, double& xgg1, double& xgg2) { using namespace Unites ; //------------------------------------------------------------- // Evaluation of various quantities at the center of each star //------------------------------------------------------------- double dnulg[2], asn2[2], dasn2[2], ny[2], dny[2], npn[2], dnpn[2], xgg[2] ; double nyso[2], dnyso[2], npnso2[2], dnpnso2[2], ori_x[2] ; for (int i=0; i<2; i++) { const Map& mp = et[i]->get_mp() ; const Metric& flat = et[i]->get_flat() ; //------------------------------------------------------------------ // Recasting Phi and chi to manifestly equal auto and comp part // - more fortunate from the point of view of Omega computation //------------------------------------------------------------------ Scalar chi = et[i]->get_chi_auto() + et[i]->get_chi_comp() + 1 ; Scalar Psi = et[i]->get_Psi_auto() + et[i]->get_Psi_comp() + 1 ; Scalar logn = log(chi) - log(Psi) ; logn.std_spectral_base() ; // Sign convention for shift (beta^i = - N^i) Vector shift = - ( et[i]->get_beta() ) ; shift.change_triad(et[i]->mp.get_bvect_cart()) ; //------------------------------------------------------------------ // d/dX( log(N) + log(Gamma) ) // in the center of the star ---> dnulg[i] //------------------------------------------------------------------ // Facteur de passage x --> X : double factx ; if (fabs(mp.get_rot_phi()) < 1.e-14) factx = 1. ; else { if (fabs(mp.get_rot_phi() - M_PI) < 1.e-14) { factx = - 1. ; } else { cout << "Binary_xcts::orbit : unknown value of rot_phi !" << endl ; abort() ; } } Scalar tmp = logn + et[i]->get_loggam() ; dnulg[i] = factx*tmp.dsdx().val_grid_point(0, 0, 0, 0) ; // For graphical outputs: Scalar tgraph = logn - log( (1. + et[i]->get_chi_auto()) / (1. + et[i]->get_Psi_auto()) ) ; // tmp = log( (1. + et[i]->get_chi_comp()) / (1. + et[i]->get_Psi_comp()) ) ; tgraph.std_spectral_base() ; save_profile(tgraph, 0., 10., 0.5*M_PI, 0., "prof_logn.d") ; save_profile(et[i]->get_loggam(), 0., 1.8, 0.5*M_PI, 0., "prof_loggam.d") ; //------------------------------------------------------------------ // Psi^4/N^2 = in the center of the star ---> asn2[i] //------------------------------------------------------------------ Scalar Psi6schi2 = pow(Psi, 6)/(chi % chi) ; Psi6schi2.std_spectral_base() ; asn2[i] = Psi6schi2.val_grid_point(0, 0, 0, 0) ; //------------------------------------------------------------------ // d/dX(A^2/N^2) in the center of the star ---> dasn2[i] //------------------------------------------------------------------ dasn2[i] = Psi6schi2.dsdx().val_grid_point(0, 0, 0, 0) ; //------------------------------------------------------------------ // N^Y in the center of the star ---> ny[i] //------------------------------------------------------------------ ny[i] = factx*shift(2).val_grid_point(0, 0, 0, 0) ; nyso[i] = ny[i] / omega ; //------------------------------------------------------------------ // dN^Y/dX in the center of the star ---> dny[i] //------------------------------------------------------------------ dny[i] = shift(2).dsdx().val_grid_point(0, 0, 0, 0) ; dnyso[i] = dny[i] / omega ; //------------------------------------------------------------------ // (N^X)^2 + (N^Y)^2 + (N^Z)^2 // in the center of the star ---> npn[i] //------------------------------------------------------------------ tmp = contract(shift, 0, shift.up_down(flat), 0) ; npn[i] = tmp.val_grid_point(0, 0, 0, 0) ; npnso2[i] = npn[i] / omega / omega ; //------------------------------------------------------------------ // d/dX( (N^X)^2 + (N^Y)^2 + (N^Z)^2 ) // in the center of the star ---> dnpn[i] //------------------------------------------------------------------ dnpn[i] = factx * tmp.dsdx().val_grid_point(0, 0, 0, 0) ; dnpnso2[i] = dnpn[i] / omega / omega ; cout << "Binary_xcts::orbit: central d(nu+log(Gam))/dX : " << dnulg[i] << endl ; cout << "Binary_xcts::orbit: central A^2/N^2 : " << asn2[i] << endl ; cout << "Binary_xcts::orbit: central d(A^2/N^2)/dX : " << dasn2[i] << endl ; cout << "Binary_xcts::orbit: central N^Y : " << ny[i] << endl ; cout << "Binary_xcts::orbit: central dN^Y/dX : " << dny[i] << endl ; cout << "Binary_xcts::orbit: central N.N : " << npn[i] << endl ; cout << "Binary_xcts::orbit: central d(N.N)/dX : " << dnpn[i] << endl ; ori_x[i] = (et[i]->get_mp()).get_ori_x() ; xgg[i] = factx * (et[i]->xa_barycenter() - ori_x[i]) ; } xgg1 = xgg[0] ; xgg2 = xgg[1] ; //--------------------------------- // axis of rotation //--------------------------------- int relat = 1 ; double ori_x1 = ori_x[0] ; double ori_x2 = ori_x[1] ; if ( et[0]->get_eos() == et[1]->get_eos() && fabs( et[0]->get_ent().val_grid_point(0,0,0,0) - et[1]->get_ent().val_grid_point(0,0,0,0) ) < 1.e-14 ) { x_axe = 0. ; } else { Param paraxe ; paraxe.add_int(relat) ; paraxe.add_double( ori_x1, 0) ; paraxe.add_double( ori_x2, 1) ; paraxe.add_double( dnulg[0], 2) ; paraxe.add_double( dnulg[1], 3) ; paraxe.add_double( asn2[0], 4) ; paraxe.add_double( asn2[1], 5) ; paraxe.add_double( dasn2[0], 6) ; paraxe.add_double( dasn2[1], 7) ; paraxe.add_double( nyso[0], 8) ; paraxe.add_double( nyso[1], 9) ; paraxe.add_double( dnyso[0], 10) ; paraxe.add_double( dnyso[1], 11) ; paraxe.add_double( npnso2[0], 12) ; paraxe.add_double( npnso2[1], 13) ; paraxe.add_double( dnpnso2[0], 14) ; paraxe.add_double( dnpnso2[1], 15) ; int nitmax_axe = 200 ; int nit_axe ; double precis_axe = 1.e-13 ; x_axe = zerosec(fonc_binary_xcts_axe, paraxe, 0.9*ori_x1, 0.9*ori_x2, precis_axe, nitmax_axe, nit_axe) ; cout << "Binary_xcts::orbit : Number of iterations in zerosec for x_axe : " << nit_axe << endl ; } cout << "Binary_xcts::orbit: x_axe [km] : " << x_axe / km << endl ; //------------------------------------- // Calcul de la vitesse orbitale //------------------------------------- Param parf ; parf.add_int(relat) ; parf.add_double( ori_x1, 0) ; parf.add_double( dnulg[0], 1) ; parf.add_double( asn2[0], 2) ; parf.add_double( dasn2[0], 3) ; parf.add_double( ny[0], 4) ; parf.add_double( dny[0], 5) ; parf.add_double( npn[0], 6) ; parf.add_double( dnpn[0], 7) ; parf.add_double( x_axe, 8) ; double omega1 = fact_omeg_min * omega ; double omega2 = fact_omeg_max * omega ; cout << "Binary_xcts::orbit: omega1, omega2 [rad/s] : " << omega1 * f_unit << " " << omega2 * f_unit << endl ; // Search for the various zeros in the interval [omega1, omega2] // ------------------------------------------------------------ int nsub = 50 ; // total number of subdivisions of the interval Tbl* azer = 0x0 ; Tbl* bzer = 0x0 ; zero_list(fonc_binary_xcts_orbit, parf, omega1, omega2, nsub, azer, bzer) ; // Search for the zero closest to the previous value of omega // ---------------------------------------------------------- double omeg_min, omeg_max ; int nzer = azer->get_taille() ; // number of zeros found by zero_list cout << "Binary_xcts:orbit : " << nzer << " zero(s) found in the interval [omega1, omega2]." << endl ; cout << "omega, omega1, omega2 : " << omega << " " << omega1 << " " << omega2 << endl ; cout << "azer : " << *azer << endl ; cout << "bzer : " << *bzer << endl ; if (nzer == 0) { cout << "Binary_xcts::orbit: WARNING : no zero detected in the interval" << endl << " [" << omega1 * f_unit << ", " << omega2 * f_unit << "] rad/s !" << endl ; omeg_min = omega1 ; omeg_max = omega2 ; } else { double dist_min = fabs(omega2 - omega1) ; int i_dist_min = -1 ; for (int i=0; i