Skip to content

Commit

Permalink
Fixed formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Holas committed Aug 14, 2023
1 parent 5de620e commit ce11267
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 67 deletions.
6 changes: 3 additions & 3 deletions singularity-eos/eos/eos.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@ using singularity::detail::transform_variadic_list;

// all eos's
static constexpr const auto full_eos_list =
tl<IdealGas, Gruneisen, Helmholtz, Vinet, JWL, DavisReactants, DavisProducts,
StiffGas, SAP_Polynomial, NobleAbel
tl<IdealGas, Gruneisen, Vinet, JWL, DavisReactants, DavisProducts, StiffGas,
SAP_Polynomial, NobleAbel
#ifdef SINGULARITY_USE_SPINER_WITH_HDF5
,
SpinerEOSDependsRhoT, SpinerEOSDependsRhoSie, StellarCollapse
Helmholtz, SpinerEOSDependsRhoT, SpinerEOSDependsRhoSie, StellarCollapse
#endif // SINGULARITY_USE_SPINER_WITH_HDF5
#ifdef SINGULARITY_USE_EOSPAC
,
Expand Down
6 changes: 3 additions & 3 deletions singularity-eos/eos/eos_helmholtz.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

// TODO(JMM): Currently spiner and HDf5 are entangled. But really this
// model should depend only on spiner and NOT HDF5.
#ifdef SPINER_USE_HDF
#ifdef SINGULARITY_USE_SPINER_WITH_HDF5

#include <cstdio>

