00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef O2SCL_TOV_EOS_H
00024 #define O2SCL_TOV_EOS_H
00025
00026 #include <cmath>
00027 #include <iostream>
00028 #include <fstream>
00029
00030 #include <o2scl/constants.h>
00031 #include <o2scl/funct.h>
00032 #include <o2scl/multi_funct.h>
00033 #include <o2scl/mm_funct.h>
00034 #include <o2scl/lib_settings.h>
00035 #include <o2scl/collection.h>
00036 #include <o2scl/table.h>
00037 #include <o2scl/base_ioc.h>
00038
00039 #include <o2scl/mroot.h>
00040 #include <o2scl/odestep.h>
00041 #include <o2scl/minimize.h>
00042 #include <o2scl/gsl_min_brent.h>
00043 #include <o2scl/gsl_mroot_hybrids.h>
00044 #include <o2scl/ode_funct.h>
00045 #include <o2scl/gsl_astep.h>
00046
00047 #ifndef DOXYGENP
00048 namespace o2scl {
00049 #endif
00050
00051
00052
00053
00054 class tov_eos {
00055
00056 public:
00057
00058 tov_eos() {
00059 baryon_column=false;
00060 verbose=1;
00061 }
00062
00063 virtual ~tov_eos() {}
00064
00065
00066 int verbose;
00067
00068
00069
00070
00071
00072
00073
00074 virtual int get_eden(double P, double &e, double &nb) {
00075 return 0;
00076 }
00077
00078
00079 virtual int get_aux(double P, size_t &np, ovector_view &auxp) {
00080 return 0;
00081 }
00082
00083
00084
00085
00086
00087 virtual int get_names(size_t &np, std::vector<std::string> &pnames) {
00088 return 0;
00089 }
00090
00091
00092
00093
00094
00095 bool baryon_column;
00096
00097 };
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116 class tov_interp_eos : public tov_eos {
00117
00118 public:
00119
00120 tov_interp_eos();
00121
00122 virtual ~tov_interp_eos() {}
00123
00124
00125 virtual int get_eden(double pres, double &ed, double &nb);
00126
00127
00128
00129
00130
00131 virtual int get_eden_user(double pres, double &ed, double &nb);
00132
00133
00134
00135
00136
00137 virtual int get_eden_ld(double pres, double &ed, double &nb);
00138
00139
00140 virtual int get_aux(double P, size_t &nv, ovector_view &auxp);
00141
00142
00143
00144
00145
00146 virtual int get_names(size_t &np, std::vector<std::string> &pnames);
00147
00148
00149 int read_table(table &eosat, std::string s_cole="ed",
00150 std::string s_colp="pr", std::string s_colnb="nb");
00151
00152
00153 int read_table_file(std::string eosfn, std::string s_cole="ed",
00154 std::string s_colp="pr", std::string s_colnb="nb");
00155
00156
00157
00158
00159 int set_low_density_eos(bool s_ldeos, std::string s_nvpath,
00160 int s_nvcole=0, int s_nvcolp=1, int s_nvcolnb=2);
00161
00162
00163
00164 int set_units(double s_efactor, double s_pfactor,
00165 double s_nfactor);
00166
00167
00168
00169 int set_units(std::string leunits,
00170 std::string lpunits, std::string lnunits);
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180 int get_transition(double &plow, double &ptrans, double &phi);
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191 int set_transition(double ptrans, double pw);
00192
00193 #ifndef DOXYGEN_INTERNAL
00194
00195 protected:
00196
00197
00198 base_ioc bio;
00199
00200
00201 int check_eos();
00202
00203
00204
00205
00206
00207 bool ldeos;
00208
00209
00210
00211
00212
00213
00214
00215
00216 bool ldeos_read;
00217
00218
00219 std::string ldpath;
00220
00221 int ldcole;
00222
00223 int ldcolp;
00224
00225 int ldcolnb;
00226
00227 table *ld_eos;
00228
00229
00230 double presld;
00231
00232 double eld;
00233
00234 double nbld;
00235
00236
00237 double prest;
00238
00239 double pwidth;
00240
00241
00242
00243
00244
00245
00246 table *eost;
00247
00248
00249 int nfile;
00250
00251
00252 int cole;
00253
00254 int colp;
00255
00256 int colnb;
00257
00258
00259 bool eos_read;
00260
00261
00262
00263
00264
00265
00266 std::string eunits;
00267
00268 std::string punits;
00269
00270 std::string nunits;
00271
00272
00273 double efactor;
00274
00275 double pfactor;
00276
00277 double nfactor;
00278
00279
00280
00281
00282 void interp(const ovector_view &x, const ovector_view &y,
00283 double xx, double &yy, int n1, int n2);
00284
00285 #endif
00286
00287 };
00288
00289
00290
00291
00292
00293
00294
00295
00296
00297
00298
00299
00300
00301
00302
00303
00304
00305
00306
00307
00308
00309
00310
00311
00312
00313
00314
00315 class tov_buchdahl_eos : public tov_eos {
00316
00317 public:
00318
00319 tov_buchdahl_eos() {
00320 Pstar=3.2e-5;
00321 }
00322
00323 virtual ~tov_buchdahl_eos() {}
00324
00325
00326
00327
00328
00329
00330 double Pstar;
00331
00332
00333
00334
00335
00336
00337
00338 virtual int get_eden(double P, double &e, double &nb) {
00339 e=12.0*sqrt(Pstar*P)-5.0*P;
00340 nb=0.0;
00341 return 0;
00342 }
00343
00344
00345 virtual int get_aux(double P, size_t &np, ovector_view &auxp) {
00346 np=0;
00347 return 0;
00348 }
00349
00350
00351
00352
00353
00354 virtual int get_names(size_t &np, std::vector<std::string> &pnames) {
00355 np=0;
00356 return 0;
00357 }
00358
00359 #ifdef NEVER_DEFINED
00360
00361 int buchfun(size_t bv, const ovector_view &bx, ovector_view &by,
00362 void *&pa) {
00363 double u, rp;
00364 u=bx[0];
00365 rp=bx[1];
00366 by[0]=rp*(1.0-beta+u)/(1.0-2.0*beta)-buchrad;
00367 by[1]=beta/biga/rp*sin(biga*rp);
00368 return gsl_success;
00369 }
00370
00371 #endif
00372
00373 };
00374
00375
00376 class tov_polytrope_eos : public tov_eos {
00377
00378 public:
00379
00380 tov_polytrope_eos() {
00381 K=1.0;
00382 n=3.0;
00383 }
00384
00385 virtual ~tov_polytrope_eos() {}
00386
00387
00388
00389
00390 double K;
00391
00392
00393 double n;
00394
00395
00396
00397
00398
00399
00400
00401 virtual int get_eden(double P, double &e, double &nb) {
00402 e=pow(P/K,1.0/(1.0+1.0/n));
00403 nb=0.0;
00404 return 0;
00405 }
00406
00407
00408 virtual int get_aux(double P, size_t &np, ovector_view &auxp) {
00409 np=0;
00410 return 0;
00411 }
00412
00413
00414
00415
00416
00417 virtual int get_names(size_t &np, std::vector<std::string> &pnames) {
00418 np=0;
00419 return 0;
00420 }
00421
00422 };
00423
00424 #ifndef DOXYGENP
00425 }
00426 #endif
00427
00428 #endif
00429
00430