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

Add soliton potential for Bondi accretion problem #371

Merged
merged 105 commits into from
Jan 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
105 commits
Select commit Hold shift + click to select a range
5fb7dd7
Check accretion radius
Jul 26, 2021
439581f
Merge pull request #27 from sandy0216/master
hyschive Jul 26, 2021
ca38b30
Check accretion radius(fixed)
Jul 27, 2021
a0a8215
Check accretion radius(fixed)
Jul 27, 2021
f033471
Delete changes not related
sandy0216 Jul 27, 2021
9fbd072
Replace some tab by space
sandy0216 Jul 27, 2021
20949dc
Merge pull request #28 from sandy0216/smbh
hyschive Jul 27, 2021
af1d6cf
Add BH mass calculation
Jul 28, 2021
8e9e2c7
update the BH mass
Jul 28, 2021
a449b67
Update BH mass every time step
Jul 29, 2021
92bff23
Merge branch 'hyschive:smbh' into smbh
sandy0216 Jul 30, 2021
8a25b74
Merge branch 'master' into smbh
hyschive Jul 30, 2021
d0d5477
Merge branch 'smbh' of https://github.com/hyschive/gamer-fork into smbh
hyschive Jul 30, 2021
34ed45e
Merge 'master' into 'smbh'
hyschive Aug 2, 2021
aaf02b7
Edit the header in Record__BondiAccretionRate
sandy0216 Aug 2, 2021
3307f40
Merge branch 'hyschive:smbh' into smbh
sandy0216 Aug 2, 2021
2a17289
Update Flu_ResetByUser_Bondi.cpp
sandy0216 Aug 3, 2021
76d448d
Update Init_TestProb_Hydro_Bondi.cpp
sandy0216 Aug 3, 2021
ce7a868
Change some local varible
Aug 3, 2021
495939b
Merge pull request #29 from sandy0216/smbh
sandy0216 Aug 3, 2021
f5f78fd
Revert "Update BH mass"
hyschive Aug 3, 2021
e6d499d
Merge pull request #30 from hyschive/revert-29-smbh
hyschive Aug 3, 2021
0d776f1
Update BH mass
Aug 3, 2021
790a589
Merge pull request #31 from sandy0216/smbh
hyschive Aug 3, 2021
86d301a
Minor update of code formatting
hyschive Aug 3, 2021
8226e2b
Add varibles
Aug 3, 2021
3e6ab6b
Add the initial profile
Aug 4, 2021
5666fcc
Add initial condition.2
Aug 4, 2021
1d01036
add external accretion
Aug 4, 2021
1e4140c
add external accretion(fixed)
Aug 4, 2021
07c342d
Merge master
hyschive Aug 12, 2021
3d0fb91
add soliton
Aug 13, 2021
a990550
Merge branch 'hyschive:master' into soliton
sandy0216 Aug 13, 2021
8639d9c
Merge branch 'master' into smbh
hyschive Aug 20, 2021
255064f
Merge "mhd-1st-corr"
hyschive Sep 5, 2021
3e3e785
Merge "master"
hyschive Sep 23, 2021
b34916f
Merge "master"
hyschive Oct 3, 2021
23cc48a
Merge branch 'master' into smbh
hyschive Oct 3, 2021
ec40b0f
Merge "master"
hyschive Oct 17, 2021
091dd94
Merge master
hyschive Oct 20, 2021
d7052c0
Merge "master"
hyschive Oct 24, 2021
b30e39f
soliton successfully add
Oct 24, 2021
fd44a46
Merge branch 'soliton' of https://github.com/sandy0216/gamer-fork int…
Oct 24, 2021
c2f36e5
Add bondi initial condition
Oct 25, 2021
f4543f8
Merge branch 'master' into smbh
hyschive Nov 13, 2021
931d50e
add bondi initial condition
Nov 16, 2021
359a955
Merge branch 'master' into smbh
hyschive Jan 4, 2022
5380ea6
Merge branch 'master' into smbh
hyschive Jan 9, 2022
be713c8
Merge branch 'master' into smbh
hyschive Jan 22, 2022
cfe1358
Merge branch 'master' into smbh
hyschive Mar 4, 2022
8661ae0
Merge branch 'hyschive:master' into soliton
sandy0216 Mar 8, 2022
e644548
Saving some change
Mar 8, 2022
621969f
Merge branch 'soliton' of https://github.com/sandy0216/gamer-fork int…
Mar 8, 2022
5d25b75
Merge branch 'master' into smbh
hyschive Mar 9, 2022
eb74d08
Merge branch 'master' into smbh
hyschive Mar 13, 2022
2508d1b
Merge branch 'master' into smbh
hyschive Mar 25, 2022
eb81d0d
Merge branch 'master' into smbh
hyschive Mar 25, 2022
fa349d7
Merge branch 'master' into smbh
hyschive Mar 25, 2022
ea7e605
Merge branch 'master' into smbh
hyschive Apr 4, 2022
d5f4fe1
Support input Mhalo and z to calculate rc
Apr 20, 2022
7317aa7
remove other density profile
Apr 20, 2022
bc6f06e
Merge "master"
hyschive Jun 14, 2022
76ba6f0
Before adding Bondi_Soliton_t
Jun 23, 2022
0c865fc
Merge branch 'master' into smbh
hyschive Jun 25, 2022
845fbae
Pass time to SetExtAccAuxArray_Bondi()
hyschive Jun 25, 2022
28a2cc2
save before merge
Jun 28, 2022
ce6b479
Merge remote-tracking branch 'fish-gamer/smbh' into soliton
Jun 28, 2022
37eacd0
change where we place arctan
Jun 29, 2022
c8fc14a
revise real/macro functions
Jun 30, 2022
33175ec
save before add linear
Jul 19, 2022
48e3be8
add linear function
Jul 24, 2022
38ddace
add smooth function and sigmoid
Jul 25, 2022
e984454
modify linear/smooth/sigmoid function
Jul 25, 2022
d4b6515
re-check functions
Jul 27, 2022
44b4e53
merge from branch smbh
Jul 31, 2022
e93a2c0
add tanh function
Aug 2, 2022
df1e411
resolve merge conflict
Jan 25, 2023
894e0d5
save before merge
May 8, 2023
02d9c0d
solve merge conflict
May 8, 2023
23a13a6
save after merge
May 8, 2023
7d99d44
Merge branch 'soliton' of https://github.com/sandy0216/gamer-fork int…
May 8, 2023
da8a1e6
change Makefile
Oct 13, 2024
0ecb25c
Merge branch 'master' of https://github.com/sandy0216/gamer-fork
Oct 13, 2024
0234e36
solving merge conflict I
Oct 13, 2024
1f0f1b1
uncomment Bondi_Init
Oct 13, 2024
c9e4af9
uncomment Bondi_Init II
Oct 13, 2024
dfd1334
set other file same for merge
Oct 13, 2024
258f1a8
set other file same for merge II
Oct 13, 2024
246001e
Make Makefile_base the same
Oct 13, 2024
998f425
Merge branch 'main' into soliton
hyschive Jan 25, 2025
2c27272
Remove tabs and trailing spaces
hyschive Jan 25, 2025
a0d9c04
Compile without GSL
hyschive Jan 25, 2025
2703181
Address reviewer's comments
hyschive Jan 25, 2025
136c7ef
Remove Bondi_Init since it's only for testing purposes
hyschive Jan 25, 2025
bc94cc1
Remove Bondi_Soliton_PresProf and GSL since they are only used for Bo…
hyschive Jan 25, 2025
2bcce2f
Add new parameters to Input__TestProb
hyschive Jan 25, 2025
abdf5e9
Disable Bondi_dynBH by default; convert units
hyschive Jan 25, 2025
8e24479
Style
hyschive Jan 25, 2025
fd82597
Minor
hyschive Jan 26, 2025
d42930f
Simplify the expression of soliton external potential
hyschive Jan 26, 2025
5112534
Minor
hyschive Jan 26, 2025
3ee9a4c
Merge branch 'main' into soliton
hyschive Jan 26, 2025
f4619f2
Set soliton parameters in Input__TestProb
hyschive Jan 26, 2025
b1af04e
Correct indices in Bondi/plot_diagonal.gpt
hyschive Jan 26, 2025
8a5149c
Merge pull request #1 from hyschive/soliton
sandy0216 Jan 26, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions example/test_problem/Hydro/Bondi/Input__TestProb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ Bondi_InBC_Rho 1.0e-32 # density inside the void region (in
Bondi_InBC_T 1.0e-7 # temperature inside the void region (in keV)
Bondi_InBC_NCell 2.0 # number of finest cells (can be a fractional number) for the inner BC
Bondi_Soften_NCell 0.0 # number of finest cells (can be a fractional number) for the soften length (<=0.0 -> disable)
Bondi_void 1 # enable the void region [1]
Bondi_dynBH 0 # dynamically increase BH mass [0]