Expand Down Expand Up @@ -153,7 +153,7 @@ using namespace eos_base;
// TODO(JMM): Maybe want to move these utility functions into something like an
// ASCII-utils file. Worth considering at some later date.
namespace HelmUtils {
using DataBox = Spiner::DataBox;
using DataBox = Spiner::DataBox<>;

// Components of the arrays returned by internal routines:
// Variable, derivs w.r.t density, temperature, abar, zbar
Expand Down Expand Up @@ -1433,5 +1433,5 @@ void Helmholtz::GetFromDensityLogTemperature_(
}; // namespace singularity

#undef ROOT_FINDER
#endif // SPINER_USE_HDF
#endif // SINGULARITY_USE_SPINER_WITH_HDF5
#endif // _SINGULARITY_EOS_EOS_HELMHOLTZ_HPP_
109 changes: 48 additions & 61 deletions test/test_eos_helmholtz.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,52 +48,45 @@ SCENARIO("Helmholtz equation of state tgiven", "[HelmholtzEOS]") {
/* Reference values calculated with test implementation, using
abar = 4.0, zbar = 2.0 */
Real ein_ref[16] = {
942247520796.137939453125,
101117704971247.1875,
756586284440018092032.0,
204533796186988033170649120768.0,
22331233357586.9296875,
100345465684484.421875,
85141422479277632.0,
20453379683965599047745536.0,
9976645702610400.0,
10007780352178464.0,
15481955850958990.0,
2045403973039441838080.0,
1256563470889144064.0,
1256594342723058944.0,
1259724628933661184.0,
2037841273725276672.0,
942247520796.137939453125, 101117704971247.1875,
756586284440018092032.0, 204533796186988033170649120768.0,
22331233357586.9296875, 100345465684484.421875,
85141422479277632.0, 20453379683965599047745536.0,
9976645702610400.0, 10007780352178464.0,
15481955850958990.0, 2045403973039441838080.0,
1256563470889144064.0, 1256594342723058944.0,
1259724628933661184.0, 2037841273725276672.0,
};
Real press_ref[16] = {
628164115.19633424282073974609375,
64881120328.5929718017578125,
252198502998578304.0,
66317830432079092035616768.0,
148867082685630.90625,
668864622842899.125,
314555378539921728.0,
66317832510490259937558528.0,
649943133468265414656.0,
652017695913837068288.0,
1006403106957914537984.0,
66338640383060857803767808.0,
486181392465836489259876352.0,
486201972259441884654469120.0,
488274539873823033716113408.0,
852398557407648750030028800.0,
628164115.19633424282073974609375,
64881120328.5929718017578125,
252198502998578304.0,
66317830432079092035616768.0,
148867082685630.90625,
668864622842899.125,
314555378539921728.0,
66317832510490259937558528.0,
649943133468265414656.0,
652017695913837068288.0,
1006403106957914537984.0,
66338640383060857803767808.0,
486181392465836489259876352.0,
486201972259441884654469120.0,
488274539873823033716113408.0,
852398557407648750030028800.0,
};

/* Compare test values. Difference should be less than 1e-12 */
Real lambda[2] = {4.0, 2.0};
int k = 0;
for (int i = 0; i < 4; ++i) {
for (int j = 0; j < 4; ++j){
Real ein = eos.InternalEnergyFromDensityTemperature(rho_in[i], temp_in[j], lambda);
Real press = eos.PressureFromDensityTemperature(rho_in[i], temp_in[j], lambda);
REQUIRE(isClose(ein, ein_ref[k], 1e-12));
REQUIRE(isClose(press, press_ref[k], 1e-12));
k++;
for (int j = 0; j < 4; ++j) {
Real ein =
eos.InternalEnergyFromDensityTemperature(rho_in[i], temp_in[j], lambda);
Real press = eos.PressureFromDensityTemperature(rho_in[i], temp_in[j], lambda);
REQUIRE(isClose(ein, ein_ref[k], 1e-12));
REQUIRE(isClose(press, press_ref[k], 1e-12));
k++;
}
}
}
Expand All @@ -111,42 +104,36 @@ SCENARIO("Helmholtz equation of state egiven", "[HelmholtzEOS]") {
Due to problems with the initial temperature guess, only a
particular range of values work with the built-in ideal
gas initial guess. */

Real rho_in[7] = {1e-3, 1e-3, 1e1, 1e1, 1e5, 1e5, 1e9};
Real ein_in[7] = {1e33, 1e38, 1e25, 1e38, 1e22, 1e32, 1e22};

/* Reference values calculated with test implementation, using
abar = 4.0, zbar = 2.0 */
Real temp_ref[7] = {
83267912059.9008941650390625,
1480649420949.600341796875,
8377732410.2377471923828125,
10000000000000.037109375,
14834616134.222881317138671875,
2633008614585.40283203125,
148051392128.0281982421875,
83267912059.9008941650390625, 1480649420949.600341796875,
8377732410.2377471923828125, 10000000000000.037109375,
14834616134.222881317138671875, 2633008614585.40283203125,
148051392128.0281982421875,
};
Real press_ref[7] = {
333178534190936501846297018368.0,
3.335059068385989208866699710405e+34,
32102269803001238788243456.0,
6.9353723467611821959666509095658e+37,
328892155446139829490810880.0,
3.3333323663968881590598358740553e+35,
3334463461062235621149686890496.0,
333178534190936501846297018368.0, 3.335059068385989208866699710405e+34,
32102269803001238788243456.0, 6.9353723467611821959666509095658e+37,
328892155446139829490810880.0, 3.3333323663968881590598358740553e+35,
3334463461062235621149686890496.0,
};

/* Compare test values. Difference should be less than 1e-6 */
Real lambda[2] = {4.0, 2.0};
for (int i = 0; i < 7; ++i) {
Real temp = eos.TemperatureFromDensityInternalEnergy(rho_in[i], ein_in[i], lambda);
Real press = eos.PressureFromDensityInternalEnergy(rho_in[i], ein_in[i], lambda);
Real temp_diff = (temp - temp_ref[i]) / temp_ref[i];
Real press_diff = (press - press_ref[i]) / press_ref[i];
REQUIRE(temp_diff < 1e6);
REQUIRE(press_diff < 1e6);
// REQUIRE(isClose(temp, temp_ref[i], 1e-0));
// REQUIRE(isClose(press, press_ref[i], 1e-0));
Real temp = eos.TemperatureFromDensityInternalEnergy(rho_in[i], ein_in[i], lambda);
Real press = eos.PressureFromDensityInternalEnergy(rho_in[i], ein_in[i], lambda);
Real temp_diff = (temp - temp_ref[i]) / temp_ref[i];
Real press_diff = (press - press_ref[i]) / press_ref[i];
REQUIRE(temp_diff < 1e6);
REQUIRE(press_diff < 1e6);
// REQUIRE(isClose(temp, temp_ref[i], 1e-0));
// REQUIRE(isClose(press, press_ref[i], 1e-0));
}
}
}

0 comments on commit ce11267

Please sign in to comment.