Main Page   Class Hierarchy   Data Structures   File List   Data Fields   Globals  

semi_to_period.C

Go to the documentation of this file.
00001 //
00008 #include "double_support.h"
00009 #include "constants.h"
00010 
00011 #ifndef TOOLBOX
00012 
00013 real period_to_semi(real period,
00014                     real m_prim,
00015                     real m_sec) {
00016 
00017   real semi = pow(period*cnsts.physics(seconds_per_day), 2)
00018             *     cnsts.physics(G)*cnsts.parameters(solar_mass)
00019             *     (m_prim+m_sec)
00020             /     (4*pow(cnsts.mathematics(pi), 2));
00021   semi = pow(semi, 1./3.)
00022        / cnsts.parameters(solar_radius);
00023   
00024   return semi;
00025 }
00026 
00027 real semi_to_period(real semi,
00028                     real m_prim,
00029                     real m_sec) {
00030 
00031   real period = sqrt((4*pow(cnsts.mathematics(pi), 2)
00032                        *pow(cnsts.parameters(solar_radius)*semi, 3))
00033                        /(cnsts.physics(G)*cnsts.parameters(solar_mass)
00034                          *(m_prim+m_sec))); 
00035 
00036   return period/cnsts.physics(seconds_per_day);
00037 }
00038 
00039 #else
00040 
00041 void main(int argc, char ** argv) {
00042 
00043     bool P_flag = false;
00044     bool q_flag = false;
00045 
00046     real m_prim = 13.1;
00047     real m_sec  =  9.8;
00048     real mass_ratio = m_sec/m_prim;
00049 
00050     real semi    = 138;
00051     real period = semi_to_period(semi, m_prim, m_sec);
00052     
00053     extern char *poptarg;
00054     int c;
00055     char* param_string = "a:P:M:m:q:";
00056 
00057     while ((c = pgetopt(argc, argv, param_string)) != -1)
00058         switch(c) {
00059             case 'a': semi = atof(poptarg);
00060                       break;
00061             case 'P': P_flag = true;
00062                       period = atof(poptarg);
00063                       break;
00064             case 'M': m_prim = atof(poptarg);
00065                       break;
00066             case 'm': m_sec = atof(poptarg);
00067                       break;
00068             case 'q': q_flag = true;
00069                       mass_ratio = atof(poptarg);
00070                       break;
00071             case '?': params_to_usage(cerr, argv[0], param_string);
00072                       exit(1);
00073         }
00074 
00075     if (q_flag) 
00076       m_sec = mass_ratio*m_prim;
00077 
00078     if (P_flag) {
00079       semi = period_to_semi(period, m_prim, m_sec);
00080       cerr << "(P [Days]; M, m [Msun]) = ("
00081            << period << "; " << m_prim << ", " << m_sec << ")";
00082       cerr << "  ===>  a = " << semi << " [Rsun]." << endl;
00083     }
00084     else {
00085       period = semi_to_period(semi, m_prim, m_sec);
00086       cerr << "(a [Rsun]; M, m [Msun]) = ("
00087            << semi << "; " << m_prim << ", " << m_sec << ")";
00088       cerr << "  ===>  P = " << period << " [Days]." << endl;
00089     }
00090 }
00091 
00092 #endif

Generated at Sun Feb 24 09:57:15 2002 for STARLAB by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001