Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update the CDM halo construction in HaloMerger test problem #134

Open
wants to merge 4 commits into
base: psidm
Choose a base branch
from

Conversation

hsinhaoHHuang
Copy link
Collaborator

@hsinhaoHHuang hsinhaoHHuang commented Sep 28, 2024

[Part I.] Support adding the external potential for CDM halo construction

Why

The CDM halo is constructed using the Par_EquilibriumIC, which can construct the particle cloud with its velocity dispersion taking the external potential into account. Previously, in the HaloMerger test problem, this functionality was forced to be turned off internally because we didn't need it. However, in future applications (e.g., putting a particle cloud inside an FDM halo), we may need to construct the particle cloud in equilibrium with an external potential.

Changes

  • Add the option HaloMerger_ParCloud_?_BuiltWithExtPot in Input__TestProb_ParCloud to decide whether to consider the external potential for constructing the particle cloud.
  • Use the parameter HaloMerger_ParCloud_?_ExtPot_Filename to provide the external potential table if HaloMerger_ParCloud_?_BuiltWithExtPot is on.
  • Add a Python script, Make_ParCloud_ExtPotTable.py, to generate the example external potential table.
    • This is the potential of a uniform-density sphere, which is consistent with and can be checked by the default external potential implementation in this test problem (set in Input__TestProb).

Verifications

Setups

  • Run python3 Make_ParCloud_ExtPotTable.py
  • Set OPT__EXT_POT = 1 in Input__Parameter.
  • In Input__TestProb
HaloMerger_Halo_Num                     0
HaloMerger_ParCloud_Num                 2
HaloMerger_ExtPot_UniDenSph_M           1.08565410e-01
HaloMerger_ExtPot_UniDenSph_R           9.70381642e-03
HaloMerger_ExtPot_UniDenSph_CenCoordX   0.19407633
HaloMerger_ExtPot_UniDenSph_CenCoordY   0.12938422
HaloMerger_ExtPot_UniDenSph_CenCoordZ   0.12938422
  • In Input__TestProb_ParCloud
HaloMerger_ParCloud_1_VelocityX         0.0
HaloMerger_ParCloud_2_VelocityX         0.0
HaloMerger_ParCloud_2_BuiltWithExtPot   1
HaloMerger_ParCloud_2_ExtPot_Filename   ParCloud_ExtPotTable

Results

  • The left halo is constructed without the external potential. It is stable by itself.
  • The right halo is constructed with the external potential. It is stable if OPT__EXT_POT = 1 (left), and it will spread out if OPT__EXT_POT = 0 (right).
Run with the external potential Run without the external potential
image image

Issues

The current version of Par_EquilibriumIC has some limitations (e.g., the bins of the external potential table have to be the same as the density profile table) and potential bugs with the effect of external potential.


[Part II.] Change the CDM halo density profile

Why

The CDM halo in the HaloMerger test problem is constructed from the given density profile.
Previously, we used the formula rho_0 * ( x**(-gamma) ) * ( ( 1.0+(x**alpha) )**( (gamma-beta)/alpha ) ) to fit the FDM halo without a soliton and construct the CDM halo.
However, the density distribution of the CDM halo looks more extended than the FDM halo.
Although the differences are in the large-radius and small-density regions, it still makes the comparison of simulation results between CDM and FDM less straightforward.

Changes

Therefore, in this PR, we change the default CDM density profile to the density profile extracted from the FDM simulations.

  • The new density profile is called "FDMHaloDensityProfile", and the old fitted one is renamed "FitHaloDensityProfile".

In this way, the density distributions (especially at the large radius) look almost the same.

Density Projections

Old CDM New CDM FDM
image image image

Density Profiles

Old CDM New CDM FDM
image image image

@hsinhaoHHuang hsinhaoHHuang changed the title Change the CDM halo density profile in HaloMerger test problem Update the CDM halo construction in HaloMerger test problem Oct 31, 2024
@hsinhaoHHuang
Copy link
Collaborator Author

Since these two parts are small and both about the CDM halo construction, I implemented them in the same branch. Therefore, I have modified this PR and changed the title and description.



###################################################################################################################
# save to file
Copy link
Collaborator

Choose a reason for hiding this comment

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

How about printing a warning message if the file already exists?

@@ -99,7 +99,7 @@ def Soliton_fitting_analytical_dens(r, m22, r_c):

###################################################################################################################
# save to file
np.savetxt( 'HaloDensityProfile',
np.savetxt( 'FitHaloDensityProfile',
Copy link
Collaborator

Choose a reason for hiding this comment

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

How about printing a warning message if the file already exists?

- The initial condition can be constructed as an equilibrium with external potential by reading the provided external potential table
- The external potential table "ParCloud_ExtPotTable" can be generated by running the Python script "python3 Make_ParCloud_ExtPotTable.py",
where the default is the potential of a uniform density sphere with 3x mass and 0.3x radius of the default CDM halo
c. Enable compilation options: PARTICLE, SUPPORT_GSL
Copy link
Collaborator

Choose a reason for hiding this comment

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

Since we do not edit Makefile directly anymore, how about changing to add options in generage_make.sh?

- Set the parameter OPT__FREEZE_FLUID to 1 in Input__Parameter for particle-only simulations
- The default particle clouds use the FDMHaloDensityProfile (see Note 7. below) to represent the CDM halos
- The initial condition can be constructed as an equilibrium with external potential by reading the provided external potential table
- The external potential table "ParCloud_ExtPotTable" can be generated by running the Python script "python3 Make_ParCloud_ExtPotTable.py",
Copy link
Collaborator

Choose a reason for hiding this comment

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

If the script is for Python3 only, how about adding a version check in the script?

7. The default FDMHaloDensityProfile is extracted from the default HALO_IC
a. Run the default ELBDM case to get Data_000000
b. Adjust the plot_script/plot__density_profile.py: set `r_sphere = (50.0, 'kpc')` and `nbin = 128`
c. Run `python3 plot__density_profile.py -s 0 -e 0`
Copy link
Collaborator

Choose a reason for hiding this comment

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

If the script is for Python3 only, how about adding a version check in the script?

Comment on lines +57 to +60
np.savetxt( 'ParCloud_ExtPotTable',
np.column_stack( (ParCloud_ExtPot_table_radius, ParCloud_ExtPot_table_potential) ),
fmt=' %9.8e',
header=' r potential' )
Copy link
Collaborator

Choose a reason for hiding this comment

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

How about using this format?

Suggested change
np.savetxt( 'ParCloud_ExtPotTable',
np.column_stack( (ParCloud_ExtPot_table_radius, ParCloud_ExtPot_table_potential) ),
fmt=' %9.8e',
header=' r potential' )
np.savetxt( 'ParCloud_ExtPotTable',
np.column_stack( (ParCloud_ExtPot_table_radius, ParCloud_ExtPot_table_potential) ),
fmt='%23.8e',
header='%21s %23s'%('r', 'potential') )

This can make it easier to maintain the text file.

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.

2 participants