Loading [MathJax]/extensions/tex2jax.js
PeTar
N-body code for collisional gravitational systems
|
Go to the documentation of this file.
8 #include "../src/io.hpp"
51 #if (defined BSEBBF) || (defined BSEEMP)
119 void zcnsts_(
double* z,
double* zpars,
int* trackmode);
121 void zcnsts_(
double* z,
double* zpars);
128 void evolv1_(
int* kw,
double* mass,
double* mt,
double* r,
double* lum,
double* mc,
double* rc,
double* menv,
double* renv,
double* ospin,
129 double* epoch,
double* tm,
double* tphys,
double* tphysf,
double* dtp,
double* z,
double* zpars,
double* vs);
132 void evolv2_(
int* kw,
double* mass,
double* mt,
double* r,
double* lum,
double* mc,
double* rc,
double* menv,
double* renv,
double* ospin,
133 double* epoch,
double* tm,
double* tphys,
double* tphysf,
double* dtp,
double* z,
double* zpars,
134 double* period,
double* ecc,
double* bse_event,
double* vkick);
136 void star_(
int* kw,
double* mass,
double* mt,
double* tm,
double* tn,
double* tscls,
double* lums,
double* GB,
double* zpars);
138 void deltat_(
int* kw,
double* age,
double* tm,
double* tn,
double* tscls,
double*
dt,
double* dtr);
140 void trdot_(
int* kw,
double* m0,
double* mt,
double* r,
double* mc,
double* rc,
double* age,
double*
dt,
double* dtr,
double* zpars);
142 void trflow_(
int* kw,
double* m0,
double* mt,
double* r,
double* mc,
double* rc,
double* age,
double*
dt,
double* semi,
double* ecc,
double* zpars);
144 void mix_(
double* m0,
double* mt,
double* age,
int* kw,
double* zpars);
150 void merge_(
int* kw,
double* m0,
double* mt,
double* r,
double* mc,
double* rc,
double* menv,
double* renv,
double* ospin,
double* age,
double* semi,
double* ecc,
double* vkick,
double* zpars);
216 void zcnsts_(
double* z,
double* zpars);
222 void evolv1_(
int* kw,
double* mass,
double* mt,
double* r,
double* lum,
double* mc,
double* rc,
double* menv,
double* renv,
double* ospin,
223 double* epoch,
double* tm,
double* tphys,
double* tphysf,
double* dtp,
double* z,
double* zpars,
double* vkick);
226 void evolv2_(
int* kw,
double* mass,
double* mt,
double* r,
double* lum,
double* mc,
double* rc,
double* menv,
double* renv,
double* ospin,
227 double* epoch,
double* tm,
double* tphys,
double* tphysf,
double* dtp,
double* z,
double* zpars,
228 double* period,
double* ecc,
double* bse_event,
double* vkick);
230 void star_(
int* kw,
double* mass,
double* mt,
double* tm,
double* tn,
double* tscls,
double* lums,
double* GB,
double* zpars);
232 void deltat_(
int* kw,
double* age,
double* tm,
double* tn,
double* tscls,
double*
dt,
double* dtr);
234 void trdot_(
int* kw,
double* m0,
double* mt,
double* r,
double* mc,
double* rc,
double* age,
double*
dt,
double* dtr,
double* zpars);
236 void trflow_(
int* kw,
double* m0,
double* mt,
double* r,
double* mc,
double* rc,
double* age,
double*
dt,
double* semi,
double* ecc,
double* zpars);
240 void mix_(
double* m0,
double* mt,
double* age,
int* kw,
double* zpars,
int* krol);
246 void merge_(
int* kw,
double* m0,
double* mt,
double* r,
double* mc,
double* rc,
double* menv,
double* renv,
double* ospin,
double* age,
double* semi,
double* ecc,
double* vkick,
double* zpars);
276 void initial(
double _mass,
int _kw=1,
double _ospin=0.0,
double _epoch=0.0) {
292 fprintf(
fp,
"%lld %26.17e %26.17e %26.17e %26.17e %26.17e %26.17e %26.17e %26.17e %26.17e ",
293 this->kw, this->m0, this->mt, this->r, this->mc, this->rc, this->ospin, this->epoch, this->tphys, this->lum);
300 int rcount=fscanf(
fp,
"%lld %lf %lf %lf %lf %lf %lf %lf %lf %lf ",
301 &this->kw, &this->m0, &this->mt, &this->r, &this->mc, &this->rc, &this->ospin, &this->epoch, &this->tphys, & this->lum);
303 std::cerr<<
"Error: Data reading fails! requiring data number is 10, only obtain "<<rcount<<
".\n";
309 void print(std::ostream & fout)
const{
328 _fout<<std::setw(_width)<<
"s_type"
329 <<std::setw(_width)<<
"s_mass0[M*]"
330 <<std::setw(_width)<<
"s_mass[M*]"
331 <<std::setw(_width)<<
"s_rad[R*]"
332 <<std::setw(_width)<<
"s_mcore[M*]"
333 <<std::setw(_width)<<
"s_rcore[R*]"
334 <<std::setw(_width)<<
"s_spin"
335 <<std::setw(_width)<<
"s_epoch[Myr]"
336 <<std::setw(_width)<<
"s_time[Myr]"
337 <<std::setw(_width)<<
"s_lum[L*]";
345 void printColumn(std::ostream & _fout,
const int _width=20)
const{
346 _fout<<std::setw(_width)<<
kw
347 <<std::setw(_width)<<
m0
348 <<std::setw(_width)<<
mt
349 <<std::setw(_width)<<
r
350 <<std::setw(_width)<<
mc
351 <<std::setw(_width)<<
rc
352 <<std::setw(_width)<<
ospin
353 <<std::setw(_width)<<
epoch
354 <<std::setw(_width)<<
tphys
355 <<std::setw(_width)<<
lum;
365 int counter = _counter;
367 _fout<<std::setw(_offset)<<
" "<<counter<<
". s_type: SSE/BSE based code stellar type\n";
369 _fout<<std::setw(_offset)<<
" "<<counter<<
". s_mass0: initial mass at each evolution stage [Msun]\n";
371 _fout<<std::setw(_offset)<<
" "<<counter<<
". s_mass: current mass [Msun]\n";
373 _fout<<std::setw(_offset)<<
" "<<counter<<
". s_rad: stellar radius [Rsun]\n";
375 _fout<<std::setw(_offset)<<
" "<<counter<<
". s_mcore: stellar core mass [Msun]\n";
377 _fout<<std::setw(_offset)<<
" "<<counter<<
". s_rcore: stellar core radius [Rsun]\n";
379 _fout<<std::setw(_offset)<<
" "<<counter<<
". s_spin: stellar rotation\n";
381 _fout<<std::setw(_offset)<<
" "<<counter<<
". s_epoch: time offset at each evolution stage [Myr]\n";
383 _fout<<std::setw(_offset)<<
" "<<counter<<
". s_time: physical time [Myr]\n";
385 _fout<<std::setw(_offset)<<
" "<<counter<<
". s_lum: luminosity [Lsun]\n";
410 _fout<<std::setw(_width)<<
"type0"
411 <<std::setw(_width)<<
"m_CE[M*]"
412 <<std::setw(_width)<<
"r_CE[R*]"
413 <<std::setw(_width)<<
"t_MS[Myr]"
414 <<std::setw(_width)<<
"vk.x[km/s]"
415 <<std::setw(_width)<<
"vk.y[km/s]"
416 <<std::setw(_width)<<
"vk.z[km/s]"
417 <<std::setw(_width)<<
"vk[km/s]"
418 <<std::setw(_width)<<
"m_loss[M*]";
426 void printColumn(std::ostream & _fout,
const int _width=20)
const{
427 _fout<<std::setw(_width)<<
kw0
428 <<std::setw(_width)<<
menv
429 <<std::setw(_width)<<
renv
430 <<std::setw(_width)<<
tm
431 <<std::setw(_width)<<
vkick[0]
432 <<std::setw(_width)<<
vkick[1]
433 <<std::setw(_width)<<
vkick[2]
434 <<std::setw(_width)<<
vkick[3]
435 <<std::setw(_width)<<
dm;
439 void print(std::ostream & fout)
const{
440 fout<<
" type0= "<<
kw0
441 <<
" menv[M*]= "<<
menv
442 <<
" renv[R*]= "<<
renv
444 <<
" vk.x[km/s]= "<<
vkick[0]
445 <<
" vk.y[km/s]= "<<
vkick[1]
446 <<
" vk.z[km/s]= "<<
vkick[2]
447 <<
" vk[km/s]= "<<
vkick[3]
448 <<
" m_loss[M*]= "<<
dm;
458 static double EstimateRocheRadiusOverSemi(
double& _q) {
459 double p = std::pow(_q,1.0/3.0);
461 double rad_semi = 0.49*p2/(0.6*p2 + std::log(1.0+p));
478 double ecc2 = _ecc*_ecc;
479 double omecc2 = 1.0 - ecc2;
480 double sqome2 = std::sqrt(omecc2);
481 double sqome5 = std::pow(sqome2,5.0);
482 double semi2 = _semi*_semi;
484 double djgr = 8.315e-10*_star1.
mt*_star2.
mt*(_star1.
mt+_star2.
mt)/(semi2*semi2)*(1.0+0.875*ecc2)/sqome5;
485 double dtr = 1.0e-9/djgr*(1-_ecc);
507 record[5][_index] = _semi;
509 double q = _p1.
mt/_p2.
mt;
510 double rl1 = EstimateRocheRadiusOverSemi(q);
512 double rl2 = EstimateRocheRadiusOverSemi(q);
513 record[7][_index] = _p1.
r/(rl1*_semi);
514 record[8][_index] = _p2.
r/(rl2*_semi);
515 record[9][_index] = _type;
545 return int(
record[9][index]);
549 void print(std::ostream & fout,
const int index)
const{
550 fout<<
" t[Myr]= "<<
record[0][index]
551 <<
" m1[M*]= "<<
record[1][index]
552 <<
" m2[M*]= "<<
record[2][index]
553 <<
" type1= "<<int(
record[3][index])
554 <<
" type2= "<<int(
record[4][index])
555 <<
" semi[R*]= "<<
record[5][index]
556 <<
" ecc= "<<
record[6][index]
557 <<
" rad1[Ro]= "<<
record[7][index]
558 <<
" rad2[Ro]= "<<
record[8][index]
559 <<
" lum1[L*]= "<<
record[10][index]
560 <<
" lum2[L*]= "<<
record[11][index]
561 <<
" rad1[R*]= "<<
record[12][index]
562 <<
" rad2[R*]= "<<
record[13][index]
563 <<
" mc1[M*]= "<<
record[14][index]
564 <<
" mc2[M*]= "<<
record[15][index]
565 <<
" rc1[R*]= "<<
record[16][index]
566 <<
" rc2[R*]= "<<
record[17][index]
567 <<
" ospin1= "<<
record[18][index]
568 <<
" ospin2= "<<
record[19][index];
577 _fout<<std::setw(_width)<<
"t[Myr]"
578 <<std::setw(_width)<<
"m1[M*]"
579 <<std::setw(_width)<<
"m2[M*]"
580 <<std::setw(_width)<<
"type1"
581 <<std::setw(_width)<<
"type2"
582 <<std::setw(_width)<<
"semi[R*]"
583 <<std::setw(_width)<<
"ecc"
584 <<std::setw(_width)<<
"rad1[Ro]"
585 <<std::setw(_width)<<
"rad2[Ro]"
586 <<std::setw(_width)<<
"btype"
587 <<std::setw(_width)<<
"lum1[L*]"
588 <<std::setw(_width)<<
"lum2[L*]"
589 <<std::setw(_width)<<
"rad1[R*]"
590 <<std::setw(_width)<<
"rad2[R*]"
591 <<std::setw(_width)<<
"mc1[M*]"
592 <<std::setw(_width)<<
"mc2[M*]"
593 <<std::setw(_width)<<
"rc1[R*]"
594 <<std::setw(_width)<<
"rc2[R*]"
595 <<std::setw(_width)<<
"ospin1"
596 <<std::setw(_width)<<
"ospin2";
606 void printColumn(std::ostream & _fout,
const int _index,
const int _width=20)
const{
607 for (
int i=0; i<3; i++) _fout<<std::setw(_width)<<
record[i][_index];
608 for (
int i=3; i<5; i++) _fout<<std::setw(_width)<<int(
record[i][_index]);
609 for (
int i=5; i<9; i++) _fout<<std::setw(_width)<<
record[i][_index];
610 _fout<<std::setw(_width)<<int(
record[9][_index]);
611 for (
int i=10; i<20; i++) _fout<<std::setw(_width)<<
record[i][_index];
634 #if (defined BSEBBF) || (defined BSEEMP)
646 #if (defined BSEBBF) || (defined BSEEMP)
668 #if (defined BSEBBF) || (defined BSEEMP)
671 bwind (
input_par_store, 0.0,
"bse-bwind",
"Binary enhanced mass loss parameter; inactive for single"),
676 beta (
input_par_store, 0.125,
"bse-beta",
"wind velocity factor: proportional to vwind**2"),
679 epsnov(
input_par_store, 0.001,
"bse-epsnov",
"The fraction of accreted matter retained in nova eruption"),
681 gamma (
input_par_store, -1.0,
"bse-gamma",
"Angular momentum factor for mass lost during Roche"),
682 sigma (
input_par_store, 265.0,
"bse-sigma",
"Dispersion in the Maxwellian for the SN kick speed [km/s]"),
687 bhflag(
input_par_store, 2,
"bse-bhflag",
"BH kick option: 0: no kick; 1: same as NS; 2: scaled by fallback"),
688 nsflag(
input_par_store, 3,
"bse-nsflag",
"NS/BH foramtion options: 0: original SSE; 1: Belczynski (2002); 2: Belczynski (2008); 3: Fryer (2012) rapid SN; 4: Fryer (2012) delayed SN; 5: Eldridge & Tout (2004)"),
689 psflag(
input_par_store, 1,
"bse-psflag",
"PPSN condition (Belczynski 2016): 0: no PPSN; 1: strong; (Leung 2019): 2: moderate; 3: weak"),
690 kmech (
input_par_store, 1,
"bse-kmech",
"Kick mechanism: 1: standard momentum-conserving; 2: convection-asymmetry-driven; 3: collapse-asymmerty-driven; 4: neutrino driven"),
696 trackmode(
input_par_store, 2,
"bse-trackmode",
"star evolution option, need to make a soft link to the data directory in bse-interface/bseEmp/emptrack/: 1: L model (larger overshoot; directory name: ffbonn); 2: M model (smaller overshoot; directory name: ffgeneva); See details in Appendix A of Tanikawa et al. (2022, ApJ, 926, 83)"),
699 tscale(
input_par_store, 1.0,
"bse-tscale",
"Time scale factor from input data unit (IN) to Myr (time[Myr]=time[IN]*tscale)"),
700 rscale(
input_par_store, 1.0,
"bse-rscale",
"Radius scale factor from input data unit (IN) to Rsun (r[Rsun]=r[IN]*rscale)"),
701 mscale(
input_par_store, 1.0,
"bse-mscale",
"Mass scale factor from input data unit (IN) to Msun (m[Msun]=m[IN]*mscale)"),
702 vscale(
input_par_store, 1.0,
"bse-vscale",
"Velocity scale factor from input data unit(IN) to km/s (v[km/s]=v[IN]*vscale)"),
704 z (
input_par_store, 0.001,
"bse-metallicity",
"Metallicity Z, ranging from 0 to 0.03; when Z<0.0001, using EMP track, please make a symbolic link in the simulation directory to the track directory according to the --bse-trackmode option"),
706 z (
input_par_store, 0.001,
"bse-metallicity",
"Metallicity Z, ranging from 0.0001 to 0.03"),
712 bwind (
input_par_store, 0.0,
"mobse-wind",
"Binary enhanced mass loss parameter; inactive for single"),
717 beta (
input_par_store, 0.125,
"mobse-beta",
"wind velocity factor: proportional to vwind**2"),
720 epsnov(
input_par_store, 0.001,
"mobse-epsnov",
"The fraction of accreted matter retained in nova eruption"),
722 gamma (
input_par_store, -1.0,
"mobse-gamma",
"Angular momentum factor for mass lost during Roche"),
723 sigma1 (
input_par_store, 265.0,
"mobse-sigma1",
"Dispersion in the Maxwellian for the CCSN kick speed [km/s]"),
724 sigma2 (
input_par_store, 265.0,
"mobse-sigma2",
"Dispersion in the Maxwellian for the ECSN kick speed [km/s]"),
729 bhflag(
input_par_store, 3,
"mobse-bhflag",
"BH kick option: 0: no kick; 1: same as NS; 2: scaled by fallback; 3: Giacobbo&Mapelli (2020)"),
730 nsflag(
input_par_store, 3,
"mobse-nsflag",
"NS/BH formation options: 0: original SSE; 1: Belczynski (2008); 2: Fryer (2012) rapid SN; 3: Fryer (2012) delayed SN; 4: Belczynski (2008); 5: no SN explosion"),
731 piflag(
input_par_store, 1,
"mobse-piflag",
"PPSN condition (Spera et al. 2015)"),
739 tscale(
input_par_store, 1.0,
"mobse-tscale",
"Time scale factor from input data unit (IN) to Myr (time[Myr]=time[IN]*tscale)"),
740 rscale(
input_par_store, 1.0,
"mobse-rscale",
"Radius scale factor from input data unit (IN) to Rsun (r[Rsun]=r[IN]*rscale)"),
741 mscale(
input_par_store, 1.0,
"mobse-msclae",
"Mass scale factor from input data unit (IN) to Msun (m[Msun]=m[IN]*mscale)"),
742 vscale(
input_par_store, 1.0,
"mobse-vsclae",
"Velocity scale factor from input data unit(IN) to km/s (v[km/s]=v[IN]*vscale)"),
754 int read(
int argc,
char *argv[],
const int opt_used_pre=0) {
755 static int sse_flag=-1;
756 const struct option long_options[] = {
757 {
neta.
key, required_argument, &sse_flag, 0},
758 {
bwind.
key, required_argument, &sse_flag, 1},
759 {
hewind.
key, required_argument, &sse_flag, 2},
761 {
alpha.
key, required_argument, &sse_flag, 22},
762 {
lambda.
key, required_argument, &sse_flag, 23},
763 {
beta.
key, required_argument, &sse_flag, 24},
764 {
xi.
key, required_argument, &sse_flag, 25},
765 {
bhwacc.
key, required_argument, &sse_flag, 26},
766 {
epsnov.
key, required_argument, &sse_flag, 27},
767 {
eddfac.
key, required_argument, &sse_flag, 28},
768 {
gamma.
key, required_argument, &sse_flag, 29},
769 #if (defined BSEBBF) || (defined BSEEMP)
770 {sigma.
key, required_argument, &sse_flag, 4},
772 {sigma1.
key, required_argument, &sse_flag, 4},
773 {sigma2.
key, required_argument, &sse_flag, 5},
776 {
ceflag.
key, required_argument, &sse_flag, 6},
777 {
tflag.
key, required_argument, &sse_flag, 7},
778 {
wdflag.
key, required_argument, &sse_flag, 8},
779 {
bhflag.
key, required_argument, &sse_flag, 9},
780 {
nsflag.
key, required_argument, &sse_flag, 10},
781 #if (defined BSEBBF) || (defined BSEEMP)
782 {psflag.
key, required_argument, &sse_flag, 11},
783 {kmech.
key, required_argument, &sse_flag, 12},
784 {ecflag.
key, required_argument, &sse_flag, 13},
786 {piflag.
key, required_argument, &sse_flag, 11},
788 {
pts1.
key, required_argument, &sse_flag, 14},
789 {
pts2.
key, required_argument, &sse_flag, 15},
790 {
pts3.
key, required_argument, &sse_flag, 16},
792 {trackmode.
key, required_argument, &sse_flag, 30},
794 {
idum.
key, required_argument, &sse_flag, 17},
795 {
tscale.
key, required_argument, &sse_flag, 18},
796 {
rscale.
key, required_argument, &sse_flag, 19},
797 {
mscale.
key, required_argument, &sse_flag, 20},
798 {
vscale.
key, required_argument, &sse_flag, 21},
799 {
z.
key, required_argument, 0,
'z'},
800 {
"help", no_argument, 0,
'h'},
804 int opt_used=opt_used_pre;
807 std::string fname_par;
809 while ((copt = getopt_long(argc, argv,
"-z:p:h", long_options, &option_index)) != -1)
832 #if (defined BSEBBF) || (defined BSEEMP)
834 sigma.
value = atof(optarg);
840 sigma1.
value = atof(optarg);
845 sigma2.
value = atof(optarg);
875 #if (defined BSEBBF) || (defined BSEEMP)
877 psflag.
value = atof(optarg);
882 kmech.
value = atof(optarg);
887 ecflag.
value = atof(optarg);
893 piflag.
value = atof(optarg);
980 trackmode.
value = atoi(optarg);
998 std::string fbse_par = fname_par+
".bse";
1000 std::string fbse_par = fname_par+
".mobse";
1002 std::string fbse_par = fname_par+
".bseEmp";
1005 if( (fpar_in = fopen(fbse_par.c_str(),
"r")) == NULL) {
1006 fprintf(stderr,
"Error: Cannot open file %s.\n", fbse_par.c_str());
1013 #ifdef PARTICLE_SIMULATOR_MPI_PARALLEL
1015 PS::Comm::barrier();
1021 std::cout<<
"SSE/BSE options:"<<std::endl;
1023 std::cout<<
"MOBSE options:"<<std::endl;
1025 std::cout<<
"BSEEMP options:"<<std::endl;
1038 if(
print_flag) std::cout<<
"----- Finish reading input options of SSE/BSE -----\n";
1040 if(
print_flag) std::cout<<
"----- Finish reading input options of MOBSE -----\n";
1042 if(
print_flag) std::cout<<
"----- Finish reading input options of BSEEMP -----\n";
1072 single_type{
"LMS",
"MS",
"HG",
"GB",
"CHeB",
"FAGB",
"SAGB",
"HeMS",
"HeHG",
"HeGB",
"HeWD",
"COWD",
"ONWD",
"NS",
"BH",
"SN"},
1093 assert(trackmode>0);
1105 if( (fin = fopen(_fname,
"w")) == NULL) {
1106 fprintf(stderr,
"Error: Cannot open file %s.\n", _fname);
1109 fprintf(fin,
"%d %d %d ", value3_.idum, rand3_.idum2, rand3_.iy);
1110 for (
int i=0; i<32; i++) fprintf(fin,
"%d ", rand3_.ir[i]);
1118 if( (fin = fopen(_fname,
"r")) == NULL) {
1119 std::cerr<<_fname<<
" not found.\n";
1122 int rcount = fscanf(fin,
"%d %d %d ", &value3_.idum, &rand3_.idum2, &rand3_.iy);
1123 for (
int i=0; i<32; i++) rcount += fscanf(fin,
"%d ", &rand3_.ir[i]);
1125 std::cerr<<
"Error: Data reading fails! requiring data number is 35, only obtain "<<rcount<<
".\n";
1133 static void printLogo(std::ostream & fout) {
1135 fout<<
"---------------------------------------\n"
1136 <<
" ╔╦╗╔═╗╔╗ ╔═╗╔═╗\n"
1137 <<
" ║║║║ ║╠╩╗╚═╗║╣ \n"
1138 <<
" ╩ ╩╚═╝╚═╝╚═╝╚═╝\n"
1139 <<
"---------------------------------------"<<std::endl;
1140 fout<<
" Online document: https://mobse-webpage.netlify.app/\n"
1147 for (
int i=0; i<offset; i++) fout<<
" ";
1148 fout<<
"SSE: Hurley J. R., Pols O. R., Tout C. A., 2000, MNRAS, 315, 543\n";
1149 for (
int i=0; i<offset; i++) fout<<
" ";
1150 fout<<
"BSE: Hurley J. R., Tout C. A., Pols O. R., 2002, MNRAS, 329, 897\n";
1152 for (
int i=0; i<offset; i++) fout<<
" ";
1153 fout<<
"Updated BSE: Banerjee S., Belczynski K., Fryer C. L., Berczik P., Hurley J. R., Spurzem R., Wang L., 2020, A&A, 639, A41"
1156 for (
int i=0; i<offset; i++) fout<<
" ";
1157 fout<<
"BSEEMP: Tanikawa A., Yoshida T., Kinugawa T., Takahashi K., Umeda H., 2020, MNRAS, 495, 4170\n";
1158 for (
int i=0; i<offset; i++) fout<<
" ";
1159 fout<<
" Tanikawa A., Susa H., Yoshida T., Trani A.~A., Kinugawa T., 2021, ApJ, 910, 30\n";
1161 for (
int i=0; i<offset; i++) fout<<
" ";
1162 fout<<
"MOBSE: Giacobbo N., Mapelli M. & Spera M., 2018, MNRAS, 474, 2959\n";
1163 fout<<
"\t \t (Online document: https://mobse-webpage.netlify.app/)"
1170 return std::string(
".sse");
1172 return std::string(
".sseEmp");
1174 return std::string(
".mosse");
1180 return std::string(
".bse");
1182 return std::string(
".bseEmp");
1184 return std::string(
".mobse");
1190 return std::string(
"SSE");
1192 return std::string(
"SSEEMP");
1194 return std::string(
"MOSSE");
1200 return std::string(
"BSE");
1202 return std::string(
"BSEEMP");
1204 return std::string(
"MOBSE");
1209 return (_binary_type>=3&&_binary_type<=9);
1218 return (_binary_type>=10&&_binary_type<=12);
1222 return (_binary_type==13);
1235 #if (defined BSEBBF) || (defined BSEEMP)
1236 value4_.sigma = _input.sigma.value;
1238 value4_.sigma1 = _input.sigma1.value;
1239 value4_.sigma2 = _input.sigma2.value;
1242 #if (defined BSEBBF) || (defined BSEEMP)
1261 #if (defined BSEBBF) || (defined BSEEMP)
1262 flags2_.psflag = _input.psflag.value;
1263 flags2_.kmech = _input.kmech.value;
1264 flags2_.ecflag = _input.ecflag.value;
1266 flags_.piflag = _input.piflag.value;
1281 if (_print_flag&&(
z>0.03))
1282 std::cerr<<
"BSE warning! metallicity Z is not in (0.0, 0.03); given value:"<<
z<<std::endl;
1283 trackmode = _input.trackmode.value;
1284 zcnsts_(&
z,
zpars, &trackmode);
1286 if (_print_flag&&(z<0.0001||z>0.03))
1287 std::cerr<<
"BSE warning! metallicity Z is not in (0.0001, 0.03); given value:"<<
z<<std::endl;
1292 #ifdef PARTICLE_SIMULATOR_MPI_PARALLEL
1294 value3_.idum += PS::Comm::getRank();
1302 std::cout<<
"z: "<<
z<<
" zpars: ";
1303 for (
int i=0;i<20;i++) std::cout<<
zpars[i]<<
" ";
1304 std::cout<<std::endl;
1306 std::cout<<
"EMPTrack: "<<trackmode<<std::endl;
1337 const double c = 2.99792458e5;
1353 assert(_out.
kw0>=0&&_out.
kw0<16);
1354 assert(_star.
kw>=0&&_star.
kw<16);
1361 for (
int k=0; k<nmax; k++) {
1362 int type = _bin_event.
getType(k);
1365 _bin_event.
print(_fout, k);
1368 else if(type<0)
break;
1374 int type = _bin_event.
getType(k);
1375 assert(type>=0&&type<14);
1376 _fout<<std::setw(16)<<
binary_type[type]<<
" Init: ";
1378 else _bin_event.
print(_fout, k-1);
1379 _fout<<
"\n"<<std::setw(16)<<
" "<<
" Final: ";
1380 _bin_event.
print(_fout, k);
1385 int type = _bin_event.
getType(k);
1386 assert(type>=0&&type<14);
1387 if (print_type_name) _fout<<std::setw(16)<<
binary_type[type];
1388 _fout<<std::setw(_width)<<type;
1400 for (
int k=0; k<3; k++) dv[k] = _out.
vkick[k]/
vscale;
1414 if (_unit_in_myr) tphysf = _dt + _star.
tphys;
1415 double dtp=tphysf*100.0+1000.0;
1417 _out.
kw0 = _star.
kw;
1419 evolv1_(&kw, &_star.
m0, &_star.
mt, &_star.
r,
1424 _out.
dm = _star.
mt - _out.
dm;
1431 else if (_out.
vkick[3]>0)
return 2;
1432 else if (_star.
kw!=_out.
kw0)
return 1;
1451 double& _semi,
double& _period,
double& _ecc,
BinaryEvent& _bse_event,
const int& _binary_init_type,
const double _dt_nb) {
1453 double tphysf = _dt_nb*
tscale + tphys;
1454 double dtp=tphysf*100.0+1000.0;
1456 double semi_rsun = _semi*
rscale;
1458 int event_flag = 0 ;
1459 _out1.
dm = _star1.
mt;
1460 _out2.
dm = _star2.
mt;
1465 if (_star1.
kw==15 || _star2.
kw==15) {
1466 if (_star1.
kw==15 && _star2.
kw==15) {
1467 _star1.
tphys = tphysf;
1468 _star2.
tphys = tphysf;
1471 if (_star1.
kw==15) {
1472 double dt = tphysf - _star2.
tphys;
1474 _star1.
tphys = tphysf;
1476 if (_star2.
kw==15) {
1477 double dt = tphysf - _star1.
tphys;
1479 _star2.
tphys = tphysf;
1481 if (event_flag<0)
return event_flag;
1482 int event_index = 0;
1483 if (event_flag>0) _bse_event.
recordEvent(_star1, _star2, semi_rsun, _ecc, 2, event_index++);
1488 if (_star1.
tphys<tphys) {
1489 double dt = tphys - _star1.
tphys;
1492 if (event_flag<0)
return event_flag;
1493 if (_star2.
tphys<tphys) {
1494 double dt = tphys - _star2.
tphys;
1497 if (event_flag<0)
return event_flag;
1500 double m0[2],mt[2],r[2],lum[2],mc[2],rc[2],menv[2],renv[2],ospin[2],epoch[2],tm[2],vkick[8];
1501 for (
int k =0; k<4; k++) {
1502 vkick[k] = _out1.
vkick[k];
1503 vkick[k+4]= _out2.
vkick[k];
1513 ospin[0] = _star1.
ospin;
1514 epoch[0] = _star1.
epoch;
1522 ospin[1] = _star2.
ospin;
1523 epoch[1] = _star2.
epoch;
1525 evolv2_(kw, m0, mt, r, lum, mc, rc, menv, renv, ospin, epoch, tm, &tphys, &tphysf, &dtp, &
z,
zpars, &period_days, &_ecc, _bse_event.
record[0], vkick);
1534 _star1.
ospin = ospin[0];
1535 _star1.
epoch = epoch[0];
1536 _star1.
tphys = tphys;
1537 _star1.
lum = lum[0];
1545 _star2.
ospin = ospin[1];
1546 _star2.
epoch = epoch[1];
1547 _star2.
tphys = tphys;
1548 _star2.
lum = lum[1];
1550 _out1.
menv = menv[0];
1551 _out1.
renv = renv[0];
1553 _out1.
dm = _star1.
mt - _out1.
dm;
1556 _out2.
menv = menv[1];
1557 _out2.
renv = renv[1];
1559 _out2.
dm = _star2.
mt - _out2.
dm;
1562 for (
int k=0; k<4; k++) _out1.
vkick[k]=vkick[k];
1563 for (
int k=0; k<4; k++) _out2.
vkick[k]=vkick[k+4];
1565 if (kw[0]<0||kw[1]<0||(_star1.
mt<0&&_star1.
kw==15)||(_star2.
mt<0&&_star2.
kw==15)) {
1587 assert(_star2.
mt>0);
1588 double q = _star1.
mt/_star2.
mt;
1589 double rl_over_semi1 = EstimateRocheRadiusOverSemi(q);
1591 double rl_over_semi2 = EstimateRocheRadiusOverSemi(q);
1592 double rl_over_semi_max =
std::max(rl_over_semi1,rl_over_semi2);
1593 double rad = _star1.
r + _star2.
r;
1594 double semi_rsun = _semi*
rscale;
1595 double rcrit =
std::max(rad,rl_over_semi_max*semi_rsun);
1596 double peri_rsun = semi_rsun*(1-_ecc);
1597 bool is_fill= (rcrit>0.5*peri_rsun);
1614 double m0[2],mt[2],r[2],mc[2],rc[2],menv[2],renv[2],ospin[2],age[2],vkick[8];
1617 for (
int k =0; k<4; k++) {
1618 vkick[k] = _out1.
vkick[k];
1619 vkick[k+4]= _out2.
vkick[k];
1628 ospin[0] = _star1.
ospin;
1637 ospin[1] = _star2.
ospin;
1640 _out1.
dm = _star1.
mt;
1641 _out2.
dm = _star2.
mt;
1643 double semi_rsun = _semi*
rscale;
1645 merge_(kw, m0, mt, r, mc, rc, menv, renv, ospin, age, &semi_rsun, &_ecc, vkick,
zpars);
1647 _semi = semi_rsun/
rscale;
1655 _star1.
ospin = ospin[0];
1664 _star2.
ospin = ospin[1];
1667 _out1.
menv = menv[0];
1668 _out1.
renv = renv[0];
1670 _out1.
dm = _star1.
mt - _out1.
dm;
1673 _out2.
menv = menv[1];
1674 _out2.
renv = renv[1];
1676 _out2.
dm = _star2.
mt - _out2.
dm;
1679 for (
int k=0; k<4; k++) _out1.
vkick[k]=vkick[k];
1680 for (
int k=0; k<4; k++) _out2.
vkick[k]=vkick[k+4];
1690 if (_star.
kw==15)
return 1.0e30/
tscale;
1694 double m0 = _star.
m0;
1695 double mt = _star.
mt;
1697 double mc = _star.
mc;
1698 double rc = _star.
rc;
1702 trdot_(&kw, &m0, &mt, &r, &mc, &rc, &age, &dtm, &dtr,
zpars);
1720 double& _semi,
double& _ecc,
int &_binary_type) {
1726 if (_star1.
kw>=10&&_star1.
kw<15&&_star2.
kw>=10&&_star2.
kw<15&&_semi>0.0) {
1727 double semi_rsun = _semi*
rscale;
1728 dt =
std::min(
dt, EstimateGRTimescale(_star1, _star2, semi_rsun, _ecc));
1732 double m0[2],mt[2],r[2],mc[2],rc[2],age[2];
1750 double semi_rsun = _semi*
rscale;
1751 trflow_(kw,m0,mt,r,mc,rc,age,&dtr,&semi_rsun,&_ecc,
zpars);
1773 if (_star1.
kw>=10&&_star1.
kw<15&&_star2.
kw>=10&&_star2.
kw<15) {
1775 double semi_rsun = _semi*
rscale;
1776 double dt_gr = EstimateGRTimescale(_star1, _star2, semi_rsun, _ecc);
1777 if (dt_gr<_dt*
tscale)
return true;
1783 double m0[2],mt[2],r[2],mc[2],rc[2],age[2];
1801 double semi_rsun = _semi*
rscale;
1802 trflow_(kw,m0,mt,r,mc,rc,age,&dtr,&semi_rsun,&_ecc,
zpars);
1803 if (dtr<_dt*
tscale)
return true;
double mt
Initial stellar mass in solar units
Definition: bse_interface.h:260
double lum
physical evolve time in Myr
Definition: bse_interface.h:267
void printColumn(std::ostream &_fout, const int _index, const int _width=20) const
print data of class members using column style
Definition: bse_interface.h:606
double dm
kick velocity for NS/BH formation
Definition: bse_interface.h:400
IOParams< long long int > nsflag
Definition: bse_interface.h:645
static void printColumnTitle(std::ostream &_fout, const int _width=20)
print titles of class members using column style
Definition: bse_interface.h:576
Type value
Definition: io.hpp:43
double mscale
radius scaling factor from NB to Rsun
Definition: bse_interface.h:1061
static void printReference(std::ostream &fout, const int offset=4)
print reference to cite
Definition: bse_interface.h:1146
void merge(StarParameter &_star1, StarParameter &_star2, StarParameterOut &_out1, StarParameterOut &_out2, double &_semi, double &_ecc)
merge two star using mix function, star 2 will becomes zero mass
Definition: bse_interface.h:1612
static std::string getBSEOutputFilenameSuffix()
Definition: bse_interface.h:1178
const double year_to_day
velocity scaling factor from NB to km/s
Definition: bse_interface.h:1063
double rscale
time scaling factor from NB to Myr (t[Myr]=t[NB]*tscale)
Definition: bse_interface.h:1060
IO parameters manager for BSE based code.
Definition: bse_interface.h:619
IOParams< double > alpha
Definition: bse_interface.h:625
double vkick[4]
Main sequence lifetime
Definition: bse_interface.h:399
IOParams< long long int > idum
Definition: bse_interface.h:659
fp
Definition: galpy_pot_movie.py:131
int evolveBinary(StarParameter &_star1, StarParameter &_star2, StarParameterOut &_out1, StarParameterOut &_out2, double &_semi, double &_period, double &_ecc, BinaryEvent &_bse_event, const int &_binary_init_type, const double _dt_nb)
call evolv2 for a binary
Definition: bse_interface.h:1450
void printBinaryEventColumnOne(std::ostream &_fout, const BinaryEvent &_bin_event, const int k, const int _width=20, const bool print_type_name=true)
print binary event one in column
Definition: bse_interface.h:1384
void readAscii(FILE *_fin)
Definition: io.hpp:112
IOParamsContainer input_par_store
Definition: bse_interface.h:621
BSEManager()
name of binary type return from BSE evolv2, notice if it is -1, it indicate the end of record
Definition: bse_interface.h:1067
bool isDisrupt(const int _binary_type)
Definition: bse_interface.h:1221
void printBinaryEvent(std::ostream &_fout, const BinaryEvent &_bin_event)
print binary event
Definition: bse_interface.h:1359
void printHelp(std::ostream &os, const int _offset_short_key=2, const int _offset_long_key=1, const int _width_key=23) const
Definition: io.hpp:198
bool isMassTransfer(const int _binary_type)
Definition: bse_interface.h:1208
dt
Definition: galpy_pot_movie.py:134
static std::string getSSEName()
Definition: bse_interface.h:1188
IOParams< double > pts2
Definition: bse_interface.h:654
void printColumn(std::ostream &_fout, const int _width=20) const
print data of class members using column style
Definition: bse_interface.h:345
void readAscii(FILE *fp)
read class data with ASCII format
Definition: bse_interface.h:299
IOParams< double > vscale
Definition: bse_interface.h:663
void print(std::ostream &fout, const int index) const
for print in one line
Definition: bse_interface.h:549
void print(std::ostream &fout) const
for print in one line
Definition: bse_interface.h:439
BSE based code event recorder class.
Definition: bse_interface.h:493
StarParameterOut()
mass loss
Definition: bse_interface.h:402
void print(std::ostream &os) const
Definition: io.hpp:54
double getStellarRadius(StarParameter &_star)
get stellar radius in NB unit
Definition: bse_interface.h:1329
double getMass(StarParameter &_star)
get current mass in NB unit
Definition: bse_interface.h:1313
static std::string getBSEName()
Definition: bse_interface.h:1198
IOParams< double > bwind
Definition: bse_interface.h:623
double getMassLoss(StarParameterOut &_out)
get mass loss in NB unit
Definition: bse_interface.h:1318
IOParams< double > eddfac
Definition: bse_interface.h:631
double r
Current mass in solar units (used for R)
Definition: bse_interface.h:261
void printColumn(std::ostream &_fout, const int _width=20) const
print data of class members using column style
Definition: bse_interface.h:426
const char * key
Definition: io.hpp:44
double tm
radius of convective envelope
Definition: bse_interface.h:398
IOParams< double > beta
Definition: bse_interface.h:627
double epoch
spin of star
Definition: bse_interface.h:265
IOParams< double > epsnov
Definition: bse_interface.h:630
IOParams< long long int > bhflag
Definition: bse_interface.h:644
double z
Definition: bse_interface.h:1055
void printBinaryEventOne(std::ostream &_fout, const BinaryEvent &_bin_event, const int k)
print binary event one
Definition: bse_interface.h:1373
IOParams< long long int > ceflag
Definition: bse_interface.h:640
double mc
Stellar radius in solar units
Definition: bse_interface.h:262
T min(const Vector3< T > &v)
Definition: pikg_vector.hpp:150
int getEventNMax() const
Maximum event number that can be recored in one call of evolv2.
Definition: bse_interface.h:534
double getTime(StarParameter &_star)
get evolved Time in NB unit
Definition: bse_interface.h:1342
bool checkParams()
Definition: bse_interface.h:1090
double getDTMiss(StarParameterOut &_out)
get the difference of required finishing time and actually evolved time in NB unit
Definition: bse_interface.h:1347
SSE/BSE based code star parameter for output.
Definition: bse_interface.h:393
void readRandConstant(const char *_fname)
read BSE rand constant from file
Definition: bse_interface.h:1116
void printTypeChange(std::ostream &_fout, StarParameter &_star, StarParameterOut &_out, const int _width=4)
print type change
Definition: bse_interface.h:1352
void initial(const IOParamsBSE &_input, const bool _print_flag=false)
initial SSE/BSE based code global parameters
Definition: bse_interface.h:1226
double getMergerRadius(StarParameter &_star)
get merger radius in NB unit
Definition: bse_interface.h:1323
bool isRocheFill(StarParameter &_star1, StarParameter &_star2, double &_semi, double &_ecc)
check Roche fill condition
Definition: bse_interface.h:1586
bool isMerger(const int _binary_type)
notice kick priority is higher than others
Definition: bse_interface.h:1217
IOParams< double > pts1
Definition: bse_interface.h:653
bool isCallBSENeeded(StarParameter &_star1, StarParameter &_star2, double &_semi, double &_ecc, double &_dt)
a simple check to determine whether call BSE is necessary by given a reference of time step
Definition: bse_interface.h:1772
IOParams< long long int > tflag
Definition: bse_interface.h:641
void initial(double _mass, int _kw=1, double _ospin=0.0, double _epoch=0.0)
Landmark luminosities
Definition: bse_interface.h:276
double m0
stellar type
Definition: bse_interface.h:259
static void printColumnTitle(std::ostream &_fout, const int _width=20)
print titles of class members using column style
Definition: bse_interface.h:327
IOParams< double > rscale
Definition: bse_interface.h:661
int evolveStar(StarParameter &_star, StarParameterOut &_out, const double _dt, bool _unit_in_myr=false)
call SSE evolv1 for single star
Definition: bse_interface.h:1412
double tscale
metallicity parameters
Definition: bse_interface.h:1059
long long int kw
Definition: bse_interface.h:258
const char * binary_type[14]
name of single type from SSE
Definition: bse_interface.h:1065
IOParams< double > bhwacc
Definition: bse_interface.h:629
SSE/BSE interface manager.
Definition: bse_interface.h:1053
IOParams< double > neta
Definition: bse_interface.h:622
IOParams< double > gamma
Definition: bse_interface.h:632
T max(const Vector3< T > &v)
Definition: pikg_vector.hpp:143
IOParams< long long int > wdflag
Definition: bse_interface.h:643
double getVelocityChange(double *dv, StarParameterOut &_out)
get velocity change in NB unit
Definition: bse_interface.h:1399
int getEventIndexInit() const
The index of initial event in record array (last one)
Definition: bse_interface.h:539
double record[20][9]
Definition: bse_interface.h:496
IOParams< double > hewind
Definition: bse_interface.h:624
double zpars[20]
Definition: bse_interface.h:1055
void writeAscii(FILE *fp) const
write class data with ASCII format
Definition: bse_interface.h:291
IOParams< double > pts3
Definition: bse_interface.h:655
double vscale
mass scaling factor from NB to Msun
Definition: bse_interface.h:1062
void recordEvent(const StarParameter &_p1, const StarParameter &_p2, const double _semi, const double _ecc, const int _type, const int _index)
set up the initial parameter of binary event based on the present status of a binary
Definition: bse_interface.h:501
IOParams< double > mscale
Definition: bse_interface.h:662
double tphys
starting time of one evolution phase, age = tphys - epoch
Definition: bse_interface.h:266
static std::string getSSEOutputFilenameSuffix()
Definition: bse_interface.h:1168
IOParams< double > xi
Definition: bse_interface.h:628
double getSpeedOfLight() const
get speed of light in NB unit
Definition: bse_interface.h:1336
void print(std::ostream &fout) const
for print in one line
Definition: bse_interface.h:309
const char * single_type[16]
year to day
Definition: bse_interface.h:1064
double dtmiss
original type before evolution
Definition: bse_interface.h:395
IO Params container.
Definition: io.hpp:82
double getTimeStepBinary(StarParameter &_star1, StarParameter &_star2, double &_semi, double &_ecc, int &_binary_type)
call BSE evolv2 for a binary
Definition: bse_interface.h:1719
long long int kw0
Definition: bse_interface.h:394
double menv
required evolution time - actually evolved time
Definition: bse_interface.h:396
IOParams< double > tscale
Definition: bse_interface.h:660
double renv
mass of convective envelope
Definition: bse_interface.h:397
int read(int argc, char *argv[], const int opt_used_pre=0)
reading parameters from GNU option API
Definition: bse_interface.h:754
void dumpRandConstant(const char *_fname)
dump rand constant to file
Definition: bse_interface.h:1103
double ospin
core radius in solar units (output)
Definition: bse_interface.h:264
IOParams< double > z
Definition: bse_interface.h:664
static void printColumnTitle(std::ostream &_fout, const int _width=20)
print titles of class members using column style
Definition: bse_interface.h:409
double getTimeStepStar(StarParameter &_star)
get next time step to check in Myr
Definition: bse_interface.h:1689
static int printTitleWithMeaning(std::ostream &_fout, const int _counter=0, const int _offset=0)
print column title with meaning (each line for one column)
Definition: bse_interface.h:364
double rc
core mass in solar units
Definition: bse_interface.h:263
void setEventIndexEnd(const int index)
set binary type to -1 for the given event index to indicate the end of record
Definition: bse_interface.h:529
IOParams< double > lambda
Definition: bse_interface.h:626
SSE/BSE based code star parameter for saving.
Definition: bse_interface.h:257
bool print_flag
Definition: bse_interface.h:666
int getType(const int index) const
Get the binary type.
Definition: bse_interface.h:544