GridFire 0.0.1a General Purpose Nuclear Network

Loading...
Searching...
No Matches
network.h
Go to the documentation of this file.
1/* ***********************************************************************
2//
3// Copyright (C) 2025 -- The 4D-STAR Collaboration
4// File Authors: Emily Boudreaux, Aaron Dotter
5// Last Modified: March 21, 2025
6//
7// 4DSSE is free software; you can use it and/or modify
8// it under the terms and restrictions the GNU General Library Public
9// License version 3 (GPLv3) as published by the Free Software Foundation.
10//
11// 4DSSE is distributed in the hope that it will be useful,
12// but WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14// See the GNU Library General Public License for more details.
15//
16// You should have received a copy of the GNU Library General Public License
17// along with this software; if not, write to the Free Software
18// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19//
20// *********************************************************************** */
21#pragma once
22
23#include <vector>
24
25#include "fourdst/logging/logging.h"
26#include "fourdst/config/config.h"
27#include "fourdst/composition/species.h"
28#include "fourdst/composition/composition.h"
29#include "fourdst/constants/const.h"
30
31#include "gridfire/reaction/reaction.h"
32
33#include "quill/Logger.h"
34
35#include <unordered_map>
36
37
38 namespace gridfire {
39
40
41 enum NetworkFormat {
42 APPROX8,
43 REACLIB,
44 UNKNOWN,
45 };
46
47 static inline std::unordered_map<NetworkFormat, std::string> FormatStringLookup = {
48 {APPROX8, "Approx8"},
49 {REACLIB, "REACLIB"},
50 {UNKNOWN, "Unknown"}
51 };
52
53 struct NetIn {
54 fourdst::composition::Composition composition;
55 double tMax;
56 double dt0;
57 double temperature;
58 double density;
59 double energy;
60 double culling = 0.0;
61
62 std::vector<double> MolarAbundance() const;
63 };
64
65 struct NetOut {
66 fourdst::composition::Composition composition;
67 int num_steps;
68 double energy;
69
70 friend std::ostream& operator<<(std::ostream& os, const NetOut& netOut) {
71 os << "NetOut(composition=" << netOut.composition << ", num_steps=" << netOut.num_steps << ", energy=" << netOut.energy << ")";
72 return os;
73 }
74 };
75
76 class Network {
77 public:
78 explicit Network(const NetworkFormat format = NetworkFormat::APPROX8);
79 virtual ~Network() = default;
80
81 [[nodiscard]] NetworkFormat getFormat() const;
82 NetworkFormat setFormat(const NetworkFormat format);
83
90 virtual NetOut evaluate(const NetIn &netIn) = 0;
91
92 virtual bool isStiff() const { return m_stiff; }
93 virtual void setStiff(const bool stiff) { m_stiff = stiff; }
94
95 protected:
96 fourdst::config::Config& m_config;
97 fourdst::logging::LogManager& m_logManager;
98 quill::Logger* m_logger;
99
100 NetworkFormat m_format;
101 fourdst::constant::Constants& m_constants;
102
103 bool m_stiff = false;
104 };
105
106
107
108} // 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