29 #include <o2scl/test_mgr.h>
30 #include <o2scl/eos_had_skyrme.h>
31 #include <o2scl/fermion_nonrel.h>
32 #include <o2scl/nstar_cold.h>
33 #include <o2scl/format_float.h>
34 #include <o2scl/hdf_file.h>
35 #include <o2scl/hdf_io.h>
36 #include <o2scl/hdf_eos_io.h>
37 #include <o2scl/cli.h>
38 #include <o2scl/lib_settings.h>
41 using namespace o2scl;
42 using namespace o2scl_const;
43 using namespace o2scl_hdf;
182 n.non_interacting=
false;
183 p.non_interacting=
false;
184 nst.set_n_and_p(n,p);
186 nst.def_eos_tov.verbose=0;
187 nst.def_tov.verbose=0;
188 nst.include_muons=
true;
194 file_prefix=
"skyrme_";
203 tneut2.clear_table();
205 tneut.new_column(
"nb");
206 tneut.new_column(
"pr_neut");
207 tneut.new_column(
"pr_nstar");
209 tneut2.new_column(
"ed");
210 tneut2.new_column(
"pr_neut");
211 tneut2.new_column(
"pr_nstar");
213 tneut.set_unit(
"nb",
"fm^-3");
214 tneut.set_unit(
"pr_neut",
"fm^-4");
215 tneut.set_unit(
"pr_nstar",
"fm^-4");
217 tneut2.set_unit(
"ed",
"fm^-4");
218 tneut2.set_unit(
"pr_neut",
"fm^-4");
219 tneut2.set_unit(
"pr_nstar",
"fm^-4");
221 for(
double nbt=0.06;nbt<0.9001;nbt+=0.02) {
224 int ret=sk.calc_e(n,p,th);
225 double line[3]={nbt,th.pr,0.0};
226 tneut.line_of_data(3,line);
227 double line2[3]={th.ed,th.pr,0.0};
228 tneut2.line_of_data(3,line2);
236 bool failed_once=
false;
239 res.inc_pressure=
true;
242 for(
double nbt=0.005;nbt<0.1601 && failed_once==
false;nbt+=0.01) {
245 int ret=sk.calc_e(n,p,th);
248 res.inc_pressure=
false;
252 if (th.ed-n.n*n.m<0.0) {
258 if (failed_once==
false) {
259 cout <<
"Pressure increases and energy of neutrons is positive.\n"
262 cout <<
"Pressure decreased or energy of neutrons is negative.\n"
272 double g_kf[4]={0.06,0.14,0.26,0.54};
273 double g_rat[4]={0.80,0.67,0.57,0.52};
277 if (verbose>0) cout <<
"Low density neutron matter: " << endl;
278 for(
double nbt=0.000003;nbt<0.0051;nbt*=1.2) {
281 int ret=sk.calc_e(n,p,th);
284 double epb=(th.ed-n.n*n.m)/nbt*
hc_mev_fm;
290 cout << nbt <<
" " << epb <<
" "
291 << n.kf <<
" " << fermi <<
" " << epb/fermi << endl;
293 double line[5]={nbt,epb,n.kf,fermi,epb/fermi};
296 if (verbose>1) cout << endl;
303 res.E_neut_n0=(th.ed/sk.n0-n.m)*
hc_mev_fm;
307 for(
size_t i=0;i<4;i++) {
309 cout << g_kf[i] <<
" " << g_rat[i] <<
" "
310 << ln.
interp(
"kf",g_kf[i],
"rat") <<
" "
311 << ln.
interp(
"kf",g_kf[i],
"epb") << endl;
313 res.neut_qual+=g_kf[i]*fabs(g_rat[i]-ln.
interp(
"kf",g_kf[i],
"rat"));
317 cout <<
"Quality: " << res.neut_qual << endl;
336 res.alt_S=sk.fesym_diff(sk.n0)*
hc_mev_fm;
340 cout <<
"Saturation: " << endl;
341 cout <<
"n_0=" << sk.n0 <<
" fm^-3" << endl;
342 cout <<
"E_B=" << sk.eoa*
hc_mev_fm <<
" MeV" << endl;
343 cout <<
"K=" << sk.comp*
hc_mev_fm <<
" MeV" << endl;
344 cout <<
"M^*/M=" << sk.msom << endl;
345 cout <<
"S=" << sk.esym*
hc_mev_fm <<
" MeV" << endl;
346 cout <<
"S2=" << res.alt_S <<
" MeV" << endl;
347 cout <<
"L=" << res.L <<
" MeV" << endl;
355 if (fabs(sk.n0-0.16)>0.013) {
361 if (fabs(sk.comp*
hc_mev_fm-220.0)>20.0) {
367 if (res.good_sat==
false) {
368 cout <<
"Bad saturation." << endl;
380 cout <<
"EOS:" << endl;
383 sk.mu_at_zero_density=
true;
384 for(
double nb=0.16;nb<=2.0001;nb+=0.001) {
390 if (n.mu-p.mu-me<0.0) {
395 sk.mu_at_zero_density=
false;
397 cout <<
"Pure neutron matter after nb=" << nb_last << endl;
406 cout <<
"Neutron stars:" << endl;
413 string fn=file_prefix+res.name+
"_eos.o2";
414 hf.open_or_create(fn.c_str());
417 fn=file_prefix+res.name+
"_mvsr.o2";
418 hf.open_or_create(fn.c_str());
424 cout <<
"M_{max} = " << tr->max(
"gm") <<
" R_{max} = "
425 << tr->get(
"r",tr->lookup(
"gm",tr->max(
"gm")))
426 <<
" cent. density = "
427 << tr->get(
"nb",tr->lookup(
"gm",tr->max(
"gm"))) << endl;
429 << tr->get(
"r",tr->lookup(
"gm",1.4)) <<
" cent. density = "
430 << tr->get(
"nb",tr->lookup(
"gm",1.4)) << endl;
433 res.m_max=tr->max(
"gm");
434 res.r_max=tr->get(
"r",tr->lookup(
"gm",tr->max(
"gm")));
435 res.nb_max=tr->get(
"nb",tr->lookup(
"gm",tr->max(
"gm")));
436 res.r_14=tr->get(
"r",tr->lookup(
"gm",1.4));
437 res.nb_14=tr->get(
"nb",tr->lookup(
"gm",1.4));
440 double nbtop=res.nb_max;
441 if (nbtop>2.0) nbtop=2.0;
442 if (nbtop<0.4) nbtop=0.7;
449 for(
double nb=0.1;nb<=nbtop;nb+=0.01) {
450 if (te->get(
"np",te->lookup(
"nb",nb))<1.0e-5) {
462 res.max_mass_ok=
true;
463 if (tr->max(
"gm")<1.6) {
464 res.max_mass_ok=
false;
469 res.acausal=nst.acausal;
470 res.pressure_flat=nst.pressure_flat;
471 if (nst.pressure_flat>0.0 &&
472 nst.pressure_flat<tr->get(
"nb",tr->lookup(
"gm",tr->max(
"gm")))) {
473 cout <<
"Pressure decreases in maximum mass star" << endl;
474 cout <<
"pressure_flat: " << nst.pressure_flat << endl;
477 if (nst.acausal>0.0 &&
478 nst.acausal<tr->get(
"nb",tr->lookup(
"gm",tr->max(
"gm")))) {
479 cout <<
"Acausal before central density of maximum mass star." << endl;
480 cout <<
"acausal: " << nst.acausal << endl;
492 int summary(vector<string> &sv,
bool itive_com) {
494 cout <<
"No model to summarize." << endl;
498 cout <<
"Model: " << sv[1] << endl;
499 cout <<
"-----------------------------------------------------"
500 <<
"-----------------------" << endl;
503 skyrme_load(sk,sv[1]);
520 compare_neut_nstar();
524 cout <<
"-----------------------------------------------------"
525 <<
"-----------------------" << endl;
531 int test(vector<string> &sv,
bool itive_com) {
535 bool of_old=output_files;
540 args.push_back(
"summary");
541 args.push_back(
"SLy4");
545 t.
test_rel(res.n0,0.1595468,1.0e-5,
"n0");
546 t.
test_rel(res.m_max,2.050391,4.0e-4,
"m_max");
547 t.
test_rel(res.r_14,11.72476,4.0e-3,
"R_1.4");
557 int store(vector<string> &sv,
bool itive_com) {
560 cout <<
"No filename specified in 'store'." << endl;
564 hf.open_or_create(sv[1]);
565 skyrme_write(hf,sk,name);
569 cout <<
"Wrote model '" << name <<
"' to file named '"
570 << sv[1] <<
"'." << endl;
577 int unedf(vector<string> &sv,
bool itive_com) {
579 double coups[13][3]={
580 {-706.382928878428856,-779.3730087208653,-650.796319465688839},
581 {240.049520427681131,287.722131583286796,291.664014339185485},
582 {868.871771539645351,891.47789044234969,768.32770588203357},
583 {-69.0518957481631617,-200.587774317884879,-283.187292227492492},
584 {-12.9172408208016112,-0.989915057807676746,9.78520558824309639},
585 {-45.1894169426759476,-33.6320970701835549,-23.3573612977035339},
586 {0.321955989588264435,0.2700180115027076,0.351455132555483607},
587 {-55.2606,-45.135131022237303,-46.8314091470605973},
588 {-55.6226,-145.382167908057,-113.163790795259004},
589 {-79.5308,-74.0263331764599,-64.3088624157838069},
590 {45.6302,-35.6582611147917,-38.6501946851355029},
591 {0.0,0.0,-54.4333635973721002},
592 {0.0,0.0,-65.9030310445938028}
596 skyrme_load(sk,
"SLy4");
598 for(
size_t i=0;i<3;i++) {
600 for(
size_t j=0;j<13;j++) {
605 sk.alt_params_set(coups[0][i],coups[1][i],coups[2][i],coups[3][i],
606 coups[4][i],coups[5][i],coups[7][i],coups[8][i],
607 coups[9][i],coups[10][i],coups[6][i]);
609 cout <<
"n0: " << sk.n0 << endl;
610 cout <<
"L: " << sk.fesym_slope(sk.n0)*
hc_mev_fm << endl;
612 hf.open_or_create(((
string)
"UNEDF")+
szttos(i)+
".o2");
613 skyrme_write(hf,sk,((
string)
"UNEDF")+
szttos(i));
621 int load(vector<string> &sv,
bool itive_com) {
624 cout <<
"No model specified in 'load'." << endl;
629 skyrme_load(sk,name);
632 cout <<
"Loaded model '" << name <<
"'." << endl;
639 int run_all(vector<string> &sv,
bool itive_com) {
642 std::string mlist[200], stemp;
645 ifstream fin(fname.c_str());
647 for(
size_t i=0;i<nmods;i++) {
652 ofstream fouu(
"table.csv");
653 fouu <<
"Name, n0, B, K, ";
654 fouu <<
"S, L, Mmax, ";
655 fouu <<
"Rmax, nB_cent_max, R1.4, ";
656 fouu <<
"nB_cent_14, acausal, pressure_flat, ";
657 fouu <<
"neut_qual, max_mass_ok, ";
658 fouu <<
"inc_pressure, pos_neut, good_sat, ";
659 fouu <<
"pure_neut, other, success" << endl;
661 ofstream fout(
"table.html");
662 fout <<
"<html><body>" << endl;
663 fout <<
"<table border=0 cellspacing=0><tr bgcolor=\"#bbbbbb\">" << endl;
664 fout <<
"<td>Name </td>" << endl;
665 fout <<
"<td>n<sub>0</sub> (fm<sup>-3</sup>)"
666 <<
" </td>" << endl;
667 fout <<
"<td>B (MeV) </td>" << endl;
668 fout <<
"<td>K (MeV) </td>" << endl;
669 fout <<
"<td>S (MeV) </td>" << endl;
670 fout <<
"<td>L (MeV) </td>" << endl;
671 fout <<
"<td>M<sub>max</sub> (M<sub>sun</sub>)"
672 <<
" </td>" << endl;
673 fout <<
"<td>R<sub>max</sub> </td>" << endl;
674 fout <<
"<td>n<sub>B,cent,max</sub> </td>" << endl;
675 fout <<
"<td>R<sub>1.4</sub> </td>" << endl;
676 fout <<
"<td>n<sub>B,cent,1.4</sub> </td>" << endl;
677 fout <<
"<td>acausal </td>" << endl;
678 fout <<
"<td>pressure_flat </td>" << endl;
679 fout <<
"<td>neut_qual </td>" << endl;
680 fout <<
"<td>max_mass_ok </td>" << endl;
681 fout <<
"<td>inc_pressure </td>" << endl;
682 fout <<
"<td>pos_neut </td>" << endl;
683 fout <<
"<td>good_sat </td>" << endl;
684 fout <<
"<td>pure_neut </td>" << endl;
685 fout <<
"<td>other </td>" << endl;
686 fout <<
"<td>success </td>" << endl;
687 fout <<
"</tr>" << endl;
692 static const size_t N=66;
693 int list[N]={0,100,101,102,103,109,110,113,114,115,121,122,123,124,
694 125,126,127,128,129,130,131,132,133,134,135,145,147,17,1,
695 25,26,27,28,29,3,40,41,42,43,44,4,51,53,54,5,
696 62,63,64,64,66,67,68,69,6,71,73,75,76,77,7,81,82,84,
699 for(
size_t j=0;j<N;j++) {
705 cout <<
"Running model: " << i << endl;
708 tmp.push_back(mlist[i]);
726 ofstream fx(
"jim.dat",ios::app);
727 fx.setf(ios::scientific);
728 fx.setf(ios::showpos);
730 fx << mlist[i] <<
" ";
731 fx << res.S <<
" " << res.alt_S <<
" "
732 << res.E_neut_n0 <<
" " << res.P_neut_n0 <<
" "
734 fx << sk.t0 <<
" " << sk.t1 <<
" " << sk.t2 <<
" " << sk.t3 <<
" ";
735 fx << sk.x0 <<
" " << sk.x1 <<
" " << sk.x2 <<
" " << sk.x3 <<
" ";
736 fx << sk.alpha <<
" " << sk.n0 <<
" " << sk.comp*
hc_mev_fm <<
" ";
756 cout << sk.t0 <<
" " << sk.t1 <<
" " << sk.t2 <<
" " << sk.t3 << endl;
757 cout << sk.x0 <<
" " << sk.x1 <<
" " << sk.x2 <<
" " << sk.x3 << endl;
758 cout << res.good_sat << endl;
759 if (res.success==
true) {
760 fout <<
"<tr bgcolor=\"#dddddd\">";
766 fout <<
"<td><a href=\"http://o2scl.svn.sourceforge.net/viewvc/"
767 <<
"o2scl/trunk/data/o2scl/skdata/" << res.name
768 <<
"\">" << res.name <<
"</a></td>";
769 fout <<
"<td>" << fd.convert(res.n0) <<
"</td>";
770 fout <<
"<td>" << fd.convert(res.B) <<
"</td>";
771 fout <<
"<td>" << fd.convert(res.K) <<
"</td>";
772 fout <<
"<td>" << fd.convert(res.S) <<
"</td>";
773 fout <<
"<td>" << fd.convert(res.L) <<
"</td>";
774 fout <<
"<td>" << fd.convert(res.m_max) <<
"</td>";
775 fout <<
"<td>" << fd.convert(res.r_max) <<
"</td>";
776 fout <<
"<td>" << fd.convert(res.nb_max) <<
"</td>";
777 fout <<
"<td>" << fd.convert(res.r_14) <<
"</td>";
778 fout <<
"<td>" << fd.convert(res.nb_14) <<
"</td>";
779 fout <<
"<td>" << fd.convert(res.acausal) <<
"</td>";
780 fout <<
"<td>" << fd.convert(res.pressure_flat) <<
"</td>";
781 fout <<
"<td>" << fd.convert(res.neut_qual) <<
"</td>";
782 if (res.max_mass_ok) fout <<
"<td>True</td>";
783 else fout <<
"<td>False</td>";
784 if (res.inc_pressure) fout <<
"<td>True</td>";
785 else fout <<
"<td>False</td>";
786 if (res.pos_neut) fout <<
"<td>True</td>";
787 else fout <<
"<td>False</td>";
788 if (res.good_sat) fout <<
"<td>True</td>";
789 else fout <<
"<td>False</td>";
790 if (res.pure_neut) fout <<
"<td>True</td>";
791 else fout <<
"<td>False</td>";
792 fout <<
"<td>" << res.other <<
"</td>";
793 if (res.success) fout <<
"<td>True</td>";
794 else fout <<
"<td>False</td>";
795 fout <<
"</tr>" << endl;
798 fouu << res.name <<
", ";
799 fouu << res.n0 <<
", ";
800 fouu << res.B <<
", ";
801 fouu << res.K <<
", ";
802 fouu << res.S <<
", ";
803 fouu << res.L <<
", ";
804 fouu << res.m_max <<
", ";
805 fouu << res.r_max <<
", ";
806 fouu << res.nb_max <<
", ";
807 fouu << res.r_14 <<
", ";
808 fouu << res.nb_14 <<
", ";
809 fouu << res.acausal <<
", ";
810 fouu << res.pressure_flat <<
", ";
811 fouu << res.neut_qual <<
", ";
812 if (res.max_mass_ok) fouu <<
"True, ";
813 else fouu <<
"False, ";
814 if (res.inc_pressure) fouu <<
"True, ";
815 else fouu <<
"False, ";
816 if (res.pos_neut) fouu <<
"True, ";
817 else fouu <<
"False, ";
818 if (res.good_sat) fouu <<
"True, ";
819 else fouu <<
"False, ";
820 if (res.pure_neut) fouu <<
"True, ";
821 else fouu <<
"False, ";
822 fouu << res.other <<
", ";
823 if (res.success) fouu <<
"True ";
824 else fouu <<
"False ";
830 fout <<
"</table></body></html>" << endl;
842 int main(
int argv,
char *argc[]) {
844 cout.setf(ios::scientific);
852 cl.
prompt=
"ex_eos_had_skyrme> ";
854 int comm_option_cl_param=1;
855 int comm_option_both=2;
857 static const int narr=6;
859 {0,
"run-all",
"Run all internally stored Skyrme models.",0,0,
"",
"",
862 {
's',
"store",
"Store current model.",1,1,
"",
"",
865 {
'l',
"load",
"Load internally stored model.",1,1,
"",
"",
868 {0,
"unedf",
"Desc.",0,0,
"",
"",
871 {
't',
"test",
"Test ex_eos_had_skyrme.",0,0,
"",
"",
874 {
'u',
"summary",
"Summarize the properties of a Skyrme model.",
887 p_verbose.
i=&se.verbose;
888 p_verbose.
help=
"Verbose (default 1).";
889 cl.
par_list.insert(make_pair(
"verbose",&p_verbose));
892 p_output_files.
b=&se.output_files;
893 p_output_files.
help=
"Output files (default 0).";
894 cl.
par_list.insert(make_pair(
"output-files",&p_output_files));
897 p_file_prefix.
str=&se.file_prefix;
898 p_file_prefix.
help=
"File prefix (default \"\").";
899 cl.
par_list.insert(make_pair(
"file-prefix",&p_file_prefix));
903 p_name.
help=
"Model name (default \"\").";
904 cl.
par_list.insert(make_pair(
"name",&p_name));
907 p_reference.
str=&se.sk.reference;
908 p_reference.
help=
"Model reference (default \"\").";
909 cl.
par_list.insert(make_pair(
"reference",&p_reference));
913 p_t0hc.
help=
"Model parameter t0 in MeV.";
914 cl.
par_list.insert(make_pair(
"t0hc",&p_t0hc));
918 p_t1hc.
help=
"Model parameter t1 in MeV.";
919 cl.
par_list.insert(make_pair(
"t1hc",&p_t1hc));
923 p_t2hc.
help=
"Model parameter t2 in MeV.";
924 cl.
par_list.insert(make_pair(
"t2hc",&p_t2hc));
928 p_t3hc.
help=
"Model parameter t3 in MeV.";
929 cl.
par_list.insert(make_pair(
"t3hc",&p_t3hc));
933 p_x0.
help=
"Model parameter x0.";
934 cl.
par_list.insert(make_pair(
"x0",&p_x0));
938 p_x1.
help=
"Model parameter x1.";
939 cl.
par_list.insert(make_pair(
"x1",&p_x1));
943 p_x2.
help=
"Model parameter x2.";
944 cl.
par_list.insert(make_pair(
"x2",&p_x2));
948 p_x3.
help=
"Model parameter x3.";
949 cl.
par_list.insert(make_pair(
"x3",&p_x3));
953 p_a.
help=
"Model parameter a.";
954 cl.
par_list.insert(make_pair(
"a",&p_a));
958 p_b.
help=
"Model parameter b.";
959 cl.
par_list.insert(make_pair(
"b",&p_b));
963 p_W0hc.
help=
"Model parameter W0hc.";
964 cl.
par_list.insert(make_pair(
"W0hc",&p_W0hc));
967 p_alpha.
d=&se.sk.alpha;
968 p_alpha.
help=
"Model parameter alpha.";
969 cl.
par_list.insert(make_pair(
"alpha",&p_alpha));
973 p_b4.
help=
"Model parameter b4.";
974 cl.
par_list.insert(make_pair(
"b4",&p_b4));
978 p_b4p.
help=
"Model parameter b4p.";
979 cl.
par_list.insert(make_pair(
"b4p",&p_b4p));
bool max_mass_ok
True if the maximum mass is large enough.
string name
Name of model.
bool good_sat
True if saturation is good.
Naive static cold neutron star.
ex_skyrme_data res
Results.
double neut_qual
Quality of neutron matter.
int check_pressure()
Check if the pressure of neutron matter is positive.
void compare_neut_nstar()
Generate a table comparing neutron matter and neutron star matter.
Class to analyze Skyrme EOSs and output the results [Example class].
virtual double convert(std::string from, std::string to, double val)
int verbose
Verbose parameter.
lib_settings_class o2scl_settings
const double mass_neutron
std::string get_data_dir()
int saturation_prop()
Test saturation density.
format_float fd
Formatting output.
void hdf_output(hdf_file &hf, o2scl::table3d &h, std::string name)
int run_auto(int argc, char *argv[], int debug=0)
double pressure_flat
True if the pressure is flat.
double L
Symmetry energy slope parameter.
double nb_14
Central baryon density of a 1.4 solar mass neutron star.
double r_max
Radius of maximum mass star.
double t2hc
Parameter t2 in MeV.
double W0hc
Parameter W0 in MeV.
int test(vector< string > &sv, bool itive_com)
Test the code.
double acausal
True if the EOS is acausal.
double interp(std::string sx, double x0, std::string sy)
int store(vector< string > &sv, bool itive_com)
Write to a file.
int load(vector< string > &sv, bool itive_com)
Load internally stored model.
double r_14
Radius of a 1.4 solar mass star.
double alt_S
Alternate description of symmetry energy.
void line_of_names(std::string newheads)
table_units tneut
Neutron matter.
eos_had_skyrme sk
Base EOS model.
convert_units & get_convert_units()
bool output_files
If true, create output files for individual EOSs.
void line_of_data(size_t nv, const vec2_t &v)
int unedf(vector< string > &sv, bool itive_com)
Desc.
virtual void add_constant(std::string name, double val)
int set_comm_option_vec(size_t list_size, vec_t &option_list)
Skyrme hadronic equation of state.
double m_max
Maximum mass.
double P_neut_n0
Pressure of neutron matter at saturation.
double t0hc
Parameter t0 in MeV.
double nb_max
Central baryon density of maximum mass star.
Output data for a Skyrme EOS [Example class].
double t3hc
Parameter t3 in MeV.
table_units tneut2
Neutron matter.
bool inc_pressure
True if the pressure is nondecreasing.
double n0
Saturation density.
double t1hc
Parameter t1 in MeV.
int summary(vector< string > &sv, bool itive_com)
Summarize the results of one model.
std::map< std::string, parameter *, string_comp > par_list
void set_output_level(int l)
string file_prefix
Prefix for output files.
double b4phc
Parameter b4p.
const double mass_electron
nstar_cold nst
To compute neutron stars.
int run_all(vector< string > &sv, bool itive_com)
Run all the models.
int low_neutron_mat()
Check low-density neutron matter.
bool pos_neut
True if neutron matter is always positive.
std::string szttos(size_t x)
bool test_rel(double result, double expected, double rel_error, std::string description)
double E_neut_n0
Energy of neutron matter at saturation.
int mvsr()
Compute the M vs. R curve.