Main Page   Class Hierarchy   Data Structures   File List   Data Fields   Globals  

add_tidal.C

Go to the documentation of this file.
00001 
00002        //=======================================================//    _\|/_
00003       //  __  _____           ___                    ___       //      /|\ ~
00004      //  /      |      ^     |   \  |         ^     |   \     //          _\|/_
00005     //   \__    |     / \    |___/  |        / \    |___/    //            /|\ ~
00006    //       \   |    /___\   |  \   |       /___\   |   \   // _\|/_
00007   //     ___/   |   /     \  |   \  |____  /     \  |___/  //   /|\ ~
00008  //                                                       //            _\|/_
00009 //=======================================================//              /|\ ~
00010 
00018 
00019 //               Code moved here from kira_init.C
00020 
00021 #ifdef TOOLBOX
00022 
00023 #include "dyn.h"
00024 
00025 main(int argc, char *argv[])
00026 {
00027     bool c_flag = false;
00028     char *comment;              // comment string
00029 
00030     bool J_flag = false;
00031     real input_r_jacobi = -1;
00032 
00033     // Use of this function means that kira's "-Q" flag is implicit,
00034     // and the default tidal field type is 1 (point-mass).
00035 
00036     bool F_flag = false;
00037     int  tidal_field_type = 0;
00038 
00039     check_help();
00040 
00041     extern char *poptarg;
00042     int c;
00043     char* param_string = "c:F:J:";
00044 
00045     dyn *b = get_dyn(cin);
00046     if (b == NULL) err_exit("Can't read input snapshot");
00047 
00048     b->log_history(argc, argv);
00049 
00050     // Parse the argument list:
00051 
00052     while ((c = pgetopt(argc, argv, param_string)) != -1) {
00053         switch (c) {
00054             case 'c':   c_flag = TRUE;
00055                         comment = poptarg;
00056                         break;
00057             case 'F':   F_flag = true;
00058                         tidal_field_type = atoi(poptarg);
00059                         break;
00060             case 'J':   J_flag = true;
00061                         input_r_jacobi = atof(poptarg);
00062                         break;
00063             default:
00064             case '?':   params_to_usage(cerr, argv[0], param_string);
00065                         get_help();
00066                         return false;
00067         }
00068     }
00069 
00070     if (c_flag)
00071         b->log_comment(comment);
00072 
00073     if (tidal_field_type < 1) tidal_field_type = 1;
00074     if (tidal_field_type > 4) tidal_field_type = 4;
00075 
00076     // Action of add_tidal depends on how the input data were created.
00077     //
00078     // 1. Some initialization functions (e.g. makeplummer, makesphere, etc.)
00079     //    don't know about tidal radii.  They write nothing to the log story
00080     //    unless they are asked to scale, in which case they write initial_mass
00081     //    and initial_rvirial.
00082     //
00083     // 2. Some (e.g. makeking) have limited knowledge, and write initial_mass,
00084     //    initial_rvirial, and initial_rtidal_over_rvirial to the log story.
00085     //
00086     // 3. Others (e.g. make_aniso_king) know a lot, and write initial_mass,
00087     //    initial_rvirial, initial_rtidal_over_rvirial, alpha3_over_alpha1,
00088     //    and kira_tidal_field_type to the log story.
00089     //
00090     // In case 1, simply add the ratio initial_rtidal_over_rvirial to the
00091     // log story.  If initial_rvirial is unknown, it will have to be
00092     // computed (by scale) in any case before the data are usable.  When
00093     // the data are used, initial_rtidal_over_rvirial will translate into
00094     // r_jacobi_over_r_virial.  The tidal field type is taken from the
00095     // command line.
00096     //
00097     // In case 2, initial_rtidal_over_rvirial is already contained in the
00098     // log story.  In keeping with the older conventions in kira, use
00099     // the 'J' input variable to scale this quantity (allows "underfilling"
00100     // King models).  The tidal field type is taken from the command line.
00101     //
00102     // In case 3, there is nothing to be done, as the tidal properties
00103     // are completely determined once the virial radius is set (or reset
00104     // by scale).  Flag a warning on any attempt to change parameters.
00105 
00106     bool print = false;
00107     real RtRv;
00108 
00109     if (!find_qmatch(b->get_log_story(), "initial_rtidal_over_rvirial")) {
00110 
00111         // Case 1:  use r_jacobi to set the tidal radius.
00112 
00113         if (input_r_jacobi <= 0)
00114             err_exit("add_tidal: insufficient data to set tidal radius.");
00115 
00116         putrq(b->get_log_story(), "initial_rtidal_over_rvirial",
00117               input_r_jacobi);
00118         putiq(b->get_log_story(), "kira_tidal_field_type", tidal_field_type);
00119 
00120         print = true;
00121         RtRv = input_r_jacobi;
00122 
00123     } else {
00124 
00125         if (find_qmatch(b->get_log_story(), "alpha3_over_alpha1")
00126             || find_qmatch(b->get_log_story(), "kira_tidal_field_type")) {
00127 
00128             // Case 3:  no action, but flag any attempt to reset.
00129 
00130             if (F_flag) warning("add_tidal: ignored -F flag");
00131             if (J_flag) warning("add_tidal: ignored -J flag");
00132 
00133         } else {
00134 
00135             // Case 2:  scale the existing tidal radius by input_r_jacobi,
00136             //          if set.
00137 
00138             if (J_flag) {
00139                 if (input_r_jacobi <= 0)
00140                     err_exit("add_tidal: input Jacobi radius < 0");
00141             }
00142 
00143             real r_tidal_over_rvirial
00144                 = getrq(b->get_log_story(), "initial_rtidal_over_rvirial");
00145 
00146             if (r_tidal_over_rvirial <= 0)
00147               err_exit("add_tidal: error reading initial_rtidal_over_rvirial");
00148 
00149             if (input_r_jacobi > 0)
00150                 r_tidal_over_rvirial *= input_r_jacobi;
00151             else
00152                 warning("add_tidal: ignored input_r_jacobi < 0");
00153 
00154             putrq(b->get_log_story(), "initial_rtidal_over_rvirial",
00155                   r_tidal_over_rvirial);
00156             putiq(b->get_log_story(), "kira_tidal_field_type",
00157                   tidal_field_type);
00158 
00159             print = true;
00160             RtRv = r_tidal_over_rvirial;
00161         }
00162     }
00163 
00164     if (print)
00165         cerr << "add_tidal:  Rt/Rv = " << RtRv << ", field type = "
00166              << tidal_field_type << endl;
00167 
00168     put_node(cout, *b);
00169 }
00170 #endif

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