Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Aug 16, 2023
1 parent 65e35d0 commit 9490fb7
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 42 deletions.
74 changes: 34 additions & 40 deletions src/CloudyCooling.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -304,58 +304,52 @@ template <typename problem_t> void computeCooling(amrex::MultiFab &mf, const Rea
}
}

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE auto ComputeCoolingLength(double rho, double Egas, double gamma, cloudyGpuConstTables const &tables) -> Real
{
// convert (rho, Egas) to cooling length

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE auto
ComputeCoolingLength(double rho, double Egas, double gamma,
cloudyGpuConstTables const &tables) -> Real {
// convert (rho, Egas) to cooling length

// 1. convert Egas (internal gas energy) to temperature
const Real Tgas = ComputeTgasFromEgas(rho, Egas, gamma, tables);
// 1. convert Egas (internal gas energy) to temperature
const Real Tgas = ComputeTgasFromEgas(rho, Egas, gamma, tables);

// 2. compute cooling time
// interpolate cooling rates from Cloudy tables
const Real rhoH = rho * cloudy_H_mass_fraction; // mass density of H species
const Real nH = rhoH / (C::m_p + C::m_e);
const Real log_nH = std::log10(nH);
const Real log_T = std::log10(Tgas);
// 2. compute cooling time
// interpolate cooling rates from Cloudy tables
const Real rhoH = rho * cloudy_H_mass_fraction; // mass density of H species
const Real nH = rhoH / (C::m_p + C::m_e);
const Real log_nH = std::log10(nH);
const Real log_T = std::log10(Tgas);

const double logPrimCool = interpolate2d(log_nH, log_T, tables.log_nH, tables.log_Tgas, tables.primCool);
const double logMetalCool = interpolate2d(log_nH, log_T, tables.log_nH, tables.log_Tgas, tables.metalCool);
const double LambdaCool = FastMath::pow10(logPrimCool) + FastMath::pow10(logMetalCool);

const double Edot = (rhoH * rhoH) * LambdaCool;
// compute cooling time
const Real t_cool = Egas / Edot;
const double Edot = (rhoH * rhoH) * LambdaCool;
// compute cooling time
const Real t_cool = Egas / Edot;

// 3. compute cooling length c_s t_cool
// compute mu from mu(T) table
const Real mu = interpolate2d(log_nH, log_T, tables.log_nH,
tables.log_Tgas, tables.meanMolWeight);
const Real c_s = std::sqrt(gamma * C::k_B * Tgas / (mu * (C::m_p + C::m_e)));
// 3. compute cooling length c_s t_cool
// compute mu from mu(T) table
const Real mu = interpolate2d(log_nH, log_T, tables.log_nH, tables.log_Tgas, tables.meanMolWeight);
const Real c_s = std::sqrt(gamma * C::k_B * Tgas / (mu * (C::m_p + C::m_e)));

// cooling length
return c_s * t_cool;
// cooling length
return c_s * t_cool;
}

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE auto
ComputeMMW(double rho, double Egas, double gamma,
cloudyGpuConstTables const &tables) -> Real {
// convert (rho, Egas) to dimensionless mean molecular weight

// 1. convert Egas (internal gas energy) to temperature
const Real Tgas = ComputeTgasFromEgas(rho, Egas, gamma, tables);

// 2. compute mu from mu(T) table
const Real rhoH = rho * cloudy_H_mass_fraction; // mass density of H species
const Real nH = rhoH / (C::m_p + C::m_e);
const Real log_nH = std::log10(nH);
const Real log_T = std::log10(Tgas);
const Real mu = interpolate2d(log_nH, log_T, tables.log_nH,
tables.log_Tgas, tables.meanMolWeight);
return mu;
}
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE auto ComputeMMW(double rho, double Egas, double gamma, cloudyGpuConstTables const &tables) -> Real
{
// convert (rho, Egas) to dimensionless mean molecular weight

// 1. convert Egas (internal gas energy) to temperature
const Real Tgas = ComputeTgasFromEgas(rho, Egas, gamma, tables);

// 2. compute mu from mu(T) table
const Real rhoH = rho * cloudy_H_mass_fraction; // mass density of H species
const Real nH = rhoH / (C::m_p + C::m_e);
const Real log_nH = std::log10(nH);
const Real log_T = std::log10(Tgas);
const Real mu = interpolate2d(log_nH, log_T, tables.log_nH, tables.log_Tgas, tables.meanMolWeight);
return mu;
}

void readCloudyData(std::string &grackle_hdf5_file, cloudy_tables &cloudyTables);

Expand Down
4 changes: 2 additions & 2 deletions src/ShockCloud/cloud.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ struct ShockCloud {
constexpr double parsec_in_cm = 3.086e18; // cm == 1 pc
constexpr double solarmass_in_g = 1.99e33; // g == 1 Msun
constexpr double keV_in_ergs = 1.60218e-9; // ergs == 1 keV
constexpr double m_H = C::m_p + C::m_e; // mass of hydrogen atom
constexpr double m_H = C::m_p + C::m_e; // mass of hydrogen atom

template <> struct Physics_Traits<ShockCloud> {
static constexpr bool is_hydro_enabled = true;
Expand All @@ -63,7 +63,7 @@ template <> struct Physics_Traits<ShockCloud> {
};

template <> struct quokka::EOS_Traits<ShockCloud> {
static constexpr double gamma = 5./3.;
static constexpr double gamma = 5. / 3.;
static constexpr double mean_molecular_weight = C::m_u;
static constexpr double boltzmann_constant = C::k_B;
};
Expand Down

0 comments on commit 9490fb7

Please sign in to comment.