00001 
00008 
00009 
00010 
00011 #include "node.h"
00012 
00013 #ifdef TOOLBOX
00014 
00015 
00016 
00017 
00018 local void double_mass(node* original, real mass_ratio)
00019 {
00020     
00021 
00022     original->set_mass(mass_ratio*original->get_mass());
00023     
00024 }
00025 
00026 local void mkheavystar(node* b, real fraction_doubled, real lower_limit,
00027                        real mass_ratio)
00028 {
00029  
00030     real sum = 0;
00031     b->set_mass(0);
00032 
00033     PRI(6); putrq(b->get_log_story(),
00034                   "fraction_of_masses_doubled", fraction_doubled);
00035 
00036     for_all_daughters(node, b, bi) {
00037         sum += fraction_doubled;
00038         if (sum >= 1) {
00039             sum -= 1;
00040 
00041             double_mass(bi, mass_ratio);
00042             putrq(bi->get_log_story(), "mass_doubled", 1);
00043         }
00044         else putiq(bi->get_log_story(), "mass_doubled", 0);
00045 
00046         b->inc_mass(bi->get_mass());
00047     }
00048 }
00049 
00050 void main(int argc, char ** argv)
00051 {
00052     real fraction_doubled = 0.1;
00053     real lower_limit = 1;
00054     int random_seed = 0;
00055     real mass_ratio = 2;
00056     
00057 
00058     check_help();
00059 
00060     extern char *poptarg;
00061     int c;
00062     char* param_string = "f:l:q:s:";
00063 
00064     while ((c = pgetopt(argc, argv, param_string)) != -1)
00065         switch(c) {
00066 
00067             case 'f': fraction_doubled = atof(poptarg);
00068                       break;
00069             case 'l': lower_limit = atof(poptarg);
00070                       break;
00071             case 'q': mass_ratio = atof(poptarg);
00072                       break;
00073             case 's': random_seed = atoi(poptarg);
00074                       break;
00075             case '?': params_to_usage(cerr, argv[0], param_string);
00076                       get_help();
00077                       exit(1);
00078         }
00079 
00080     if (fraction_doubled < 0 || fraction_doubled > 1)
00081         err_exit("mkheavystar: Illegal doubling fraction");
00082     
00083     
00084 
00085     node* b;
00086     b = get_node(cin);
00087 
00088     b->log_history(argc, argv);
00089 
00090     
00091 
00092     
00093     
00094     
00095 
00096     mkheavystar(b, fraction_doubled, lower_limit, mass_ratio);
00097 
00098     put_node(cout, *b);
00099 
00100 }
00101 #endif