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

New IMEX integrator #612

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
48 changes: 45 additions & 3 deletions src/driver/driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@ Driver::Driver(ParameterInput *pin, Mesh *pmesh, Real wtlim, Kokkos::Timer* ptim
nimp_stages = 3;
nexp_stages = 2;
cfl_limit = 1.0;
gam0[0] = 0.0;
gam1[0] = 1.0;
gam0[0] = 1.0;
gam1[0] = 0.0;
beta[0] = 1.0;

gam0[1] = 0.5;
Expand All @@ -185,6 +185,48 @@ Driver::Driver(ParameterInput *pin, Mesh *pmesh, Real wtlim, Kokkos::Timer* ptim
a_twid[2][1] = 0.25;
a_twid[2][2] = 0.25;
a_impl = 0.5;
} else if (integrator == "imex2+") {
// IMEX(4,3,2): Krapp et al. (2024, arXiv:2310.04435), Eq.30.
// three-stage explicit, four-stage implicit, second-order ImEx
// the first two implicit stages are added for adapting Athenak's overall architecture
// Note explicit steps may not reduce to RK2 based on the parameters chosen
nimp_stages = 4;
nexp_stages = 3;
cfl_limit = 1.0;
gamma = 1.707106781186547; //1+1/sqrt(2)
gam0[0] = 1.0;
gam1[0] = 0.0;
beta[0] = gamma;

gam0[1] = (2.0*gamma-1.0)/(2.0*gamma*gamma);
gam1[1] = (1.0-(2.0*gamma-1.0)/(2.0*gamma*gamma));
beta[1] = 1.0/(2.0*gamma);

gam0[2] = 1.0;
gam1[2] = 0.0;
beta[2] = 0.0;

a_twid[0][0] = 0.0;
a_twid[0][1] = 0.0;
a_twid[0][2] = 0.0;
a_twid[0][3] = 0.0;

a_twid[1][0] = 0.0;
a_twid[1][1] = 0.0;
a_twid[1][2] = 0.0;
a_twid[1][3] = 0.0;

a_twid[2][0] = 0.0;
a_twid[2][1] = 0.0;
a_twid[2][2] = (1.0-2.0*gamma*gamma)/2.0/gamma;
a_twid[2][3] = 0.0;

a_twid[3][0] = 0.0;
a_twid[3][1] = 0.0;
a_twid[3][2] = 0.0;
a_twid[3][3] = 0.0;

a_impl = gamma;
} else if (integrator == "imex3") {
// IMEX-SSP3(4,3,3): Pareschi & Russo (2005) Table VI.
// three-stage explicit, four-stage implicit, third-order ImEx
Expand Down Expand Up @@ -258,7 +300,7 @@ Driver::Driver(ParameterInput *pin, Mesh *pmesh, Real wtlim, Kokkos::Timer* ptim
} else {
std::cout << "### FATAL ERROR in " << __FILE__ << " at line " << __LINE__
<< std::endl << "integrator=" << integrator << " not implemented. "
<< "Valid choices are [rk1,rk2,rk3,imex2,imex3]." << std::endl;
<< "Valid choices are [rk1,rk2,rk3,imex2,imex2+,imex3]." << std::endl;
exit(EXIT_FAILURE);
}
}
Expand Down
1 change: 1 addition & 0 deletions src/driver/driver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class Driver {
Real delta[4]; // weights for updating the intermediate stage (u1)
Real a_twid[4][4], a_impl; // matrix elements for implicit stages in ImEx
Real cfl_limit; // maximum CFL number for integrator
Real gamma; // gamma value for the IMEX_new integrator
Kokkos::Timer* pwall_clock_; // timer for tracking the wall clock
Real wall_time;

Expand Down
21 changes: 18 additions & 3 deletions src/ion-neutral/ion-neutral_tasks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,24 @@ TaskStatus IonNeutral::ImpRKUpdate(Driver *pdriver, int estage) {
// equations for ion-neutral drag.
// Only required for istage = (1,2,3,[4])
if (estage < pdriver->nexp_stages) {
Real gamma_adt = drag_coeff*(pdriver->a_impl)*(pmy_pack->pmesh->dt);
Real xi_adt = ionization_coeff*(pdriver->a_impl)*(pmy_pack->pmesh->dt);
Real alpha_adt = recombination_coeff*(pdriver->a_impl)*(pmy_pack->pmesh->dt);
Real gamma_adt;
Real xi_adt;
Real alpha_adt;

// Condition to set gamma_adt, xi_adt, and alpha_adt to zero
if (istage < 3 && pdriver->integrator == "imex2+") {
gamma_adt = 0.0;
xi_adt = 0.0;
alpha_adt = 0.0;
} else {
gamma_adt = drag_coeff * (pdriver->a_impl) * (pmy_pack->pmesh->dt);
xi_adt = ionization_coeff * (pdriver->a_impl) * (pmy_pack->pmesh->dt);
alpha_adt = recombination_coeff * (pdriver->a_impl) * (pmy_pack->pmesh->dt);
}

//Real gamma_adt = drag_coeff*(pdriver->a_impl)*(pmy_pack->pmesh->dt);
//Real xi_adt = ionization_coeff*(pdriver->a_impl)*(pmy_pack->pmesh->dt);
//Real alpha_adt = recombination_coeff*(pdriver->a_impl)*(pmy_pack->pmesh->dt)
auto ui = pmhd->u0;
auto un = phyd->u0;
par_for("imex_imp",DevExeSpace(),0,nmb1,0,(n3-1),0,(n2-1),0,(n1-1),
Expand Down
Loading