LORENE
et_bin_bhns_extr_phi.C
1 /*
2  * Method of class Et_bin_bhns_extr to search the position of the longest
3  * radius from the position of the maximum enthalpy
4  * The code returns the position of "phi" only because "xi=1" and
5  * "theta=pi/2".
6  *
7  * (see file et_bin_bhns_extr.h for documentation).
8  *
9  */
10 
11 /*
12  * Copyright (c) 2004 Keisuke Taniguchi
13  *
14  * This file is part of LORENE.
15  *
16  * LORENE is free software; you can redistribute it and/or modify
17  * it under the terms of the GNU General Public License version 2
18  * as published by the Free Software Foundation.
19  *
20  * LORENE is distributed in the hope that it will be useful,
21  * but WITHOUT ANY WARRANTY; without even the implied warranty of
22  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23  * GNU General Public License for more details.
24  *
25  * You should have received a copy of the GNU General Public License
26  * along with LORENE; if not, write to the Free Software
27  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28  *
29  */
30 
31 
32 
33 /*
34  * $Id: et_bin_bhns_extr_phi.C,v 1.4 2016/12/05 16:17:52 j_novak Exp $
35  * $Log: et_bin_bhns_extr_phi.C,v $
36  * Revision 1.4 2016/12/05 16:17:52 j_novak
37  * Suppression of some global variables (file names, loch, ...) to prevent redefinitions
38  *
39  * Revision 1.3 2014/10/13 08:52:55 j_novak
40  * Lorene classes and functions now belong to the namespace Lorene.
41  *
42  * Revision 1.2 2014/10/06 15:13:08 j_novak
43  * Modified #include directives to use c++ syntax.
44  *
45  * Revision 1.1 2004/11/30 20:50:48 k_taniguchi
46  * *** empty log message ***
47  *
48  *
49  * $Header: /cvsroot/Lorene/C++/Source/Etoile/et_bin_bhns_extr_phi.C,v 1.4 2016/12/05 16:17:52 j_novak Exp $
50  *
51  */
52 
53 // C headers
54 #include <cmath>
55 
56 // Lorene headers
57 #include "et_bin_bhns_extr.h"
58 #include "utilitaires.h"
59 
60 namespace Lorene {
61 double Et_bin_bhns_extr::phi_longest_rad(double x_max, double y_max) const {
62 
63  //----------------------------------------------------------------//
64  // Construct the surface function S(theta, phi) //
65  //----------------------------------------------------------------//
66 
67  // The following is required to access functions of Map_et
68  Map_et& mp_et = dynamic_cast<Map_et&>(mp) ;
69 
70  const Valeur& ff0 = mp_et.get_ff() ;
71  const Valeur& gg0 = mp_et.get_gg() ;
72 
73  Valeur fff = ff0 ;
74  Valeur ggg = gg0 ;
75  Valeur dff = fff.dsdp() ;
76  Valeur dgg = ggg.dsdp() ;
77 
78  double ppp = M_PI/2. ; // Initial position of the phi-coordinate
79  double ptmp ;
80  int mm ; // Number of steps to the phi-direction
81  double dp = 1. ; // Step interval to the phi-direction, initialized to 1
82  double diff ;
83  double diff_prev ;
84  double ss ;
85 
86  while ( dp > 1.e-15 ) {
87 
88  diff = 1. ;
89  mm = 0 ;
90  dp = 0.1 * dp ;
91 
92  diff_prev = ( dff.val_point(0,1.,M_PI/2.,ppp)
93  + dgg.val_point(0,1.,M_PI/2.,ppp) )
94  * ( 1. + ff0.val_point(0,1.,M_PI/2.,ppp)
95  + gg0.val_point(0,1.,M_PI/2.,ppp)
96  - x_max * cos(ppp) - y_max * sin(ppp) )
97  - ( 1. + ff0.val_point(0,1.,M_PI/2.,ppp)
98  + gg0.val_point(0,1.,M_PI/2.,ppp) )
99  * ( - x_max * sin(ppp) + y_max * cos(ppp) ) ;
100 
101  if ( diff_prev > 0. ) {
102  ss = 1. ;
103  }
104  else {
105  ss = -1. ;
106  }
107 
108  while ( diff > 1.e-15 ) {
109 
110  mm++ ;
111  ptmp = ppp + mm * dp ;
112 
113  diff = ss * ( ( dff.val_point(0,1.,M_PI/2.,ptmp)
114  + dgg.val_point(0,1.,M_PI/2.,ptmp) )
115  * ( 1. + ff0.val_point(0,1.,M_PI/2.,ptmp)
116  + gg0.val_point(0,1.,M_PI/2.,ptmp)
117  - x_max * cos(ptmp) - y_max * sin(ptmp) )
118  - ( 1. + ff0.val_point(0,1.,M_PI/2.,ptmp)
119  + gg0.val_point(0,1.,M_PI/2.,ptmp) )
120  * ( - x_max * sin(ptmp) + y_max * cos(ptmp) ) ) ;
121 
122  }
123  ppp += ss * (mm - 1) * dp ;
124 
125  }
126 
127  return ppp ;
128 
129 }
130 }
double phi_longest_rad(double x_max, double y_max) const
Searches the position (phi) of the longest radius of NS from the position of the maximum enthalpy...
Radial mapping of rather general form.
Definition: map.h:2783
Lorene prototypes.
Definition: app_hor.h:67
const Valeur & dsdp() const
Returns of *this.
Definition: valeur_dsdp.C:101
const Valeur & get_gg() const
Returns a (constant) reference to the function .
Definition: map_et.C:1061
Values and coefficients of a (real-value) function.
Definition: valeur.h:297
Cmp cos(const Cmp &)
Cosine.
Definition: cmp_math.C:97
const Valeur & get_ff() const
Returns a (constant) reference to the function .
Definition: map_et.C:1057
double val_point(int l, double x, double theta, double phi) const
Computes the value of the field represented by *this at an arbitrary point, by means of the spectral ...
Definition: valeur.C:885
Map & mp
Mapping associated with the star.
Definition: etoile.h:432
Cmp sin(const Cmp &)
Sine.
Definition: cmp_math.C:72