Generalized 3BBF and bug fixes#75
Open
ceoconnor1996 wants to merge 3 commits into
Open
Conversation
There was a problem hiding this comment.
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_POWERinput and threaded it through the 3BBF rate and hardness sampling. - Extended
THREEBODYBINARIESto support deterministic (mass-sorted) vs random pairing of triplets. - Fixed an
initial.esc.datheader typo and corrected energy redistribution indexing inbreak_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 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 on lines
1706
to
1707
| CHECK_PARSED(THREEBODYBINARIES, 0, PARAMDOC_THREEBODYBINARIES); | ||
| CHECK_PARSED(MIN_BINARY_HARDNESS, 5.0, PARAMDOC_MIN_BINARY_HARDNESS); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Added inputs to customize 3BBF physics and prevent related bugs:
Other bug fixes: