Skip to content

Number density - #871

Merged
danieljprice merged 45 commits into
mainfrom
number-density
Sep 6, 2026
Merged

danieljprice merged 45 commits into
mainfrom
number-density

Conversation

@danieljprice

Copy link
Copy Markdown
Owner

Description:
Implement h-depends-on-number density as described in Price (2012), needed for APR. Without APR the h-n formulation is identical to the usual h-rho formulation.

This P-R also implements preliminary work to allow the number density kernel to differ from the density kernel. Right now these kernels are wired to be the same but the infrastructure exists to allow them to change.

The main structural change in the code is that we now explicitly store the density as an array, rho(:), which avoids the need to use the rhoh() function all over the place. This neatens the code in a number of places.

To save disk space, we still only write h to the dump, and reconstruct rho-from-h on reading the dump, in the case where no apr is used, and when the kernel for number density is the same as the kernel for mass density.

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:
Conservation properties tested with APR (thanks to Chunliang Mu and Rebecca Nealon) and in test suite.

Did you run the bots? no

Did you update relevant documentation in the docs directory? yes

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? yes

If so, please describe what a unit test might check:
some unit tests already added

Related issues: #

@coderabbitai

coderabbitai Bot commented Aug 31, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Too many files!

This PR contains 212 files, which is 112 over the limit of 100.

To get a review, reduce the PR to 100 files or fewer by splitting it into smaller PRs or changing its base branch.

Upgrade to a paid plan to raise the limit.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Team

Run ID: 3a11dbc7-9929-4b9e-8d53-c4ea1a701512

📥 Commits

Reviewing files that changed from the base of the PR and between cb9f763 and 86f035c.

