Skip to content

Generalized 3BBF and bug fixes#75

Open
ceoconnor1996 wants to merge 3 commits into
ClusterMonteCarlo:masterfrom
ceoconnor1996:master
Open

Generalized 3BBF and bug fixes#75
ceoconnor1996 wants to merge 3 commits into
ClusterMonteCarlo:masterfrom
ceoconnor1996:master

Conversation

@ceoconnor1996

Copy link
Copy Markdown

Added inputs to customize 3BBF physics and prevent related bugs:

  • THREEBODYBINARIES can now be set to 0 (off), 1 (pair two most massive objects, default), or 2 (pair randomly)
  • BINARY_HARDNESS_POWER sets the slope of the hardness distribution for new binaries (default == -5.5)
  • Slight adjustment in the 3BBF rate normalization, per Atallah+ (2024)
  • New binaries from 3BBF are assigned an eccentricity from a truncated thermal distribution on the interval [0,0.7], to avoid downstream bugs that occur when arbitrarily large eccentricities are allowed

Other bug fixes:

  • Fixed a stray character in the header of initial.esc.dat, which was goofing up automatic parsing of that file
  • Fixed an indexing error in break_wide_binaries, which caused excess energy sometimes to be distributed to non-neighboring stars
  • Corrected sampling of cluster velocity distribution of newly formed binaries from 3BBF to ensure spherical isotropy

Copilot AI review requested due to automatic review settings June 10, 2026 17:27

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR generalizes the three-body binary formation (3BBF) prescription by adding new runtime inputs (pairing mode and hardness slope), updates the 3BBF rate normalization, and applies several fixes to downstream issues (output header parsing, wide-binary energy redistribution indexing, and isotropic velocity sampling).

Changes:

  • Added BINARY_HARDNESS_POWER input and threaded it through the 3BBF rate and hardness sampling.
  • Extended THREEBODYBINARIES to support deterministic (mass-sorted) vs random pairing of triplets.
  • Fixed an initial.esc.dat header typo and corrected energy redistribution indexing in break_wide_binaries; adjusted 3BBF velocity-direction sampling for isotropy and truncated new-binary eccentricities.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/cmc/cmc_io.c Parses BINARY_HARDNESS_POWER, adds defaulting logic, and fixes an output header character that broke parsers.
src/cmc/cmc_dynamics.c Uses new pairing modes and applies updated 3BBF rate normalization / hardness slope plumbing.
src/cmc/cmc_dynamics_helper.c Implements random triplet permutation, generalized hardness sampling, truncated eccentricities, isotropic sampling, and fixes break_wide_binaries indexing.
include/cmc/cmc.h Updates parameter docs/prototypes for generalized 3BBF and exposes the new input.
include/cmc/cmc_vars.h Adds global BINARY_HARDNESS_POWER declaration.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 531 to 543
// INITIAL VALUES
m1=star_m[get_global_idx(k1)];
m2=star_m[get_global_idx(k2)];
m3=star_m[get_global_idx(k3)];
r1=star_r[get_global_idx(k1)];
r2=star_r[get_global_idx(k2)];
r3=star_r[get_global_idx(k3)];
//starrad1=star[k1].rad;
//starrad2=star[k2].rad;
//rad3=star[k3].rad;

// Initial energy
PE_i = madhoc*(m1*star_phi[get_global_idx(k1)] + m2*star_phi[get_global_idx(k2)] + m3*star_phi[get_global_idx(k3)]);
KE_i = 0.5*madhoc*(m1 * sqr(v1[0]) + m2 * sqr(v2[0]) + m3 * sqr(v3[0]));

// COM of candidate binary pair
// COM of candidate binary pair
binary_cm = (m1 * r1 + m2 * r2)/(m1 + m2);
Comment on lines +478 to +482
comp_ymax = kk * norm * pow(eta_test, 1.+eta_power);
comp_y = rng_t113_dbl_new(curr_st)*comp_ymax;
/* now accept or reject the point if it lies below/above true distribution:
d(rate)/d(eta) ~ norm*(5*eta^-6 + 8*eta^-5) */
// true_y = norm*(5.0*pow(eta_test, -6.0) + 8.0*pow(eta_test, -5.0));
true_y = norm*(5.5*pow(eta_test, -6.5) + (4.5 * kk +9.0) * (pow(eta_test, -5.5)) +7.0 * kk * (pow(eta_test, -4.5)));
if (comp_y < true_y) { /* fall within true distribution */
/* now accept or reject the point if it lies below/above true distribution: */
true_y = norm*(pow(eta_min,eta_power) - pow(eta_test,1.+eta_power)) + (2.+kk)*(pow(eta_min,1.+eta_power) - pow(eta_test,1.+eta_power)) + 2.*kk*(pow(eta_min,2.+eta_power) - pow(eta_test,2.+eta_power));
if (comp_y < true_y) { /* fall within true distribution */
Comment thread include/cmc/cmc.h
Comment on lines +688 to +692
#define PARAMDOC_BINARY_HARDNESS_POWER "power law index for hardness of newly formed three-body binaries"
/**
* @brief Power-law index for hardness of three-body binaries (default is -3.0).
*/
double BINARY_HARDNESS_POWER;
Comment thread src/cmc/cmc_io.c
Comment on lines 1706 to 1707
CHECK_PARSED(THREEBODYBINARIES, 0, PARAMDOC_THREEBODYBINARIES);
CHECK_PARSED(MIN_BINARY_HARDNESS, 5.0, PARAMDOC_MIN_BINARY_HARDNESS);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants