Skip to content

Collated merge of pull requests from the workshop#844

Merged
danieljprice merged 28 commits into
mainfrom
mega-merge
Jun 19, 2026
Merged

Collated merge of pull requests from the workshop#844
danieljprice merged 28 commits into
mainfrom
mega-merge

Conversation

@danieljprice

@danieljprice danieljprice commented Jun 19, 2026

Copy link
Copy Markdown
Owner

Description:
This is a merge to resolve build failures and merge two pull-requests leftover from the workshop #832 and #839. Also contains a run of the bots, and a minor update to metric_binarybh to read the trajectory file into a memory buffer instead of continuously rewriting the file.

Also contains a post-workshop run of the bots, including a bug fix to the align-bot

Components modified:

  • Setup (src/setup)
  • Main code (src/main)
  • Moddump utilities (src/utils/moddump)
  • Analysis utilities (src/utils/analysis)
  • Test suite (src/tests)
  • Documentation (docs/)
  • Build/CI (build/ or github actions)

Type of change:

  • Bug fix
  • Physics improvements
  • Better initial conditions
  • Performance improvements
  • Documentation update
  • Better testing
  • Code cleanup / refactor
  • Other (please describe)

Testing:
Should pass continuous integration tests

Did you run the bots? yes

Did you update relevant documentation in the docs directory? no

Did you add comments such that the purpose of the code is understandable? yes/no

Is there a unit test that could be added for this feature/bug? yes/no

If so, please describe what a unit test might check:
n/a

Related issues: #835
#839
#826

Summary by CodeRabbit

Release Notes

  • New Features
    • Added Reissner–Nordström (charged) metric support with configurable central-object charge in metric and setup inputs.
    • Enhanced flyby dump customization to drive encounters via general orbital parameters from a .moddump file.
    • Improved binary black hole setups by caching trajectory data to reduce repeated file reads.
  • Bug Fixes
    • Strengthened GR setup validation for RN/charged initial conditions.
    • Fixed an outward fragmentation threshold output label.
  • Tests
    • Added RN charged circular-orbit coverage and expanded GR precession coverage to RN.
  • Documentation
    • Refreshed EOS/metric option and parameter descriptions.

ahermosillo and others added 22 commits June 12, 2026 05:56
Implemented the Reissner-Nordstrom metric and its derivatives in Cartesian-like and spherical coordinates

- Define a dummy charge parameter in all metrices
So the compiler won't complain for unused variables.
- Integration tests for RN: CO in various charges.
@coderabbitai

coderabbitai Bot commented Jun 19, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 1b8f4fd2-5bb5-4e04-8660-91637a1e29cf

📥 Commits

Reviewing files that changed from the base of the PR and between 7957c4e and a40f108.

📒 Files selected for processing (1)
  • src/setup/setup_grtde.f90

📝 Walkthrough

Walkthrough

This PR adds a full Reissner–Nordström (RN) charged metric module (metric_rn.f90, imetric=8) and propagates a charge public parameter to all existing metric backends. GR external forces, accretion, timestep constraints, setup routines, and a new unit test are updated accordingly. Separately, moddump_addflyby is rewritten from a parabolic prompt flow to a general orbital parameter approach using setorbit, and the set_orbit public API is expanded. The remainder of the diff is widespread declaration formatting, script improvements, and documentation housekeeping.

Changes

Reissner–Nordström Metric Implementation

