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 #138

Closed
wants to merge 89 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
89 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
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
57 changes: 56 additions & 1 deletion 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 @@ -43,6 +48,38 @@ void SetExtAccAuxArray_Bondi( double AuxArray[], const double Time )
AuxArray[2] = amr->BoxCenter[2];
AuxArray[3] = NEWTON_G*Bondi_MassBH; // gravitational_constant*point_source_mass
AuxArray[4] = Bondi_Soften_R; // soften_length (<=0.0 --> disable)
AuxArray[5] = Bondi_Soliton;
if( Bondi_Soliton )
{
AuxArray[6] = Bondi_Soliton_m22;
AuxArray[7] = Bondi_Soliton_rc;
AuxArray[8] = NEWTON_G*Const_Msun/UNIT_M;
AuxArray[9] = UNIT_L/Const_kpc;
if( Bondi_Soliton_type > 0 )
{
switch(Bondi_Soliton_type)
{
case 1: // arctan function
AuxArray[8] *= 2/(real)3.14159265*ATAN(Time/Bondi_Soliton_t);
break;
case 2: // linear function
if( Time < Bondi_Soliton_t )
AuxArray[8] *= Time/Bondi_Soliton_t;
break;
case 3: // smooth step function
if( Time < Bondi_Soliton_t )
AuxArray[8] *= 3*SQR(Time/Bondi_Soliton_t)-2*CUBE(Time/Bondi_Soliton_t);
break;
case 4: // sigmoid
AuxArray[8] *= 2/(1+exp(-Time*log(3)/Bondi_Soliton_t))-1;
break;
case 5: // tanh
AuxArray[8] *= tanh(Time/Bondi_Soliton_t);
break;

}
}
}

} // FUNCTION : SetExtAccAuxArray_Bondi
#endif // #ifndef __CUDACC__
Expand Down Expand Up @@ -73,13 +110,31 @@ static void ExtAcc_Bondi( real Acc[], const double x, const double y, const doub
{

const double Cen[3] = { UserArray[0], UserArray[1], UserArray[2] };
const real GM = (real)UserArray[3];
real GM = (real)UserArray[3];
const real eps = (real)UserArray[4];
const bool SOL = (real)UserArray[5];
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( SOL )
{
const real m22 = (real)UserArray[6];
const real rc = (real)UserArray[7]; // In code unit or kpc
const real Coeff = (real)UserArray[8];
const real UNIT_L = (real)UserArray[9];

#ifdef Plummer
double M = GM*CUBE(r)/pow(SQR(r)+SQR(rc),1.5);
#else
real a = SQRT(POW(2.0,1.0/8.0)-1)*(r/rc);
real M = (real)4.17e9/(SQR(m22/1e-1)*(rc*UNIT_L*1e3)*POW(SQR(a)+1, 7.0))*((real)3465*POW(a,13.0)+(real)23100*POW(a,11.0)+(real)65373*POW(a,9.0)+(real)101376*POW(a,7.0)+(real)92323*POW(a,5.0)+(real)48580*POW(a,3.0)-(real)3465*a+(real)3465*POW(SQR(a)+1, 7.0)*ATAN(a));
M *= Coeff;
#endif
GM += M;
}

// Plummer
# if ( defined SOFTEN_PLUMMER )
const real _r3 = ( eps <= (real)0.0 ) ? (real)1.0/CUBE(r) : POW( SQR(r)+SQR(eps), (real)-1.5 );
Expand Down
28 changes: 22 additions & 6 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,8 +18,8 @@ extern double Bondi_SinkEk;
extern double Bondi_SinkEt;
extern int Bondi_SinkNCell;



extern bool Bondi_void;
extern bool Bondi_dynBH;

//-------------------------------------------------------------------------------------------------------
// Function : Flu_ResetByUser_Func_Bondi
Expand Down Expand Up @@ -52,6 +51,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 +115,17 @@ 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;
// Define varible to record sink mass at every time step
double SinkMass_OneSubStep_ThisRank = 0;
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 +198,23 @@ 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++)

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

if( Bondi_dynBH ){ Bondi_MassBH += SinkMass_OneSubStep_AllRank; }

} // FUNCTION : Flu_ResetByUser_API_Bondi


Expand Down
Loading