test(composition_sandbox): added some sandbox tests
This commit is contained in:
@@ -11,5 +11,81 @@ int main(int argv, char* argc[]) {
|
||||
}
|
||||
Config::getInstance().loadConfig(pathToConfigFile);
|
||||
composition::Composition comp;
|
||||
std::vector<std::string> symbols = {"H-1", "He-4"};
|
||||
comp.registerSymbol(symbols);
|
||||
comp.setMassFraction("H-1", 0.7);
|
||||
comp.setMassFraction("He-4", 0.3);
|
||||
comp.finalize();
|
||||
std::cout << "=== Mass Fraction Mode ===" << std::endl;
|
||||
std::cout << "\tH-1 Mass Frac: " << comp.getMassFraction("H-1") << std::endl;
|
||||
std::cout << "\tH-1 Number Frac: " << comp.getNumberFraction("H-1") << std::endl;
|
||||
std::cout << "\tHe-4 Mass Frac: " << comp.getMassFraction("He-4") << std::endl;
|
||||
std::cout << "\tHe-4 Number Frac: " << comp.getNumberFraction("He-4") << std::endl;
|
||||
|
||||
std::cout << "\tMass Frac Sum: " << comp.getMassFraction("H-1") + comp.getMassFraction("He-4") << std::endl;
|
||||
std::cout << "\tNumber Frac Sum: " << comp.getNumberFraction("H-1") + comp.getNumberFraction("He-4") << std::endl;
|
||||
|
||||
composition::Composition comp2;
|
||||
comp2.registerSymbol(symbols, false);
|
||||
comp2.setNumberFraction("H-1", comp.getNumberFraction("H-1"));
|
||||
comp2.setNumberFraction("He-4", comp.getNumberFraction("He-4"));
|
||||
|
||||
comp2.finalize();
|
||||
std::cout << "=== Number Fraction Mode ===" << std::endl;
|
||||
std::cout << "\tH-1 Mass Frac: " << comp2.getMassFraction("H-1") << std::endl;
|
||||
std::cout << "\tH-1 Number Frac: " << comp2.getNumberFraction("H-1") << std::endl;
|
||||
std::cout << "\tHe-4 Mass Frac: " << comp2.getMassFraction("He-4") << std::endl;
|
||||
std::cout << "\tHe-4 Number Frac: " << comp2.getNumberFraction("He-4") << std::endl;
|
||||
|
||||
std::cout << "\tMass Frac Sum: " << comp2.getMassFraction("H-1") + comp2.getMassFraction("He-4") << std::endl;
|
||||
std::cout << "\tNumber Frac Sum: " << comp2.getNumberFraction("H-1") + comp2.getNumberFraction("He-4") << std::endl;
|
||||
|
||||
|
||||
std::vector<std::string> symbols3 = {
|
||||
"H-1",
|
||||
"He-3",
|
||||
"He-4",
|
||||
"Li-6",
|
||||
"Li-7",
|
||||
"O-16",
|
||||
"C-12",
|
||||
"Fe-56",
|
||||
"Ne-20",
|
||||
"N-14",
|
||||
"Mg-24",
|
||||
"Si-28",
|
||||
"S-32",
|
||||
"Ca-40",
|
||||
};
|
||||
std::vector<double> mass_fractions = {
|
||||
0.71243,
|
||||
1e-5,
|
||||
0.27,
|
||||
1e-11,
|
||||
1e-9,
|
||||
0.009,
|
||||
0.003,
|
||||
0.0014,
|
||||
0.0015,
|
||||
0.001,
|
||||
0.0006,
|
||||
0.0006,
|
||||
0.0004,
|
||||
0.00006
|
||||
};
|
||||
composition::Composition comp3(symbols3, mass_fractions, true);
|
||||
std::cout << "=== Mass Fraction Mode ===" << std::endl;
|
||||
double massFracSum = 0.0;
|
||||
double numberFracSum = 0.0;
|
||||
for (const auto& symbol : symbols3) {
|
||||
std::cout << "\t" << symbol << " Mass Frac: " << comp3.getMassFraction(symbol) << std::endl;
|
||||
std::cout << "\t" << symbol << " Number Frac: " << comp3.getNumberFraction(symbol) << std::endl;
|
||||
massFracSum += comp3.getMassFraction(symbol);
|
||||
numberFracSum += comp3.getNumberFraction(symbol);
|
||||
}
|
||||
std::cout << "\tMass Frac Sum: " << massFracSum << std::endl;
|
||||
std::cout << "\tNumber Frac Sum: " << numberFracSum << std::endl;
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user