Layer / File(s) Summary
imet_rn identifier and charge in existing metric modules
src/main/metric_tools.f90, src/main/metric_schwarzschild.f90, src/main/metric_kerr.f90, src/main/metric_kerr-schild.f90, src/main/metric_minkowski.f90, src/main/metric_et.f90, src/main/metric_binarybh.f90
Adds imet_rn=8 to the metric identifier list and adds real, public :: charge = 0. to every existing metric module for uniform interface compatibility.
New metric_rn module: header, tensors, derivatives, transforms
src/main/metric_rn.f90
Implements the full RN metric module: public parameters (mass1, a, charge, imetric=8), covariant/contravariant metric tensors in Cartesian and spherical coordinates, analytic derivative tensors, and coordinate transformation utilities (Jacobian, cartesian2spherical, spherical2cartesian).
metric_rn I/O and accretion hooks
src/main/metric_rn.f90
Adds write_options_metric/read_options_metric for mass1 and charge, stub implementations of update_metric (empty) and accrete_particles_metric (always accreted=.false.), and empty dump header read/write hooks.
metric_binarybh trajectory caching
src/main/metric_binarybh.f90
Adds charge parameter and rewrites get_trajectory_from_file to lazily load the trajectory table once via load_trajectory(ierr), then interpolate from cached arrays instead of re-reading the file per call.
GR forces: charge export, accretion, timestep for RN
src/main/externalforces.f90, src/main/externalforces_gr.f90, src/main/extern_gr.f90
Exports charge from externalforces and re-exports through externalforces_gr; extends accrete_particles and dt_grforce to include imet_rn alongside Schwarzschild/Kerr.
checksetup: RN metric validation
src/main/checksetup.f90
Imports charge/mass1 in check_gr and adds validation: imet_rn requires mass1≈1; all other metrics require charge≈0; failures increment nerror.
setup_grtde: charge runtime parameter and signature update
src/setup/setup_grtde.f90
Adds charge to the GR TDE setup: imports from externalforces, documents it, sets default, writes and reads in .setup file when imet==imet_rn, and changes fileprefix to assumed-length.
GR unit test: RN charged circular orbits
src/tests/test_gr.f90
Adds test_rn_charged to test_gr: loops over Q/M ratios (0, 0.5, 0.9, 1.1), integrates geodesics, validates angular momentum and final radius tolerances.

moddump_addflyby Refactor and set_orbit API Expansion

Layer / File(s) Summary
set_orbit public API and build relocation
src/setup/set_orbit.f90, build/Makefile
Expands setorbit module exports to include set_defaults_orbit, write_options_orbit, read_options_orbit, get_orbital_time; moves set_orbit.f90 from SRCSETUP to SRCSETSTAR.
moddump_addflyby: general orbital flyby
src/utils/moddump_addflyby.f90
Replaces parabolic prompt/math with modify_dump that reads overrides from <fileprefix>.moddump, calls set_orbit for secondary initial state, and computes timing from get_orbital_time. Adds read_interactive_moddumpfile, write_moddumpfile, read_moddumpfile.
phantom_moddump: fileprefix from io module
src/utils/phantom_moddump.f90
Removes program-local fileprefix declaration and imports it directly from the io module.

Formatting, Housekeeping, and Tooling

Layer / File(s) Summary
Scripts
scripts/no-dims.pl, scripts/writemake.sh
Centralizes format_decl helper in no-dims.pl with queue-based parameter/optional/local ordering; writemake.sh uses ${SPLASH_DIR:-~/splash}.
AUTHORS updates
AUTHORS
Adds Antoine Alaguero, Ali Pourmand (alternate email), Angelos Karakonstantakis, and ahermosillo; reorders existing entries.
src/main declaration formatting
src/main/H2regions.f90, src/main/eos*.f90, src/main/force.F90, src/main/growth.f90, src/main/krome.F90, src/main/deriv.f90, src/main/dens.F90, src/main/porosity.f90, src/main/readwrite_dumps.f90, src/main/substepping.F90, src/tests/test_eos.f90
Whitespace/alignment reformatting of dummy-argument declarations and comments across source files; no logic changes.
src/setup declaration formatting
src/setup/relax_star.f90, src/setup/setup_dust*.f90, src/setup/setup_testgrowthsphere.f90
Reformats dummy-argument declarations and updates module header documentation; no logic changes.
src/utils formatting and minor refactors
src/utils/analysis_*.f90, src/utils/utils_disc.f90, src/utils/moddump_centreonsink.f90, src/utils/moddump_removeparticles_density.f90, src/utils/moddump_rotate_ref.f90
Updates owner/copyright metadata, reformats declarations, refactors moddump_centreonsink loop to use explicit cycle, and removes redundant return in moddump_rotate_ref.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Poem

