feat(pythonInterface/eos): fast forward
This commit is contained in:
@@ -5,6 +5,8 @@ subdir('yaml-cpp')
|
||||
subdir('quill')
|
||||
subdir('boost')
|
||||
subdir('opatIO')
|
||||
subdir('mpi')
|
||||
subdir('hypre')
|
||||
subdir('pybind')
|
||||
subdir('mpi')
|
||||
subdir('hypre')
|
||||
|
||||
@@ -1,3 +1,23 @@
|
||||
/* ***********************************************************************
|
||||
//
|
||||
// Copyright (C) 2025 -- The 4D-STAR Collaboration
|
||||
// File Author: Emily Boudreaux
|
||||
// Last Modified: March 26, 2025
|
||||
//
|
||||
// 4DSSE is free software; you can use it and/or modify
|
||||
// it under the terms and restrictions the GNU General Library Public
|
||||
// License version 3 (GPLv3) as published by the Free Software Foundation.
|
||||
//
|
||||
// 4DSSE is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
// See the GNU Library General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Library General Public License
|
||||
// along with this software; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
//
|
||||
// *********************************************************************** */
|
||||
#include "composition.h"
|
||||
#include "quill/LogMacros.h"
|
||||
|
||||
@@ -10,7 +30,7 @@
|
||||
|
||||
#include "atomicSpecies.h"
|
||||
|
||||
using namespace composition;
|
||||
namespace serif::composition {
|
||||
|
||||
CompositionEntry::CompositionEntry() : m_symbol("H-1"), m_isotope(chemSpecies::species.at("H-1")), m_initialized(false) {}
|
||||
|
||||
@@ -527,10 +547,24 @@ Composition Composition::operator+(const Composition& other) const {
|
||||
return mix(other, 0.5);
|
||||
}
|
||||
|
||||
std::ostream& composition::operator<<(std::ostream& os, const Composition& composition) {
|
||||
std::ostream& operator<<(std::ostream& os, const GlobalComposition& comp) {
|
||||
os << "Global Composition: \n";
|
||||
os << "\tSpecific Number Density: " << comp.specificNumberDensity << "\n";
|
||||
os << "\tMean Particle Mass: " << comp.meanParticleMass << "\n";
|
||||
return os;
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, const CompositionEntry& entry) {
|
||||
os << "<" << entry.m_symbol << " : m_frac = " << entry.mass_fraction() << ">";
|
||||
return os;
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, const Composition& composition) {
|
||||
os << "Composition: \n";
|
||||
for (const auto& [symbol, entry] : composition.m_compositions) {
|
||||
os << entry << "\n";
|
||||
}
|
||||
return os;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace serif::composition
|
||||
@@ -1,3 +1,23 @@
|
||||
/* ***********************************************************************
|
||||
//
|
||||
// Copyright (C) 2025 -- The 4D-STAR Collaboration
|
||||
// File Author: Emily Boudreaux
|
||||
// Last Modified: March 26, 2025
|
||||
//
|
||||
// 4DSSE is free software; you can use it and/or modify
|
||||
// it under the terms and restrictions the GNU General Library Public
|
||||
// License version 3 (GPLv3) as published by the Free Software Foundation.
|
||||
//
|
||||
// 4DSSE is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
// See the GNU Library General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Library General Public License
|
||||
// along with this software; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
//
|
||||
// *********************************************************************** */
|
||||
#ifndef COMPOSITION_H
|
||||
#define COMPOSITION_H
|
||||
|
||||
@@ -13,7 +33,7 @@
|
||||
|
||||
#include "atomicSpecies.h"
|
||||
|
||||
namespace composition{
|
||||
namespace serif::composition {
|
||||
/**
|
||||
* @brief Represents the global composition of a system. This tends to be used after finalize and is primarily for internal use.
|
||||
*/
|
||||
@@ -22,12 +42,7 @@ namespace composition{
|
||||
double meanParticleMass; ///< The mean particle mass of the composition (\sum_{i} \frac{n_i}{m_i}. where n_i is the number fraction of the ith species and m_i is the mass of the ith species).
|
||||
|
||||
// Overload the output stream operator for GlobalComposition
|
||||
friend std::ostream& operator<<(std::ostream& os, const GlobalComposition& comp) {
|
||||
os << "Global Composition: \n";
|
||||
os << "\tSpecific Number Density: " << comp.specificNumberDensity << "\n";
|
||||
os << "\tMean Particle Mass: " << comp.meanParticleMass << "\n";
|
||||
return os;
|
||||
}
|
||||
friend std::ostream& operator<<(std::ostream& os, const GlobalComposition& comp);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -154,10 +169,7 @@ namespace composition{
|
||||
* @param entry The CompositionEntry to output.
|
||||
* @return The output stream.
|
||||
*/
|
||||
friend std::ostream& operator<<(std::ostream& os, const CompositionEntry& entry) {
|
||||
os << "<" << entry.m_symbol << " : m_frac = " << entry.mass_fraction() << ">";
|
||||
return os;
|
||||
}
|
||||
friend std::ostream& operator<<(std::ostream& os, const CompositionEntry& entry);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -190,7 +202,8 @@ namespace composition{
|
||||
*/
|
||||
class Composition {
|
||||
private:
|
||||
Probe::LogManager& m_logManager = Probe::LogManager::getInstance();
|
||||
serif::config::Config& m_config = serif::config::Config::getInstance();
|
||||
serif::probe::LogManager& m_logManager = serif::probe::LogManager::getInstance();
|
||||
quill::Logger* m_logger = m_logManager.getLogger("log");
|
||||
|
||||
bool m_finalized = false; ///< True if the composition is finalized.
|
||||
@@ -450,6 +463,6 @@ namespace composition{
|
||||
Composition operator+(const Composition& other) const;
|
||||
|
||||
};
|
||||
};
|
||||
}; // namespace serif::composition
|
||||
|
||||
#endif // COMPOSITION_H
|
||||
@@ -25,13 +25,13 @@ TEST_F(compositionTest, isotopeMasses) {
|
||||
}
|
||||
|
||||
TEST_F(compositionTest, constructor) {
|
||||
Config::getInstance().loadConfig(EXAMPLE_FILENAME);
|
||||
EXPECT_NO_THROW(composition::Composition comp);
|
||||
serif::config::Config::getInstance().loadConfig(EXAMPLE_FILENAME);
|
||||
EXPECT_NO_THROW(serif::composition::Composition comp);
|
||||
}
|
||||
|
||||
TEST_F(compositionTest, registerSymbol) {
|
||||
Config::getInstance().loadConfig(EXAMPLE_FILENAME);
|
||||
composition::Composition comp;
|
||||
serif::config::Config::getInstance().loadConfig(EXAMPLE_FILENAME);
|
||||
serif::composition::Composition comp;
|
||||
EXPECT_NO_THROW(comp.registerSymbol("H-1"));
|
||||
EXPECT_NO_THROW(comp.registerSymbol("He-4"));
|
||||
EXPECT_THROW(comp.registerSymbol("H-19"), std::runtime_error);
|
||||
@@ -45,8 +45,8 @@ TEST_F(compositionTest, registerSymbol) {
|
||||
}
|
||||
|
||||
TEST_F(compositionTest, setGetComposition) {
|
||||
Config::getInstance().loadConfig(EXAMPLE_FILENAME);
|
||||
composition::Composition comp;
|
||||
serif::config::Config::getInstance().loadConfig(EXAMPLE_FILENAME);
|
||||
serif::composition::Composition comp;
|
||||
comp.registerSymbol("H-1");
|
||||
comp.registerSymbol("He-4");
|
||||
|
||||
@@ -71,8 +71,8 @@ TEST_F(compositionTest, setGetComposition) {
|
||||
}
|
||||
|
||||
TEST_F(compositionTest, setGetNumberFraction) {
|
||||
Config::getInstance().loadConfig(EXAMPLE_FILENAME);
|
||||
composition::Composition comp;
|
||||
serif::config::Config::getInstance().loadConfig(EXAMPLE_FILENAME);
|
||||
serif::composition::Composition comp;
|
||||
comp.registerSymbol("H-1", false);
|
||||
comp.registerSymbol("He-4", false);
|
||||
|
||||
@@ -88,8 +88,8 @@ TEST_F(compositionTest, setGetNumberFraction) {
|
||||
}
|
||||
|
||||
TEST_F(compositionTest, subset) {
|
||||
Config::getInstance().loadConfig(EXAMPLE_FILENAME);
|
||||
composition::Composition comp;
|
||||
serif::config::Config::getInstance().loadConfig(EXAMPLE_FILENAME);
|
||||
serif::composition::Composition comp;
|
||||
comp.registerSymbol("H-1");
|
||||
comp.registerSymbol("He-4");
|
||||
comp.setMassFraction("H-1", 0.6);
|
||||
@@ -97,14 +97,14 @@ TEST_F(compositionTest, subset) {
|
||||
EXPECT_NO_THROW(comp.finalize());
|
||||
|
||||
std::vector<std::string> symbols = {"H-1"};
|
||||
composition::Composition subsetComp = comp.subset(symbols, "norm");
|
||||
serif::composition::Composition subsetComp = comp.subset(symbols, "norm");
|
||||
EXPECT_TRUE(subsetComp.finalize());
|
||||
EXPECT_DOUBLE_EQ(subsetComp.getMassFraction("H-1"), 1.0);
|
||||
}
|
||||
|
||||
TEST_F(compositionTest, finalizeWithNormalization) {
|
||||
Config::getInstance().loadConfig(EXAMPLE_FILENAME);
|
||||
composition::Composition comp;
|
||||
serif::config::Config::getInstance().loadConfig(EXAMPLE_FILENAME);
|
||||
serif::composition::Composition comp;
|
||||
comp.registerSymbol("H-1");
|
||||
comp.registerSymbol("He-4");
|
||||
comp.setMassFraction("H-1", 0.3);
|
||||
@@ -115,8 +115,8 @@ TEST_F(compositionTest, finalizeWithNormalization) {
|
||||
}
|
||||
|
||||
TEST_F(compositionTest, finalizeWithoutNormalization) {
|
||||
Config::getInstance().loadConfig(EXAMPLE_FILENAME);
|
||||
composition::Composition comp;
|
||||
serif::config::Config::getInstance().loadConfig(EXAMPLE_FILENAME);
|
||||
serif::composition::Composition comp;
|
||||
comp.registerSymbol("H-1");
|
||||
comp.registerSymbol("He-4");
|
||||
comp.setMassFraction("H-1", 0.5);
|
||||
@@ -127,8 +127,8 @@ TEST_F(compositionTest, finalizeWithoutNormalization) {
|
||||
}
|
||||
|
||||
TEST_F(compositionTest, getComposition) {
|
||||
Config::getInstance().loadConfig(EXAMPLE_FILENAME);
|
||||
composition::Composition comp;
|
||||
serif::config::Config::getInstance().loadConfig(EXAMPLE_FILENAME);
|
||||
serif::composition::Composition comp;
|
||||
comp.registerSymbol("H-1");
|
||||
comp.registerSymbol("He-4");
|
||||
comp.setMassFraction("H-1", 0.6);
|
||||
@@ -142,8 +142,8 @@ TEST_F(compositionTest, getComposition) {
|
||||
}
|
||||
|
||||
TEST_F(compositionTest, setCompositionMode) {
|
||||
Config::getInstance().loadConfig(EXAMPLE_FILENAME);
|
||||
composition::Composition comp;
|
||||
serif::config::Config::getInstance().loadConfig(EXAMPLE_FILENAME);
|
||||
serif::composition::Composition comp;
|
||||
comp.registerSymbol("H-1");
|
||||
comp.registerSymbol("He-4");
|
||||
comp.setMassFraction("H-1", 0.6);
|
||||
@@ -164,8 +164,8 @@ TEST_F(compositionTest, setCompositionMode) {
|
||||
}
|
||||
|
||||
TEST_F(compositionTest, hasSymbol) {
|
||||
Config::getInstance().loadConfig(EXAMPLE_FILENAME);
|
||||
composition::Composition comp;
|
||||
serif::config::Config::getInstance().loadConfig(EXAMPLE_FILENAME);
|
||||
serif::composition::Composition comp;
|
||||
comp.registerSymbol("H-1");
|
||||
comp.registerSymbol("He-4");
|
||||
comp.setMassFraction("H-1", 0.6);
|
||||
@@ -179,27 +179,27 @@ TEST_F(compositionTest, hasSymbol) {
|
||||
}
|
||||
|
||||
TEST_F(compositionTest, mix) {
|
||||
Config::getInstance().loadConfig(EXAMPLE_FILENAME);
|
||||
composition::Composition comp1;
|
||||
serif::config::Config::getInstance().loadConfig(EXAMPLE_FILENAME);
|
||||
serif::composition::Composition comp1;
|
||||
comp1.registerSymbol("H-1");
|
||||
comp1.registerSymbol("He-4");
|
||||
comp1.setMassFraction("H-1", 0.6);
|
||||
comp1.setMassFraction("He-4", 0.4);
|
||||
EXPECT_NO_THROW(comp1.finalize());
|
||||
|
||||
composition::Composition comp2;
|
||||
serif::composition::Composition comp2;
|
||||
comp2.registerSymbol("H-1");
|
||||
comp2.registerSymbol("He-4");
|
||||
comp2.setMassFraction("H-1", 0.4);
|
||||
comp2.setMassFraction("He-4", 0.6);
|
||||
EXPECT_NO_THROW(comp2.finalize());
|
||||
|
||||
composition::Composition mixedComp = comp1 + comp2;
|
||||
serif::composition::Composition mixedComp = comp1 + comp2;
|
||||
EXPECT_TRUE(mixedComp.finalize());
|
||||
EXPECT_DOUBLE_EQ(mixedComp.getMassFraction("H-1"), 0.5);
|
||||
EXPECT_DOUBLE_EQ(mixedComp.getMassFraction("He-4"), 0.5);
|
||||
|
||||
composition::Composition mixedComp2 = comp1.mix(comp2, 0.25);
|
||||
serif::composition::Composition mixedComp2 = comp1.mix(comp2, 0.25);
|
||||
EXPECT_TRUE(mixedComp2.finalize());
|
||||
EXPECT_DOUBLE_EQ(mixedComp2.getMassFraction("H-1"), 0.45);
|
||||
EXPECT_DOUBLE_EQ(mixedComp2.getMassFraction("He-4"), 0.55);
|
||||
|
||||
Reference in New Issue
Block a user