Debian Codegraph @

Codes/Rot_star/chent.C

raw
1 /*
2 * Simple code to search for the enthalpy corresponding
3 * to a given value of a global parameter
4 *
5 */
6
7 /*
8 * Copyright (c) 2003 Eric Gourgoulhon
9 *
10 * This file is part of LORENE.
11 *
12 * LORENE is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License version 2
14 * as published by the Free Software Foundation.
15 *
16 * LORENE is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with LORENE; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 *
25 */
26
27 char chent_C[] = "$Header: /cvsroot/Lorene/Codes/Rot_star/chent.C,v 1.3 2014/10/13 08:53:58 j_novak Exp $" ;
28
29 /*
30 * $Id: chent.C,v 1.3 2014/10/13 08:53:58 j_novak Exp $
31 * $Log: chent.C,v $
32 * Revision 1.3 2014/10/13 08:53:58 j_novak
33 * Lorene classes and functions now belong to the namespace Lorene.
34 *
35 * Revision 1.2 2014/10/06 15:09:45 j_novak
36 * Modified #include directives to use c++ syntax.
37 *
38 * Revision 1.1 2003/09/08 15:12:06 e_gourgoulhon
39 * Initial version.
40 *
41 *
42 *
43 * $Header: /cvsroot/Lorene/Codes/Rot_star/chent.C,v 1.3 2014/10/13 08:53:58 j_novak Exp $
44 *
45 */
46
47 // C++ headers
48 #include "headcpp.h"
49
50 // C headers
51 #include <cstdio>
52
53 using namespace Lorene ;
54
55 int main(int argc, char** argv){
56
57 if (argc < 2) {
58 cout <<
59 "chent : the value of the global quantity Q for which the enthalpy is searched "
60 << endl << " must be given in argument !" << endl ;
61 return -1 ;
62 }
63
64 char* qchar = argv[1] ;
65
66 double qq ;
67 sscanf(qchar, "%lf", &qq) ;
68
69 cout << "Search of ent for Q = " << qq << " : " << endl ;
70
71 double ent1, ent2, qq1, qq2 ;
72 cout << " ent1, Q1 ? " ;
73 cin >> ent1 ;
74 cin >> qq1 ;
75 cout << endl << " ent2, Q2 ? " ;
76 cin >> ent2 ;
77 cin >> qq2 ;
78
79 double y1 = qq1 - qq ;
80 double y2 = qq2 - qq ;
81
82 double ent = ent1 - y1 /(y2 - y1) * (ent2 - ent1) ;
83 cout.precision(16) ;
84 cout << endl << "ent for Q = " << qq << " : "
85 << ent << endl ;
86
87 return 0 ;
88
89 }