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 char et_bin_bhns_extr_phi_C[] = "$Header: /cvsroot/Lorene/C++/Source/Etoile/et_bin_bhns_extr_phi.C,v 1.3 2014/10/13 08:52:55 j_novak Exp $" ;
32 
33 /*
34  * $Id: et_bin_bhns_extr_phi.C,v 1.3 2014/10/13 08:52:55 j_novak Exp $
35  * $Log: et_bin_bhns_extr_phi.C,v $
36  * Revision 1.3 2014/10/13 08:52:55 j_novak
37  * Lorene classes and functions now belong to the namespace Lorene.
38  *
39  * Revision 1.2 2014/10/06 15:13:08 j_novak
40  * Modified #include directives to use c++ syntax.
41  *
42  * Revision 1.1 2004/11/30 20:50:48 k_taniguchi
43  * *** empty log message ***
44  *
45  *
46  * $Header: /cvsroot/Lorene/C++/Source/Etoile/et_bin_bhns_extr_phi.C,v 1.3 2014/10/13 08:52:55 j_novak Exp $
47  *
48  */
49 
50 // C headers
51 #include <cmath>
52 
53 // Lorene headers
54 #include "et_bin_bhns_extr.h"
55 #include "utilitaires.h"
56 
57 namespace Lorene {
58 double Et_bin_bhns_extr::phi_longest_rad(double x_max, double y_max) const {
59 
60  //----------------------------------------------------------------//
61  // Construct the surface function S(theta, phi) //
62  //----------------------------------------------------------------//
63 
64  // The following is required to access functions of Map_et
65  Map_et& mp_et = dynamic_cast<Map_et&>(mp) ;
66 
67  const Valeur& ff0 = mp_et.get_ff() ;
68  const Valeur& gg0 = mp_et.get_gg() ;
69 
70  Valeur fff = ff0 ;
71  Valeur ggg = gg0 ;
72  Valeur dff = fff.dsdp() ;
73  Valeur dgg = ggg.dsdp() ;
74 
75  double ppp = M_PI/2. ; // Initial position of the phi-coordinate
76  double ptmp ;
77  int mm ; // Number of steps to the phi-direction
78  double dp = 1. ; // Step interval to the phi-direction, initialized to 1
79  double diff ;
80  double diff_prev ;
81  double ss ;
82 
83  while ( dp > 1.e-15 ) {
84 
85  diff = 1. ;
86  mm = 0 ;
87  dp = 0.1 * dp ;
88 
89  diff_prev = ( dff.val_point(0,1.,M_PI/2.,ppp)
90  + dgg.val_point(0,1.,M_PI/2.,ppp) )
91  * ( 1. + ff0.val_point(0,1.,M_PI/2.,ppp)
92  + gg0.val_point(0,1.,M_PI/2.,ppp)
93  - x_max * cos(ppp) - y_max * sin(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 * sin(ppp) + y_max * cos(ppp) ) ;
97 
98  if ( diff_prev > 0. ) {
99  ss = 1. ;
100  }
101  else {
102  ss = -1. ;
103  }
104 
105  while ( diff > 1.e-15 ) {
106 
107  mm++ ;
108  ptmp = ppp + mm * dp ;
109 
110  diff = ss * ( ( dff.val_point(0,1.,M_PI/2.,ptmp)
111  + dgg.val_point(0,1.,M_PI/2.,ptmp) )
112  * ( 1. + ff0.val_point(0,1.,M_PI/2.,ptmp)
113  + gg0.val_point(0,1.,M_PI/2.,ptmp)
114  - x_max * cos(ptmp) - y_max * sin(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 * sin(ptmp) + y_max * cos(ptmp) ) ) ;
118 
119  }
120  ppp += ss * (mm - 1) * dp ;
121 
122  }
123 
124  return ppp ;
125 
126 }
127 }
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.
Map & mp
Mapping associated with the star.
Definition: etoile.h:429
Radial mapping of rather general form.
Definition: map.h:2752
const Valeur & get_ff() const
Returns a (constant) reference to the function .
Definition: map_et.C:1034
const Valeur & get_gg() const
Returns a (constant) reference to the function .
Definition: map_et.C:1038
Values and coefficients of a (real-value) function.
Definition: valeur.h:287
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:882
const Valeur & dsdp() const
Returns of *this.
Definition: valeur_dsdp.C:98
Cmp sin(const Cmp &)
Sine.
Definition: cmp_math.C:69
Cmp cos(const Cmp &)
Cosine.
Definition: cmp_math.C:94
Lorene prototypes.
Definition: app_hor.h:64