00001
00002
00003
00004
00005 #include "star_support.h"
00006
00007 char* type_string(stellar_type tpe) {
00008
00009 switch(tpe) {
00010 case Static_Star: return "static_star";
00011 case SPZDCH_Star: return "SPZDCH_star";
00012 case NAS: return "not_a_star";
00013 case Proto_Star: return "proto_star";
00014 case Planet: return "planet";
00015 case Brown_Dwarf: return "brown_dwarf";
00016 case Main_Sequence: return "main_sequence";
00017 case Hyper_Giant: return "hyper_giant";
00018 case Hertzsprung_Gap: return "hertzsprung_gap";
00019 case Sub_Giant: return "sub_giant";
00020 case Horizontal_Branch: return "horizontal_branch";
00021 case Super_Giant: return "super_giant";
00022 case Carbon_Star: return "carbon_star";
00023 case Helium_Star: return "helium_star";
00024 case Helium_Giant: return "helium_giant";
00025 case Helium_Dwarf: return "helium_dwarf";
00026 case Carbon_Dwarf: return "carbon_dwarf";
00027 case Oxygen_Dwarf: return "oxygen_dwarf";
00028 case Thorn_Zytkow: return "thorne_zytkow";
00029 case Xray_Pulsar: return "xray_pulsar";
00030 case Radio_Pulsar: return "radio_pulsar";
00031 case Neutron_Star: return "neutron_star";
00032 case Black_Hole: return "black_hole";
00033 case Disintegrated: return "Disintegrated";
00034 case Double: return "binary";
00035 default: return "unknown_stellar_type";
00036 }
00037 }
00038
00039 char* type_short_string(stellar_type tpe) {
00040
00041 switch(tpe) {
00042 case Static_Star: return "SS";
00043 case SPZDCH_Star: return "PZHs";
00044 case NAS: return "nas";
00045 case Proto_Star: return "ps";
00046 case Planet: return "pl";
00047 case Brown_Dwarf: return "bd";
00048 case Main_Sequence: return "ms";
00049 case Hyper_Giant: return "hy";
00050 case Hertzsprung_Gap: return "hg";
00051 case Sub_Giant: return "gs";
00052 case Horizontal_Branch: return "hb";
00053 case Super_Giant: return "sg";
00054 case Carbon_Star: return "co";
00055 case Helium_Star: return "he";
00056 case Helium_Giant: return "gh";
00057 case Helium_Dwarf: return "hd";
00058 case Carbon_Dwarf: return "cd";
00059 case Oxygen_Dwarf: return "od";
00060 case Thorn_Zytkow: return "TZO";
00061 case Xray_Pulsar: return "xp";
00062 case Radio_Pulsar: return "rp";
00063 case Neutron_Star: return "ns";
00064 case Black_Hole: return "bh";
00065 case Disintegrated: return "di";
00066 case Double: return "bin";
00067 default: return "?";
00068 }
00069 }
00070
00071 char* type_string(stellar_type_summary tpe) {
00072
00073 switch(tpe) {
00074 case ZAMS: return "ZAMS";
00075 case Early_Giant: return "early_giant";
00076 case Late_Giant: return "late_giant";
00077 case Helium_Remnant: return "helium_remnant";
00078 case White_Dwarf: return "white_dwarf";
00079 case Neutron_Remnant: return "neutron_remnant";
00080 case Inert_Remnant: return "inert_remnant";
00081 case Unspecified: return "unspecified";
00082 case Undefined: return "undefined";
00083 default: return "unknown_stellar_type_summary";
00084 }
00085 }
00086
00087 char* type_short_string(stellar_type_summary tpe) {
00088
00089 switch(tpe) {
00090 case ZAMS: return "ms";
00091 case Early_Giant: return "ge";
00092 case Late_Giant: return "gl";
00093 case Helium_Remnant: return "dh";
00094 case White_Dwarf: return "dw";
00095 case Neutron_Remnant: return "rn";
00096 case Inert_Remnant: return "ri";
00097 case Unspecified: return "unspecified";
00098 case Undefined: return "undefined";
00099 default: return "unknown_stellar_type_summary";
00100 }
00101 }
00102
00103 stellar_type_summary summarize_stellar_type(stellar_type tpe) {
00104
00105 switch(tpe) {
00106 case Static_Star:
00107 case SPZDCH_Star:
00108 case Proto_Star:
00109 case Planet:
00110 case Brown_Dwarf: return Unspecified;
00111
00112 case Main_Sequence: return ZAMS;
00113 case Hyper_Giant:
00114 case Hertzsprung_Gap:
00115 case Sub_Giant: return Early_Giant;
00116
00117 case Horizontal_Branch:
00118 case Super_Giant:
00119 case Thorn_Zytkow: return Late_Giant;
00120
00121 case Carbon_Star:
00122 case Helium_Star:
00123 case Helium_Giant: return Helium_Remnant;
00124
00125 case Helium_Dwarf:
00126 case Carbon_Dwarf:
00127 case Oxygen_Dwarf: return White_Dwarf;
00128
00129 case Xray_Pulsar:
00130 case Radio_Pulsar:
00131 case Neutron_Star: return Neutron_Remnant;
00132
00133
00134 case Black_Hole: return Inert_Remnant;
00135
00136
00137 case NAS:
00138 case Disintegrated:
00139 case Double:
00140 default: return Undefined;
00141 }
00142 }
00143
00144 char* type_string(spectral_class class_tpe) {
00145
00146 switch(class_tpe) {
00147 case O5: return "O5";
00148 case O6: return "O6";
00149 case O7: return "O7";
00150 case O8: return "O8";
00151 case O9: return "O9";
00152 case O95: return "O9.5";
00153 case B0: return "B0";
00154 case B05: return "B0.5";
00155 case B1: return "B1";
00156 case B2: return "B2";
00157 case B3: return "B3";
00158 case B5: return "B5";
00159 case B6: return "B6";
00160 case B7: return "B7";
00161 case B8: return "B8";
00162 case B9: return "B9";
00163 case B95: return "B9.5";
00164 case A0: return "A0";
00165 case A1: return "A1";
00166 case A2: return "A2";
00167 case A3: return "A3";
00168 case A4: return "A4";
00169 case A5: return "A5";
00170 case A7: return "A7";
00171 case F0: return "F0";
00172 case F2: return "F2";
00173 case F3: return "F3";
00174 case F5: return "F5";
00175 case F6: return "F6";
00176 case F7: return "F7";
00177 case F8: return "F8";
00178 case G0: return "G0";
00179 case G1: return "G1";
00180 case G2: return "G2";
00181 case G5: return "G5";
00182 case K0: return "K0";
00183 case K5: return "K5";
00184 case M0: return "M0";
00185 case M5: return "M5";
00186 case M8: return "M8";
00187 case he: return "he";
00188 case wd: return "wd";
00189 case ns: return "ns";
00190 case bh: return "bh";
00191 case bd: return "bd";
00192 case di: return "di";
00193 case bin: return "bin";
00194 default: return " ";
00195 }
00196 }
00197
00198
00199 char* type_short_string(spectral_class class_tpe) {
00200
00201 switch(class_tpe) {
00202 case O5:
00203 case O6:
00204 case O7:
00205 case O8:
00206 case O9:
00207 case O95: return "O";
00208 case B0:
00209 case B05:
00210 case B1:
00211 case B2:
00212 case B3:
00213 case B5:
00214 case B6:
00215 case B7:
00216 case B8:
00217 case B9:
00218 case B95: return "B";
00219 case A0:
00220 case A1:
00221 case A2:
00222 case A3:
00223 case A4:
00224 case A5:
00225 case A7: return "A";
00226 case F0:
00227 case F2:
00228 case F3:
00229 case F5:
00230 case F6:
00231 case F7:
00232 case F8: return "F";
00233 case G0:
00234 case G1:
00235 case G2:
00236 case G5: return "G";
00237 case K0:
00238 case K5: return "K";
00239 case M0:
00240 case M5:
00241 case M8: return "M";
00242 case he: return "O";
00243 case wd: return "O";
00244 case ns:
00245 case bh:
00246 case bd:
00247 case di:
00248 case bin:
00249 default: return "N";
00250 }
00251 }
00252
00253 char* type_string(luminosity_class lum_c) {
00254
00255 switch(lum_c) {
00256 case I: return "I";
00257 case II: return "II";
00258 case III: return "III";
00259 case IV: return "IV";
00260 case V: return "V";
00261 default: return "?";
00262 }
00263 }
00264
00265 char* type_string(star_type_spec spec) {
00266
00267 switch(spec) {
00268 case NAC: return "";
00269 case Emission: return "emission";
00270 case Barium: return "Barium";
00271 case Blue_Straggler: return "blue_straggler";
00272 case Rl_filling: return "Roche_lobe_filling";
00273 case Runaway: return "runaway";
00274 case Merger: return "merger";
00275 case Accreting: return "accreting";
00276 case Dsntgr: return "disintegrated";
00277 default: return "?";
00278 }
00279 }
00280
00281 char* type_short_string(star_type_spec spec) {
00282
00283 switch(spec) {
00284 case NAC: return "";
00285 case Emission: return "e";
00286 case Barium: return "Ba";
00287 case Blue_Straggler: return "Bs";
00288 case Rl_filling: return "Rlof";
00289 case Runaway: return "rnway";
00290 case Merger: return "mrgr";
00291 case Accreting: return "accr";
00292 case Dsntgr: return "dsntgr";
00293 default: return "?";
00294 }
00295 }
00296
00297
00298
00299 spectral_class get_spectral_class(const real temperature) {
00300
00301
00302
00303
00304
00305
00306
00307
00308 real log_temp = log10(temperature);
00309 spectral_class spectral_type;
00310 if(log_temp>=5.574) spectral_type = O5;
00311 else if(log_temp>=4.562) spectral_type = O6;
00312 else if(log_temp>=4.553) spectral_type = O7;
00313 else if(log_temp>=4.544) spectral_type = O8;
00314 else if(log_temp>=4.535) spectral_type = O9;
00315 else if(log_temp>=4.506) spectral_type = O95;
00316 else if(log_temp>=4.490) spectral_type = B0;
00317 else if(log_temp>=4.418) spectral_type = B05;
00318 else if(log_temp>=4.354) spectral_type = B1;
00319 else if(log_temp>=4.312) spectral_type = B2;
00320 else if(log_temp>=4.253) spectral_type = B3;
00321 else if(log_temp>=4.193) spectral_type = B5;
00322 else if(log_temp>=4.164) spectral_type = B6;
00323 else if(log_temp>=4.134) spectral_type = B7;
00324 else if(log_temp>=4.079) spectral_type = B8;
00325 else if(log_temp>=4.029) spectral_type = B9;
00326 else if(log_temp>=4.000) spectral_type = B95;
00327 else if(log_temp>=4.000) spectral_type = A0;
00328 else if(log_temp>=3.982) spectral_type = A1;
00329 else if(log_temp>=3.969) spectral_type = A2;
00330 else if(log_temp>=3.958) spectral_type = A3;
00331 else if(log_temp>=3.936) spectral_type = A4;
00332 else if(log_temp>=3.929) spectral_type = A5;
00333 else if(log_temp>=3.914) spectral_type = A7;
00334 else if(log_temp>=3.876) spectral_type = F0;
00335 else if(log_temp>=3.860) spectral_type = F2;
00336 else if(log_temp>=3.845) spectral_type = F3;
00337 else if(log_temp>=3.833) spectral_type = F5;
00338 else if(log_temp>=3.818) spectral_type = F6;
00339 else if(log_temp>=3.804) spectral_type = F7;
00340 else if(log_temp>=3.793) spectral_type = F8;
00341 else if(log_temp>=3.777) spectral_type = G0;
00342 else if(log_temp>=3.770) spectral_type = G1;
00343 else if(log_temp>=3.763) spectral_type = G2;
00344 else if(log_temp>=3.748) spectral_type = G5;
00345 else if(log_temp>=3.708) spectral_type = K0;
00346 else if(log_temp>=3.623) spectral_type = K5;
00347 else if(log_temp>=3.568) spectral_type = M0;
00348 else if(log_temp>=3.477) spectral_type = M5;
00349 else if(log_temp>=3.398) spectral_type = M8;
00350 else spectral_type = M8;
00351
00352 return spectral_type;
00353 }
00354
00355 luminosity_class get_luminosity_class(const real temperature,
00356 const real lum) {
00357
00358 luminosity_class lum_c = V;
00359 real log_temp = log10(temperature);
00360 real log_lum = log10(lum);
00361
00362 if (log_temp<=4.5 && log_lum>=lum_class_limit(log_temp, I))
00363 lum_c = I;
00364 else if (log_temp<=4.4 && log_lum>=lum_class_limit(log_temp,II))
00365 lum_c = II;
00366 else if (log_temp<=4.2 && log_lum>=lum_class_limit(log_temp,III))
00367 lum_c = III;
00368 else if (log_temp<=4.1 && log_lum>=lum_class_limit(log_temp,IV))
00369 lum_c = IV;
00370
00371 return lum_c;
00372 }
00373
00374 real lum_class_limit(const real log_temp,
00375 luminosity_class lmc) {
00376
00377 real cfit1, cfit2, cfit3, cfit4;
00378
00379 switch(lmc) {
00380 case I: cfit1 = -30.49;
00381 cfit2 = 24.21;
00382 cfit3 = -6.01;
00383 cfit4 = 0.532;
00384 break;
00385 case II: cfit1 = 173.3;
00386 cfit2 = -112.2;
00387 cfit3 = 23.78;
00388 cfit4 = -1.591;
00389 break;
00390 case III: cfit1 = -251.3;
00391 cfit2 = 239.8;
00392 cfit3 = -73.16;
00393 cfit4 = 7.266;
00394 break;
00395 case IV: cfit1 = -89.86;
00396 cfit2 = 83.60;
00397 cfit3 = -25.62;
00398 cfit4 = 2.61;
00399 break;
00400 default: cfit1 = cfit2 = cfit3 = cfit4 = 0;
00401 }
00402
00403 return cfit1 + log_temp*(cfit2 + log_temp*(cfit3 + log_temp*(cfit4)));
00404 }
00405
00406
00407 stellar_type extract_stellar_type_string(char* star_type_string) {
00408
00409 stellar_type type = NAS;
00410
00411 if (!strcmp(star_type_string, "planet"))
00412 type = Planet;
00413 else if (!strcmp(star_type_string, "proto_star"))
00414 type = Proto_Star;
00415 else if (!strcmp(star_type_string, "brown_dwarf"))
00416 type = Brown_Dwarf;
00417 else if (!strcmp(star_type_string, "main_sequence"))
00418 type = Main_Sequence;
00419 else if (!strcmp(star_type_string, "hyper_giant"))
00420 type = Hyper_Giant;
00421 else if (!strcmp(star_type_string, "hertzsprung_gap"))
00422 type = Hertzsprung_Gap;
00423 else if (!strcmp(star_type_string, "sub_giant"))
00424 type = Sub_Giant;
00425 else if (!strcmp(star_type_string, "horizontal_branch"))
00426 type = Horizontal_Branch;
00427 else if (!strcmp(star_type_string, "super_giant"))
00428 type = Super_Giant;
00429 else if (!strcmp(star_type_string, "thorne_zytkow"))
00430 type = Thorn_Zytkow;
00431 else if (!strcmp(star_type_string, "carbon_star"))
00432 type = Carbon_Star;
00433 else if (!strcmp(star_type_string, "helium_star"))
00434 type = Helium_Star;
00435 else if (!strcmp(star_type_string, "helium_giant"))
00436 type = Helium_Giant;
00437 else if (!strcmp(star_type_string, "helium_dwarf"))
00438 type = Helium_Dwarf;
00439 else if (!strcmp(star_type_string, "carbon_dwarf"))
00440 type = Carbon_Dwarf;
00441 else if (!strcmp(star_type_string, "oxygen_dwarf"))
00442 type = Oxygen_Dwarf;
00443 else if (!strcmp(star_type_string, "xray_pulsar"))
00444 type = Xray_Pulsar;
00445 else if (!strcmp(star_type_string, "radio_pulsar"))
00446 type = Radio_Pulsar;
00447 else if (!strcmp(star_type_string, "neutron_star"))
00448 type = Neutron_Star;
00449 else if (!strcmp(star_type_string, "black_hole"))
00450 type = Black_Hole;
00451 else if (!strcmp(star_type_string, "Disintegrated"))
00452 type = Disintegrated;
00453 else if (!strcmp(star_type_string, "SPZDCH_star"))
00454 type = SPZDCH_Star;
00455 else if (!strcmp(star_type_string, "static_star"))
00456 type = Static_Star;
00457 else
00458 type = NAS;
00459
00460 return type;
00461 }
00462
00463
00464 stellar_type_summary extract_stellar_type_summary_string(char* star_type_string) {
00465
00466 stellar_type_summary type = ZAMS;
00467
00468 if (!strcmp(star_type_string, "zams"))
00469 type = ZAMS;
00470 else if (!strcmp(star_type_string, "early_giant"))
00471 type = Early_Giant;
00472 else if (!strcmp(star_type_string, "late_giant"))
00473 type = Late_Giant;
00474 else if (!strcmp(star_type_string, "helium_remnant"))
00475 type = Helium_Remnant;
00476 else if (!strcmp(star_type_string, "white_dwarf"))
00477 type = White_Dwarf;
00478 else if (!strcmp(star_type_string, "inert_remnant"))
00479 type = Inert_Remnant;
00480 else if (!strcmp(star_type_string, "unspecified"))
00481 type = Unspecified;
00482 else if (!strcmp(star_type_string, "undefined"))
00483 type = Undefined;
00484 else if (!strcmp(star_type_string, "SPZDCH_star"))
00485 type = Unspecified;
00486 else if (!strcmp(star_type_string, "proto_star"))
00487 type = Unspecified;
00488 else if (!strcmp(star_type_string, "static_star"))
00489 type = Unspecified;
00490 else
00491 type = no_of_star_type_summ;
00492
00493 return type;
00494 }
00495
00496 star_type_spec extract_stellar_spec_summary_string(char* star_spec_string) {
00497
00498 star_type_spec type = NAC;
00499
00500 if (!strcmp(star_spec_string, "emission"))
00501 type = Emission;
00502 else if (!strcmp(star_spec_string, "Barium"))
00503 type = Barium;
00504 else if (!strcmp(star_spec_string, "blue_straggler"))
00505 type = Blue_Straggler;
00506 else if (!strcmp(star_spec_string, "Roche_lobe_filling"))
00507 type = Rl_filling;
00508 else if (!strcmp(star_spec_string, "runaway"))
00509 type = Runaway;
00510 else if (!strcmp(star_spec_string, "merger"))
00511 type = Merger;
00512 else if (!strcmp(star_spec_string, "accreting"))
00513 type = Accreting;
00514 else if (!strcmp(star_spec_string, "disintegrated"))
00515 type = Dsntgr;
00516 else
00517 type = NAC;
00518
00519 return type;
00520 }
00521
00522
00523 char* type_string(mass_transfer_type type) {
00524
00525 switch(type) {
00526 case Unknown: return "Unknown";
00527 case Nuclear: return "Nuclear";
00528 case AML_driven: return "AML_driven";
00529 case Thermal: return "Thermal";
00530 case Dynamic: return "Dynamic";
00531 default: return "unknown_mass_transfer_type";
00532 }
00533 }
00534
00535 char* type_short_string(mass_transfer_type type) {
00536
00537 switch(type) {
00538 case Unknown: return "?";
00539 case Nuclear: return "nuc";
00540 case AML_driven: return "aml";
00541 case Thermal: return "th";
00542 case Dynamic: return "dyn";
00543 default: return "???";
00544 }
00545 }
00546
00547
00548 bool post_supernova_star(stellar_type tpe) {
00549
00550 if (tpe == Xray_Pulsar ||
00551 tpe == Radio_Pulsar ||
00552 tpe == Neutron_Star ||
00553 tpe == Black_Hole)
00554 return true;
00555
00556 return false;
00557 }
00558
00559 supernova_type type_of_supernova(stellar_type progenitor) {
00560
00561 supernova_type ns_type = NAT;
00562 switch(progenitor) {
00563 case Super_Giant: ns_type = SN_II;
00564 break;
00565 case Hyper_Giant: ns_type = SN_Ic;
00566 break;
00567 case Helium_Giant: ns_type = SN_Ib;
00568 break;
00569 case Thorn_Zytkow: ns_type = SN_II;
00570 break;
00571 case Carbon_Dwarf:
00572 case Helium_Dwarf:
00573 case Oxygen_Dwarf:
00574 ns_type = SN_Ia;
00575 break;
00576
00577
00578
00579
00580
00581
00582 default:
00583 ns_type = NAT;
00584 };
00585
00586 return ns_type;
00587 }
00588
00589 char *type_string(supernova_type sn_type) {
00590
00591 switch(sn_type) {
00592 case NAT: return "nat";
00593 break;
00594 case SN_Ia: return "Ia";
00595 break;
00596 case SN_Ib: return "Ib";
00597 break;
00598 case SN_Ic: return "Ic";
00599 break;
00600 case SN_II: return "II";
00601 break;
00602 case SN_IIL: return "IIL";
00603 break;
00604 case SN_IIP: return "IIP";
00605 break;
00606 case SN_IV: return "IV";
00607 break;
00608 default: return "Unknown supernova_type";
00609 }
00610 }
00611
00612 bool remmant(stellar_type tpe) {
00613
00614 if (tpe == Helium_Dwarf ||
00615 tpe == Carbon_Dwarf ||
00616 tpe == Oxygen_Dwarf ||
00617 tpe == Xray_Pulsar ||
00618 tpe == Radio_Pulsar ||
00619 tpe == Neutron_Star ||
00620 tpe == Black_Hole)
00621 return true;
00622
00623 return false;
00624 }
00625
00626 #if 0
00627 real main_sequence_mass_loss() {
00628
00629 static time[] = { , , };
00630 static mass[] = { , , };
00631
00632
00633 }
00634
00635
00636 real lineair_interpolation(const real x,
00637 const real x1, const real x2,
00638 const real y1, const real y2) {
00639
00640 #endif
00641
00642
00643
00644
00645
00646