From 9490fb7223ca9e47c4fd98bc1727947c756a60f9 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 16 Aug 2023 18:50:42 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/CloudyCooling.hpp | 74 ++++++++++++++++++---------------------- src/ShockCloud/cloud.cpp | 4 +-- 2 files changed, 36 insertions(+), 42 deletions(-) diff --git a/src/CloudyCooling.hpp b/src/CloudyCooling.hpp index e8219554d..37b97c814 100644 --- a/src/CloudyCooling.hpp +++ b/src/CloudyCooling.hpp @@ -304,58 +304,52 @@ template 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); diff --git a/src/ShockCloud/cloud.cpp b/src/ShockCloud/cloud.cpp index a6a3854ae..42d505e3e 100644 --- a/src/ShockCloud/cloud.cpp +++ b/src/ShockCloud/cloud.cpp @@ -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 { static constexpr bool is_hydro_enabled = true; @@ -63,7 +63,7 @@ template <> struct Physics_Traits { }; template <> struct quokka::EOS_Traits { - 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; };