🐇 A new metric blooms from charge and mass,
RN orbits tested, no bugs to harass.
The flyby now follows a general arc,
No more parabolas lost in the dark.
Declarations aligned, the AUTHORS grow,
A rabbit signs off — on with the show! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title is vague and generic, using non-descriptive phrasing like 'Collated merge' without clearly conveying the main purpose or impact of the PR changes. Use a more descriptive title that captures the main objective, such as 'Add Reissner-Nordström metric support and merge workshop PRs' or 'Implement charged metric and consolidate workshop changes'.
✅ Passed checks (4 passed)
Check name Status Explanation
Description check ✅ Passed The description is mostly complete with sections for components modified, type of change, testing status, and related issues; however, it lacks detail in the 'Description' section itself and leaves some yes/no questions incomplete or ambiguous.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch mega-merge

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a Reissner-Nordstrom (RN) metric module, adds trajectory caching in the binary black hole metric to improve performance, and updates the flyby moddump utility to support general orbital parameters. Critical feedback highlights that when adding a flyby, both the primary and secondary body positions and velocities must be updated to maintain the correct orbit. Additionally, using tiny(0.) as a tolerance for floating-point equality in setup checks is risky due to roundoff errors and should be replaced with a machine epsilon or a reasonable tolerance. Finally, intent(out) variables in the trajectory retrieval subroutine should be initialized to prevent undefined behavior if loading fails.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread src/utils/moddump_addflyby.f90
Comment thread src/main/checksetup.f90 Outdated
Comment thread src/main/metric_binarybh.f90

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 10

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/main/growth.f90 (1)

199-204: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Label the outward fragmentation threshold correctly.

The else branch prints vfragin again even though it reports vfragoutSI/vfragout, so the diagnostic text is misleading.

Fix
-       write(iprint,"(2(a,1pg10.3),a)") ' vfragin = ',vfragoutSI,' m/s = ',vfragout,' (code units)'
+       write(iprint,"(2(a,1pg10.3),a)") ' vfragout = ',vfragoutSI,' m/s = ',vfragout,' (code units)'
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/main/growth.f90` around lines 199 - 204, In the else branch of the if
statement starting with isnow == 0, the second write statement has an incorrect
label in its format string. It currently prints "vfragin" as the label, but the
actual values being printed are vfragoutSI and vfragout. Change the label in the
second write statement from "vfragin" to "vfragout" to correctly describe the
outward fragmentation threshold values that are being displayed.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/main/deriv.f90`:
- Line 143: The comment line at line 143 in src/main/deriv.f90 exceeds the
configured line-length limit for Fortitude, causing the linter to fail. Split
this single long comment into multiple shorter comment lines, each staying
within the line-length limit, while preserving the complete information about
the flag for pressure calculation from dens, the cons2primall call,
densityiterate function, and the eos_vars import details.

In `@src/main/growth.f90`:
- Around line 210-211: The write statements for the Vrel messages exceed the
Fortitude line width limit and the endif statements throughout the file are
missing proper spacing. Refactor the long write statements for Vrel (lines
checking ivrelkin == 0 and ivrelkin == 1) to fit within the width limit by using
line continuation or splitting the string literals across multiple lines, and
ensure all endif statements in the file have proper spacing before them as
required by Fortitude style guidelines. Apply these formatting fixes to the
locations at 210-211, 308-315, and 370-380.

In `@src/main/krome.F90`:
- Around line 142-147: In the dummy if statement block within the else
preprocessor directive (the block containing the comment about avoiding compiler
warning for unused variables), change the `endif` keyword to `end if` (using two
words instead of one). This applies to the line that terminates the if (.false.)
then block to comply with Fortran style requirements.

