diff --git a/CHANGELOG.md b/CHANGELOG.md index b3bd59a068..96a429262a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -49,6 +49,7 @@ - [[PR245]](https://github.com/lanl/singularity-eos/pull/245) Separating get_sg_eos to other files. Build/compilation improvements, warning fixes/suppression. ### Removed (removing behavior/API/varaibles/...) +- [[PR293]](https://github.com/lanl/singularity-eos/pull/293) Removing PTofRE function. This will no longer be callable downstream. ## Release 1.7.0 Date: 12/14/2022 diff --git a/doc/sphinx/src/contributing.rst b/doc/sphinx/src/contributing.rst index dcc6dd5081..feb6105952 100644 --- a/doc/sphinx/src/contributing.rst +++ b/doc/sphinx/src/contributing.rst @@ -491,14 +491,13 @@ The CRTP slass structure and static polymorphism ```````````````````````````````````````````````` Each of the EOS models in ``singularity-eos`` inherits from a base class in -order to centralize default functionality and avoid code duplication. The two -main examples of this are the vector overloads and the ``PTofRE`` scalar lookup -function. In the vector overloads, a simple for loop is used to iterate over +order to centralize default functionality and avoid code duplication. The +main example of this are the vector overloads. +In the vector overloads, a simple for loop is used to iterate over the set of states provided to the function and then call the scalar version on -each state. The ``PTofRE`` function is designed to provide a common method for -getting the needed information for a PTE solve from an EOS. Both of these -features are general to all types of EOS, but are reliant on specific -implementations of the EOS lookups. In both cases, these functions provide a +each state. This feature is +general to all types of EOS, but reliant on specific +implementations of the EOS lookups. These functions provide a default behaviour that we might also want to override for a given equation of state. diff --git a/doc/sphinx/src/using-eos.rst b/doc/sphinx/src/using-eos.rst index 6db213dd6a..bbb3e413a7 100644 --- a/doc/sphinx/src/using-eos.rst +++ b/doc/sphinx/src/using-eos.rst @@ -547,12 +547,3 @@ root finder to meaningful bound the root search. Similarly, returns the density at which pressure is minimized for a given temperature. This is again useful for root finds. - -Finally the method - -.. cpp:function:: void PTofRE(Real &rho, Real &sie, Real *lambda, Real &press, Real &temp, Real &dpdr, Real &dpde, Real &dtdr, Real &dtde) const; - -returns pressure and temperature, as well as the thermodynamic -derivatives of pressure and temperature with respect to density and -specific internal energy, as a function of density and specific -internal energy. diff --git a/python/module.hpp b/python/module.hpp index 37b1c7a0f3..a4a3788a8f 100644 --- a/python/module.hpp +++ b/python/module.hpp @@ -344,44 +344,6 @@ py::class_ eos_class(py::module_ & m, std::string name) { .def("MinimumDensity", &T::MinimumDensity) .def("MinimumTemperature", &T::MinimumTemperature) - - .def("PTofRE", [](const T & self, Real rho, Real sie, py::array_t lambda) { - EOSState s; - s.density = rho; - s.specific_internal_energy = sie; - self.PTofRE(s.density, s.specific_internal_energy, lambda.mutable_data(), s.pressure, s.temperature, s.dpdr, s.dpde, s.dtdr, s.dtde); - return s; - }, py::arg("rho"), py::arg("sie"), py::arg("lmbda")) - .def("PTofRE", [](const T & self, Real rho, Real sie) { - EOSState s; - s.density = rho; - s.specific_internal_energy = sie; - self.PTofRE(s.density, s.specific_internal_energy, nullptr, s.pressure, s.temperature, s.dpdr, s.dpde, s.dtdr, s.dtde); - return s; - }, py::arg("rho"), py::arg("sie")) - .def("PTofRE", [](const T & self, py::array_t rhos, py::array_t sies, py::array_t pressures, py::array_t temperatures, py::array_t dpdrs, py::array_t dpdes, py::array_t dtdrs, py::array_t dtdes, - const int num, py::array_t lambdas) { - py::buffer_info lambdas_info = lambdas.request(); - if (lambdas_info.ndim != 2) - throw std::runtime_error("lambdas dimension must be 2!"); - - if(lambdas_info.shape[1] > 0) { - self.PTofRE(rhos.mutable_data(), sies.mutable_data(), - pressures.mutable_data(), temperatures.mutable_data(), dpdrs.mutable_data(), - dpdes.mutable_data(), dtdrs.mutable_data(), dtdes.mutable_data(), num, - LambdaHelper(lambdas)); - } else { - self.PTofRE(rhos.mutable_data(), sies.mutable_data(), - pressures.mutable_data(), temperatures.mutable_data(), dpdrs.mutable_data(), - dpdes.mutable_data(), dtdrs.mutable_data(), dtdes.mutable_data(), num, - NoLambdaHelper()); - } - }, py::arg("rhos"), py::arg("sies"), py::arg("pressures"), py::arg("temperatures"), py::arg("dpdrs"), py::arg("dpdes"), py::arg("dtdrs"), py::arg("dtdes"), py::arg("num"), py::arg("lmbdas")) - .def("PTofRE", [](const T & self, py::array_t rhos, py::array_t sies, py::array_t pressures, py::array_t temperatures, py::array_t dpdrs, py::array_t dpdes, py::array_t dtdrs, py::array_t dtdes, - const int num) { - self.PTofRE(rhos.mutable_data(), sies.mutable_data(), pressures.mutable_data(), temperatures.mutable_data(), dpdrs.mutable_data(), dpdes.mutable_data(), dtdrs.mutable_data(), dtdes.mutable_data(), num, NoLambdaHelper()); - }, py::arg("rhos"), py::arg("sies"), py::arg("pressures"), py::arg("temperatures"), py::arg("dpdrs"), py::arg("dpdes"), py::arg("dtdrs"), py::arg("dtdes"), py::arg("num")) - .def_property_readonly("nlambda", &T::nlambda) .def_property_readonly_static("PreferredInput", [](py::object) { return T::PreferredInput(); }) .def("PrintParams", &T::PrintParams) diff --git a/singularity-eos/eos/eos_base.hpp b/singularity-eos/eos/eos_base.hpp index 3b4174e1ed..f206a01a58 100644 --- a/singularity-eos/eos/eos_base.hpp +++ b/singularity-eos/eos/eos_base.hpp @@ -76,7 +76,6 @@ char *StrCat(char *destination, const char *source) { using EosBase::GruneisenParamFromDensityInternalEnergy; \ using EosBase::MinimumDensity; \ using EosBase::MinimumTemperature; \ - using EosBase::PTofRE; \ using EosBase::FillEos; \ using EosBase::EntropyFromDensityTemperature; \ using EosBase::EntropyFromDensityInternalEnergy; \ @@ -554,43 +553,6 @@ class EosBase { PORTABLE_FORCEINLINE_FUNCTION Real MinimumTemperature() const { return 0; } - template - inline void PTofRE(RealIndexer &&rhos, RealIndexer &&sies, RealIndexer &&presses, - RealIndexer &&temps, RealIndexer &&dpdrs, RealIndexer &&dpdes, - RealIndexer &&dtdrs, RealIndexer &&dtdes, const int num, - LambdaIndexer &&lambdas) const { - static auto const name = SG_MEMBER_FUNC_NAME(); - static auto const cname = name.c_str(); - CRTP copy = *(static_cast(this)); - portableFor( - cname, 0, num, PORTABLE_LAMBDA(const int i) { - copy.PTofRE(rhos[i], sies[i], lambdas[i], presses[i], temps[i], dpdrs[i], - dpdes[i], dtdrs[i], dtdes[i]); - }); - } - // Scalar version of PTofRE - PORTABLE_INLINE_FUNCTION - void PTofRE(Real &rho, Real &sie, Real *lambda, Real &press, Real &temp, Real &dpdr, - Real &dpde, Real &dtdr, Real &dtde) const { - // Get the dervived class - auto eos = static_cast(*this); - - press = eos.PressureFromDensityInternalEnergy(rho, sie, lambda); - temp = eos.TemperatureFromDensityInternalEnergy(rho, sie, lambda); - const Real drho = rho * 1.0e-6; - const Real de = sie * 1.0e-6; - const Real Pr = eos.PressureFromDensityInternalEnergy(rho + drho, sie, lambda); - const Real Pe = eos.PressureFromDensityInternalEnergy(rho, sie + de, lambda); - const Real Tr = eos.TemperatureFromDensityInternalEnergy(rho + drho, sie, lambda); - const Real Te = eos.TemperatureFromDensityInternalEnergy(rho, sie + de, lambda); - dpdr = (Pr - press) / drho; - dpde = (Pe - press) / de; - dtdr = (Tr - temp) / drho; - dtde = (Te - temp) / - de; // Would it be better to skip the calculation of Te and return 1/cv? - return; - } - PORTABLE_INLINE_FUNCTION Real RhoPmin(const Real temp) const { return 0.0; } diff --git a/singularity-eos/eos/eos_davis.hpp b/singularity-eos/eos/eos_davis.hpp index d728ca2591..311314c674 100644 --- a/singularity-eos/eos/eos_davis.hpp +++ b/singularity-eos/eos/eos_davis.hpp @@ -436,30 +436,6 @@ void DavisProducts::ValuesAtReferenceState(Real &rho, Real &temp, Real &sie, Rea Real gm1 = GruneisenParamFromDensityTemperature(rho, temp) * rho; dvdt = gm1 * cv / bmod; } -#if 0 -PORTABLE_INLINE_FUNCTION void DavisProducts::PTofRE(const Real rho, const Real sie, Real * lambda, Real& press, Real& temp, Real & dpdr, Real & dpde, Real & dtdr, Real & dtde) const -{ - using namespace math_utils; - press = PressureFromDensityInternalEnergy(rho,sie,lambda); - temp = TemperatureFromDensityInternalEnergy(rho,sie,lambda); - - const Real vvc = 1/(rho*_vc); - const Real Fx = -4*_a*std::pow(vvc,2*_n-1)/pow<2>(1+std::pow(vvc,2*_n)); - const Real tmp = std::pow(0.5*(std::pow(vvc,_n)+std::pow(vvc,-_n)),_a/_n)/std::pow(vvc,_k+_a); - const Real tmp_x = 0.5*_a*(std::pow(vvc,_n-1)-std::pow(vvc,-_n-1))*std::pow(0.5*(std::pow(vvc,_n)+std::pow(vvc,-_n)),_a/_n-1)/std::pow(vvc,_k+_a)-(_k+_a)*tmp/vvc; - const Real psv = _pc/(_k-1+_a)*(tmp*Fx+(_k-1+F(rho))*tmp_x)/_vc; - //const Real esv = _pc*_vc/(_k-1+_a)*(tmp+vvc*tmp_x)/_vc; - const Real esv = _pc/(_k-1+_a)*(tmp+vvc*tmp_x); - const Real gamma = Gamma(rho); - const Real gammav = (1-_b)*Fx*_vc; - dpde = gamma*rho; - dpdr = (psv+(sie-Es(rho))*rho*(gammav-gamma*rho)-gamma*rho*esv)/pow<2>(rho); - dtde = 1.0/_Cv; - const Real tsv = Ts(rho)*rho*(_a*(1.0-_b)*(std::pow(vvc,2.0*_n)-1.0)/(std::pow(vvc,2.0*_n)+1.0)-(_k-1.0+_a*(1.0-_b))); - dtdr = -(tsv-esv/_Cv)/pow<2>(rho); -} -#endif - } // namespace singularity #endif // _SINGULARITY_EOS_EOS_EOS_DAVIS_HPP_ diff --git a/singularity-eos/eos/eos_eospac.hpp b/singularity-eos/eos/eos_eospac.hpp index 7a2ac5a332..bcc558a8ae 100644 --- a/singularity-eos/eos/eos_eospac.hpp +++ b/singularity-eos/eos/eos_eospac.hpp @@ -326,7 +326,6 @@ class EOSPAC : public EosBase { lambdas); } - using EosBase::PTofRE; using EosBase::FillEos; using EosBase::EntropyIsNotEnabled; @@ -1064,77 +1063,6 @@ class EOSPAC : public EosBase { }); } - template - inline void PTofRE(Real *rhos, Real *sies, Real *presses, Real *temps, Real *dpdrs, - Real *dpdes, Real *dtdrs, Real *dtdes, Real *scratch, const int num, - LambdaIndexer lambdas) const { - static auto const name = - singularity::mfuncname::member_func_name(typeid(EOSPAC).name(), __func__); - static auto const cname = name.c_str(); - - PressureFromDensityInternalEnergy(rhos, sies, presses, scratch, num, lambdas); - TemperatureFromDensityInternalEnergy(rhos, sies, temps, scratch, num, lambdas); - - Real *drho = scratch; - Real *de = scratch + num; - Real *Pr = scratch + 2 * num; - Real *Pe = scratch + 3 * num; - Real *Tr = scratch + 4 * num; - Real *Te = scratch + 5 * num; - Real *rho_p_drho = scratch + 6 * num; - Real *sie_p_de = scratch + 7 * num; - - portableFor( - cname, 0, num, PORTABLE_LAMBDA(const int i) { - drho[i] = rhos[i] * 1.0e-6; - de[i] = sies[i] * 1.0e-6; - rho_p_drho[i] = rhos[i] + drho[i]; - sie_p_de[i] = sies[i] + de[i]; - }); - - Real *R = &rhos[0]; - Real *E = &sies[0]; - - Real *internal_scratch = scratch + 8 * num; - - PressureFromDensityInternalEnergy(rho_p_drho, E, Pr, internal_scratch, num, lambdas); - PressureFromDensityInternalEnergy(R, sie_p_de, Pe, internal_scratch, num, lambdas); - TemperatureFromDensityInternalEnergy(rho_p_drho, E, Tr, internal_scratch, num, - lambdas); - TemperatureFromDensityInternalEnergy(R, sie_p_de, Te, internal_scratch, num, lambdas); - - portableFor( - cname, 0, num, PORTABLE_LAMBDA(const int i) { - dpdrs[i] = (Pr[i] - presses[i]) / drho[i]; - dpdes[i] = (Pe[i] - presses[i]) / de[i]; - dtdrs[i] = (Tr[i] - temps[i]) / drho[i]; - dtdes[i] = - (Te[i] - temps[i]) / - de[i]; // Would it be better to skip the calculation of Te and return 1/cv? - }); - } - - SG_PIF_NOWARN - PORTABLE_INLINE_FUNCTION void PTofRE(Real &rho, Real &sie, Real *lambda, Real &press, - Real &temp, Real &dpdr, Real &dpde, Real &dtdr, - Real &dtde) const { - - press = PressureFromDensityInternalEnergy(rho, sie, lambda); - temp = TemperatureFromDensityInternalEnergy(rho, sie, lambda); - const Real drho = rho * 1.0e-6; - const Real de = sie * 1.0e-6; - const Real Pr = PressureFromDensityInternalEnergy(rho + drho, sie, lambda); - const Real Pe = PressureFromDensityInternalEnergy(rho, sie + de, lambda); - const Real Tr = TemperatureFromDensityInternalEnergy(rho + drho, sie, lambda); - const Real Te = TemperatureFromDensityInternalEnergy(rho, sie + de, lambda); - dpdr = (Pr - press) / drho; - dpde = (Pe - press) / de; - dtdr = (Tr - temp) / drho; - dtde = (Te - temp) / - de; // Would it be better to skip the calculation of Te and return 1/cv? - return; - } - static inline unsigned long scratch_size(std::string method, unsigned int nelements) { auto nbuffers = scratch_nbuffers(); if (nbuffers.find(method) != nbuffers.end()) { @@ -1201,8 +1129,7 @@ class EOSPAC : public EosBase { {"BulkModulusFromDensityTemperature", 6}, {"BulkModulusFromDensityInternalEnergy", 6}, {"GruneisenParamFromDensityTemperature", 4}, - {"GruneisenParamFromDensityInternalEnergy", 5}, - {"PTofRE", 11}}; + {"GruneisenParamFromDensityInternalEnergy", 5}}; return nbuffers; } }; diff --git a/singularity-eos/eos/eos_spiner.hpp b/singularity-eos/eos/eos_spiner.hpp index 2dddbc3bdc..dced1a33c3 100644 --- a/singularity-eos/eos/eos_spiner.hpp +++ b/singularity-eos/eos/eos_spiner.hpp @@ -88,7 +88,6 @@ class SpinerEOSDependsRhoT : public EosBase { using EosBase::BulkModulusFromDensityInternalEnergy; using EosBase::GruneisenParamFromDensityTemperature; using EosBase::GruneisenParamFromDensityInternalEnergy; - using EosBase::PTofRE; using EosBase::FillEos; using EosBase::EntropyIsNotEnabled; @@ -318,7 +317,6 @@ class SpinerEOSDependsRhoSie : public EosBase { using EosBase::BulkModulusFromDensityInternalEnergy; using EosBase::GruneisenParamFromDensityTemperature; using EosBase::GruneisenParamFromDensityInternalEnergy; - using EosBase::PTofRE; using EosBase::FillEos; using EosBase::EntropyIsNotEnabled; diff --git a/singularity-eos/eos/eos_stellar_collapse.hpp b/singularity-eos/eos/eos_stellar_collapse.hpp index 8fa1e7ad7a..caee2758e0 100644 --- a/singularity-eos/eos/eos_stellar_collapse.hpp +++ b/singularity-eos/eos/eos_stellar_collapse.hpp @@ -82,7 +82,6 @@ class StellarCollapse : public EosBase { using EosBase::BulkModulusFromDensityInternalEnergy; using EosBase::GruneisenParamFromDensityTemperature; using EosBase::GruneisenParamFromDensityInternalEnergy; - using EosBase::PTofRE; using EosBase::FillEos; inline StellarCollapse(const std::string &filename, bool use_sp5 = false, diff --git a/singularity-eos/eos/eos_variant.hpp b/singularity-eos/eos/eos_variant.hpp index dbab82d1ce..04dc51a9bf 100644 --- a/singularity-eos/eos/eos_variant.hpp +++ b/singularity-eos/eos/eos_variant.hpp @@ -222,17 +222,6 @@ class Variant { eos_); } - PORTABLE_INLINE_FUNCTION - void PTofRE(Real &rho, Real &sie, Real *lambda, Real &press, Real &temp, Real &dpdr, - Real &dpde, Real &dtdr, Real &dtde) const { - return mpark::visit( - [&rho, &sie, &lambda, &press, &temp, &dpdr, &dpde, &dtdr, - &dtde](const auto &eos) { - return eos.PTofRE(rho, sie, lambda, press, temp, dpdr, dpde, dtdr, dtde); - }, - eos_); - } - PORTABLE_INLINE_FUNCTION void DensityEnergyFromPressureTemperature(const Real press, const Real temp, Real *lambda, Real &rho, Real &sie) const { @@ -929,36 +918,6 @@ class Variant { eos_); } - template - inline void PTofRE(RealIndexer &&rhos, RealIndexer &&sies, RealIndexer &&presses, - RealIndexer &&temps, RealIndexer &&dpdrs, RealIndexer &&dpdes, - RealIndexer &&dtdrs, RealIndexer &&dtdes, const int num) const { - NullIndexer lambdas{}; // Returns null pointer for every index - return PTofRE(std::forward(rhos), std::forward(sies), - std::forward(presses), std::forward(temps), - std::forward(dpdrs), std::forward(dpdes), - std::forward(dtdrs), std::forward(dtdes), num, - lambdas); - } - - template - inline void PTofRE(RealIndexer &&rhos, RealIndexer &&sies, RealIndexer &&presses, - RealIndexer &&temps, RealIndexer &&dpdrs, RealIndexer &&dpdes, - RealIndexer &&dtdrs, RealIndexer &&dtdes, const int num, - LambdaIndexer &&lambdas) const { - return mpark::visit( - [&rhos, &sies, &presses, &temps, &dpdrs, &dpdes, &dtdrs, &dtdes, &num, - &lambdas](const auto &eos) { - return eos.PTofRE( - std::forward(rhos), std::forward(sies), - std::forward(presses), std::forward(temps), - std::forward(dpdrs), std::forward(dpdes), - std::forward(dtdrs), std::forward(dtdes), num, - std::forward(lambdas)); - }, - eos_); - } - // Tooling for modifiers inline constexpr bool IsModified() const { return mpark::visit([](const auto &eos) { return eos.IsModified(); }, eos_); diff --git a/singularity-eos/eos/modifiers/eos_unitsystem.hpp b/singularity-eos/eos/modifiers/eos_unitsystem.hpp index fff1e10475..debfc71bdc 100644 --- a/singularity-eos/eos/modifiers/eos_unitsystem.hpp +++ b/singularity-eos/eos/modifiers/eos_unitsystem.hpp @@ -63,7 +63,6 @@ class UnitSystem : public EosBase> { using EosBase>::BulkModulusFromDensityInternalEnergy; using EosBase>::GruneisenParamFromDensityTemperature; using EosBase>::GruneisenParamFromDensityInternalEnergy; - using EosBase>::PTofRE; using EosBase>::FillEos; using BaseType = T; diff --git a/singularity-eos/eos/modifiers/relativistic_eos.hpp b/singularity-eos/eos/modifiers/relativistic_eos.hpp index 174349f5fd..87447b7ef8 100644 --- a/singularity-eos/eos/modifiers/relativistic_eos.hpp +++ b/singularity-eos/eos/modifiers/relativistic_eos.hpp @@ -55,7 +55,6 @@ class RelativisticEOS : public EosBase> { using EosBase>::BulkModulusFromDensityInternalEnergy; using EosBase>::GruneisenParamFromDensityTemperature; using EosBase>::GruneisenParamFromDensityInternalEnergy; - using EosBase>::PTofRE; using EosBase>::FillEos; using BaseType = T; diff --git a/singularity-eos/eos/modifiers/scaled_eos.hpp b/singularity-eos/eos/modifiers/scaled_eos.hpp index c1397c6e85..2bd9c5f81b 100644 --- a/singularity-eos/eos/modifiers/scaled_eos.hpp +++ b/singularity-eos/eos/modifiers/scaled_eos.hpp @@ -55,7 +55,6 @@ class ScaledEOS : public EosBase> { using EosBase>::BulkModulusFromDensityInternalEnergy; using EosBase>::GruneisenParamFromDensityTemperature; using EosBase>::GruneisenParamFromDensityInternalEnergy; - using EosBase>::PTofRE; using EosBase>::FillEos; using BaseType = T; diff --git a/singularity-eos/eos/modifiers/shifted_eos.hpp b/singularity-eos/eos/modifiers/shifted_eos.hpp index 45c3ed4d4b..450dc5eb7f 100644 --- a/singularity-eos/eos/modifiers/shifted_eos.hpp +++ b/singularity-eos/eos/modifiers/shifted_eos.hpp @@ -55,7 +55,6 @@ class ShiftedEOS : public EosBase> { using EosBase>::BulkModulusFromDensityInternalEnergy; using EosBase>::GruneisenParamFromDensityTemperature; using EosBase>::GruneisenParamFromDensityInternalEnergy; - using EosBase>::PTofRE; using EosBase>::FillEos; using BaseType = T;