Skip to content

Conversation

@alisonkyoung1
Copy link
Contributor

Description:
This introduces tests for icooling=9 and ieos=24. First there's the test test_eos_stam.f90 that checks the read and interpolation of the EOS/opacity table. Second, there's a new Github workflow to run a collapsing sphere test and compare the evolution to a reference result.
Additionally, there's an improved table search in eos_stamatellos.f90.
(Lots of files have changed because I ran the bots and the year updated to 2026.)

Components modified:

  • [x ] 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:
Checked the results of the test.

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

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

alisonkyoung1 and others added 30 commits February 12, 2025 10:18
…re to save dudt_radiative, Warning- these changes make break reads for production runs: fix this
… and use epicyclic frequency in calculation of Q.
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @alisonkyoung1, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the testing infrastructure for the radiative cooling approximation (icooling=9) and a specific equation of state (ieos=24). It introduces a dedicated test for the EOS/opacity table interpolation and integrates a new GitHub workflow to validate the simulation's evolution against reference data for a collapsing sphere. These changes aim to improve the reliability and accuracy of the code's astrophysical models.

Highlights

  • New Test for Radiative Cooling Approximation: Introduced a new test (test_eos_stam.f90) specifically designed for icooling=9 and ieos=24, which checks the reading and interpolation of EOS/opacity tables.
  • Collapsing Sphere Test Workflow: Added a new GitHub Actions workflow to run a collapsing sphere test and compare its evolution against a reference result, enhancing continuous integration for this physics model.
  • Improved Table Search in EOS Module: The eos_stamatellos.f90 module now features a more robust and efficient table search mechanism for interpolation, improving the accuracy and performance of EOS calculations.
  • Copyright Year Update: The copyright year in numerous source files has been updated from 2025 to 2026, reflecting routine maintenance and project longevity.
  • New Setup for Radiative Cooling: A new setup, testcoolra, has been added to build/Makefile_setups to specifically configure simulations for star cluster formation using the radiative cooling approximation.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Ignored Files
  • Ignored by pattern: .github/workflows/** (1)
    • .github/workflows/coolingra.yml
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

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

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 tests for a new radiative cooling approximation, including a new test file, a GitHub workflow, and associated data files. It also includes a performance improvement in the table search logic within eos_stamatellos.f90 by replacing a linear search with a binary search. However, there are several issues that need to be addressed. The AUTHORS file contains merge conflicts that must be resolved. There are also critical bugs in src/setup/set_disc.f90 related to physical formula implementations. Additionally, the new test script check_masunaga_vs_maxvals.f90 has some inconsistencies that reduce its clarity and correctness. I've provided detailed comments and suggestions for these issues.

outind = leftind
return
endif
midind = floor((rightind - leftind) / 2.) + leftind
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The use of floor for integer binary search is unusual in Fortran and might be slightly less efficient than pure integer arithmetic. A more idiomatic and standard way to calculate the midpoint is midind = (leftind + rightind) / 2.

    midind = (rightind + leftind) / 2

@alisonkyoung1
Copy link
Contributor Author

Running ./phantomsetup crashes and fails to write a dump for >10^6 particles.
The issue is readwrite_dumps.f90 line 227
call write_array(1,eos_vars(itemp,:),eos_vars_label(itemp),npart,k,ipass,idump,nums,nerr)
Is this something to do with a temporary array being created due to non-contiguous data and it being too big for memory?

@alisonkyoung1
Copy link
Contributor Author

/gemini review

Copy link
Contributor

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

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 tests for the radiative cooling approximation, including a new test for EOS table interpolation and a GitHub workflow for a collapsing sphere test. The changes also include performance improvements in the table search algorithm. My review focuses on improving code clarity, robustness, and maintainability. I've identified some duplicate entries in the AUTHORS file, potential issues in a new test script, and opportunities for code refinement in the updated modules, such as removing magic numbers and commented-out code.

Stephane Michoulier <[email protected]>
Simone Ceppi <[email protected]>
Alison Young <[email protected]>
Enrico Ragusa <[email protected]>
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The author Enrico Ragusa <[email protected]> is already listed on line 13. Please remove this duplicate entry to keep the AUTHORS file clean.

Davide Dionese <[email protected]>
Josh Calcino <[email protected]>
Timothée David--Cléris <[email protected]>
Chunliang Mu <[email protected].com>
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The author Chunliang Mu <[email protected]> is already listed on line 51. Please remove this duplicate entry.

real(dp),intent(out) :: x(MAXMASU), y(MAXMASU)
integer, intent(out) :: n
integer :: u, ios, i
character(len=40) :: line
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The line buffer size is fixed to 40 characters. While this is sufficient for the current data in Masunaga_2000_collapse.csv, it's quite tight and could lead to truncation errors if the data format changes even slightly. It would be more robust to use a larger buffer, for example character(len=80) :: line.

    character(len=80) :: line

print *, "opening file", fname
open(newunit=u, file=fname, status='old', action='read', iostat=ios)
if (ios /= 0) then
print *, 'test_coolra','file not found:',fname
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The program name 'test_coolra' is hardcoded in this error message. This appears to be a copy-paste error. It should be 'check_masunaga_vs_maxvals' to match the actual program name.

       print *, 'check_masunaga_vs_maxvals','file not found:',fname

close(u)

if (n < 1) then
print *, "test_coolra","ERROR: no valid rows in ",trim(fname)
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

Similar to a previous comment, the program name 'test_coolra' is hardcoded here. It should be 'check_masunaga_vs_maxvals'.

       print *, "check_masunaga_vs_maxvals","ERROR: no valid rows in ",trim(fname)

outind = leftind
return
endif
midind = floor((rightind - leftind) / 2.) + leftind
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The use of floor here is redundant because Fortran's integer division already truncates the result. You can simplify this expression for clarity and minor performance improvement. A common and robust way to calculate the midpoint to avoid potential overflow with very large indices is midind = leftind + (rightind - leftind) / 2.

    midind = (leftind + rightind) / 2

use io, only:warning,id,master
use options, only:alpha,use_dustfrac,use_var_comp
use sphNGutils, only:itype_from_sphNG_iphase,isphNG_accreted
! use cooling_radapprox,only:od_method
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

This use statement is commented out. It appears to be leftover code, possibly from debugging. It should be removed to maintain code cleanliness.

omega = sqrt(G*star_m/r**3)
cs = cs_func(cs0,r,q_index)
if (lumdisc_setup) then
cs = get_cs_from_lum(L_lumdisc,r,Tbg_lumdisc,5./3.)
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The value for gamma is hardcoded as 5./3. in this call to get_cs_from_lum. This could lead to inconsistencies, as other parts of the code might use a different gamma. It would be more robust to pass gamma as an argument to get_HonR and use it here, ensuring consistency.

Comment on lines +1495 to +1497
real :: mu

mu = 2.381 !mean molecular mass
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The value 2.381 for the mean molecular weight mu is a magic number. It's better practice to define it as a named constant using the parameter attribute. This improves readability and makes it easier to change if needed.

 real,intent(in) :: L_star,r,T_bg,gamma
 real, parameter :: mu = 2.381 !mean molecular mass

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.

1 participant