diff --git a/double2bin.c b/double2bin.c index 78f3295b66811c4be5e0cafe5eff8d4624ce6831..75b356bad2fce92aca75d9cbe0c5448050ffc00d 100644 --- a/double2bin.c +++ b/double2bin.c @@ -9,8 +9,9 @@ int main() double p; while(fscanf(stdin,"%lf",&p)!=EOF) { - fwrite(&p,sizeof(double),1,stdout); + if(!fwrite(&p,sizeof(double),1,stdout)) return 1; } fflush(stdout); + return 0; } diff --git a/src/binary_c_unit_tests.h b/src/binary_c_unit_tests.h index 1ceac12ee3c6d98cc3234e026665d371fcfce475..10b76a3d235a040c87911f3257e1f92bb7433810 100644 --- a/src/binary_c_unit_tests.h +++ b/src/binary_c_unit_tests.h @@ -23,6 +23,8 @@ #define UNDEF -666.6 +#define UNDEF_STARS UNDEF,UNDEF + #define UNIT_TEST_PREFIX \ "BINARY_C_UNIT_TEST" @@ -55,14 +57,12 @@ "vwind2", \ "stellar_timestep1", \ "stellar_timestep2", \ + "NTP1", \ + "NTP2", \ "tm1", \ "tm2", \ "tn1", \ "tn2", \ - "dt1", \ - "dt2", \ - "NTP1", \ - "NTP2", \ "dt", \ "dtm", \ "Jorb", \ @@ -147,7 +147,7 @@ #define UNIT_TEST_HEADER_FORMAT \ - "%s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s" + "%s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s" #define UNIT_TEST_FORMAT \ "%g %g %g %g %g %d %d %d %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g" @@ -177,7 +177,8 @@ /* * No nucsyn, set to undefined */ -#define UNIT_TESTS_NUCSYN UNDEF,UNDEF,UNDEF,UNDEF,UNDEF,UNDEF,UNDEF,UNDEF,UNDEF,UNDEF,UNDEF,UNDEF,UNDEF,UNDEF,UNDEF,UNDEF,UNDEF,UNDEF,UNDEF,UNDEF,UNDEF +#define UNIT_TESTS_NUCSYN UNDEF_STARS,UNDEF_STARS,UNDEF_STARS,UNDEF_STARS,UNDEF_STARS,UNDEF_STARS,UNDEF_STARS,UNDEF_STARS,UNDEF_STARS,UNDEF_STARS + #endif #define UNIT_TEST_time stardata->model.time @@ -186,6 +187,7 @@ STARS(mass), \ STARS(core_mass), \ STARS(stellar_type), \ + stardata->model.sgl, \ STARS(radius), \ STARS(roche_radius), \ STARS(age), \ @@ -206,25 +208,25 @@ stardata->common.eccentricity, \ Jdot_orbit(stardata), \ stardata->model.derivative[DERIVATIVE_ORBIT_ANGMOM_GRAVITATIONAL_RADIATION], \ - UNDEF, \ - UNDEF, \ - UNDEF, \ - UNDEF, \ - UNDEF, \ - UNDEF, \ - UNDEF, \ - UNDEF, \ - UNDEF, \ + stardata->model.derivative[DERIVATIVE_ORBIT_ANGMOM_WIND_LOSS], \ + stardata->model.derivative[DERIVATIVE_ORBIT_ANGMOM_WIND_GAIN], \ + stardata->model.derivative[DERIVATIVE_ORBIT_ANGMOM_RLOF_LOSS], \ + stardata->model.derivative[DERIVATIVE_ORBIT_ANGMOM_RLOF_GAIN], \ + stardata->model.derivative[DERIVATIVE_ORBIT_ANGMOM_CBDISC], \ + stardata->model.derivative[DERIVATIVE_ORBIT_ANGMOM_TIDES], \ + stardata->model.derivative[DERIVATIVE_ORBIT_ANGMOM_NONCONSERVATIVE_LOSS], \ + stardata->model.derivative[DERIVATIVE_ORBIT_ANGMOM_NOVA], \ + stardata->model.derivative[DERIVATIVE_ORBIT_ANGMOM_ARTIFICIAL], \ edot_orbit(stardata), \ stardata->model.derivative[DERIVATIVE_ORBIT_ECCENTRICITY_GRAVITATIONAL_RADIATION], \ stardata->model.derivative[DERIVATIVE_ORBIT_ECCENTRICITY_TIDES], \ stardata->model.derivative[DERIVATIVE_ORBIT_ECCENTRICITY_WINDS], \ - UNDEF, \ + stardata->model.derivative[DERIVATIVE_ORBIT_ECCENTRICITY_CBDISC], \ STARS(derivative[DERIVATIVE_STELLAR_MASS_WIND_LOSS]), \ STARS(derivative[DERIVATIVE_STELLAR_MASS_WIND_GAIN]), \ STARS(derivative[DERIVATIVE_STELLAR_MASS_RLOF_LOSS]), \ STARS(derivative[DERIVATIVE_STELLAR_MASS_RLOF_GAIN]), \ - UNDEF, \ + STARS(derivative[DERIVATIVE_STELLAR_MASS_NOVA]), \ STARS(derivative[DERIVATIVE_STELLAR_MASS_NONCONSERVATIVE_LOSS]), \ STARS(derivative[DERIVATIVE_STELLAR_MASS_CBDISC_GAIN]), \ STARS(derivative[DERIVATIVE_STELLAR_MASS_DECRETION_DISC]), \ @@ -243,6 +245,7 @@ 666.0 + /* V 2.0pre27 */ #elif BINARY_C_MAJOR_VERSION >= 2 && \ BINARY_C_MINOR_VERSION >= 0 && \ @@ -268,7 +271,7 @@ /* * No nucsyn, set to undefined */ -#define UNIT_TESTS_NUCSYN UNDEF,UNDEF,UNDEF,UNDEF,UNDEF,UNDEF,UNDEF,UNDEF,UNDEF,UNDEF,UNDEF,UNDEF,UNDEF,UNDEF,UNDEF,UNDEF,UNDEF,UNDEF,UNDEF,UNDEF,UNDEF +#define UNIT_TESTS_NUCSYN UNDEF_STARS,UNDEF_STARS,UNDEF_STARS,UNDEF_STARS,UNDEF_STARS,UNDEF_STARS,UNDEF_STARS,UNDEF_STARS,UNDEF_STARS,UNDEF_STARS,UNDEF_STARS,UNDEF_STARS,UNDEF_STARS,UNDEF_STARS,UNDEF_STARS,UNDEF_STARS,UNDEF_STARS,UNDEF_STARS,UNDEF_STARS,UNDEF_STARS,UNDEF_STARS #endif #define UNIT_TEST_time stardata->model.time @@ -277,6 +280,7 @@ STARS(mass), \ STARS(core_mass), \ STARS(stellar_type), \ + stardata->model.sgl, \ STARS(radius), \ STARS(roche_radius), \ STARS(age), \ @@ -297,37 +301,37 @@ stardata->common.eccentricity, \ Jdot_orbit(stardata), \ stardata->model.derivative[DERIVATIVE_ORBIT_ANGMOM_GRAVITATIONAL_RADIATION], \ - UNDEF, \ - UNDEF, \ - UNDEF, \ - UNDEF, \ - UNDEF, \ - UNDEF, \ - UNDEF, \ - UNDEF, \ - UNDEF, \ + UNDEF, \ + UNDEF, \ + UNDEF, \ + UNDEF, \ + UNDEF, \ + UNDEF, \ + UNDEF, \ + UNDEF, \ + UNDEF, \ edot_orbit(stardata), \ stardata->model.derivative[DERIVATIVE_ORBIT_ECCENTRICITY_GRAVITATIONAL_RADIATION], \ stardata->model.derivative[DERIVATIVE_ORBIT_ECCENTRICITY_TIDES], \ stardata->model.derivative[DERIVATIVE_ORBIT_ECCENTRICITY_WINDS], \ - UNDEF, \ + UNDEF, \ STARS(derivative[DERIVATIVE_STELLAR_MASS_WIND_LOSS]), \ STARS(derivative[DERIVATIVE_STELLAR_MASS_WIND_GAIN]), \ STARS(derivative[DERIVATIVE_STELLAR_MASS_RLOF_LOSS]), \ STARS(derivative[DERIVATIVE_STELLAR_MASS_RLOF_GAIN]), \ - UNDEF, \ - UNDEF, \ - UNDEF, \ - UNDEF, \ - UNDEF, \ + UNDEF_STARS, \ + UNDEF_STARS, \ + UNDEF_STARS, \ + UNDEF_STARS, \ + UNDEF_STARS, \ STARS(derivative[DERIVATIVE_STELLAR_ANGMOM_WIND_LOSS]), \ STARS(derivative[DERIVATIVE_STELLAR_ANGMOM_WIND_GAIN]), \ STARS(derivative[DERIVATIVE_STELLAR_ANGMOM_RLOF_LOSS]), \ STARS(derivative[DERIVATIVE_STELLAR_ANGMOM_RLOF_GAIN]), \ - UNDEF, \ - UNDEF, \ - UNDEF, \ - UNDEF, \ + UNDEF_STARS, \ + UNDEF_STARS, \ + UNDEF_STARS, \ + UNDEF_STARS, \ STARS(derivative[DERIVATIVE_STELLAR_ANGMOM_TIDE]), \ STARS(derivative[DERIVATIVE_STELLAR_ANGMOM_MAGNETIC_BRAKING]), \ UNIT_TESTS_NUCSYN, \ @@ -348,6 +352,7 @@ * Newer binary_c uses PRINTF for output, but if this * is not defined instead use printf */ +#undef PRINTF #ifndef PRINTF #define PRINTF printf #endif diff --git a/src/binary_parameters.h b/src/binary_parameters.h index bc583a91e3ea413236ab19d11305f53c227f39b8..2c212ac7782da54e0fc49a900e0f3075810a0c49 100644 --- a/src/binary_parameters.h +++ b/src/binary_parameters.h @@ -536,10 +536,11 @@ * Enable these to reduce the timestep when R approaches R_lobe (roche_radius) * on the EAGB and/or TPAGB */ -//#define SLOW_DOWN_PREROCHE_HG -//#define SLOW_DOWN_PREROCHE_EAGB -//#define SLOW_DOWN_PREROCHE_TPAGB -//#define SLOW_DOWN_PREROCHE_MS +#define SLOW_DOWN_PREROCHE_MS +#define SLOW_DOWN_PREROCHE_HG +#define SLOW_DOWN_PREROCHE_EAGB +#define SLOW_DOWN_PREROCHE_TPAGB + /* * Perhaps reduce the timestep when the star is rotating @@ -651,7 +652,7 @@ /* * The fraction of matter retained in a nova explosion */ -#define EPSNOV_DEFAULT 1e-3 +#define NOVA_RETENTION_FRACTION_DEFAULT 1e-3 /* * Define TIME_RESOLVE_NOVAE to time-resolve novae to within @@ -840,11 +841,9 @@ /* * defaults: * RLOF_OVERFLOW_THRESHOLD 1.0 - * RLOF_STABILITY_FACTOR 0.9999 + * RLOF_STABILITY_FACTOR 1.0 */ #define RLOF_OVERFLOW_THRESHOLD 1.0 -//#define RLOF_STABILITY_FACTOR 0.99999 -//#define RLOF_STABILITY_FACTOR 0.99 #define RLOF_STABILITY_FACTOR 1.0 /* diff --git a/src/code_options.h b/src/code_options.h index e0304c6a7ec1d9855e2cdb514faccc3ef1dd0f77..b99af574435ab390c6184e7b5c18aced02508650 100644 --- a/src/code_options.h +++ b/src/code_options.h @@ -600,7 +600,7 @@ /* * Enable unit testing */ -#define UNIT_TESTS +//#define UNIT_TESTS #endif //CODE_OPTIONS_H diff --git a/src/setup/reset_preferences.c b/src/setup/reset_preferences.c index a8835be7e9896327850371ce3ad3aedc7952875d..ccfc661f43bfc9ce54014ca52795839be7a813ec 100644 --- a/src/setup/reset_preferences.c +++ b/src/setup/reset_preferences.c @@ -68,7 +68,7 @@ void reset_preferences(struct preferences_t * RESTRICT preferences) #endif//NUCSYN // initialize other free parameters - preferences->nova_retention_fraction=EPSNOV_DEFAULT; + preferences->nova_retention_fraction=NOVA_RETENTION_FRACTION_DEFAULT; preferences->accretion_limit_eddington_multiplier=ACCRETION_LIMIT_EDDINGTON_MULTIPLIER_DEFAULT; preferences->accretion_limit_thermal_multiplier=ACCRETION_LIMIT_THERMAL_MULTIPLIER_DEFAULT; preferences->accretion_limit_dynamical_multiplier=ACCRETION_LIMIT_DYNAMICAL_MULTIPLIER_DEFAULT; diff --git a/src/setup/version.c b/src/setup/version.c index 5ddd85fe0e5c8d87a090e4e5c5a7027c2a05b6cc..a91b8f22c4c12152b53a86fb34a278f31e6765a1 100644 --- a/src/setup/version.c +++ b/src/setup/version.c @@ -404,8 +404,8 @@ void version(struct stardata_t * RESTRICT stardata) PRINTF("MIN_SEP_FOR_CLOSE_ANG_MOM_LOSS1 %g\n",MIN_SEP_FOR_CLOSE_ANG_MOM_LOSS1); PRINTF("MIN_SEP_FOR_CLOSE_ANG_MOM_LOSS2 %g\n",MIN_SEP_FOR_CLOSE_ANG_MOM_LOSS2); PRINTF("MIN_SEP_FOR_CLOSE_ANG_MOM_LOSS %g\n",MIN_SEP_FOR_CLOSE_ANG_MOM_LOSS); - PRINTF("EPSNOV_DEFAULT (fraction of matter retained in a nova explosion) default=%g\n", - EPSNOV_DEFAULT); + PRINTF("NOVA_RETENTION_FRACTION_DEFAULT (fraction of matter retained in a nova explosion) default=%g\n", + NOVA_RETENTION_FRACTION_DEFAULT); PRINTF("Accretion rate limit defaults: NOVAE_UPPER_LIMIT=%g SOFT_XRAY_UPPER_LIMIT=%g\n", ACCRETION_RATE_NOVAE_UPPER_LIMIT_DEFAULT, diff --git a/src/stellar_structure/stellar_structure_BSE.c b/src/stellar_structure/stellar_structure_BSE.c index 6469011aa3a0fb0353ebe67cebe76bd73b0b6ee0..90cceae33f677c9ecebb4f67c3fdc6f5f1e11906 100644 --- a/src/stellar_structure/stellar_structure_BSE.c +++ b/src/stellar_structure/stellar_structure_BSE.c @@ -204,7 +204,8 @@ void stellar_structure_BSE(struct new_stellar_structure_t * s, * When stars merge their MS lifetimes are a bit off * sometimes because the mass has increased. * Compensate for this by putting a merged HG - * at the beginning of the HG. + * at the beginning of the HG: evolution on the HG + * will, in any case, be fast. */ if(s->age - s->tm < TINY && s->stellar_type > 1) diff --git a/src/supernovae/monte_carlo_kick.c b/src/supernovae/monte_carlo_kick.c index e9fcbf065a9f698ab9c35a86d6b6ec988cadc215..1307a7b041060d45444e7fec0a57545173e126e2 100644 --- a/src/supernovae/monte_carlo_kick.c +++ b/src/supernovae/monte_carlo_kick.c @@ -114,11 +114,13 @@ double monte_carlo_kick(struct star_t * exploder, /* logging */ Append_logstring(LOG_SN_AND_KICK, - "%s %s (%d %d) -> kick %d(%g) vk=%g vr=%g omega=%g phi=%g -> vn=%g ; ", + "%s %s (SN type %d %d, pre-explosion M=%g Mc=%g) -> kick %d(%g) vk=%g vr=%g omega=%g phi=%g -> vn=%g ; ", exploder->SN_type==SN_WDKICK ? "WD kick" : "SN kick", strings[exploder->SN_type], exploder->SN_type, pre_explosion_star->SN_type, + pre_explosion_star->mass, + pre_explosion_star->core_mass, kick_distribution, kick_dispersion, kick_system->kick_speed, diff --git a/src/timestep/timestep_EAGB.c b/src/timestep/timestep_EAGB.c index 1e2b33f9d2f1ec827b2c8ff55d10ab3d18570ba7..c282ae6157c100ee26db274f7c45919360fd0a81 100644 --- a/src/timestep/timestep_EAGB.c +++ b/src/timestep/timestep_EAGB.c @@ -17,12 +17,6 @@ void timestep_EAGB(Timestep_prototype_args) HRDIAG_DT_NEGATIVE_CHECK; #endif // HRDIAG - /* - * RGI : I am not sure what tn has to do with calculating - * the time remaining in this phase of evolution. Indeed, - * sometimes using the MIN of tn and the time at the first - * pulse leads to problems. - */ //*time_remaining = MIN(tn,tscls[T_TPAGB_FIRST_PULSE]) - age; *time_remaining = tscls[T_TPAGB_FIRST_PULSE] - age; @@ -30,12 +24,12 @@ void timestep_EAGB(Timestep_prototype_args) * Slow down as we approach RLOF, we want to make this * as accurate as possible. */ -#if (defined(SLOW_DOWN_PREROCHE_EAGB)&& !defined(RLOF_REDUCE_TIMESTEP)) +#if defined SLOW_DOWN_PREROCHE_EAGB && !defined RLOF_REDUCE_TIMESTEP double rr=star->radius / star->roche_radius; rr=1.0-rr; rr=MIN(1.0,rr); rr=MAX(0.1,rr); double newdt = *dt * rr; - Limit_timestep(*dt,newdt,star,DT_LIMIT_PREROCHE_EAGB); + Limit_timestep(*dt,newdt,star,DT_LIMIT_EAGB_PREROCHE); #endif // SLOW_DOWN_PREROCHE_EAGB } diff --git a/src/timestep/timestep_TPAGB.c b/src/timestep/timestep_TPAGB.c index 5263f489fb4715b638c164ca09119095eb22bc6a..6bbc7024f2d4c7471e4e588333db69d3f81421c2 100644 --- a/src/timestep/timestep_TPAGB.c +++ b/src/timestep/timestep_TPAGB.c @@ -60,12 +60,13 @@ void timestep_TPAGB(Timestep_prototype_args) Set_timestep(*dt,tip,star,DT_LIMIT_TPAGB_NUCSYN_INTERPULSE); } -#if (defined(SLOW_DOWN_PREROCHE_TPAGB)&& !defined(RLOF_REDUCE_TIMESTEP)) +#if defined SLOW_DOWN_PREROCHE_TPAGB && !defined RLOF_REDUCE_TIMESTEP /* * Slow down as we approach RLOF, we want to make this * as accurate as possible. */ { + double tip=star->interpulse_period*stardata->preferences->dtfac*0.9999; double rr=star->radius / star->roche_radius; rr=1.0-rr; rr=MIN(1.0,rr); diff --git a/tbse b/tbse index 3722eaab7cb33d85d2b1ceb8fa33fe257ebfec3d..19f820e5c97f80230c06d79a2846e031f427ce50 100755 --- a/tbse +++ b/tbse @@ -281,7 +281,9 @@ E2_PRESCRIPTION=1 ############################ # # Method for calculting the Roche-lobe overflow rate: -# 0=H02, 1=Adaptive (for radiative stars), 2=Ritter (broken), +# 0=H02 +# 1=Adaptive (really only good for radiative stars) +# 2=Ritter (probably broken), # 3=Claeys etal 2014 variant on H02 RLOF_METHOD=3 @@ -951,7 +953,7 @@ YIELDS_DT=100 #NONCONSERVATIVE_ANGMOM_GAMMA=-2 #TPAGBWIND=1 #ELD_ACC_MASS=1000.0 -#NOVA_RETENTION_FACTOR=0.1 +#NOVA_RETENTION_FRACTION=0.1 #AGB_CORE_ALGORITHM=1 #AGB_3DUP_ALGORITHM=2 #REIMERS_ETA=0.5 diff --git a/valgrind.pl b/valgrind.pl index 04b0d91f7d7662b2a203c183fd9eef443ceae4fb..2697105a9535c30380c85bddcbab8f047490e306 100755 --- a/valgrind.pl +++ b/valgrind.pl @@ -15,6 +15,7 @@ use 5.16.0; # my $valgrind = ''; # valgrind or '' +my $nice = "nice"; my $repeat = 1; my $q = robqueue->new( nthreads=>rob_misc::ncpus(), @@ -42,8 +43,7 @@ sub runsystem } else { - - my $r = `tbse $valgrind --repeat $repeat --random_systems 1 --log_filename /tmp/c_log-$n.dat 2>\&1 | tail -1000`; + my $r = `$nice tbse $valgrind --repeat $repeat --random_systems 1 --log_filename /tmp/c_log-$n.dat 2>\&1 | tail -1000`; my $status = $?; my $args = ($r=~/(--M_1.*)/g)[$valgrind ? 1 : 1];