From 25d6c4457e5fb91a6c19a1b052dd50af946214b6 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 27 Oct 2024 07:11:22 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/QuokkaSimulation.hpp | 9 ++++++--- src/hydro/EOS.hpp | 6 ++++-- src/physics_info.hpp | 4 ++-- .../RadhydroShockCGS/test_radhydro_shock_cgs.cpp | 6 +++--- src/radiation/radiation_system.hpp | 11 ++++++++--- src/simulation.hpp | 4 +++- 6 files changed, 26 insertions(+), 14 deletions(-) diff --git a/src/QuokkaSimulation.hpp b/src/QuokkaSimulation.hpp index 8f231c345..3e8018e2e 100644 --- a/src/QuokkaSimulation.hpp +++ b/src/QuokkaSimulation.hpp @@ -325,8 +325,9 @@ template void QuokkaSimulation::defineComponentN template void AMRSimulation::initializeSimulationMetadata() { if constexpr (Physics_Traits::unit_system == UnitSystem::CONSTANTS) { - // if unit system is CONSTANTS, the units are not well defined unless all four constants, G, k_B, c, and a_rad, are defined. However, in a hydro simulation, only k_B is defined. In a radiation-hydrodynamics simulation, only k_B, c, and a_rad are defined. Besides, CONSTANTS is only used for testing purposes, so we don't care about the units in that case. - // units + // if unit system is CONSTANTS, the units are not well defined unless all four constants, G, k_B, c, and a_rad, are defined. However, in a hydro + // simulation, only k_B is defined. In a radiation-hydrodynamics simulation, only k_B, c, and a_rad are defined. Besides, CONSTANTS is only used + // for testing purposes, so we don't care about the units in that case. units simulationMetadata_["unit_length"] = "undefined"; simulationMetadata_["unit_mass"] = "undefined"; simulationMetadata_["unit_time"] = "undefined"; @@ -353,7 +354,9 @@ template void AMRSimulation::initializeSimulatio k_B = C::k_B; } else if constexpr (Physics_Traits::unit_system == UnitSystem::CUSTOM) { // Have to do a conversion because EOS class is not accessible here - k_B = C::k_B / (Physics_Traits::unit_length * Physics_Traits::unit_length * Physics_Traits::unit_mass / (Physics_Traits::unit_time * Physics_Traits::unit_time) / Physics_Traits::unit_temperature); + k_B = C::k_B / + (Physics_Traits::unit_length * Physics_Traits::unit_length * Physics_Traits::unit_mass / + (Physics_Traits::unit_time * Physics_Traits::unit_time) / Physics_Traits::unit_temperature); } simulationMetadata_["k_B"] = k_B; simulationMetadata_["G"] = Gconst_; diff --git a/src/hydro/EOS.hpp b/src/hydro/EOS.hpp index a4129a4d4..b629a2b22 100644 --- a/src/hydro/EOS.hpp +++ b/src/hydro/EOS.hpp @@ -72,11 +72,13 @@ template class EOS static constexpr amrex::Real boltzmann_constant_ = []() constexpr { if constexpr (Physics_Traits::unit_system == UnitSystem::CGS) { return C::k_B; - } else if constexpr (Physics_Traits::unit_system == UnitSystem::CONSTANTS) { + } else if constexpr (Physics_Traits::unit_system == UnitSystem::CONSTANTS) { return Physics_Traits::boltzmann_constant; } else if constexpr (Physics_Traits::unit_system == UnitSystem::CUSTOM) { // k_B / k_B_bar = u_l^2 * u_m / u_t^2 / u_T - return C::k_B / (Physics_Traits::unit_length * Physics_Traits::unit_length * Physics_Traits::unit_mass / (Physics_Traits::unit_time * Physics_Traits::unit_time) / Physics_Traits::unit_temperature); + return C::k_B / + (Physics_Traits::unit_length * Physics_Traits::unit_length * Physics_Traits::unit_mass / + (Physics_Traits::unit_time * Physics_Traits::unit_time) / Physics_Traits::unit_temperature); } else { static_assert(false, "Invalid unit system"); } diff --git a/src/physics_info.hpp b/src/physics_info.hpp index c35964f96..2f880fdb0 100644 --- a/src/physics_info.hpp +++ b/src/physics_info.hpp @@ -1,8 +1,8 @@ #ifndef PHYSICS_INFO_HPP_ // NOLINT #define PHYSICS_INFO_HPP_ -#include "physics_numVars.hpp" #include "fundamental_constants.H" +#include "physics_numVars.hpp" #include // enum for unit system, one of CGS, CONSTANTS, CUSTOM @@ -19,7 +19,7 @@ template struct Physics_Traits { static constexpr bool is_mhd_enabled = false; static constexpr int nGroups = 1; // number of radiation groups static constexpr UnitSystem unit_system = UnitSystem::CGS; - static constexpr double boltzmann_constant = C::k_B; // Hydro, EOS + static constexpr double boltzmann_constant = C::k_B; // Hydro, EOS static constexpr double gravitational_constant = C::Gconst; // gravity static constexpr double unit_length = 1.0; static constexpr double unit_mass = 1.0; diff --git a/src/problems/RadhydroShockCGS/test_radhydro_shock_cgs.cpp b/src/problems/RadhydroShockCGS/test_radhydro_shock_cgs.cpp index 24f0504d8..763b7263b 100644 --- a/src/problems/RadhydroShockCGS/test_radhydro_shock_cgs.cpp +++ b/src/problems/RadhydroShockCGS/test_radhydro_shock_cgs.cpp @@ -76,9 +76,9 @@ template <> struct Physics_Traits { static constexpr int nGroups = 1; // A custom unit system is used here to replicate the CGS units, for testing units conversion static constexpr UnitSystem unit_system = UnitSystem::CUSTOM; - static constexpr double unit_length = 1.0; // cm - static constexpr double unit_mass = 1.0; // g - static constexpr double unit_time = 1.0; // s + static constexpr double unit_length = 1.0; // cm + static constexpr double unit_mass = 1.0; // g + static constexpr double unit_time = 1.0; // s static constexpr double unit_temperature = 1.0; // K }; diff --git a/src/radiation/radiation_system.hpp b/src/radiation/radiation_system.hpp index 567ba39cc..56fa3f5fd 100644 --- a/src/radiation/radiation_system.hpp +++ b/src/radiation/radiation_system.hpp @@ -212,7 +212,10 @@ template class RadSystem : public HyperbolicSystem::radiation_constant; } else if constexpr (Physics_Traits::unit_system == UnitSystem::CUSTOM) { // a_rad / a_rad_bar = 1 / u_l * u_m / u_t^2 / u_T^4 - return C::a_rad / (1.0 / Physics_Traits::unit_length * Physics_Traits::unit_mass / (Physics_Traits::unit_time * Physics_Traits::unit_time) / (Physics_Traits::unit_temperature * Physics_Traits::unit_temperature * Physics_Traits::unit_temperature * Physics_Traits::unit_temperature)); + return C::a_rad / (1.0 / Physics_Traits::unit_length * Physics_Traits::unit_mass / + (Physics_Traits::unit_time * Physics_Traits::unit_time) / + (Physics_Traits::unit_temperature * Physics_Traits::unit_temperature * + Physics_Traits::unit_temperature * Physics_Traits::unit_temperature)); } else { static_assert(false, "Invalid unit system"); } @@ -257,11 +260,13 @@ template class RadSystem : public HyperbolicSystem::unit_system == UnitSystem::CGS) { return C::k_B; - } else if constexpr (Physics_Traits::unit_system == UnitSystem::CONSTANTS) { + } else if constexpr (Physics_Traits::unit_system == UnitSystem::CONSTANTS) { return Physics_Traits::boltzmann_constant; } else if constexpr (Physics_Traits::unit_system == UnitSystem::CUSTOM) { // k_B / k_B_bar = u_l^2 * u_m / u_t^2 / u_T - return C::k_B / (Physics_Traits::unit_length * Physics_Traits::unit_length * Physics_Traits::unit_mass / (Physics_Traits::unit_time * Physics_Traits::unit_time) / Physics_Traits::unit_temperature); + return C::k_B / + (Physics_Traits::unit_length * Physics_Traits::unit_length * Physics_Traits::unit_mass / + (Physics_Traits::unit_time * Physics_Traits::unit_time) / Physics_Traits::unit_temperature); } else { static_assert(false, "Invalid unit system"); } diff --git a/src/simulation.hpp b/src/simulation.hpp index 2f708b514..b39e8ea04 100644 --- a/src/simulation.hpp +++ b/src/simulation.hpp @@ -399,7 +399,9 @@ template class AMRSimulation : public amrex::AmrCore return Physics_Traits::gravitational_constant; // gravitational constant G, user defined } else if constexpr (Physics_Traits::unit_system == UnitSystem::CUSTOM) { // G / G_bar = u_l^3 / u_m / u_t^2 - return C::Gconst / (Physics_Traits::unit_length * Physics_Traits::unit_length * Physics_Traits::unit_length / Physics_Traits::unit_mass / (Physics_Traits::unit_time * Physics_Traits::unit_time)); + return C::Gconst / + (Physics_Traits::unit_length * Physics_Traits::unit_length * Physics_Traits::unit_length / + Physics_Traits::unit_mass / (Physics_Traits::unit_time * Physics_Traits::unit_time)); } else { static_assert(false, "Invalid unit system"); }