In `@src/main/metric_binarybh.f90`:
- Around line 123-138: The trajectory interpolation block in metric_binarybh
contains Fortitude linting violations that need to be corrected. First, replace
the single-quoted strings in the error call (the error function call with the
message about trajectory file) with double-quoted strings to match Fortran style
conventions. Second, the error message line is too long and exceeds the line
length limit, so split the error message construction across multiple lines
using continuation or break it into a separate string variable before passing it
to the error function. Finally, review the spacing around the endif at the start
of the block and the enddo at line 133 to ensure they follow consistent
formatting conventions with appropriate whitespace or comments as needed per
your project's Fortitude configuration.
- Around line 116-117: The update_metric function returns with ierr=0 (success)
even when trajectory loading or time validation fails, allowing binary-BH runs
to proceed with invalid data. In the load_trajectory section (around line
116-117), set ierr to a non-zero value when ntraj remains 0 after calling
load_trajectory, since this indicates the trajectory table is empty or invalid.
Similarly, for the out-of-range time clamping logic (lines 137-139 and
throughout lines 161-186), either set ierr to a non-zero value to signal failure
when time is out-of-range, or downgrade those error logs to warnings if
out-of-range clamping is intentional behavior. Ensure that any error condition
logged in this function results in a non-zero ierr value being returned to the
caller.

In `@src/main/metric_rn.f90`:
- Around line 7-22: The metric module needs to be brought into Fortitude
compliance by adding a default accessibility declaration (such as private)
following the module declaration at the top, ensuring the implicit none
statement is properly formatted with any required external attributes, fixing
the spacing and indentation of all endif statements throughout the file,
converting old-style array constructors to modern Fortran syntax in the affected
sections, replacing all single-quoted string literals with double quotes, and
refactoring line 331 to ensure it does not exceed 100 columns by breaking long
statements into multiple lines as appropriate.

In `@src/setup/setup_grtde.f90`:
- Around line 224-226: The charge variable is being unconditionally reset to 0.0
on line 225, which overwrites the value that was previously read from the setup
file. Remove the line that sets charge to 0.0 to preserve the charge value
loaded from the setup file. If initialization is needed for other cases, add a
conditional check to only reset charge when appropriate rather than
unconditionally discarding the setup file value.

In `@src/utils/moddump_addflyby.f90`:
- Around line 107-110: The prompt function call with orbit%input_type allows a
maximum value of 4 (the last parameter), but the prompt string only documents
options 0 through 3, creating a mismatch between what is shown to the user and
what is actually accepted. Either extend the prompt string to document what
option 4 represents (adding a new line with '4=<description>'), or reduce the
maximum allowed value from 4 to 3 in the prompt function call to ensure the
interactive input options match the documentation.
- Around line 80-88: The issue is that body 2 is being copied from set_orbit
output without validating the orbit state and without checking for errors. After
the set_orbit call in the block with parameters including nptmass_in,
xyzmh_ptmass_in, vxyz_ptmass_in, and ierr, check the ierr status before
proceeding with the copy operations. Additionally, initialize the scratch
buffers xyzmh_ptmass_in and vxyz_ptmass_in before the set_orbit call to ensure
clean state. Finally, verify or adjust the primary sink (first body) position
and velocity to match what set_orbit generated for body 1, so that when body 2
is copied to nptmass, it represents the correct relative orbit with respect to
the actual primary that will be used.

In `@src/utils/phantom_moddump.f90`:
- Line 26: The `use io` import statement with all its imported entities
(set_io_unit_numbers, iprint, idisk1, warning, fatal, iwritein, id, master,
fileprefix) exceeds the 100-character line limit at 104 characters. Split this
use statement across multiple lines by wrapping the list of imported entities,
following Fortran's standard syntax for continuation lines, to ensure no single
line exceeds the 100-character limit while maintaining the same imports.

---

Outside diff comments:
In `@src/main/growth.f90`:
- Around line 199-204: In the else branch of the if statement starting with
isnow == 0, the second write statement has an incorrect label in its format
string. It currently prints "vfragin" as the label, but the actual values being
printed are vfragoutSI and vfragout. Change the label in the second write
statement from "vfragin" to "vfragout" to correctly describe the outward
fragmentation threshold values that are being displayed.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 86e1360b-3d4e-46a2-9761-dd974d4b2827

📥 Commits

Reviewing files that changed from the base of the PR and between fbf2c68 and 6bf19f0.

