Skip to content

Improve Par_EquilibriumIC#315

Merged
hyschive merged 96 commits intogamer-project:mainfrom
hsinhaoHHuang:Refine_Par_EquilibriumIC
Feb 12, 2026
Merged

Improve Par_EquilibriumIC#315
hyschive merged 96 commits intogamer-project:mainfrom
hsinhaoHHuang:Refine_Par_EquilibriumIC

Conversation

@hsinhaoHHuang
Copy link
Contributor

@hsinhaoHHuang hsinhaoHHuang commented May 22, 2024

Goal

Changes

  1. Adjust the user interface

    1. Move the part with reading the parameters from the input files into TestProblem/Hydro/ParticleEquilibriumIC/Init_TestProb_Hydro_ParEqmIC.cpp like other test problems.
    2. Use setXXX() as the interface to set the parameters for the cloud constructors from test problems, and only the necessary parameters are needed to be set.
    3. Support adding analytical external potential. Users can define their analytical function. Also, the potentials of some analytical models are provided.
    4. Output the relative error of the total enclosed mass by comparing it to the analytical solution instead.
    5. Output the radial distribution and energy distribution for debugging.
    6. Separate the number of bins of the input density profile, input external potential, inner radial profiles, and inner energy distribution.
  2. Adjust the calculation

    1. Unify the processes for density profiles from the table and from the analytical models.
    2. Construct the radial profiles more consistently, from the density profile to the enclosed mass profile, the potential profile, and finally the drho_dPsi profile.
    3. Use the central difference for the differentiation instead of linear regression.
    4. Add the external potential before the usage of potential to be more consistent.
    5. Extend the radial profile to a radius larger than the given MaxR for scattered particles for calculation of the distribution function to reduce the truncation error.
    6. Include the low-binding-energy (high-velocity) distribution function. When the E is smaller than the Psi_min ( at large r ), the dRho/dPsi is approximated using power-law extrapolation.
    7. Use linear extrapolation for the density profile at r = 0.
    8. Integrate the enclosed mass profile with a higher-order shell mass for the density table.
    9. Use interpolation to sample E from the probability distribution.
    10. Use interpolation to find the drho/dPsi for a given Psi.
  3. Adjust the format

    1. Rename some variables and functions.
    2. Remove some no longer used variables and functions.
    3. Add more description.
    4. Adjust the coding styles.

Verification Tests

  1. Compare the distribution to the old branch with the default double-cloud setup. ->The results can roughly match the previous results.
    1. Type = NFW

image

2. Type = Table

image

  1. Compare the distribution to the analytical solutions. -> The results can match analytical solutions.

    1. Hernquist
      image
    2. Plummer
      image
  2. Check the stability of a single NFW profile with the default setup. -> The results are stable.

New Old
Proj Proj
Prof Prof
image fig_ErrorDensityProfile
  1. Check the stability of a single Einasto density profile (scale density=1.0, scale radius=0.1)with the Plummer external potential (scale density=80.0, scale radius=0.05) (constructed with external potential and run with the same external potential). -> The results are stable.
Case Projections Profiles Error
Construct with ExtPot, Run with ExtPot Proj Prof image
Construct without ExtPot, Run with ExtPot Proj Prof image
Construct with ExtPot, Run without ExtPot Proj Prof image

@hsinhaoHHuang
Copy link
Contributor Author

I have updated it to the latest main branch and resolved the conflicts.

Copy link
Contributor

@koarakawaii koarakawaii left a comment

Choose a reason for hiding this comment

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

Temporarily review break point.

@hsinhaoHHuang
Copy link
Contributor Author

Updated to the latest main branch.

Conflicts:
	src/Particle/Par_EquilibriumIC.cpp
Co-authored-by: Hsinhao Huang <hsinaohuang@gmail.com>
Copy link
Contributor

@hyschive hyschive left a comment

Choose a reason for hiding this comment

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

@hsinhaoHHuang This PR is neat. Thanks for the excellent contributions! I only have minor comments and will proceed with merge once they are addressed.

In addition to the inline comments, please also take care of the following tasks:

  • Update the wiki to provide instructions on how to use this initial condition constructor
  • Add Record__ParEquilibriumIC_Model_* to example/test_problem/Hydro/ParticleEquilibriumIC/clean.sh

Copy link
Contributor

@hyschive hyschive left a comment

Choose a reason for hiding this comment

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

@hsinhaoHHuang This PR is neat. Thanks for the excellent contributions! I only have minor comments and will proceed with merge once they are addressed.

In addition to the inline comments, please also take care of the following tasks:

  • Update the wiki to provide instructions on how to use this initial condition constructor
  • Add Record__ParEquilibriumIC_Model_* to example/test_problem/Hydro/ParticleEquilibriumIC/clean.sh

@hsinhaoHHuang
Copy link
Contributor Author

@hyschive I have updated this PR according to the comments, including adding sanity checks for the order of function calls and adding instructions to the wiki.
Besides,

  • I changed the default Cloud_Type to Hernquist because I only have analytical distribution functions for the Plummer and Hernquist models, and Plummer has its own test problem already.
  • I fixed more grammar errors and style issues.
  • I updated the script to plot the phase-space distribution.

Please have another look when you have time and let me know whether there is anything that needs further modifications.
Thank you so much again for your thorough review and all of your helpful suggestions to improve this PR.

Copy link
Contributor

@hyschive hyschive left a comment

Choose a reason for hiding this comment

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

@hsinhaoHHuang Looks good. I only have a few minor comments before merging. Please also check this comment.

@hsinhaoHHuang
Copy link
Contributor Author

I have updated the PR according to the comments.

@hyschive hyschive merged commit bb0f20e into gamer-project:main Feb 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

3 participants