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 Oct 27, 2024
1 parent 7316bb8 commit 25d6c44
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 14 deletions.
9 changes: 6 additions & 3 deletions src/QuokkaSimulation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -325,8 +325,9 @@ template <typename problem_t> void QuokkaSimulation<problem_t>::defineComponentN
template <typename problem_t> void AMRSimulation<problem_t>::initializeSimulationMetadata()
{
if constexpr (Physics_Traits<problem_t>::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";
Expand All @@ -353,7 +354,9 @@ template <typename problem_t> void AMRSimulation<problem_t>::initializeSimulatio
k_B = C::k_B;
} else if constexpr (Physics_Traits<problem_t>::unit_system == UnitSystem::CUSTOM) {
// Have to do a conversion because EOS class is not accessible here
k_B = C::k_B / (Physics_Traits<problem_t>::unit_length * Physics_Traits<problem_t>::unit_length * Physics_Traits<problem_t>::unit_mass / (Physics_Traits<problem_t>::unit_time * Physics_Traits<problem_t>::unit_time) / Physics_Traits<problem_t>::unit_temperature);
k_B = C::k_B /
(Physics_Traits<problem_t>::unit_length * Physics_Traits<problem_t>::unit_length * Physics_Traits<problem_t>::unit_mass /
(Physics_Traits<problem_t>::unit_time * Physics_Traits<problem_t>::unit_time) / Physics_Traits<problem_t>::unit_temperature);
}
simulationMetadata_["k_B"] = k_B;
simulationMetadata_["G"] = Gconst_;
Expand Down
6 changes: 4 additions & 2 deletions src/hydro/EOS.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,13 @@ template <typename problem_t> class EOS
static constexpr amrex::Real boltzmann_constant_ = []() constexpr {
if constexpr (Physics_Traits<problem_t>::unit_system == UnitSystem::CGS) {
return C::k_B;
} else if constexpr (Physics_Traits<problem_t>::unit_system == UnitSystem::CONSTANTS) {
} else if constexpr (Physics_Traits<problem_t>::unit_system == UnitSystem::CONSTANTS) {
return Physics_Traits<problem_t>::boltzmann_constant;
} else if constexpr (Physics_Traits<problem_t>::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<problem_t>::unit_length * Physics_Traits<problem_t>::unit_length * Physics_Traits<problem_t>::unit_mass / (Physics_Traits<problem_t>::unit_time * Physics_Traits<problem_t>::unit_time) / Physics_Traits<problem_t>::unit_temperature);
return C::k_B /
(Physics_Traits<problem_t>::unit_length * Physics_Traits<problem_t>::unit_length * Physics_Traits<problem_t>::unit_mass /
(Physics_Traits<problem_t>::unit_time * Physics_Traits<problem_t>::unit_time) / Physics_Traits<problem_t>::unit_temperature);
} else {
static_assert(false, "Invalid unit system");
}
Expand Down
4 changes: 2 additions & 2 deletions src/physics_info.hpp
Original file line number Diff line number Diff line change
@@ -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 <AMReX.H>

// enum for unit system, one of CGS, CONSTANTS, CUSTOM
Expand All @@ -19,7 +19,7 @@ template <typename problem_t> 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;
Expand Down
6 changes: 3 additions & 3 deletions src/problems/RadhydroShockCGS/test_radhydro_shock_cgs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ template <> struct Physics_Traits<ShockProblem> {
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
};

Expand Down
11 changes: 8 additions & 3 deletions src/radiation/radiation_system.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,10 @@ template <typename problem_t> class RadSystem : public HyperbolicSystem<problem_
return RadSystem_Traits<problem_t>::radiation_constant;
} else if constexpr (Physics_Traits<problem_t>::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<problem_t>::unit_length * Physics_Traits<problem_t>::unit_mass / (Physics_Traits<problem_t>::unit_time * Physics_Traits<problem_t>::unit_time) / (Physics_Traits<problem_t>::unit_temperature * Physics_Traits<problem_t>::unit_temperature * Physics_Traits<problem_t>::unit_temperature * Physics_Traits<problem_t>::unit_temperature));
return C::a_rad / (1.0 / Physics_Traits<problem_t>::unit_length * Physics_Traits<problem_t>::unit_mass /
(Physics_Traits<problem_t>::unit_time * Physics_Traits<problem_t>::unit_time) /
(Physics_Traits<problem_t>::unit_temperature * Physics_Traits<problem_t>::unit_temperature *
Physics_Traits<problem_t>::unit_temperature * Physics_Traits<problem_t>::unit_temperature));
} else {
static_assert(false, "Invalid unit system");
}
Expand Down Expand Up @@ -257,11 +260,13 @@ template <typename problem_t> class RadSystem : public HyperbolicSystem<problem_
static constexpr amrex::Real boltzmann_constant_ = []() constexpr {
if constexpr (Physics_Traits<problem_t>::unit_system == UnitSystem::CGS) {
return C::k_B;
} else if constexpr (Physics_Traits<problem_t>::unit_system == UnitSystem::CONSTANTS) {
} else if constexpr (Physics_Traits<problem_t>::unit_system == UnitSystem::CONSTANTS) {
return Physics_Traits<problem_t>::boltzmann_constant;
} else if constexpr (Physics_Traits<problem_t>::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<problem_t>::unit_length * Physics_Traits<problem_t>::unit_length * Physics_Traits<problem_t>::unit_mass / (Physics_Traits<problem_t>::unit_time * Physics_Traits<problem_t>::unit_time) / Physics_Traits<problem_t>::unit_temperature);
return C::k_B /
(Physics_Traits<problem_t>::unit_length * Physics_Traits<problem_t>::unit_length * Physics_Traits<problem_t>::unit_mass /
(Physics_Traits<problem_t>::unit_time * Physics_Traits<problem_t>::unit_time) / Physics_Traits<problem_t>::unit_temperature);
} else {
static_assert(false, "Invalid unit system");
}
Expand Down
4 changes: 3 additions & 1 deletion src/simulation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,9 @@ template <typename problem_t> class AMRSimulation : public amrex::AmrCore
return Physics_Traits<problem_t>::gravitational_constant; // gravitational constant G, user defined
} else if constexpr (Physics_Traits<problem_t>::unit_system == UnitSystem::CUSTOM) {
// G / G_bar = u_l^3 / u_m / u_t^2
return C::Gconst / (Physics_Traits<problem_t>::unit_length * Physics_Traits<problem_t>::unit_length * Physics_Traits<problem_t>::unit_length / Physics_Traits<problem_t>::unit_mass / (Physics_Traits<problem_t>::unit_time * Physics_Traits<problem_t>::unit_time));
return C::Gconst /
(Physics_Traits<problem_t>::unit_length * Physics_Traits<problem_t>::unit_length * Physics_Traits<problem_t>::unit_length /
Physics_Traits<problem_t>::unit_mass / (Physics_Traits<problem_t>::unit_time * Physics_Traits<problem_t>::unit_time));
} else {
static_assert(false, "Invalid unit system");
}
Expand Down

0 comments on commit 25d6c44

Please sign in to comment.