📒 Files selected for processing (45)
  • AUTHORS
  • build/Makefile
  • scripts/no-dims.pl
  • scripts/writemake.sh
  • src/main/H2regions.f90
  • src/main/checksetup.f90
  • src/main/dens.F90
  • src/main/deriv.f90
  • src/main/eos.f90
  • src/main/eos_HIIR.f90
  • src/main/eos_helmholtz.f90
  • src/main/extern_gr.f90
  • src/main/externalforces.f90
  • src/main/externalforces_gr.f90
  • src/main/force.F90
  • src/main/growth.f90
  • src/main/krome.F90
  • src/main/metric_binarybh.f90
  • src/main/metric_et.f90
  • src/main/metric_kerr-schild.f90
  • src/main/metric_kerr.f90
  • src/main/metric_minkowski.f90
  • src/main/metric_rn.f90
  • src/main/metric_schwarzschild.f90
  • src/main/metric_tools.f90
  • src/main/porosity.f90
  • src/main/readwrite_dumps.f90
  • src/main/substepping.F90
  • src/setup/relax_star.f90
  • src/setup/set_orbit.f90
  • src/setup/setup_dustgaussvel.f90
  • src/setup/setup_dustybox.f90
  • src/setup/setup_dustysedov.f90
  • src/setup/setup_grtde.f90
  • src/setup/setup_testgrowthsphere.f90
  • src/tests/test_eos.f90
  • src/tests/test_gr.f90
  • src/utils/analysis_growingdisc.f90
  • src/utils/analysis_maxquant.f90
  • src/utils/moddump_addflyby.f90
  • src/utils/moddump_centreonsink.f90
  • src/utils/moddump_removeparticles_density.f90
  • src/utils/moddump_rotate_ref.f90
  • src/utils/phantom_moddump.f90
  • src/utils/utils_disc.f90

Comment thread src/main/deriv.f90
Comment thread src/main/growth.f90
Comment thread src/main/krome.F90
Comment thread src/main/metric_binarybh.f90 Outdated
Comment thread src/main/metric_binarybh.f90
Comment thread src/main/metric_rn.f90
Comment on lines +7 to +22
module metric
!
! None
!
! :References: None
!
! :Owner: Angelos Karakonstantakis
!
! :Runtime parameters:
! - charge : *charge parameter for Reissner-Nordstrom metric*
! - mass1 : *black hole mass in code units*
!
! :Dependencies: dump_utils, infile_utils, io
!
implicit none
character(len=*), parameter :: metric_type = 'RN'

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Bring the new RN module into Fortitude compliance.

Fortitude reports errors in this new file: missing default accessibility, implicit none missing external, endif spacing, old-style array constructors, single-quoted literals, and Line 331 exceeding 100 columns. Apply the configured style or explicitly suppress metric modules if they are intentionally exempt.

Also applies to: 97-150, 331-331, 364-390, 406-422, 437-439

🧰 Tools
🪛 Fortitude (0.9.0)

[error] 7-8: module 'metric' missing default accessibility statement

(C131)


[error] 21-21: 'implicit none' missing 'external'

(C003)


[error] 22-22: String uses single quotes but double quotes preferred

(S241)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/main/metric_rn.f90` around lines 7 - 22, The metric module needs to be
brought into Fortitude compliance by adding a default accessibility declaration
(such as private) following the module declaration at the top, ensuring the
implicit none statement is properly formatted with any required external
attributes, fixing the spacing and indentation of all endif statements
throughout the file, converting old-style array constructors to modern Fortran
syntax in the affected sections, replacing all single-quoted string literals
with double quotes, and refactoring line 331 to ensure it does not exceed 100
columns by breaking long statements into multiple lines as appropriate.

Source: Linters/SAST tools

Comment thread src/setup/setup_grtde.f90
Comment thread src/utils/moddump_addflyby.f90
Comment thread src/utils/moddump_addflyby.f90
Comment thread src/utils/phantom_moddump.f90
@danieljprice danieljprice merged commit 6a853b3 into main Jun 19, 2026
270 checks passed
@danieljprice danieljprice deleted the mega-merge branch June 19, 2026 12:59
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.

3 participants