feat(network): added ReaclibNetwork and functions to build network
This commit is contained in:
@@ -18,6 +18,7 @@ dependencies = [
|
||||
probe_dep,
|
||||
species_weight_dep,
|
||||
composition_dep,
|
||||
reaclib_reactions_dep,
|
||||
]
|
||||
|
||||
# Define the libnetwork library so it can be linked against by other parts of the build system
|
||||
|
||||
@@ -20,9 +20,13 @@
|
||||
// *********************************************************************** */
|
||||
#include "network.h"
|
||||
|
||||
#include <ranges>
|
||||
|
||||
#include "approx8.h"
|
||||
#include "probe.h"
|
||||
#include "quill/LogMacros.h"
|
||||
#include "reaclib.h"
|
||||
#include "reactions.h"
|
||||
|
||||
namespace serif::network {
|
||||
Network::Network(const NetworkFormat format) :
|
||||
@@ -65,4 +69,43 @@ namespace serif::network {
|
||||
}
|
||||
return netOut;
|
||||
}
|
||||
|
||||
serif::network::reaclib::REACLIBReactionSet build_reaclib_nuclear_network(const serif::composition::Composition &composition) {
|
||||
using namespace serif::network::reaclib;
|
||||
REACLIBReactionSet reactions;
|
||||
|
||||
if (!s_initialized) {
|
||||
LOG_INFO(serif::probe::LogManager::getInstance().getLogger("log"), "REACLIB reactions not initialized. Calling initializeAllReaclibReactions()...");
|
||||
initializeAllReaclibReactions();
|
||||
}
|
||||
|
||||
for (const auto &reaction: s_all_reaclib_reactions | std::views::values) {
|
||||
bool gotReaction = true;
|
||||
const auto& reactants = reaction.reactants();
|
||||
for (const auto& reactant : reactants) {
|
||||
if (!composition.contains(reactant)) {
|
||||
gotReaction = false;
|
||||
break; // If any reactant is not in the composition, skip this reaction
|
||||
}
|
||||
}
|
||||
if (gotReaction) {
|
||||
reactions.add_reaction(reaction);
|
||||
}
|
||||
}
|
||||
reactions.sort();
|
||||
return reactions;
|
||||
}
|
||||
|
||||
serif::network::reaclib::REACLIBReactionSet build_reaclib_nuclear_network(const serif::composition::Composition &composition, const double culling, const double T9) {
|
||||
using namespace serif::network::reaclib;
|
||||
REACLIBReactionSet allReactions = build_reaclib_nuclear_network(composition);
|
||||
REACLIBReactionSet reactions;
|
||||
for (const auto& reaction : allReactions) {
|
||||
if (reaction.calculate_rate(T9) >= culling) {
|
||||
reactions.add_reaction(reaction);
|
||||
}
|
||||
}
|
||||
return reactions;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include "config.h"
|
||||
#include "quill/Logger.h"
|
||||
#include "composition.h"
|
||||
#include "reaclib.h"
|
||||
#include <unordered_map>
|
||||
|
||||
namespace serif::network {
|
||||
@@ -105,7 +106,7 @@ namespace serif::network {
|
||||
explicit Network(const NetworkFormat format = NetworkFormat::APPROX8);
|
||||
virtual ~Network() = default;
|
||||
|
||||
NetworkFormat getFormat() const;
|
||||
[[nodiscard]] NetworkFormat getFormat() const;
|
||||
NetworkFormat setFormat(const NetworkFormat format);
|
||||
|
||||
/**
|
||||
@@ -124,6 +125,19 @@ namespace serif::network {
|
||||
NetworkFormat m_format; ///< Format of the network
|
||||
};
|
||||
|
||||
class ReaclibNetwork final : public Network {
|
||||
public:
|
||||
explicit ReaclibNetwork(const NetworkFormat format = NetworkFormat::APPROX8);
|
||||
|
||||
explicit ReaclibNetwork(serif::composition::Composition composition, const NetworkFormat format = NetworkFormat::APPROX8);
|
||||
|
||||
NetOut evaluate(const NetIn &netIn) override;
|
||||
private:
|
||||
serif::network::reaclib::REACLIBReactionSet m_reactions; ///< Set of REACLIB reactions
|
||||
};
|
||||
|
||||
serif::network::reaclib::REACLIBReactionSet build_reaclib_nuclear_network(const serif::composition::Composition &composition);
|
||||
serif::network::reaclib::REACLIBReactionSet build_reaclib_nuclear_network(const serif::composition::Composition &composition, double culling, double T9 = 1.0);
|
||||
|
||||
|
||||
} // namespace nuclearNetwork
|
||||
|
||||
Reference in New Issue
Block a user