Skip to content

Commit

Permalink
rename
Browse files Browse the repository at this point in the history
  • Loading branch information
chongchonghe committed Oct 22, 2024
1 parent 823227b commit 6731a5e
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 26 deletions.
26 changes: 13 additions & 13 deletions src/radiation/radiation_dust_system.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ AMREX_GPU_DEVICE auto RadSystem<problem_t>::SolveGasDustRadiationEnergyExchange(
double Egas_guess = Egas0;
auto EradVec_guess = Erad0Vec;

const double atomic_H_num_den = ComputeNumberDensityAtomicH(rho, massScalars);
const double H_num_den = ComputeNumberDensityH(rho, massScalars);

T_gas = quokka::EOS<problem_t>::ComputeTgasFromEint(rho, Egas_guess, massScalars);
AMREX_ASSERT(T_gas >= 0.);
Expand Down Expand Up @@ -437,7 +437,7 @@ AMREX_GPU_DEVICE auto RadSystem<problem_t>::SolveGasDustRadiationEnergyExchange(

if (dust_model == 1) {
jacobian = ComputeJacobianForGasAndDust(T_gas, T_d, Egas_diff, Erad_diff, Rvec, Src, coeff_n, tau, c_v, lambda_gd_times_dt,
opacity_terms.kappaPoverE, d_fourpiboverc_d_t, atomic_H_num_den, dt);
opacity_terms.kappaPoverE, d_fourpiboverc_d_t, H_num_den, dt);
} else {
jacobian = ComputeJacobianForGasAndDustDecoupled(T_gas, T_d, Egas_diff, Erad_diff, Rvec, Src, coeff_n, tau, c_v, lambda_gd_times_dt,
opacity_terms.kappaPoverE, d_fourpiboverc_d_t);
Expand Down Expand Up @@ -512,25 +512,25 @@ AMREX_GPU_DEVICE auto RadSystem<problem_t>::SolveGasDustRadiationEnergyExchange(
// }
} // END NEWTON-RAPHSON LOOP

const auto cooling_tend = DefineNetCoolingRate(T_gas, atomic_H_num_den) * dt;
const auto cooling_tend = DefineNetCoolingRate(T_gas, H_num_den) * dt;
if (dust_model == 2) {
// include line cooling/heating, cosmic ray heating terms; implicitly update Egas_guess

const double CR_heating = DefineCosmicRayHeatingRate(atomic_H_num_den) * dt;
const double CR_heating = DefineCosmicRayHeatingRate(H_num_den) * dt;

const double compare = Egas_guess + cscale * lambda_gd_times_dt + sum(abs(cooling_tend)) + CR_heating;

// RHS of the equation 0 = Egas - Egas0 + cscale * lambda_gd_times_dt + sum(cooling)
auto rhs = [=](double Egas_) -> double {
const double T_gas_ = quokka::EOS<problem_t>::ComputeTgasFromEint(rho, Egas_, massScalars);
const auto cooling_ = DefineNetCoolingRate(T_gas_, atomic_H_num_den) * dt;
const auto cooling_ = DefineNetCoolingRate(T_gas_, H_num_den) * dt;
return Egas_ - Egas0 + cscale * lambda_gd_times_dt + sum(cooling_) - CR_heating;
};

// Jacobian of the RHS of the equation 0 = Egas - Egas0 + cscale * lambda_gd_times_dt + sum(cooling)
auto jac = [=](double Egas_) -> double {
const double T_gas_ = quokka::EOS<problem_t>::ComputeTgasFromEint(rho, Egas_, massScalars);
const auto d_cooling_d_Tgas_ = DefineNetCoolingRateTempDerivative(T_gas_, atomic_H_num_den) * dt;
const auto d_cooling_d_Tgas_ = DefineNetCoolingRateTempDerivative(T_gas_, H_num_den) * dt;
return 1.0 + sum(d_cooling_d_Tgas_);
};

Expand Down Expand Up @@ -681,8 +681,8 @@ AMREX_GPU_DEVICE auto RadSystem<problem_t>::SolveGasDustRadiationEnergyExchangeW
AMREX_ASSERT(T_gas >= 0.);

// phtoelectric heating
const double atomic_H_num_den = ComputeNumberDensityAtomicH(rho, massScalars);
const double PE_heating_energy_derivative = dt * DefinePhotoelectricHeatingE1Derivative(T_gas, atomic_H_num_den);
const double H_num_den = ComputeNumberDensityH(rho, massScalars);
const double PE_heating_energy_derivative = dt * DefinePhotoelectricHeatingE1Derivative(T_gas, H_num_den);

const double resid_tol = 1.0e-11; // 1.0e-15;
const int maxIter = 100;
Expand Down Expand Up @@ -789,7 +789,7 @@ AMREX_GPU_DEVICE auto RadSystem<problem_t>::SolveGasDustRadiationEnergyExchangeW
if (dust_model == 1) {
jacobian = ComputeJacobianForGasAndDustWithPE(T_gas, T_d, Egas_diff, EradVec_guess, Erad0Vec, PE_heating_energy_derivative, Rvec, Src,
coeff_n, tau, c_v, lambda_gd_times_dt, opacity_terms.kappaPoverE, d_fourpiboverc_d_t,
atomic_H_num_den, dt);
H_num_den, dt);
} else {
jacobian = ComputeJacobianForGasAndDustDecoupled(T_gas, T_d, Egas_diff, Erad_diff, Rvec, Src, coeff_n, tau, c_v, lambda_gd_times_dt,
opacity_terms.kappaPoverE, d_fourpiboverc_d_t);
Expand Down Expand Up @@ -864,18 +864,18 @@ AMREX_GPU_DEVICE auto RadSystem<problem_t>::SolveGasDustRadiationEnergyExchangeW
// }
} // END NEWTON-RAPHSON LOOP

const auto cooling_tend = DefineNetCoolingRate(T_gas, atomic_H_num_den) * dt;
const auto cooling_tend = DefineNetCoolingRate(T_gas, H_num_den) * dt;
if (dust_model == 2) {
// compute cooling/heating terms; implicitly update Egas_guess

const double CR_heating = DefineCosmicRayHeatingRate(atomic_H_num_den) * dt;
const double CR_heating = DefineCosmicRayHeatingRate(H_num_den) * dt;
const double compare = Egas_guess + cscale * lambda_gd_times_dt + sum(abs(cooling_tend)) + CR_heating;

// RHS of the equation 0 = Egas - Egas0 + cscale * lambda_gd_times_dt + sum(cooling) - PE_heating_energy_derivative * EradVec_guess[nGroups_ -
// 1];
auto rhs = [=](double Egas_) -> double {
const double T_gas_ = quokka::EOS<problem_t>::ComputeTgasFromEint(rho, Egas_, massScalars);
const auto cooling_ = DefineNetCoolingRate(T_gas_, atomic_H_num_den) * dt;
const auto cooling_ = DefineNetCoolingRate(T_gas_, H_num_den) * dt;
return Egas_ - Egas0 + cscale * lambda_gd_times_dt + sum(cooling_) - PE_heating_energy_derivative * EradVec_guess[nGroups_ - 1] -
CR_heating;
};
Expand All @@ -884,7 +884,7 @@ AMREX_GPU_DEVICE auto RadSystem<problem_t>::SolveGasDustRadiationEnergyExchangeW
// EradVec_guess[nGroups_ - 1];
auto jac = [=](double Egas_) -> double {
const double T_gas_ = quokka::EOS<problem_t>::ComputeTgasFromEint(rho, Egas_, massScalars);
const auto d_cooling_d_Tgas_ = DefineNetCoolingRateTempDerivative(T_gas_, atomic_H_num_den) * dt;
const auto d_cooling_d_Tgas_ = DefineNetCoolingRateTempDerivative(T_gas_, H_num_den) * dt;
return 1.0 + sum(d_cooling_d_Tgas_);
};

Expand Down
4 changes: 2 additions & 2 deletions src/radiation/radiation_system.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ template <typename problem_t> class RadSystem : public HyperbolicSystem<problem_

AMREX_GPU_HOST_DEVICE static auto ComputeEddingtonFactor(double f) -> double;

AMREX_GPU_HOST_DEVICE static auto ComputeNumberDensityAtomicH(double rho, amrex::GpuArray<Real, nmscalars_> const &massScalars) -> double;
AMREX_GPU_HOST_DEVICE static auto ComputeNumberDensityH(double rho, amrex::GpuArray<Real, nmscalars_> const &massScalars) -> double;

// Used for single-group RHD only. Not used for multi-group RHD.
AMREX_GPU_HOST_DEVICE static auto ComputePlanckOpacity(double rho, double Tgas) -> Real;
Expand Down Expand Up @@ -462,7 +462,7 @@ AMREX_GPU_HOST_DEVICE auto RadSystem<problem_t>::ComputePlanckEnergyFractions(am
}

template <typename problem_t>
AMREX_GPU_HOST_DEVICE auto RadSystem<problem_t>::ComputeNumberDensityAtomicH(double rho, amrex::GpuArray<Real, nmscalars_> const & /*massScalars*/) -> double
AMREX_GPU_HOST_DEVICE auto RadSystem<problem_t>::ComputeNumberDensityH(double rho, amrex::GpuArray<Real, nmscalars_> const & /*massScalars*/) -> double
{
return rho / mean_molecular_mass_;
}
Expand Down
8 changes: 4 additions & 4 deletions src/radiation/source_terms_multi_group.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ AMREX_GPU_DEVICE auto RadSystem<problem_t>::SolveGasRadiationEnergyExchange(
const double chat = c_hat_;
const double cscale = c / chat;

const double atomic_H_num_den = ComputeNumberDensityAtomicH(rho, massScalars);
const double H_num_den = ComputeNumberDensityH(rho, massScalars);

// const double Etot0 = Egas0 + cscale * (sum(Erad0Vec) + sum(Src));
double Etot0 = Egas0 + cscale * (sum(Erad0Vec) + sum(Src));
Expand Down Expand Up @@ -311,7 +311,7 @@ AMREX_GPU_DEVICE auto RadSystem<problem_t>::SolveGasRadiationEnergyExchange(
const auto Erad_diff = EradVec_guess - Erad0Vec;

auto jacobian =
ComputeJacobianForGas(T_d, Egas_diff, Erad_diff, Rvec, Src, tau, c_v, opacity_terms.kappaPoverE, d_fourpiboverc_d_t, atomic_H_num_den, dt);
ComputeJacobianForGas(T_d, Egas_diff, Erad_diff, Rvec, Src, tau, c_v, opacity_terms.kappaPoverE, d_fourpiboverc_d_t, H_num_den, dt);

if constexpr (use_D_as_base) {
jacobian.J0g = jacobian.J0g * tau0;
Expand Down Expand Up @@ -666,11 +666,11 @@ void RadSystem<problem_t>::AddSourceTermsMultiGroup(array_t &consVar, arrayconst
gas_update_factor = IMEX_a32;
}

const double atomic_H_num_den = ComputeNumberDensityAtomicH(rho, massScalars);
const double H_num_den = ComputeNumberDensityH(rho, massScalars);
const double cscale = c / chat;
double coeff_n = NAN;
if constexpr (enable_dust_gas_thermal_coupling_model_) {
coeff_n = dt * dustGasCoeff_local * atomic_H_num_den * atomic_H_num_den / cscale;
coeff_n = dt * dustGasCoeff_local * H_num_den * H_num_den / cscale;
}

// Outer iteration loop to update the work term until it converges
Expand Down
14 changes: 7 additions & 7 deletions src/radiation/source_terms_single_group.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,12 @@ void RadSystem<problem_t>::AddSourceTermsSingleGroup(array_t &consVar, arraycons
}

double coeff_n = NAN;
const double atomic_H_num_den = ComputeNumberDensityAtomicH(rho, massScalars);
const double H_num_den = ComputeNumberDensityH(rho, massScalars);
if constexpr (enable_dust_gas_thermal_coupling_model_) {
coeff_n = dt * dustGasCoeff_ * atomic_H_num_den * atomic_H_num_den / cscale;
coeff_n = dt * dustGasCoeff_ * H_num_den * H_num_den / cscale;
} else {
amrex::ignore_unused(coeff_n);
amrex::ignore_unused(atomic_H_num_den);
amrex::ignore_unused(H_num_den);
amrex::ignore_unused(dustGasCoeff_);
}

Expand Down Expand Up @@ -230,10 +230,10 @@ void RadSystem<problem_t>::AddSourceTermsSingleGroup(array_t &consVar, arraycons

double cooling = 0.0;
double cooling_derivative = 0.0;
const double CR_heating = DefineCosmicRayHeatingRate(atomic_H_num_den) * dt;
const double CR_heating = DefineCosmicRayHeatingRate(H_num_den) * dt;
if constexpr (enable_dust_gas_thermal_coupling_model_) {
cooling = DefineNetCoolingRate(T_gas, atomic_H_num_den)[0];
cooling_derivative = DefineNetCoolingRateTempDerivative(T_gas, atomic_H_num_den)[0];
cooling = DefineNetCoolingRate(T_gas, H_num_den)[0];
cooling_derivative = DefineNetCoolingRateTempDerivative(T_gas, H_num_den)[0];
}

F_G = Egas_guess - Egas0 + cscale * R + cooling * dt - CR_heating;
Expand Down Expand Up @@ -349,7 +349,7 @@ void RadSystem<problem_t>::AddSourceTermsSingleGroup(array_t &consVar, arraycons
AMREX_ASSERT(Erad_guess >= 0.0);

if constexpr (!add_line_cooling_to_radiation_in_jac) {
const auto cooling_tend = DefineNetCoolingRate(T_gas, atomic_H_num_den)[0] * dt;
const auto cooling_tend = DefineNetCoolingRate(T_gas, H_num_den)[0] * dt;
AMREX_ASSERT_WITH_MESSAGE(cooling_tend >= 0.,
"add_line_cooling_to_radiation has to be enabled when there is negative cooling rate!");
// TODO(CCH): potential GPU-related issue here.
Expand Down

0 comments on commit 6731a5e

Please sign in to comment.