@@ -885,6 +885,31 @@ auto accrete::dist_planetary_masses(sun &the_sun, long double inner_dust,
885885
886886 // std::cout << planet_inner_bound << " " << planet_outer_bound << std::endl;
887887
888+ // --- Metallicity-dependent giant-formation gate (default-on; see const.h) -----
889+ // Decide ONCE whether this star can form gas giants, from a per-star [Fe/H] draw
890+ // and the observed giant-frequency-metallicity relation. Three fixed draws in a
891+ // fixed order (Box-Muller [Fe/H] = 2 draws, then the acceptance draw) -> no
892+ // rejection loops, serial == parallel byte-identical. If not giant-capable, gas
893+ // runaway is suppressed below (crit_mass made unreachable) so bodies stay cores.
894+ bool giant_capable = true ;
895+ {
896+ const long double u1 = random_ctx->randDouble (1 .0e-12L , 1 .0L ); // avoid log(0)
897+ const long double u2 = random_ctx->randDouble (0 .0L , 1 .0L );
898+ const long double feh =
899+ GIANT_METALLICITY_MEAN +
900+ GIANT_METALLICITY_SIGMA * sqrt (-2 .0L * log (u1)) * cos (2 .0L * PI * u2);
901+ long double p_giant = GIANT_FORMATION_NORM * stell_mass_ratio *
902+ std::pow (10 .0L , GIANT_FORMATION_FEH_SLOPE * feh);
903+ if (stell_mass_ratio > GIANT_FORMATION_MASS_TURNOVER_MSUN ) { // steep drop for A-stars
904+ p_giant *= GIANT_FORMATION_MASS_TURNOVER_MSUN / stell_mass_ratio;
905+ }
906+ if (p_giant > GIANT_FORMATION_PROB_CAP ) {
907+ p_giant = GIANT_FORMATION_PROB_CAP ;
908+ }
909+ const long double u_giant = random_ctx->randDouble (0 .0L , 1 .0L );
910+ giant_capable = (u_giant < p_giant);
911+ }
912+
888913 // while there's still dust left...
889914 while (dust_left) {
890915 if (seeds != nullptr ) {
@@ -952,6 +977,9 @@ auto accrete::dist_planetary_masses(sun &the_sun, long double inner_dust,
952977 dust_density = dust_density_coeff * sqrt (stell_mass_ratio) *
953978 exp (-ALPHA * std::pow (a, 1.0 / NDENSITY ));
954979 crit_mass = critical_limit (a, e, stell_luminosity_ratio);
980+ if (!giant_capable) {
981+ crit_mass = INCREDIBLY_LARGE_NUMBER ; // metallicity gate: suppress gas runaway -> rocky/ice core
982+ }
955983 if (total_mass == PROTOPLANET_MASS && is_seed == false ) {
956984 // std::cout << "test1\n";
957985 // std::cout << total_mass << " " << dust_mass << " " << gas_mass << " " << a
@@ -1009,6 +1037,9 @@ auto accrete::dist_planetary_masses(sun &the_sun, long double inner_dust,
10091037 r_inner = inner_effect_limit (a, e, reduced_mass);
10101038 r_outer = outer_effect_limit (a, e, reduced_mass);
10111039 crit_mass = critical_limit (a, e, stell_luminosity_ratio);
1040+ if (!giant_capable) {
1041+ crit_mass = INCREDIBLY_LARGE_NUMBER ; // metallicity gate: suppress gas runaway -> rocky/ice core
1042+ }
10121043 if (planet_inner_bound > a) {
10131044 planet_inner_bound = a;
10141045 }
0 commit comments