Bondi_HSE 0 # enable HSE [0]
Bondi_HSE_Mode 1 # initial configuration (1:T=Bondi_T0, 2:rho~1/r, 3:beta model) [1]
Expand All @@ -22,3 +24,13 @@ Bondi_HSE_TrunD 1.6735328e-24 # see Bondi_HSE_Truncate (in g/cm^3)
Bondi_HSE_TrunSmoothR 5.0e-2 # smooth out density within TrunR-SmoothR<r<TrunR+SmoothR (in kpc; <0.0->off) [-1.0]
Bondi_HSE_Pres_NormT 0 # normalize pressure profile such that T(r=Dens_NormR)=Bondi_T0 [0]
Bondi_HSE_Beta_Rcore 1.0e-1 # core radius in the beta model (in kpc)

Bondi_Soliton 0 # add soliton external potential [0]
Bondi_Soliton_m22 1.0 # FDM particle mass in 1e-22 eV/c^2 for Bondi_Soliton [-1.0]
Bondi_Soliton_type 5 # functional form for gradually introducing the soliton potential
# (0:unity, 1:arctan, 2:linear, 3:smooth step function, 4:sigmoid, 5:tanh) [5]
Bondi_Soliton_t 4.0e3 # characteristic time normalized to Bondi_TimeB for adding the soliton potential [-1.0]
Bondi_Soliton_rc -1.0 # soliton radius for Bondi_Soliton (in kpc)
# (<0.0 --> compute from Bondi_Soliton_MassHalo/Redshift using the core-halo relation) [-1.0]
Bondi_Soliton_MassHalo 1.0e11 # halo mass for determining Bondi_Soliton_rc (in Msun) [-1.0]
Bondi_Soliton_Redshift 7.0 # redshift for determining Bondi_Soliton_rc [-1.0]
4 changes: 2 additions & 2 deletions example/test_problem/Hydro/Bondi/plot_diagonal.gpt
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ do for [ID=ID_START:ID_END:ID_DELTA] {
set yrange [1.0e-3:2.0e1]

plot sprintf( '%s/Diag_%06d', FILE_SIMU, ID ) \
u (abs($4-CENTER)*3**0.5):16 w p pt 6 lc 6 tit 'Simulation' \
u (abs($4-CENTER)*3**0.5):17 w p pt 6 lc 6 tit 'Simulation' \
,FILE_BONDI u 2:7 w l lc -1 tit 'Analytical'


Expand All @@ -79,7 +79,7 @@ do for [ID=ID_START:ID_END:ID_DELTA] {
set yrange [1.0e-2:1.0e3]

plot sprintf( '%s/Diag_%06d', FILE_SIMU, ID ) \
u (abs($4-CENTER)*3**0.5):13 w p pt 6 lc 6 tit 'Simulation' \
u (abs($4-CENTER)*3**0.5):14 w p pt 6 lc 6 tit 'Simulation' \
,FILE_BONDI u 2:( ($6/$7)**2.0*$4/GAMMA ) w l lc -1 tit 'Analytical'


Expand Down
84 changes: 76 additions & 8 deletions src/TestProblem/Hydro/Bondi/ExtAcc_Bondi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@

extern double Bondi_MassBH;
extern double Bondi_Soften_R;
extern bool Bondi_Soliton;
extern double Bondi_Soliton_m22;
extern double Bondi_Soliton_rc;
extern int Bondi_Soliton_type;
extern double Bondi_Soliton_t;

//-------------------------------------------------------------------------------------------------------
// Function : SetExtAccAuxArray_Bondi
Expand All @@ -41,9 +46,55 @@ void SetExtAccAuxArray_Bondi( double AuxArray[], const double Time )
AuxArray[0] = amr->BoxCenter[0];
AuxArray[1] = amr->BoxCenter[1];
AuxArray[2] = amr->BoxCenter[2];
AuxArray[3] = NEWTON_G*Bondi_MassBH; // gravitational_constant*point_source_mass
AuxArray[3] = NEWTON_G*Bondi_MassBH; // gravitational_constant*black_hole_mass (in code units)
AuxArray[4] = Bondi_Soften_R; // soften_length (<=0.0 --> disable)

double Coeff_t;
switch ( Bondi_Soliton_type )
{
// unity
case 0: Coeff_t = 1.0;
break;

// arctan function
case 1: Coeff_t = 2.0/M_PI*atan( Time/Bondi_Soliton_t );
break;

// linear function
case 2: Coeff_t = ( Time < Bondi_Soliton_t ) ? Time/Bondi_Soliton_t
: 1.0;
break;

// smooth step function
case 3: Coeff_t = ( Time < Bondi_Soliton_t ) ? 3.0*SQR( Time/Bondi_Soliton_t ) - 2.0*CUBE( Time/Bondi_Soliton_t )
: 1.0;
break;

// sigmoid
case 4: Coeff_t = 2.0 / ( 1.0 + exp( -Time*log(3.0)/Bondi_Soliton_t ) ) - 1.0;
break;

// tanh
case 5: Coeff_t = tanh( Time/Bondi_Soliton_t );
break;

default:
Aux_Error( ERROR_INFO, "unsupported Bondi_Soliton_type (%d) !!\n", Bondi_Soliton_type );
} // switch ( Bondi_Soliton_type )

if ( Bondi_Soliton )
{
AuxArray[5] = Coeff_t*NEWTON_G*( 4.17e9*Const_Msun/UNIT_M )/
( SQR( Bondi_Soliton_m22*(real)10.0 )*( Bondi_Soliton_rc*UNIT_L/Const_pc ) );
AuxArray[6] = Bondi_Soliton_rc;
}

else
{
AuxArray[5] = -1.0;
AuxArray[6] = -1.0;
}

} // FUNCTION : SetExtAccAuxArray_Bondi
#endif // #ifndef __CUDACC__

Expand Down Expand Up @@ -72,13 +123,30 @@ static void ExtAcc_Bondi( real Acc[], const double x, const double y, const doub
const double UserArray[] )
{

const double Cen[3] = { UserArray[0], UserArray[1], UserArray[2] };
const real GM = (real)UserArray[3];
const real eps = (real)UserArray[4];
const real dx = (real)(x - Cen[0]);
const real dy = (real)(y - Cen[1]);
const real dz = (real)(z - Cen[2]);
const real r = SQRT( dx*dx + dy*dy + dz*dz );
const double Cen[3] = { UserArray[0], UserArray[1], UserArray[2] };
real GM = (real)UserArray[3];
const real eps = (real)UserArray[4];
const real GM0_sol = (real)UserArray[5];
const real rc = (real)UserArray[6];
const real dx = (real)(x - Cen[0]);
const real dy = (real)(y - Cen[1]);
const real dz = (real)(z - Cen[2]);
const real r = SQRT( dx*dx + dy*dy + dz*dz );

if ( GM0_sol > (real)0.0 && rc > (real)0.0 )
{
const real a = SQRT( POW( (real)2.0, (real)1.0/(real)8.0 ) - (real)1.0 )*(r/rc);
const real GM_sol = (real)GM0_sol/( POW( SQR(a)+(real)1.0, (real)7.0 ) )*
( (real) 3465*POW( a, (real)13.0 )
+(real) 23100*POW( a, (real)11.0 )
+(real) 65373*POW( a, (real) 9.0 )
+(real)101376*POW( a, (real) 7.0 )
+(real) 92323*POW( a, (real) 5.0 )
+(real) 48580*POW( a, (real) 3.0 )
-(real) 3465*a
+(real) 3465*POW( SQR(a)+(real)1.0, (real)7.0 )*ATAN(a) );
GM += GM_sol;
} // if ( GM0_sol > 0.0 && rc > 0.0 )

// Plummer
# if ( defined SOFTEN_PLUMMER )
Expand Down
29 changes: 25 additions & 4 deletions src/TestProblem/Hydro/Bondi/Flu_ResetByUser_Bondi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

#if ( MODEL == HYDRO && defined GRAVITY )



extern double Bondi_MassBH;
extern double Bondi_InBC_Rho;
extern double Bondi_InBC_R;
extern double Bondi_InBC_E;
Expand All @@ -19,6 +18,9 @@ extern double Bondi_SinkEk;
extern double Bondi_SinkEt;
extern int Bondi_SinkNCell;

extern bool Bondi_void;
extern bool Bondi_dynBH;




Expand Down Expand Up @@ -52,6 +54,9 @@ int Flu_ResetByUser_Func_Bondi( real fluid[], const double Emag, const double x,
const double dt, const int lv, double AuxArray[] )
{

if ( !Bondi_void ) return false;


const double Pos[3] = { x, y, z };
const double InBC_R2 = SQR( Bondi_InBC_R );
double dr2[3], r2;
Expand Down Expand Up @@ -113,14 +118,16 @@ void Flu_ResetByUser_API_Bondi( const int lv, const int FluSg, const int MagSg,
int Reset;
real fluid[NCOMP_TOTAL], fluid_bk[NCOMP_TOTAL];
double x, y, z, x0, y0, z0;
double SinkMass_OneSubStep_ThisRank = 0.0; // variables to record sink mass at every time step
double SinkMass_OneSubStep_AllRank;

// reset to 0 since we only want to record the number of void cells **for one sub-step**
Bondi_SinkNCell = 0;


# pragma omp parallel for private( Reset, fluid, fluid_bk, x, y, z, x0, y0, z0 ) schedule( runtime ) \
reduction(+:Bondi_SinkMass, Bondi_SinkMomX, Bondi_SinkMomY, Bondi_SinkMomZ, Bondi_SinkMomXAbs, Bondi_SinkMomYAbs, Bondi_SinkMomZAbs, \
Bondi_SinkEk, Bondi_SinkEt, Bondi_SinkNCell)
Bondi_SinkEk, Bondi_SinkEt, Bondi_SinkNCell, SinkMass_OneSubStep_ThisRank )
for (int PID=0; PID<amr->NPatchComma[lv][1]; PID++)
{
x0 = amr->patch[0][lv][PID]->EdgeL[0] + 0.5*dh;
Expand Down Expand Up @@ -193,12 +200,26 @@ void Flu_ResetByUser_API_Bondi( const int lv, const int FluSg, const int MagSg,
Bondi_SinkEk += dv*Ek;
Bondi_SinkEt += dv*Et;
Bondi_SinkNCell ++;

SinkMass_OneSubStep_ThisRank += dv*fluid_bk[DENS];
}
} // if ( Reset )

else if ( amr->patch[0][lv][PID]->son == -1 )
{
// void region must be completely refined to the max level
Aux_Error( ERROR_INFO, "void region lies outside the max-level region !!\n" );
}
} // if ( Reset )
}}} // i,j,k
} // for (int PID=0; PID<amr->NPatchComma[lv][1]; PID++)

if ( Bondi_dynBH )
{
MPI_Allreduce( &SinkMass_OneSubStep_ThisRank, &SinkMass_OneSubStep_AllRank, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD );

Bondi_MassBH += SinkMass_OneSubStep_AllRank;
}

} // FUNCTION : Flu_ResetByUser_API_Bondi


Expand Down
Loading
Loading