diff --git a/src/units.cpp b/src/units.cpp index 28879dee..22735241 100644 --- a/src/units.cpp +++ b/src/units.cpp @@ -37,6 +37,8 @@ void idfx::Units::ShowConfig() { idfx::cout << "Units: [Length] = " << this->_length << " cm" << std::endl; idfx::cout << "Units: [Velocity] = " << this->_velocity << " cm/s" << std::endl; idfx::cout << "Units: [Density] = " << this->_density << " g/cm3" << std::endl; + idfx::cout << "Units: [Energy] = " << this->_energy << " erg/cm3" << std::endl; + idfx::cout << "Units: [Time] = " << this->_time << " s" << std::endl; idfx::cout << "Units: [Temperature] = " << this->_Kelvin << " K" << std::endl; idfx::cout << "Units: [Mag. Field] = " << this->_magField << " G" << std::endl; } @@ -46,4 +48,7 @@ void idfx::Units::ComputeUnits() { this->_isInitialized = true; this->_magField = std::sqrt(4*M_PI*_density*_velocity*_velocity); this->_Kelvin = u * _velocity*_velocity/k_B; + this->_energy = _density*_velocity*_velocity; + this->_time = _length/_velocity; } + diff --git a/src/units.hpp b/src/units.hpp index 48502eb5..b6c9b4a8 100644 --- a/src/units.hpp +++ b/src/units.hpp @@ -19,12 +19,13 @@ class Units { void Init(Input &input); - const real u {1.6605390666e-24}; // Atomic mass unit (g) + const real u{1.6605390666e-24}; // Atomic mass unit (g) const real m_p{1.67262192369e-24}; // Proton mass unit (g) const real m_n{1.67492749804e-24}; // neutron mass unit (g) const real m_e{9.1093837015e-28}; // electron mass unit (g) const real k_B{1.380649e-16}; // Boltzmann constant (erg/K) const real sigma_sb{5.6703744191844314e-05}; // Stephan Boltzmann constant (g/(K^4 s^3)) + const real ar{7.5646e-15}; // Radiation constant = 4*sigma_sb/c (g/(K^4 s^2 cm)) const real c{29979245800.0}; // Speed of light (cm/s) const real M_sun{1.988409870698051e+33}; // Solar mass (g) const real R_sun{69570000000.0}; // Solar radius (cm) @@ -33,11 +34,11 @@ class Units { const real G{6.674299999999999e-8}; // Gravitatonal constant (cm3 / (g s2)) const real h{6.62607015e-27}; // Planck constant (erg.s) const real pc{3.08568e+18}; // Parsec (cm) - const real au{1.49598e+13}; // Astronomical unit (cm) + const real au{1.49597892e13}; // Astronomical unit (cm) // User-defined units, non user-modifiable - KOKKOS_INLINE_FUNCTION real GetLength() const {return _density;} // L (cm) = L (code) * Units::length + KOKKOS_INLINE_FUNCTION real GetLength() const {return _length;} // L (cm) = L (code) * Units::length KOKKOS_INLINE_FUNCTION real GetVelocity() const {return _velocity;} // V(cm/s) = V(code) * Units::velocity KOKKOS_INLINE_FUNCTION real GetDensity() const {return _density;} // density (g/cm^3) = density(code) // * Units::density @@ -45,6 +46,8 @@ class Units { // Deduced units from user-defined units KOKKOS_INLINE_FUNCTION real GetKelvin() const {return _Kelvin;} // T(K) = P(code)/rho(code) * mu * Units::Kelvin KOKKOS_INLINE_FUNCTION real GetMagField() const {return _magField;} // B(G) = B(code) * Units::MagField + KOKKOS_INLINE_FUNCTION real GetEnergy() const {return _energy;} // energy(erg/cm3) = energy(code) * Units::energy + KOKKOS_INLINE_FUNCTION real GetTime() const {return _time;} // time(s) = time(code) * Units::time KOKKOS_INLINE_FUNCTION bool GetIsInitialized() const {return _isInitialized;} @@ -66,9 +69,12 @@ class Units { // Deduced units from user-defined units real _Kelvin{1.0}; real _magField{1.0}; + real _time{1.0}; + real _energy{1.0}; // Recompute deduced user-units void ComputeUnits(); }; } // namespace idfx #endif // UNITS_HPP_ +