Skip to content

Commit

Permalink
rename variables
Browse files Browse the repository at this point in the history
  • Loading branch information
chongchonghe committed Sep 5, 2024
1 parent ad53e13 commit 75ac699
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 20 deletions.
14 changes: 7 additions & 7 deletions src/radiation/radiation_system.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ static constexpr bool special_edge_bin_slopes = false; // Use 2 and -4 as th
static constexpr bool force_rad_floor_in_iteration = false; // force radiation energy density to be positive (and above the floor value) in the Newton iteration
static constexpr bool include_work_term_in_source = true;

static const int max_ite_to_update_alpha_E = 5; // Apply to the PPL_opacity_full_spectrum only. Only update alpha_E for the first max_ite_to_update_alpha_E
static const int max_iter_to_update_alpha_E = 5; // Apply to the PPL_opacity_full_spectrum only. Only update alpha_E for the first max_iter_to_update_alpha_E
// iterations of the Newton iteration
static constexpr bool enable_dE_constrain = true;
static constexpr bool use_D_as_base = false;
Expand Down Expand Up @@ -1288,9 +1288,9 @@ AMREX_GPU_DEVICE auto RadSystem<problem_t>::ComputeDustTemperatureBateKeto(doubl
// solve for dust temperature T_d using Newton iteration
double T_d = T_d_init;
const double lambda_rel_tol = 1.0e-8;
const int max_ite_td = 100;
int ite_td = 0;
for (; ite_td < max_ite_td; ++ite_td) {
const int max_iter_td = 100;
int iter_Td = 0;
for (; iter_Td < max_iter_td; ++iter_Td) {
quokka::valarray<double, nGroups_> fourPiBoverC{};

if constexpr (nGroups_ == 1) {
Expand Down Expand Up @@ -1338,15 +1338,15 @@ AMREX_GPU_DEVICE auto RadSystem<problem_t>::ComputeDustTemperatureBateKeto(doubl
const double delta_T_d = LHS / dLHS_dTd;
T_d -= delta_T_d;

if (ite_td > 0) {
if (iter_Td > 0) {
if (std::abs(delta_T_d) < lambda_rel_tol * std::abs(T_d)) {
break;
}
}
}

AMREX_ASSERT_WITH_MESSAGE(ite_td < max_ite_td, "Newton iteration for dust temperature failed to converge.");
if (ite_td >= max_ite_td) {
AMREX_ASSERT_WITH_MESSAGE(iter_Td < max_iter_td, "Newton iteration for dust temperature failed to converge.");
if (iter_Td >= max_iter_td) {
T_d = -1.0;
}
return T_d;
Expand Down
24 changes: 12 additions & 12 deletions src/radiation/source_terms_multi_group.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ AMREX_GPU_DEVICE auto RadSystem<problem_t>::SolveMatterRadiationEnergyExchange(
kappaPVec = ComputeGroupMeanOpacity(kappa_expo_and_lower_value, radBoundaryRatios_copy, alpha_quant_minus_one);
kappaEVec = kappaPVec;
} else if constexpr (opacity_model_ == OpacityModel::PPL_opacity_full_spectrum) {
if (n < max_ite_to_update_alpha_E) {
if (n < max_iter_to_update_alpha_E) {
alpha_B = ComputeRadQuantityExponents(fourPiBoverC, radBoundaries_g_copy);
alpha_E = ComputeRadQuantityExponents(EradVec_guess, radBoundaries_g_copy);
}
Expand Down Expand Up @@ -529,9 +529,9 @@ void RadSystem<problem_t>::AddSourceTermsMultiGroup(array_t &consVar, arrayconst
}

// Outer iteration loop
const int max_ite = 5;
int ite = 0;
for (; ite < max_ite; ++ite) {
const int max_iter = 5;
int iter = 0;
for (; iter < max_iter; ++iter) {
quokka::valarray<double, nGroups_> Rvec{};
quokka::valarray<double, nGroups_> fourPiBoverC{};
quokka::valarray<double, nGroups_> kappaPVec{};
Expand All @@ -547,7 +547,7 @@ void RadSystem<problem_t>::AddSourceTermsMultiGroup(array_t &consVar, arrayconst
// Step 1.1: Compute a term required to calculate the work. This is only required in the first outer loop.

quokka::valarray<double, nGroups_> vel_times_F{};
if (ite == 0) {
if (iter == 0) {
for (int g = 0; g < nGroups_; ++g) {
const double frad0 = consPrev(i, j, k, x1RadFlux_index + numRadVars_ * g);
const double frad1 = consPrev(i, j, k, x2RadFlux_index + numRadVars_ * g);
Expand All @@ -557,22 +557,22 @@ void RadSystem<problem_t>::AddSourceTermsMultiGroup(array_t &consVar, arrayconst
}
}

// Step 1.2: Compute the gas and radiation energy update. This also updates the opacities. When ite == 0, this also computes the
// Step 1.2: Compute the gas and radiation energy update. This also updates the opacities. When iter == 0, this also computes the
// work term.

if (enable_dust_gas_thermal_coupling_model_) {
updated_energy = SolveMatterRadiationEnergyExchange(Egas0, Erad0Vec, rho, coeff_n, dt, massScalars, ite, work,
updated_energy = SolveMatterRadiationEnergyExchange(Egas0, Erad0Vec, rho, coeff_n, dt, massScalars, iter, work,
vel_times_F, Src, radBoundaries_g_copy, radBoundaryRatios_copy,
&ComputeJacobianForGasAndDust, &ComputeDustTemperatureBateKeto,
p_iteration_counter_local, p_iteration_failure_counter_local);
} else {
// Passing ComputeDustTemperatureGasOnly as GPU_LAMBDA function didn't work
// updated_energy = SolveMatterRadiationEnergyExchange(Egas0, Erad0Vec, rho, coeff_n, dt, massScalars, ite, work,
// Passing ComputeDustTemperatureGasOnly as GPU_LAMBDA function didn't work, so I have to define a separate function.
// updated_energy = SolveMatterRadiationEnergyExchange(Egas0, Erad0Vec, rho, coeff_n, dt, massScalars, iter, work,
// vel_times_F, Src, radBoundaries_g_copy, radBoundaryRatios_copy, &ComputeJacobianForGas, AMREX_GPU_LAMBDA(double
// T_gas_, double, double, quokka::valarray<double, nGroups_>, double, double, double, int,
// amrex::GpuArray<double, nGroups_ + 1>, amrex::GpuArray<double, nGroups_>) -> double { return T_gas_; }
// );
updated_energy = SolveMatterRadiationEnergyExchange(Egas0, Erad0Vec, rho, coeff_n, dt, massScalars, ite, work,
updated_energy = SolveMatterRadiationEnergyExchange(Egas0, Erad0Vec, rho, coeff_n, dt, massScalars, iter, work,
vel_times_F, Src, radBoundaries_g_copy, radBoundaryRatios_copy,
&ComputeJacobianForGas, &ComputeDustTemperatureGasOnly,
p_iteration_counter_local, p_iteration_failure_counter_local);
Expand Down Expand Up @@ -757,8 +757,8 @@ void RadSystem<problem_t>::AddSourceTermsMultiGroup(array_t &consVar, arrayconst
}
} // end full-step iteration

AMREX_ASSERT_WITH_MESSAGE(ite < max_ite, "AddSourceTerms iteration failed to converge!");
if (ite >= max_ite) {
AMREX_ASSERT_WITH_MESSAGE(iter < max_iter, "AddSourceTerms iteration failed to converge!");
if (iter >= max_iter) {
amrex::Gpu::Atomic::Add(&p_iteration_failure_counter_local[2], 1);
}

Expand Down
2 changes: 1 addition & 1 deletion src/radiation/source_terms_single_group.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ void RadSystem<problem_t>::AddSourceTermsSingleGroup(array_t &consVar, arraycons
double F_D = NAN;

const double resid_tol = 1.0e-11; // 1.0e-15;
const int maxIter = enable_dust_gas_thermal_coupling_model_ ? 100 : 50;
const int maxIter = 100;
int n = 0;
for (; n < maxIter; ++n) {
T_gas = quokka::EOS<problem_t>::ComputeTgasFromEint(rho, Egas_guess, massScalars);
Expand Down

0 comments on commit 75ac699

Please sign in to comment.