test(tests): Standard Solar Composition Unit Tests
Added first basic unit test to ensure all standard solar compositions can load. Not currently passing
This commit is contained in:
@@ -58,8 +58,8 @@ namespace fourdst::composition::io {
|
||||
};
|
||||
|
||||
inline std::unordered_map<IsotopicPercentages, std::string> IsotopicPercentages_to_string_map = {
|
||||
{IsotopicPercentages::L03, "L03"},
|
||||
{IsotopicPercentages::L09, "L09"}
|
||||
{IsotopicPercentages::L03, "L03_data"},
|
||||
{IsotopicPercentages::L09, "L09_data"}
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -248,6 +248,7 @@ namespace fourdst::composition {
|
||||
const std::string& isotopic_percentage_scheme,
|
||||
double initial_z, double initial_y) {
|
||||
|
||||
|
||||
std::vector<char> data;
|
||||
|
||||
io::ChemicalFileParser parser;
|
||||
@@ -260,18 +261,16 @@ namespace fourdst::composition {
|
||||
compositions = parser.parse_compositon_data(data,metal_fraction_scheme);
|
||||
isotopes = parser.parse_isotopic_percentage(data,isotopic_percentage_scheme);
|
||||
|
||||
|
||||
std::string name;
|
||||
std::vector<fourdst::atomic::Species> species;
|
||||
|
||||
|
||||
// construct name of the isotopes
|
||||
for (const auto [E,A] : std::ranges::views::zip(isotopes.elements, isotopes.mass_numbers)){
|
||||
name = std::format("{}-{}",E,A);
|
||||
// std::println("{}", name);
|
||||
auto SpeciesObject = fourdst::atomic::species.at(name);
|
||||
species.push_back(SpeciesObject);
|
||||
|
||||
// std::println("Species: {} has mass: {}", SpeciesObject.name(), SpeciesObject.mass());
|
||||
|
||||
}
|
||||
|
||||
std::vector<double> massFracs, metal_fractions;
|
||||
@@ -324,7 +323,6 @@ namespace fourdst::composition {
|
||||
double sum = std::accumulate(metal_fractions.begin(),metal_fractions.end(),0.0);
|
||||
|
||||
for(size_t i=0;i < metal_fractions.size();++i){
|
||||
std::println("testing: {} , {}", i,compositions.elements[i]);
|
||||
metal_fractions[i] = metal_fractions[i]/sum;
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include "fourdst/composition/exceptions/exceptions_composition.h"
|
||||
#include "fourdst/composition/utils.h"
|
||||
#include "fourdst/composition/decorators/composition_masked.h"
|
||||
#include "fourdst/composition/io/standard_compositions.h"
|
||||
#include "fourdst/composition/utils/composition_hash.h"
|
||||
|
||||
#include "fourdst/config/config.h"
|
||||
@@ -482,4 +483,37 @@ TEST_F(compositionTest, iterationOrdering) {
|
||||
EXPECT_EQ(sp, speciesInOrder[count]);
|
||||
++count;
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(compositionTest, standardSolarCompositions) {
|
||||
using namespace fourdst::composition;
|
||||
|
||||
std::vector<io::SolarCompositions> comps = {
|
||||
io::SolarCompositions::AG89,
|
||||
io::SolarCompositions::GS98,
|
||||
io::SolarCompositions::L03,
|
||||
io::SolarCompositions::A09_Pryzbilla,
|
||||
io::SolarCompositions::AGS05,
|
||||
io::SolarCompositions::AGS09,
|
||||
io::SolarCompositions::AAG21_photospheric,
|
||||
io::SolarCompositions::MB22_photospheric,
|
||||
io::SolarCompositions::L09
|
||||
};
|
||||
|
||||
std::vector<io::IsotopicPercentages> isos = {
|
||||
io::IsotopicPercentages::L03,
|
||||
io::IsotopicPercentages::L09
|
||||
};
|
||||
|
||||
|
||||
for (const auto comp : comps) {
|
||||
for (const auto iso: isos) {
|
||||
std::string string_comp = io::SolarCompositions_to_string_map.at(comp);
|
||||
std::string string_iso = io::IsotopicPercentages_to_string_map.at(iso);
|
||||
|
||||
EXPECT_NO_THROW(get_composition_record(comp, iso, 0.02, 0.28));
|
||||
EXPECT_NO_THROW(get_composition_record(string_comp, string_iso, 0.02, 0.28));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user