fix(Standard-Compositions): fixed the compositions that were not working
This commit is contained in:
@@ -7,7 +7,7 @@ const unsigned char StandardAbundances[] = {
|
|||||||
0x6e, 0x63, 0x65, 0x20, 0x64, 0x61, 0x74, 0x61, 0x2c, 0x20, 0x69, 0x73, 0x6f, 0x74, 0x6f, 0x70,
|
0x6e, 0x63, 0x65, 0x20, 0x64, 0x61, 0x74, 0x61, 0x2c, 0x20, 0x69, 0x73, 0x6f, 0x74, 0x6f, 0x70,
|
||||||
0x69, 0x63, 0x20, 0x70, 0x65, 0x72, 0x63, 0x65, 0x6e, 0x74, 0x61, 0x67, 0x65, 0x5d, 0x0a, 0x43,
|
0x69, 0x63, 0x20, 0x70, 0x65, 0x72, 0x63, 0x65, 0x6e, 0x74, 0x61, 0x67, 0x65, 0x5d, 0x0a, 0x43,
|
||||||
0x52, 0x45, 0x41, 0x54, 0x45, 0x44, 0x20, 0x4f, 0x4e, 0x3a, 0x20, 0x32, 0x30, 0x32, 0x36, 0x2d,
|
0x52, 0x45, 0x41, 0x54, 0x45, 0x44, 0x20, 0x4f, 0x4e, 0x3a, 0x20, 0x32, 0x30, 0x32, 0x36, 0x2d,
|
||||||
0x30, 0x35, 0x2d, 0x32, 0x32, 0x0a, 0x42, 0x45, 0x47, 0x49, 0x4e, 0x20, 0x53, 0x45, 0x43, 0x54,
|
0x30, 0x36, 0x2d, 0x30, 0x34, 0x0a, 0x42, 0x45, 0x47, 0x49, 0x4e, 0x20, 0x53, 0x45, 0x43, 0x54,
|
||||||
0x49, 0x4f, 0x4e, 0x20, 0x61, 0x62, 0x75, 0x6e, 0x64, 0x61, 0x6e, 0x63, 0x65, 0x20, 0x64, 0x61,
|
0x49, 0x4f, 0x4e, 0x20, 0x61, 0x62, 0x75, 0x6e, 0x64, 0x61, 0x6e, 0x63, 0x65, 0x20, 0x64, 0x61,
|
||||||
0x74, 0x61, 0x0a, 0x09, 0x20, 0x49, 0x4e, 0x43, 0x4c, 0x55, 0x44, 0x45, 0x44, 0x20, 0x5b, 0x27,
|
0x74, 0x61, 0x0a, 0x09, 0x20, 0x49, 0x4e, 0x43, 0x4c, 0x55, 0x44, 0x45, 0x44, 0x20, 0x5b, 0x27,
|
||||||
0x41, 0x47, 0x38, 0x39, 0x27, 0x2c, 0x20, 0x27, 0x47, 0x4e, 0x39, 0x33, 0x27, 0x2c, 0x20, 0x27,
|
0x41, 0x47, 0x38, 0x39, 0x27, 0x2c, 0x20, 0x27, 0x47, 0x4e, 0x39, 0x33, 0x27, 0x2c, 0x20, 0x27,
|
||||||
|
|||||||
@@ -32,8 +32,8 @@ namespace fourdst::composition::io {
|
|||||||
GS98,
|
GS98,
|
||||||
L03,
|
L03,
|
||||||
AGS05,
|
AGS05,
|
||||||
AGS09,
|
AGSS09,
|
||||||
A09_Pryzbilla,
|
A09_Przybilla,
|
||||||
MB22_photospheric,
|
MB22_photospheric,
|
||||||
AAG21_photospheric,
|
AAG21_photospheric,
|
||||||
L09
|
L09
|
||||||
@@ -50,8 +50,8 @@ namespace fourdst::composition::io {
|
|||||||
{SolarCompositions::GS98, "GS98"},
|
{SolarCompositions::GS98, "GS98"},
|
||||||
{SolarCompositions::L03, "L03"},
|
{SolarCompositions::L03, "L03"},
|
||||||
{SolarCompositions::AGS05, "AGS05"},
|
{SolarCompositions::AGS05, "AGS05"},
|
||||||
{SolarCompositions::AGS09, "AGS09"},
|
{SolarCompositions::AGSS09, "AGSS09"},
|
||||||
{SolarCompositions::A09_Pryzbilla, "A09_Pryzbilla"},
|
{SolarCompositions::A09_Przybilla, "A09_Przybilla"},
|
||||||
{SolarCompositions::MB22_photospheric, "MB22_photospheric"},
|
{SolarCompositions::MB22_photospheric, "MB22_photospheric"},
|
||||||
{SolarCompositions::AAG21_photospheric, "AAG21_photospheric"},
|
{SolarCompositions::AAG21_photospheric, "AAG21_photospheric"},
|
||||||
{SolarCompositions::L09, "L09"}
|
{SolarCompositions::L09, "L09"}
|
||||||
|
|||||||
@@ -262,14 +262,14 @@ namespace fourdst::composition {
|
|||||||
isotopes = parser.parse_isotopic_percentage(data,isotopic_percentage_scheme);
|
isotopes = parser.parse_isotopic_percentage(data,isotopic_percentage_scheme);
|
||||||
|
|
||||||
std::string name;
|
std::string name;
|
||||||
std::vector<fourdst::atomic::Species> species;
|
std::vector<atomic::Species> species;
|
||||||
|
|
||||||
|
|
||||||
// construct name of the isotopes for all elements
|
// construct name of the isotopes for all elements
|
||||||
for (const auto [E,A] : std::ranges::views::zip(isotopes.elements, isotopes.mass_numbers)){
|
for (const auto [E,A] : std::ranges::views::zip(isotopes.elements, isotopes.mass_numbers)){
|
||||||
if (std::ranges::contains(compositions.elements,E)) {
|
if (std::ranges::contains(compositions.elements,E)) {
|
||||||
name = std::format("{}-{}",E,A);
|
name = std::format("{}-{}",E,A);
|
||||||
// std::println("{}", name);
|
auto SpeciesObject = atomic::species.at(name);
|
||||||
auto SpeciesObject = fourdst::atomic::species.at(name);
|
|
||||||
species.push_back(SpeciesObject);
|
species.push_back(SpeciesObject);
|
||||||
// std::println("Species: {} has mass: {}", SpeciesObject.name(), SpeciesObject.mass());
|
// std::println("Species: {} has mass: {}", SpeciesObject.name(), SpeciesObject.mass());
|
||||||
}
|
}
|
||||||
@@ -299,35 +299,32 @@ namespace fourdst::composition {
|
|||||||
|
|
||||||
if (compositions.requires_atomic_weight){
|
if (compositions.requires_atomic_weight){
|
||||||
// get isotope with max abundance for each metal
|
// get isotope with max abundance for each metal
|
||||||
// and store the corresponding mass
|
// and store the corresponding mass number
|
||||||
std::vector<double> element_atomic_weight;
|
auto element_atomic_weight = [&isotopes]() {
|
||||||
size_t i = 0;
|
std::unordered_map<std::string, std::pair<double, int>> elem_info;
|
||||||
while (i < isotopes.atomic_numbers.size()) {
|
|
||||||
size_t Z = isotopes.atomic_numbers[i];
|
|
||||||
if (Z<=2) {
|
|
||||||
++i;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
double max_iso = isotopes.percentages[i];
|
|
||||||
size_t loc = i;
|
|
||||||
size_t j = i ;
|
|
||||||
|
|
||||||
if (std::ranges::contains(compositions.elements,isotopes.elements[i])) {
|
for (const auto& [iso, prcnt, a] : std::views::zip(isotopes.elements, isotopes.percentages, isotopes.mass_numbers)) {
|
||||||
while (j<isotopes.atomic_numbers.size() && isotopes.atomic_numbers[j] == Z) {
|
if (iso == "H" || iso == "He") {
|
||||||
if (isotopes.percentages[j]>max_iso) {
|
continue;
|
||||||
loc = j;
|
}
|
||||||
}
|
if (elem_info.contains(iso) && elem_info.at(iso).first <= prcnt) {
|
||||||
++j;
|
elem_info[iso] = std::make_pair(prcnt, a);
|
||||||
|
} else if (! elem_info.contains(iso)) {
|
||||||
|
elem_info[iso] = std::make_pair(prcnt, a);
|
||||||
}
|
}
|
||||||
element_atomic_weight.push_back(species[loc].mass());
|
|
||||||
}
|
}
|
||||||
i=j;
|
return elem_info;
|
||||||
}
|
}();
|
||||||
for(size_t i=0;i < compositions.abundances.size();++i){
|
|
||||||
metal_fractions.emplace(compositions.elements[i], element_atomic_weight[i]*compositions.abundances[i]);
|
|
||||||
// std::println("metal_fractions: {}", metal_fractions);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
for (const auto [E,A] : std::ranges::views::zip(compositions.elements, compositions.abundances)) {
|
||||||
|
// std::println("element: {}", E);
|
||||||
|
auto name = std::format("{}-{}",E,element_atomic_weight.at(E).second);
|
||||||
|
// std::println("{}", name);
|
||||||
|
auto SpeciesObject = atomic::species.at(name);
|
||||||
|
double weight = SpeciesObject.mass();
|
||||||
|
metal_fractions.emplace(E,A*weight);
|
||||||
|
// std::println("End");
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
for (const auto [E,A] : std::ranges::views::zip(compositions.elements, compositions.abundances)) {
|
for (const auto [E,A] : std::ranges::views::zip(compositions.elements, compositions.abundances)) {
|
||||||
metal_fractions.emplace(E,A);
|
metal_fractions.emplace(E,A);
|
||||||
@@ -370,7 +367,7 @@ namespace fourdst::composition {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::println("ztotal: {}, zsum:{}", ztotal, zsum);
|
// std::println("ztotal: {}, zsum:{}", ztotal, zsum);
|
||||||
//Renormalize
|
//Renormalize
|
||||||
if (zsum > 0.0) {
|
if (zsum > 0.0) {
|
||||||
for (size_t i = 0; i < massFracs.size();++i) {
|
for (size_t i = 0; i < massFracs.size();++i) {
|
||||||
|
|||||||
@@ -492,9 +492,9 @@ TEST_F(compositionTest, standardSolarCompositions) {
|
|||||||
io::SolarCompositions::AG89,
|
io::SolarCompositions::AG89,
|
||||||
io::SolarCompositions::GS98,
|
io::SolarCompositions::GS98,
|
||||||
io::SolarCompositions::L03,
|
io::SolarCompositions::L03,
|
||||||
io::SolarCompositions::A09_Pryzbilla,
|
io::SolarCompositions::A09_Przybilla,
|
||||||
io::SolarCompositions::AGS05,
|
io::SolarCompositions::AGS05,
|
||||||
io::SolarCompositions::AGS09,
|
io::SolarCompositions::AGSS09,
|
||||||
io::SolarCompositions::AAG21_photospheric,
|
io::SolarCompositions::AAG21_photospheric,
|
||||||
io::SolarCompositions::MB22_photospheric,
|
io::SolarCompositions::MB22_photospheric,
|
||||||
io::SolarCompositions::L09
|
io::SolarCompositions::L09
|
||||||
@@ -511,6 +511,7 @@ TEST_F(compositionTest, standardSolarCompositions) {
|
|||||||
std::string string_comp = io::SolarCompositions_to_string_map.at(comp);
|
std::string string_comp = io::SolarCompositions_to_string_map.at(comp);
|
||||||
std::string string_iso = io::IsotopicPercentages_to_string_map.at(iso);
|
std::string string_iso = io::IsotopicPercentages_to_string_map.at(iso);
|
||||||
|
|
||||||
|
// std::println("Testing: {} with {}", string_comp, string_iso);
|
||||||
EXPECT_NO_THROW(get_composition_record(comp, iso, 0.02, 0.28));
|
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));
|
EXPECT_NO_THROW(get_composition_record(string_comp, string_iso, 0.02, 0.28));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user