📒 Files selected for processing (212)
  • .github/workflows/test.yml
  • docs/user-guide/infile.rst
  • scripts/kernels.py
  • src/main/H2regions.f90
  • src/main/apr.f90
  • src/main/apr_region.f90
  • src/main/boundary_dynamic.f90
  • src/main/checkoptions.F90
  • src/main/checksetup.f90
  • src/main/config.F90
  • src/main/cons2prim.f90
  • src/main/cooling_radapprox.f90
  • src/main/dens.F90
  • src/main/deriv.f90
  • src/main/energies.f90
  • src/main/evolve.f90
  • src/main/extern_Bfield.f90
  • src/main/externalforces.f90
  • src/main/externalforces_gr.f90
  • src/main/force.F90
  • src/main/get_apr_level.f90
  • src/main/growth.f90
  • src/main/growth_coala.F90
  • src/main/initial.F90
  • src/main/inject_BHL.f90
  • src/main/inject_bondi.f90
  • src/main/inject_disk.f90
  • src/main/inject_firehose.f90
  • src/main/inject_galcen_winds.f90
  • src/main/inject_keplerian.f90
  • src/main/inject_keplerianshear.f90
  • src/main/inject_masstransfer.f90
  • src/main/inject_randomwind.f90
  • src/main/inject_sim.f90
  • src/main/inject_sne.f90
  • src/main/inject_steadydisc.f90
  • src/main/inject_streamer.f90
  • src/main/inject_streamer_pineda.f90
  • src/main/inject_unifwind.f90
  • src/main/inject_wind.f90
  • src/main/inject_windtunnel.f90
  • src/main/ionization.f90
  • src/main/kdtree.F90
  • src/main/kernel_WendlandC2.f90
  • src/main/kernel_WendlandC4.f90
  • src/main/kernel_WendlandC6.f90
  • src/main/kernel_cubic.f90
  • src/main/kernel_quartic.f90
  • src/main/kernel_quintic.f90
  • src/main/libphantom-amuse.f90
  • src/main/memory.f90
  • src/main/mf_write.f90
  • src/main/mpi_derivs.F90
  • src/main/mpi_utils.F90
  • src/main/options.f90
  • src/main/part.F90
  • src/main/partinject.f90
  • src/main/porosity.f90
  • src/main/ptmass.F90
  • src/main/ptmass_radiation.f90
  • src/main/radiation_implicit.f90
  • src/main/radiation_utils.f90
  • src/main/readwrite_dumps.f90
  • src/main/readwrite_infile.f90
  • src/main/relaxem.f90
  • src/main/step_leapfrog.f90
  • src/main/substepping.F90
  • src/main/tmunu2grid.f90
  • src/main/utils_gr.f90
  • src/main/utils_inject.f90
  • src/main/utils_raytracer.f90
  • src/main/utils_shuffleparticles.F90
  • src/main/writeheader.f90
  • src/setup/phantomsetup.F90
  • src/setup/relax_star.f90
  • src/setup/set_dust_options.f90
  • src/setup/set_localdisk.f90
  • src/setup/set_slab.f90
  • src/setup/set_star_utils.f90
  • src/setup/setup_BHL.f90
  • src/setup/setup_HII.f90
  • src/setup/setup_alfvenwave.f90
  • src/setup/setup_asteroidwind.f90
  • src/setup/setup_binary.f90
  • src/setup/setup_binary_coll.f90
  • src/setup/setup_blob.f90
  • src/setup/setup_bondi.f90
  • src/setup/setup_bondiinject.f90
  • src/setup/setup_chinchen.f90
  • src/setup/setup_cluster.f90
  • src/setup/setup_collidingclouds.f90
  • src/setup/setup_disc.f90
  • src/setup/setup_dustgaussvel.f90
  • src/setup/setup_dustsettle.f90
  • src/setup/setup_dustybox.f90
  • src/setup/setup_dustysedov.f90
  • src/setup/setup_empty.f90
  • src/setup/setup_firehose.f90
  • src/setup/setup_flrw.f90
  • src/setup/setup_flrwpspec.f90
  • src/setup/setup_galaxies.f90
  • src/setup/setup_galcen_stars.f90
  • src/setup/setup_galdisc.f90
  • src/setup/setup_grdisc.f90
  • src/setup/setup_grtde.f90
  • src/setup/setup_gwdisc.f90
  • src/setup/setup_hierarchical.f90
  • src/setup/setup_jadvect.f90
  • src/setup/setup_kh.f90
  • src/setup/setup_masstransfer.f90
  • src/setup/setup_mhdblast.f90
  • src/setup/setup_mhdrotor.f90
  • src/setup/setup_mhdsine.f90
  • src/setup/setup_mhdvortex.f90
  • src/setup/setup_mhdwave.f90
  • src/setup/setup_nsdisc.f90
  • src/setup/setup_orstang.f90
  • src/setup/setup_planetdisc.f90
  • src/setup/setup_prtest.f90
  • src/setup/setup_quebec.f90
  • src/setup/setup_radiativebox.f90
  • src/setup/setup_sedov.f90
  • src/setup/setup_shock.f90
  • src/setup/setup_solarsystem.f90
  • src/setup/setup_sphere.f90
  • src/setup/setup_sphereinbox.f90
  • src/setup/setup_srblast.f90
  • src/setup/setup_srpolytrope.f90
  • src/setup/setup_star.f90
  • src/setup/setup_starcluster.f90
  • src/setup/setup_taylorgreen.f90
  • src/setup/setup_testgrowthsphere.f90
  • src/setup/setup_testparticles.f90
  • src/setup/setup_tokamak.f90
  • src/setup/setup_torus.f90
  • src/setup/setup_turb.f90
  • src/setup/setup_unifdis.f90
  • src/setup/setup_wave.f90
  • src/setup/setup_wavedamp.f90
  • src/setup/setup_wddisc.f90
  • src/setup/setup_wind.f90
  • src/setup/setup_windtunnel.f90
  • src/tests/directsum.f90
  • src/tests/test_apr.f90
  • src/tests/test_coala.F90
  • src/tests/test_derivs.f90
  • src/tests/test_dust.f90
  • src/tests/test_externf.f90
  • src/tests/test_gr.f90
  • src/tests/test_gravity.f90
  • src/tests/test_growth.f90
  • src/tests/test_kernel.f90
  • src/tests/test_nonidealmhd.f90
  • src/tests/test_ptmass.f90
  • src/tests/test_radiation.f90
  • src/tests/test_sedov.f90
  • src/tests/test_setstar.f90
  • src/tests/test_wind.f90
  • src/utils/analysis_BRhoOrientation.F90
  • src/utils/analysis_CoM.f90
  • src/utils/analysis_GalMerger.f90
  • src/utils/analysis_MWpdf.f90
  • src/utils/analysis_NSmerger.f90
  • src/utils/analysis_bzrms.f90
  • src/utils/analysis_clumpfind.F90
  • src/utils/analysis_clumpfindWB23.F90
  • src/utils/analysis_collidingcloudevolution.f90
  • src/utils/analysis_collidingcloudhistograms.f90
  • src/utils/analysis_common_envelope.f90
  • src/utils/analysis_disc_MFlow.f90
  • src/utils/analysis_disc_eccentric.f90
  • src/utils/analysis_disc_mag.f90
  • src/utils/analysis_disc_stresses.f90
  • src/utils/analysis_dustydisc.f90
  • src/utils/analysis_dustywind.f90
  • src/utils/analysis_gws.f90
  • src/utils/analysis_jet.f90
  • src/utils/analysis_kepler.f90
  • src/utils/analysis_krome.F90
  • src/utils/analysis_maxquant.f90
  • src/utils/analysis_mcfost.f90
  • src/utils/analysis_pdfs.f90
  • src/utils/analysis_polytropes.f90
  • src/utils/analysis_protostar_environ.F90
  • src/utils/analysis_radiotde.f90
  • src/utils/analysis_raytracer.f90
  • src/utils/analysis_sphere.f90
  • src/utils/analysis_structurefn.f90
  • src/utils/analysis_torus.f90
  • src/utils/analysis_velocitydispersion_vs_scale.f90
  • src/utils/analysis_velocityshear.f90
  • src/utils/einsteintk_utils.f90
  • src/utils/einsteintk_wrapper.f90
  • src/utils/libphantom.f90
  • src/utils/moddump_CoM.f90
  • src/utils/moddump_LTE_to_rad.f90
  • src/utils/moddump_addsink.f90
  • src/utils/moddump_binary.f90
  • src/utils/moddump_binarystar.f90
  • src/utils/moddump_disc.f90
  • src/utils/moddump_radiotde.f90
  • src/utils/moddump_recalcuT.f90
  • src/utils/moddump_recenter.f90
  • src/utils/moddump_removeparticles_density.f90
  • src/utils/moddump_tdesink.f90
  • src/utils/moddump_temp.f90
  • src/utils/phantom2divb.f90
  • src/utils/phantom2gadget.f90
  • src/utils/phantomevcompare.f90
  • src/utils/struct_part.f90
  • src/utils/utils_getneighbours.F90
  • src/utils/utils_raytracer_all.f90

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Review on demand using usage pricing

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@danieljprice
danieljprice merged commit d3860a9 into main Sep 6, 2026
270 checks passed
@danieljprice
danieljprice deleted the number-density branch September 6, 2026 23:09
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