All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
ex_eos_had_skyrme.cpp
Go to the documentation of this file.
1 /*
2  -------------------------------------------------------------------
3 
4  Copyright (C) 2006-2014, Andrew W. Steiner
5 
6  This file is part of O2scl.
7 
8  O2scl is free software; you can redistribute it and/or modify
9  it under the terms of the GNU General Public License as published by
10  the Free Software Foundation; either version 3 of the License, or
11  (at your option) any later version.
12 
13  O2scl is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with O2scl. If not, see <http://www.gnu.org/licenses/>.
20 
21  -------------------------------------------------------------------
22 */
23 /** \file ex_eos_had_skyrme.cpp
24  \brief File defining \ref ex_eos_had_skyrme class
25 */
26 /* Example: ex_eos_had_skyrme.cpp
27  -------------------------------------------------------------------
28 */
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>
39 
40 using namespace std;
41 using namespace o2scl;
42 using namespace o2scl_const;
43 using namespace o2scl_hdf;
44 
45 /** \brief Output data for a Skyrme EOS [Example class]
46  */
48 
49 public:
50 
51  /// Name of model
52  string name;
53  /// Saturation density
54  double n0;
55  /// Binding energy
56  double B;
57  /// Compressibility
58  double K;
59  /// Symmetry energy
60  double S;
61  /// Symmetry energy slope parameter
62  double L;
63  /// Maximum mass
64  double m_max;
65  /// Radius of maximum mass star
66  double r_max;
67  /// Central baryon density of maximum mass star
68  double nb_max;
69  /// Radius of a 1.4 solar mass star
70  double r_14;
71  /// Central baryon density of a 1.4 solar mass neutron star
72  double nb_14;
73  /// True if the EOS is acausal
74  double acausal;
75  /// True if the pressure is flat
76  double pressure_flat;
77  /// Quality of neutron matter
78  double neut_qual;
79  /// True if the maximum mass is large enough
81  /// True if the pressure is nondecreasing
83  /// True if neutron matter is always positive
84  bool pos_neut;
85  /// True if saturation is good
86  bool good_sat;
87  /// Desc
88  double pure_neut;
89  /// Desc
90  int other;
91  /// Desc
92  bool success;
93  /// Alternate description of symmetry energy
94  double alt_S;
95  /// Energy of neutron matter at saturation
96  double E_neut_n0;
97  /// Pressure of neutron matter at saturation
98  double P_neut_n0;
99 };
100 
101 /** \brief Class to analyze Skyrme EOSs and output the results
102  [Example class]
103  */
105 
106 protected:
107 
108  /// To compute neutron stars
110 
111  /// Neutron
113 
114  /// Proton
116 
117  /// Thermodynamics
119 
120  /// File for I/O
122 
123  /// Results
125 
126  /// Formatting output
128 
129  /// Neutron matter
131 
132  /// Neutron matter
134 
135 public:
136 
137  /// Base EOS model
139 
140  /// Model name
141  string name;
142 
143  /// Parameter t0 in MeV
144  double t0hc;
145 
146  /// Parameter t1 in MeV
147  double t1hc;
148 
149  /// Parameter t2 in MeV
150  double t2hc;
151 
152  /// Parameter t3 in MeV
153  double t3hc;
154 
155  /// Parameter W0 in MeV
156  double W0hc;
157 
158  /// Parameter b4
159  double b4hc;
160 
161  /// Parameter b4p
162  double b4phc;
163 
164  /// Verbose parameter
165  int verbose;
166 
167  /// If true, create output files for individual EOSs
169 
170  /// Prefix for output files
171  string file_prefix;
172 
174 
175  // Ensure that this works without GNU units
177 
179  ("kg","1/fm",o2scl_mks::mass_neutron),2.0);
181  ("kg","1/fm",o2scl_mks::mass_proton),2.0);
182  n.non_interacting=false;
183  p.non_interacting=false;
184  nst.set_n_and_p(n,p);
185  nst.set_eos(sk);
186  nst.def_eos_tov.verbose=0;
187  nst.def_tov.verbose=0;
188  nst.include_muons=true;
189  verbose=1;
190 
191  fd.html_mode();
192 
193  output_files=false;
194  file_prefix="skyrme_";
195  }
196 
197  /** \brief Generate a table comparing neutron matter and neutron
198  star matter
199  */
201 
202  tneut.clear_table();
203  tneut2.clear_table();
204 
205  tneut.new_column("nb");
206  tneut.new_column("pr_neut");
207  tneut.new_column("pr_nstar");
208 
209  tneut2.new_column("ed");
210  tneut2.new_column("pr_neut");
211  tneut2.new_column("pr_nstar");
212 
213  tneut.set_unit("nb","fm^-3");
214  tneut.set_unit("pr_neut","fm^-4");
215  tneut.set_unit("pr_nstar","fm^-4");
216 
217  tneut2.set_unit("ed","fm^-4");
218  tneut2.set_unit("pr_neut","fm^-4");
219  tneut2.set_unit("pr_nstar","fm^-4");
220 
221  for(double nbt=0.06;nbt<0.9001;nbt+=0.02) {
222  n.n=nbt;
223  p.n=0;
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);
229  }
230 
231  return;
232  }
233 
234  /// Check if the pressure of neutron matter is positive
236  bool failed_once=false;
237 
238  res.pos_neut=true;
239  res.inc_pressure=true;
240 
241  double prlast=0.0;
242  for(double nbt=0.005;nbt<0.1601 && failed_once==false;nbt+=0.01) {
243  n.n=nbt;
244  p.n=0;
245  int ret=sk.calc_e(n,p,th);
246 
247  if (th.pr<prlast) {
248  res.inc_pressure=false;
249  res.success=false;
250  prlast=th.pr;
251  }
252  if (th.ed-n.n*n.m<0.0) {
253  res.pos_neut=false;
254  res.success=false;
255  }
256  }
257  if (verbose>0) {
258  if (failed_once==false) {
259  cout << "Pressure increases and energy of neutrons is positive.\n"
260  << endl;
261  } else {
262  cout << "Pressure decreased or energy of neutrons is negative.\n"
263  << endl;
264  }
265  }
266  return 0;
267  }
268 
269  /// Check low-density neutron matter
271 
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};
274 
275  table_units<> ln;
276  ln.line_of_names("nb epb kf fermi rat");
277  if (verbose>0) cout << "Low density neutron matter: " << endl;
278  for(double nbt=0.000003;nbt<0.0051;nbt*=1.2) {
279  n.n=nbt;
280  p.n=0;
281  int ret=sk.calc_e(n,p,th);
282 
283  // The APR energy per baryon
284  double epb=(th.ed-n.n*n.m)/nbt*hc_mev_fm;
285 
286  // The Fermi gas energy per baryon
287  double fermi=pow(n.kf,5.0)/10.0/o2scl_const::pi2/n.ms/nbt*hc_mev_fm;
288 
289  if (verbose>1) {
290  cout << nbt << " " << epb << " "
291  << n.kf << " " << fermi << " " << epb/fermi << endl;
292  }
293  double line[5]={nbt,epb,n.kf,fermi,epb/fermi};
294  ln.line_of_data(5,line);
295  }
296  if (verbose>1) cout << endl;
297 
298  // At the saturation density, evaluate the properties of
299  // neutron matter
300  n.n=sk.n0;
301  p.n=0.0;
302  sk.calc_e(n,p,th);
303  res.E_neut_n0=(th.ed/sk.n0-n.m)*hc_mev_fm;
304  res.P_neut_n0=th.pr*hc_mev_fm;
305 
306  res.neut_qual=0.0;
307  for(size_t i=0;i<4;i++) {
308  if (verbose>0) {
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;
312  }
313  res.neut_qual+=g_kf[i]*fabs(g_rat[i]-ln.interp("kf",g_kf[i],"rat"));
314  }
315  ln.add_constant("neut_qual",res.neut_qual);
316  if (verbose>0) {
317  cout << "Quality: " << res.neut_qual << endl;
318  cout << endl;
319  }
320 
321  return 0;
322  }
323 
324  /// Test saturation density
326 
327  n.n=0.08;
328  p.n=0.08;
329  sk.saturation();
330 
331  // Collect saturation results
332  res.n0=sk.n0;
333  res.B=sk.eoa*hc_mev_fm;
334  res.K=sk.comp*hc_mev_fm;
335  res.S=sk.esym*hc_mev_fm;
336  res.alt_S=sk.fesym_diff(sk.n0)*hc_mev_fm;
337  res.L=sk.fesym_slope(sk.n0)*hc_mev_fm;
338 
339  if (verbose>0) {
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;
348  cout << endl;
349  }
350 
351  // Check saturation properties
352 
353  res.good_sat=true;
354 
355  if (fabs(sk.n0-0.16)>0.013) {
356  res.good_sat=false;
357  }
358  if (fabs(sk.eoa*hc_mev_fm+16.0)>1.2) {
359  res.good_sat=false;
360  }
361  if (fabs(sk.comp*hc_mev_fm-220.0)>20.0) {
362  res.good_sat=false;
363  }
364  if (fabs(sk.esym*hc_mev_fm-32.0)>4.0) {
365  res.good_sat=false;
366  }
367  if (res.good_sat==false) {
368  cout << "Bad saturation." << endl;
369  res.success=false;
370  }
371 
372  return 0;
373  }
374 
375  /// Compute the M vs. R curve
376  int mvsr() {
377 
378  res.other=0;
379 
380  cout << "EOS:" << endl;
381  {
382  double nb_last=10.0;
383  sk.mu_at_zero_density=true;
384  for(double nb=0.16;nb<=2.0001;nb+=0.001) {
385  p.n=0.0;
386  n.n=nb-p.n;
387  sk.calc_e(n,p,th);
389  ("kg","1/fm",o2scl_mks::mass_electron);
390  if (n.mu-p.mu-me<0.0) {
391  nb_last=nb-0.001;
392  nb=2.1;
393  }
394  }
395  sk.mu_at_zero_density=false;
396  if (nb_last<10.0) {
397  cout << "Pure neutron matter after nb=" << nb_last << endl;
398  nst.nb_end=nb_last;
399  } else {
400  nst.nb_end=2.0;
401  }
402  }
403  nst.calc_eos();
404  cout << endl;
405 
406  cout << "Neutron stars:" << endl;
407  nst.calc_nstar();
408  o2_shared_ptr<table_units<> >::type te=nst.get_eos_results();
409  o2_shared_ptr<table_units<> >::type tr=nst.get_tov_results();
410 
411  if (output_files) {
412  // Output EOS and M vs. R curve to file
413  string fn=file_prefix+res.name+"_eos.o2";
414  hf.open_or_create(fn.c_str());
415  hdf_output(hf,*te,"eos");
416  hf.close();
417  fn=file_prefix+res.name+"_mvsr.o2";
418  hf.open_or_create(fn.c_str());
419  hdf_output(hf,*tr,"mvsr");
420  hf.close();
421  }
422 
423  if (verbose>0) {
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;
428  cout << "R_{1.4} = "
429  << tr->get("r",tr->lookup("gm",1.4)) << " cent. density = "
430  << tr->get("nb",tr->lookup("gm",1.4)) << endl;
431  }
432 
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));
438 
439  // Fix the maximum density to check if necessary
440  double nbtop=res.nb_max;
441  if (nbtop>2.0) nbtop=2.0;
442  if (nbtop<0.4) nbtop=0.7;
443 
444  // Check for pure neutron matter, now that we have the central
445  // density of the maximum mass star. If we find pure neutron
446  // matter, set the neutron star parameters to zero since they're
447  // likely invalid.
448  res.pure_neut=true;
449  for(double nb=0.1;nb<=nbtop;nb+=0.01) {
450  if (te->get("np",te->lookup("nb",nb))<1.0e-5) {
451  res.success=false;
452  res.m_max=0.0;
453  res.r_max=0.0;
454  res.nb_max=0.0;
455  res.r_14=0.0;
456  res.nb_14=0.0;
457  res.pure_neut=false;
458  }
459  }
460 
461  // Check that the maximum mass is larger than 1.6
462  res.max_mass_ok=true;
463  if (tr->max("gm")<1.6) {
464  res.max_mass_ok=false;
465  res.success=false;
466  }
467 
468  // Find where the EOS becomes acausal
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;
475  res.success=false;
476  }
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;
481  res.success=false;
482  }
483 
484  if (verbose>0) {
485  cout << endl;
486  }
487 
488  return 0;
489  }
490 
491  /// Summarize the results of one model
492  int summary(vector<string> &sv, bool itive_com) {
493  if (sv.size()<1) {
494  cout << "No model to summarize." << endl;
495  return exc_einval;
496  }
497 
498  cout << "Model: " << sv[1] << endl;
499  cout << "-----------------------------------------------------"
500  << "-----------------------" << endl;
501  cout << endl;
502 
503  skyrme_load(sk,sv[1]);
504  name=sv[1];
505  res.name=sv[1];
506 
507  W0hc=sk.W0*hc_mev_fm;
508  t0hc=sk.t0*hc_mev_fm;
509  t1hc=sk.t1*hc_mev_fm;
510  t2hc=sk.t2*hc_mev_fm;
511  t3hc=sk.t3*hc_mev_fm;
512 
513  nst.verbose=0;
514  nst.nb_end=1.18;
515 
516  saturation_prop();
517  check_pressure();
518  low_neutron_mat();
519 
520  compare_neut_nstar();
521 
522  mvsr();
523 
524  cout << "-----------------------------------------------------"
525  << "-----------------------" << endl;
526 
527  return 0;
528  }
529 
530  /// Test the code
531  int test(vector<string> &sv, bool itive_com) {
532  test_mgr t;
533  t.set_output_level(1);
534 
535  bool of_old=output_files;
536  output_files=true;
537 
538  // Just summarize SLy4
539  vector<string> args;
540  args.push_back("summary");
541  args.push_back("SLy4");
542  summary(args,0);
543 
544  // And compare to expected results
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");
548 
549  t.report();
550 
551  output_files=of_old;
552 
553  return 0;
554  }
555 
556  /// Write to a file
557  int store(vector<string> &sv, bool itive_com) {
558 
559  if (sv.size()<2) {
560  cout << "No filename specified in 'store'." << endl;
561  return exc_efailed;
562  }
563 
564  hf.open_or_create(sv[1]);
565  skyrme_write(hf,sk,name);
566  hf.close();
567 
568  if (verbose>0) {
569  cout << "Wrote model '" << name << "' to file named '"
570  << sv[1] << "'." << endl;
571  }
572 
573  return 0;
574  }
575 
576  /// Desc
577  int unedf(vector<string> &sv, bool itive_com) {
578 
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}
593  };
594 
595  // Why is this necessary?
596  skyrme_load(sk,"SLy4");
597 
598  for(size_t i=0;i<3;i++) {
599  // Convert to O2scl units
600  for(size_t j=0;j<13;j++) {
601  if (j!=6) {
602  coups[j][i]/=hc_mev_fm;
603  }
604  }
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]);
608  sk.saturation();
609  cout << "n0: " << sk.n0 << endl;
610  cout << "L: " << sk.fesym_slope(sk.n0)*hc_mev_fm << endl;
611 
612  hf.open_or_create(((string)"UNEDF")+szttos(i)+".o2");
613  skyrme_write(hf,sk,((string)"UNEDF")+szttos(i));
614  hf.close();
615  }
616 
617  return 0;
618  }
619 
620  /// Load internally stored model
621  int load(vector<string> &sv, bool itive_com) {
622 
623  if (sv.size()<2) {
624  cout << "No model specified in 'load'." << endl;
625  return exc_efailed;
626  }
627 
628  name=sv[1];
629  skyrme_load(sk,name);
630 
631  if (verbose>0) {
632  cout << "Loaded model '" << name << "'." << endl;
633  }
634 
635  return 0;
636  }
637 
638  /// Run all the models
639  int run_all(vector<string> &sv, bool itive_com) {
640 
641  size_t nmods=0;
642  std::string mlist[200], stemp;
643 
644  string fname=o2scl_settings.get_data_dir()+"/skdata/model_list";
645  ifstream fin(fname.c_str());
646  fin >> nmods;
647  for(size_t i=0;i<nmods;i++) {
648  fin >> mlist[i];
649  }
650  fin.close();
651 
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;
660 
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&nbsp;&nbsp;&nbsp;&nbsp;</td>" << endl;
665  fout << "<td>n<sub>0</sub>&nbsp;(fm<sup>-3</sup>)"
666  << "&nbsp;&nbsp;&nbsp;&nbsp;</td>" << endl;
667  fout << "<td>B&nbsp;(MeV)&nbsp;&nbsp;&nbsp;&nbsp;</td>" << endl;
668  fout << "<td>K&nbsp;(MeV)&nbsp;&nbsp;&nbsp;&nbsp;</td>" << endl;
669  fout << "<td>S&nbsp;(MeV)&nbsp;&nbsp;&nbsp;&nbsp;</td>" << endl;
670  fout << "<td>L&nbsp;(MeV)&nbsp;&nbsp;&nbsp;&nbsp;</td>" << endl;
671  fout << "<td>M<sub>max</sub>&nbsp;(M<sub>sun</sub>)"
672  << "&nbsp;&nbsp;&nbsp;&nbsp;</td>" << endl;
673  fout << "<td>R<sub>max</sub>&nbsp;&nbsp;&nbsp;&nbsp;</td>" << endl;
674  fout << "<td>n<sub>B,cent,max</sub>&nbsp;&nbsp;&nbsp;&nbsp;</td>" << endl;
675  fout << "<td>R<sub>1.4</sub>&nbsp;&nbsp;&nbsp;&nbsp;</td>" << endl;
676  fout << "<td>n<sub>B,cent,1.4</sub>&nbsp;&nbsp;&nbsp;&nbsp;</td>" << endl;
677  fout << "<td>acausal&nbsp;&nbsp;&nbsp;&nbsp;</td>" << endl;
678  fout << "<td>pressure_flat&nbsp;&nbsp;&nbsp;&nbsp;</td>" << endl;
679  fout << "<td>neut_qual&nbsp;&nbsp;&nbsp;&nbsp;</td>" << endl;
680  fout << "<td>max_mass_ok&nbsp;&nbsp;&nbsp;&nbsp;</td>" << endl;
681  fout << "<td>inc_pressure&nbsp;&nbsp;&nbsp;&nbsp;</td>" << endl;
682  fout << "<td>pos_neut&nbsp;&nbsp;&nbsp;&nbsp;</td>" << endl;
683  fout << "<td>good_sat&nbsp;&nbsp;&nbsp;&nbsp;</td>" << endl;
684  fout << "<td>pure_neut&nbsp;&nbsp;&nbsp;&nbsp;</td>" << endl;
685  fout << "<td>other&nbsp;&nbsp;&nbsp;&nbsp;</td>" << endl;
686  fout << "<td>success&nbsp;&nbsp;&nbsp;&nbsp;</td>" << endl;
687  fout << "</tr>" << endl;
688 
689  // Currently only models which don't give pure neutron matter work.
690  // This list rules out those which have pure neutron matter and
691  // the PeHF-type models which don't work.
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,
697  97,98,99};
698 
699  for(size_t j=0;j<N;j++) {
700 
701  size_t i=list[j];
702 
703  i=2;
704 
705  cout << "Running model: " << i << endl;
706  vector<string> tmp;
707  tmp.push_back("x");
708  tmp.push_back(mlist[i]);
709 
710  // These models are the ones that I used to compute pressure
711  // corrections for neutron -> neutron star matter
712  //
713  //if (mlist[i]=="SkT3" || mlist[i]=="SLy3" || mlist[i]=="SLy4" ||
714  //mlist[i]=="SLy7" || mlist[i]=="SLy230a" || mlist[i]=="SV-mas07" ||
715  //mlist[i]=="SV-sym34" || mlist[i]=="BSk9" || mlist[i]=="KDE0v" ||
716  //mlist[i]=="KDE0v1" || mlist[i]=="Ly5" || mlist[i]=="mst0.81" ||
717  //mlist[i]=="NRAPR" || mlist[i]=="SkMP" || mlist[i]=="BSk14" ||
718  //mlist[i]=="SkO" || mlist[i]=="SkOp" || mlist[i]=="SkT1") {
719 
720  {
721 
722  res.success=true;
723  summary(tmp,true);
724  exit(-1);
725 
726  ofstream fx("jim.dat",ios::app);
727  fx.setf(ios::scientific);
728  fx.setf(ios::showpos);
729  fx.width(10);
730  fx << mlist[i] << " ";
731  fx << res.S << " " << res.alt_S << " "
732  << res.E_neut_n0 << " " << res.P_neut_n0 << " "
733  << res.L << " ";
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 << " ";
737 
738  double c2;
739  {
740  double h=1.0e-4;
741  n.n=sk.n0-h;
742  p.n=0.0;
743  sk.calc_e(n,p,th);
744  double pr1=th.pr;
745  n.n=sk.n0+h;
746  p.n=0.0;
747  sk.calc_e(n,p,th);
748  double pr2=th.pr;
749  c2=(pr2-pr1)/2.0/h*9.0*hc_mev_fm;
750  }
751  fx << c2;
752 
753  fx << endl;
754  fx.close();
755 
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\">";
761  } else {
762  fout << "<tr>";
763  }
764 
765  // Output HTML row
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;
796 
797  // Output CSV row
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 ";
825  fouu << endl;
826 
827  }
828  }
829 
830  fout << "</table></body></html>" << endl;
831  fout.close();
832 
833  fouu.close();
834 
835 
836  return 0;
837  }
838 
839 };
840 
841 
842 int main(int argv, char *argc[]) {
843 
844  cout.setf(ios::scientific);
845 
847 
848  // ---------------------------------------
849  // Specify command-line option object
850 
851  cli cl;
852  cl.prompt="ex_eos_had_skyrme> ";
853 
854  int comm_option_cl_param=1;
855  int comm_option_both=2;
856 
857  static const int narr=6;
858  comm_option_s options_arr[narr]={
859  {0,"run-all","Run all internally stored Skyrme models.",0,0,"","",
861  comm_option_both},
862  {'s',"store","Store current model.",1,1,"","",
864  comm_option_both},
865  {'l',"load","Load internally stored model.",1,1,"","",
867  comm_option_both},
868  {0,"unedf","Desc.",0,0,"","",
870  comm_option_both},
871  {'t',"test","Test ex_eos_had_skyrme.",0,0,"","",
873  comm_option_both},
874  {'u',"summary","Summarize the properties of a Skyrme model.",
875  1,1,"<model>","",
877  comm_option_both}
878  };
879 
880  cl.set_comm_option_vec(narr,options_arr);
881  cl.cmd_name="ex_eos_had_skyrme";
882 
883  // ---------------------------------------
884  // Set the parameters
885 
886  cli::parameter_int p_verbose;
887  p_verbose.i=&se.verbose;
888  p_verbose.help="Verbose (default 1).";
889  cl.par_list.insert(make_pair("verbose",&p_verbose));
890 
891  cli::parameter_bool p_output_files;
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));
895 
896  cli::parameter_string p_file_prefix;
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));
900 
901  cli::parameter_string p_name;
902  p_name.str=&se.name;
903  p_name.help="Model name (default \"\").";
904  cl.par_list.insert(make_pair("name",&p_name));
905 
906  cli::parameter_string p_reference;
907  p_reference.str=&se.sk.reference;
908  p_reference.help="Model reference (default \"\").";
909  cl.par_list.insert(make_pair("reference",&p_reference));
910 
911  cli::parameter_double p_t0hc;
912  p_t0hc.d=&se.t0hc;
913  p_t0hc.help="Model parameter t0 in MeV.";
914  cl.par_list.insert(make_pair("t0hc",&p_t0hc));
915 
916  cli::parameter_double p_t1hc;
917  p_t1hc.d=&se.t1hc;
918  p_t1hc.help="Model parameter t1 in MeV.";
919  cl.par_list.insert(make_pair("t1hc",&p_t1hc));
920 
921  cli::parameter_double p_t2hc;
922  p_t2hc.d=&se.t2hc;
923  p_t2hc.help="Model parameter t2 in MeV.";
924  cl.par_list.insert(make_pair("t2hc",&p_t2hc));
925 
926  cli::parameter_double p_t3hc;
927  p_t3hc.d=&se.t3hc;
928  p_t3hc.help="Model parameter t3 in MeV.";
929  cl.par_list.insert(make_pair("t3hc",&p_t3hc));
930 
932  p_x0.d=&se.sk.x0;
933  p_x0.help="Model parameter x0.";
934  cl.par_list.insert(make_pair("x0",&p_x0));
935 
937  p_x1.d=&se.sk.x1;
938  p_x1.help="Model parameter x1.";
939  cl.par_list.insert(make_pair("x1",&p_x1));
940 
942  p_x2.d=&se.sk.x2;
943  p_x2.help="Model parameter x2.";
944  cl.par_list.insert(make_pair("x2",&p_x2));
945 
947  p_x3.d=&se.sk.x3;
948  p_x3.help="Model parameter x3.";
949  cl.par_list.insert(make_pair("x3",&p_x3));
950 
952  p_a.d=&se.sk.a;
953  p_a.help="Model parameter a.";
954  cl.par_list.insert(make_pair("a",&p_a));
955 
957  p_b.d=&se.sk.b;
958  p_b.help="Model parameter b.";
959  cl.par_list.insert(make_pair("b",&p_b));
960 
961  cli::parameter_double p_W0hc;
962  p_W0hc.d=&se.W0hc;
963  p_W0hc.help="Model parameter W0hc.";
964  cl.par_list.insert(make_pair("W0hc",&p_W0hc));
965 
966  cli::parameter_double p_alpha;
967  p_alpha.d=&se.sk.alpha;
968  p_alpha.help="Model parameter alpha.";
969  cl.par_list.insert(make_pair("alpha",&p_alpha));
970 
972  p_b4.d=&se.sk.b4;
973  p_b4.help="Model parameter b4.";
974  cl.par_list.insert(make_pair("b4",&p_b4));
975 
976  cli::parameter_double p_b4p;
977  p_b4p.d=&se.sk.b4p;
978  p_b4p.help="Model parameter b4p.";
979  cl.par_list.insert(make_pair("b4p",&p_b4p));
980 
981  // ---------------------------------------
982  // Process command-line options
983 
984  cl.run_auto(argv,argc);
985 
986  return 0;
987 }
988 
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.
double S
Symmetry energy.
hdf_file hf
File for I/O.
std::string cmd_name
const double mass_proton
Naive static cold neutron star.
Definition: nstar_cold.h:163
ex_skyrme_data res
Results.
double neut_qual
Quality of neutron matter.
string name
Model name.
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
thermo th
Thermodynamics.
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)
const double hc_mev_fm
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.
std::string prompt
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)
double K
Compressibility.
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 B
Binding energy.
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 pure_neut
Desc.
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
fermion n
Neutron.
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.
double b4hc
Parameter b4.
const double pi2
int mvsr()
Compute the M vs. R curve.

Documentation generated with Doxygen. Provided under the GNU Free Documentation License (see License Information).
Hosted at Get Object-oriented Scientific Computing
Lib at SourceForge.net. Fast, secure and Free Open Source software
downloads..