-
Notifications
You must be signed in to change notification settings - Fork 65
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
Add DynamicalFriction Test Problem #252
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @ej-1211 ,
I am really sorry for the delayed review. 😢
Thank you for your patience.
I've had a quick look at this PR recently.
I can run the three default cases and reproduce similar results in this page.
However, the figure for the Quick_Burkert
is not 100% identical with the reference. Here is my results:
I am not sure why and I didn't figure out what may went wrong.
I provided some suggestions in the inline comments. Please take a look.
Please let me know if my messages are not clear or I misunderstood anything. 🙏 Thanks!
example/test_problem/Hydro/DynamicalFriction/Input__Parameter_NFW_interpolation
Outdated
Show resolved
Hide resolved
src/TestProblem/Hydro/DynamicalFriction/Init_TestProb_Hydro_DynamicalFriction.cpp
Outdated
Show resolved
Hide resolved
example/test_problem/Hydro/DynamicalFriction/Input__TestProb_NFW_interpolation
Outdated
Show resolved
Hide resolved
example/test_problem/Hydro/DynamicalFriction/Input__TestProb_NFW_interpolation
Outdated
Show resolved
Hide resolved
example/test_problem/Hydro/DynamicalFriction/Tools/Density_Profile_Barry_table_for_GAMER.txt
Outdated
Show resolved
Hide resolved
example/test_problem/Hydro/DynamicalFriction/Tools/plot_trajectory_movie.py
Outdated
Show resolved
Hide resolved
# (1) HALO and STELLAR Parameters | ||
HALO_TYPE NFW #* [Burkert] | ||
HALO_RHO_0 1.96311939345708e-03 #* [Msun/pc^3][665.3026853292199e-3] | ||
HALO_Rs 5.48799489144317e+03 #*Scale radius for the profile [pc][0.25e3] | ||
HALO_Rt 35e3 #*Truncate radius for the halo [pc][6e3] | ||
|
||
STELLAR_TYPE None #*[None] | ||
STELLAR_RHO_0 0 #*[Msun/pc^3][0] | ||
STELLAR_Rs 0 #*[pc][0] | ||
STELLAR_Rt 0 #*[pc][0] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found there are several parameters (e.g. HALO_*
, STELLAR_*
, PURE_TABLE
) in Input__TestProb
that are not used and are even not read by GAMER. This is weird for me.
The */+/!
notation for the variables is also quite not consistent with other test problems in GAMER. I think the input and the output for the Python script are put in the same file is confusing.
Also, it would be better if the default run is as simple as possible such that users can run it without doing many steps.
Therefore, I suggest two workflows for this test problem to improve it.
I personally prefer the 1st one because it is simpler for the user.
But I think the 2nd one is easier to implement from your current code.
The 1st suggestion:
- Put the calculation in
A_SET_IC.py
(generating density profile and deciding initial parameters) inside the GAMER source code.- Maybe take the
Plummer
test problem as the reference, seesrc/TestProblem/Hydro/Plummer/Par_Init_ByFunction_Plummer.cpp
.
- Maybe take the
- Combine
C_Chandrasekhar_dynamical_friction.py
andD_Compare.py
into the same file to handle the simulation analysis.
Steps:
- In
Input__Testprob
GC_SmallGas
FIX_CENTER
SEARCH_RADIUS
Cloud_Center
HALO_TYPE
,HALO_Rs
,HALO_Rt
,HALO_Rho0
STELLAR_TYPE
,STELLAR_Rs
,STELLAR_Rt
,STELLAR_Rho0
GC_MASS
,GC_Initial_R
PURE_TABLE
- In
Init_TestProb_Hydro_DynamicalFriction()
- Goal:
- to read the parameters to set the fluid
- to read the parameters to record the center
- to read the parameters for the GC
- Input:
GC_SmallGas
GC_MASS
,GC_Initial_R
FIX_CENTER
SEARCH_RADIUS
- Goal:
Par_Init_ByFunction_GC()
- Goal:
- to set the initial condition of the halo
- to set the initial condition of the GC
- to set the derived parameters from the input model
- Input
Cloud_Center
HALO_TYPE
,HALO_Rs
,HALO_Rt
,HALO_Rho0
STELLAR_TYPE
,STELLAR_Rs
,STELLAR_Rt
,STELLAR_Rho0
GC_MASS
,GC_Initial_R
PURE_TABLE
- Derived Parameters
- Density profile and mass profile of the halo
GC_POS
GC_VEL
Cloud_BulkVel
Cloud_Rho0
Cloud_R0
Cloud_MaxR
- Goal:
Init_ExtPot_GC()
- Goal:
- to set the external potential
- Input:
DynamicialFriction_ExtPot_Rho0
DynamicalFriction_ExtPot_R
DynamicalFriction_ExtPot_Center
DynamicalFriction_ExtPot_MFrac
- Goal:
Aux_Record_User_GC()
- Goal:
- to record the position of minimum potential
- to record the position of GC
- Input:
FIX_CENTER
SEARCH_RADIUS
- Output:
- table of the position of the minimum potential
- table of the position of the GC
- Goal:
plot_compare.py
- Goal:
- to provide the Chandrasekhar prediction
- to plot the comparison of Chandrasekhar's prediction and the simulation results.
- Input:
- Chandrasekhar_result_r-t
- table of the position of the minimum potential
- table of the position of the GC
BOX_SIZE
,NXO_TOT_X
,END_T
LN_LAMBDA_BMAX_FACTOR
,LN_LAMBDA_BMIN_FACTOR
GC_Sortening
- Output:
- Chandrasekhar_result_r-t
- radius-time comparison figures
- Goal:
The 2nd suggestion:
- Combine
A_SET_IC.py
andC_Chandrasekhar_dynamical_friction.py
to calculate the initial parameters and analytical prediction. - Set the parameters manually in
Input__TestProb
and only feed needed parameters to GAMER. - Use a script to analyze the results.
Steps
- Use a Python script to get the initial parameters
- Goal:
- to provide a density profile of the halo as the initial condition
- to provide the initial parameters for halos and GC
- to provide the Chandrasekhar prediction
- Input
Cloud_Center
HALO_TYPE
,HALO_Rs
,HALO_Rt
,HALO_Rho0
STELLAR_TYPE
,STELLAR_Rs
,STELLAR_Rt
,STELLAR_Rho0
GC_MASS
,GC_Initial_R
PURE_TABLE
BOX_SIZE
,NXO_TOT_X
,END_T
LN_LAMBDA_BMAX_FACTOR
,LN_LAMBDA_BMIN_FACTOR
GC_Sortening
- Output
- Density profile file
- Mass profile file
GC_POS
GC_VEL
Cloud_BulkVel
Cloud_Rho0
Cloud_R0
Cloud_MaxR
- Chandrasekhar_result_r-t
- Goal:
- In
Input__TestProb
GC_SmallGas
FIX_CENTER
SEARCH_RADIUS
- Density profile of the halo
- Here, maybe we can provide the generated density profiles in this test problem directory and the recommended parameters in README for the three default cases to save the user’s time.
Cloud_BulkVel
Cloud_Rho0
Cloud_R0
Cloud_MaxR
GC_MASS
GC_POS
GC_VEL
Init_TestProb_Hydro_DynamicalFriction()
- Goal:
- to read the parameters to set the fluid
- to read the parameters to record the center
- to read the parameters for the GC
- Input:
GC_SmallGas
FIX_CENTER
SEARCH_RADIUS
GC_MASS
GC_POS
GC_VEL
- Goal:
Par_Init_ByFunction_GC()
- Goal:
- to set the initial condition of the halo
- to set the initial condition of the GC
- Input
- Density profile of the halo
Cloud_BulkVel
Cloud_Rho0
Cloud_R0
Cloud_MaxR
GC_MASS
GC_POS
GC_VEL
- Goal:
Init_ExtPot_GC()
- Goal:
- to set the external potential
- Input:
DynamicialFriction_ExtPot_Rho0
DynamicalFriction_ExtPot_R
DynamicalFriction_ExtPot_Center
DynamicalFriction_ExtPot_MFrac
- Goal:
Aux_Record_User_GC()
- Goal:
- to record the position of the minimum potential
- to record the position of the GC
- Input:
FIX_CENTER
SEARCH_RADIUS
- Output:
- table of the position of the minimum potential
- table of the position of the GC
- Goal:
plot_compare.py
- Goal:
- to plot the comparison of Chandrasekhar's prediction and the simulation results.
- Input:
- Chandrasskhar_result_r-t
- table of the position of the minimum potential
- table of the position of the GC
BOX_SIZE
,NX0_TOT_X0
- Output:
- radius-time comparison figures
- Goal:
@JeiwHuang Thanks for the extremely careful and thorough review! @ej-1211: I agree with @JeiwHuang's most comments. For example,
If you have any questions or different opinions, please feel free to speak out 😉 |
|
|
|
@hsinhaoHHuang (@hyschive) Sorry for the late update, I have chosen the 1st suggestion above and have already fixed most of the problems (comments and suggestions) above, besides the fixing, in this version, we
Please review my pull request again and please tell me if you have any suggestion! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @ej-1211, Thanks for your update!
I have finished my second review and left some comments.
Please take another look, and please let me know if I didn't make myself clear.
Thanks!
Here is the result I got from the default set-up (DoublePowerLaw
)
The vertical lines look a little weird to me but I am not sure whether this is expected.
example/test_problem/Hydro/DynamicalFriction/Input__Profile_Params
Outdated
Show resolved
Hide resolved
SEARCH_RADIUS 2 # search radius for the potential minimum search (unit:spatial resolution) | ||
# If FIX_CENTER = 1, this parameter is useless | ||
# (1) HALO and STELLAR Parameters | ||
HALO_TYPE DoublePowerLaw # the type of the halo (NFW,Burkert,King,DoublePowerLaw)[DoublePowerLaw] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about adding space between different halo types (i.e. (NFW, Burkert, King, DoublePowerLaw)
)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hsinhaoHHuang Do you mean in the comment area? If the answer is yes, I have fixed it!
Aux_Message( stdout, " GC small Gas = %13.5e\n", GC_SmallGas ); | ||
Aux_Message( stdout, " GC initial radius = %13.5e\n", GC_R ); | ||
Aux_Message( stdout, " GC Mass = %13.5e\n", GC_MASS ); | ||
Aux_Message( stdout, " Fix Center = %d\n", FixCenter ); | ||
Aux_Message( stdout, " Search Radius = %13.5e\n", SearchRadius ); | ||
Aux_Message( stdout, " Pure Table = %d\n", PURE_TABLE ); | ||
Aux_Message( stdout, " Density Table Name = %s\n", TableName ); | ||
Aux_Message( stdout, " Halo Type = %s\n", HaloType ); | ||
Aux_Message( stdout, " HALO_RHO_0 = %13.5e\n", Halo_Rho0 ); | ||
Aux_Message( stdout, " HALO_Rs = %13.5e\n", Halo_Rs ); | ||
Aux_Message( stdout, " HALO_Rt = %13.5e\n", Halo_Rt ); | ||
Aux_Message( stdout, " Halo_Profle_Param_a = %13.5f\n", Halo_Profile_Param_a ); | ||
Aux_Message( stdout, " Halo_Profle_Param_b = %13.5f\n", Halo_Profile_Param_b ); | ||
Aux_Message( stdout, " Halo_Profle_Param_c = %13.5f\n", Halo_Profile_Param_c ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about using %13.7e
for better alignment?
if ( MPI_Rank == 0 ) | ||
{ | ||
char Filename[MAX_STRING]; | ||
sprintf( Filename, "%s", "Record__Result_Center" ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about specifying that it is the minimum potential in the filename?
{ | ||
fprintf(File, "%15s\t%15s\t%15s\t%15s\n", "# Time", " CenterX", " CenterY", " CenterZ"); | ||
} | ||
fprintf(File, "%15.7f\t%15.7e\t%15.7e\t%15.7e\n", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about also printing the Time as %15.7e
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I got this warning:
IntegrationWarning: The maximum number of subdivisions (50) has been achieved.
If increasing the limit yields no improvement it is advised to analyze
the integrand in order to determine the difficulties. If the position of a
local difficulty can be determined (singularity, discontinuity) one will
probably gain from splitting up the interval and calling the integrator
on the subranges. Perhaps a special-purpose integrator should be used.
@ej-1211 Just a reminder. Let's get it done this summer 💪 |
No description provided.