00001
00002
00003 #include "stdfunc.h"
00004 #include "sstar_to_dyn.h"
00005 #ifndef TOOLBOX
00006
00007 local real kingfit(const real X, int nfit, const real Xarray[],
00008 const real Yarray[]) {
00009
00010 real parameter = -1;
00011 if (X>=Xarray[1] || X<=Xarray[nfit-1])
00012 return parameter;
00013
00014 if (X>=Xarray[1])
00015 return Yarray[0];
00016 else if(X<=Xarray[nfit-1])
00017 return Yarray[nfit-1];
00018 else
00019 for (int i=1; i<nfit; i++)
00020 if (X>=Xarray[i])
00021 return lineair_interpolation(X,
00022 Xarray[i-1], Xarray[i],
00023 Yarray[i-1], Yarray[i]);
00024 return parameter;
00025 }
00026
00027
00028
00029 void print_fitted_king_model(const real fractional_radius,
00030 const radius_fraction which_fraction) {
00031
00032 int nfit = 16;
00033 real WoKing[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
00034 real CKing[] = {0., 0.2956, 0.5054, 0.6739, 0.8405, 1.03059,
00035 1.2560, 1.5284, 1.8341, 2.1202, 2.3516, 2.5495,
00036 2.7396, 2.9346, 3.1414, 3.3570};
00037 real RK_Rvir[] = {2.0, 1.29917, 0.87470, .66626, 0.52325, 0.40736,
00038 0.30368, 0.20692, 0.12217, 0.06357, 0.03311,
00039 0.01870, 0.01132, 0.00710, 0.00450, 0.00282};
00040
00041 real Rc_Rvir[] = {1., 0.5078, 0.4711, 0.4274, 0.3718, 0.3136, 0.2479,
00042 0.1744, 0.1087, 0.05839, 0.03240, 0.01895, 0.01335,
00043 0.009796, 0.007413, 0.006709};
00044
00045 real proj_r1r9[] = {0, 0.2370, 0.2282, 0.2146, 0.1945, 0.1716, 0.1397,
00046 0.1050, 0.07199, 0.05437, 0.05082, 0.05855, 0.06782,
00047 0.07320, 0.07627, 0.07587};
00048
00049 real r1r9[] = {0, 0.3234, 0.3052, 0.2825, 0.2520, 0.2160, 0.1711,
00050 0.1224, 0.08080, 0.06040, 0.05631, 0.06693, 0.08000,
00051 0.08907, 0.09046, 0.08942};
00052
00053 real Wo = -1;
00054 real C = -1;
00055 switch(which_fraction) {
00056 case rcore_rvirial:
00057 Wo = kingfit(fractional_radius, nfit, Rc_Rvir, WoKing);
00058 C = kingfit(fractional_radius, nfit, Rc_Rvir, CKing);
00059 cerr <<" (non projected rcore/rvir)\n";
00060 break;
00061 case r10_r90_light:
00062 Wo = kingfit(fractional_radius, nfit, r1r9, WoKing);
00063 C = kingfit(fractional_radius, nfit, r1r9, CKing);
00064 cerr <<" (non projected r at 10% / 90% light )\n";
00065 break;
00066 case proj_r10_r90_light:
00067 Wo = kingfit(fractional_radius, nfit, proj_r1r9, WoKing);
00068 C = kingfit(fractional_radius, nfit, proj_r1r9, CKing);
00069 cerr <<" (projected r at 10% / 90% light )\n";
00070 break;
00071 default:
00072 cerr << " Unknown option in fitted_king_model()." << endl;
00073 return;
00074 }
00075
00076 cerr << " King model Wo = " << Wo
00077 << " concentration c = " << C
00078 << endl;
00079
00080 }
00081
00082 #else
00083
00084 main(int argc, char **argv)
00085 {
00086 real rc_rvir = 0;
00087 real r_lumi = 0;
00088 int nlagrad = 0;
00089
00090 extern char *poptarg;
00091 int c;
00092 char* param_string = "L:l:R:r:";
00093
00094 if (nlagrad<0 || nlagrad>2) {
00095 cerr << " kingfit -n " << nlagrad << endl;
00096 cerr << "please specify n between 0 and 2." << endl;
00097 exit (1);
00098 }
00099
00100 while ((c = pgetopt(argc, argv, param_string)) != -1)
00101 switch(c) {
00102 case 'R':
00103 case 'r': rc_rvir = atof(poptarg);
00104 break;
00105 case 'L':
00106 case 'l': r_lumi = atof(poptarg);
00107 break;
00108 case '?': params_to_usage(cerr, argv[0], param_string);
00109 exit(1);
00110 }
00111
00112 if (rc_rvir)
00113 print_fitted_king_model(rc_rvir, rcore_rvirial);
00114 else
00115 print_fitted_king_model(r_lumi, proj_r10_r90_light);
00116
00117 }
00118 #endif