Loading...
Searching...
No Matches
network.h
Go to the documentation of this file.
/* ***********************************************************************
//
// Copyright (C) 2025 -- The 4D-STAR Collaboration
// File Authors: Emily Boudreaux, Aaron Dotter
// Last Modified: March 21, 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
//
// *********************************************************************** */
#pragma once
#include <vector>
#include "fourdst/logging/logging.h"
#include "fourdst/config/config.h"
#include "fourdst/composition/species.h"
#include "fourdst/composition/composition.h"
#include "fourdst/constants/const.h"
#include "gridfire/reaction/reaction.h"
#include "quill/Logger.h"
#include <unordered_map>
namespace gridfire {
enum NetworkFormat {
APPROX8,
REACLIB,
UNKNOWN,
};
static inline std::unordered_map<NetworkFormat, std::string> FormatStringLookup = {
{APPROX8, "Approx8"},
{REACLIB, "REACLIB"},
{UNKNOWN, "Unknown"}
};
struct NetIn {
fourdst::composition::Composition composition;
double tMax;
double dt0;
double temperature;
double density;
double energy;
double culling = 0.0;
std::vector<double> MolarAbundance() const;
};
struct NetOut {
fourdst::composition::Composition composition;
int num_steps;
double energy;
friend std::ostream& operator<<(std::ostream& os, const NetOut& netOut) {
os << "NetOut(composition=" << netOut.composition << ", num_steps=" << netOut.num_steps << ", energy=" << netOut.energy << ")";
return os;
}
};
class Network {
public:
explicit Network(const NetworkFormat format = NetworkFormat::APPROX8);
virtual ~Network() = default;
[[nodiscard]] NetworkFormat getFormat() const;
NetworkFormat setFormat(const NetworkFormat format);
virtual NetOut evaluate(const NetIn &netIn) = 0;
virtual bool isStiff() const { return m_stiff; }
virtual void setStiff(const bool stiff) { m_stiff = stiff; }
protected:
fourdst::config::Config& m_config;
fourdst::logging::LogManager& m_logManager;
quill::Logger* m_logger;
NetworkFormat m_format;
fourdst::constant::Constants& m_constants;
bool m_stiff = false;
};
} // namespace nuclearNetwork
gridfire::Network::m_logManager
fourdst::logging::LogManager & m_logManager
Log manager instance.
Definition network.h:97
gridfire::Network::Network
Network(const NetworkFormat format=NetworkFormat::APPROX8)
Definition network.cpp:41
gridfire::Network::getFormat
NetworkFormat getFormat() const
Definition network.cpp:54
gridfire::Network::m_format
NetworkFormat m_format
Format of the network.
Definition network.h:100
gridfire::Network::setFormat
NetworkFormat setFormat(const NetworkFormat format)
Definition network.cpp:58
gridfire::Network::setStiff
virtual void setStiff(const bool stiff)
Definition network.h:93
gridfire::Network::m_logger
quill::Logger * m_logger
Logger instance.
Definition network.h:98
gridfire::Network::m_config
fourdst::config::Config & m_config
Configuration instance.
Definition network.h:96
gridfire::Network::~Network
virtual ~Network()=default
gridfire::Network::m_constants
fourdst::constant::Constants & m_constants
Definition network.h:101
gridfire::Network::isStiff
virtual bool isStiff() const
Definition network.h:92
gridfire::Network::m_stiff
bool m_stiff
Flag indicating if the network is stiff.
Definition network.h:103
gridfire::Network::evaluate
virtual NetOut evaluate(const NetIn &netIn)=0
Evaluate the network based on the input parameters.
gridfire
Definition engine_abstract.h:31
gridfire::NetworkFormat
NetworkFormat
Definition network.h:41
gridfire::APPROX8
@ APPROX8
Approx8 nuclear reaction network format.
Definition network.h:42
gridfire::REACLIB
@ REACLIB
General REACLIB nuclear reaction network format.
Definition network.h:43
gridfire::UNKNOWN
@ UNKNOWN
Definition network.h:44
gridfire::FormatStringLookup
static std::unordered_map< NetworkFormat, std::string > FormatStringLookup
Definition network.h:47
reaction.h
Defines classes for representing and managing nuclear reactions.
gridfire::NetIn
Definition network.h:53
gridfire::NetIn::density
double density
Density in g/cm^3.
Definition network.h:58
gridfire::NetIn::tMax
double tMax
Maximum time.
Definition network.h:55
gridfire::NetIn::composition
fourdst::composition::Composition composition
Composition of the network.
Definition network.h:54
gridfire::NetIn::MolarAbundance
std::vector< double > MolarAbundance() const
Definition network.cpp:30
gridfire::NetIn::dt0
double dt0
Initial time step.
Definition network.h:56
gridfire::NetIn::temperature
double temperature
Temperature in Kelvin.
Definition network.h:57
gridfire::NetIn::culling
double culling
Culling threshold for reactions (default is 0.0, meaning no culling)
Definition network.h:60
gridfire::NetIn::energy
double energy
Energy in ergs.
Definition network.h:59
gridfire::NetOut
Definition network.h:65
gridfire::NetOut::composition
fourdst::composition::Composition composition
Composition of the network after evaluation.
Definition network.h:66
gridfire::NetOut::energy
double energy
Energy in ergs after evaluation.
Definition network.h:68
gridfire::NetOut::num_steps
int num_steps
Number of steps taken in the evaluation.
Definition network.h:67
gridfire::NetOut::operator<<
friend std::ostream & operator<<(std::ostream &os, const NetOut &netOut)
Definition network.h:70