SERiF 0.0.1a
3+1D Stellar Structure and Evolution
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 "probe.h"
26#include "config.h"
27#include "quill/Logger.h"
28#include "composition.h"
29#include "reaclib.h"
30#include <unordered_map>
31
32#include "const.h"
33
34namespace serif::network {
35
41
42 static inline std::unordered_map<NetworkFormat, std::string> FormatStringLookup = {
43 {APPROX8, "Approx8"},
44 {REACLIB, "REACLIB"},
45 {UNKNOWN, "Unknown"}
46 };
47
65 struct NetIn {
67 double tMax;
68 double dt0;
69 double temperature;
70 double density;
71 double energy;
72 double culling = 0.0;
73 };
74
89 struct NetOut {
92 double energy;
93
94 friend std::ostream& operator<<(std::ostream& os, const NetOut& netOut) {
95 os << "NetOut(composition=" << netOut.composition << ", num_steps=" << netOut.num_steps << ", energy=" << netOut.energy << ")";
96 return os;
97 }
98 };
99
114 class Network {
115 public:
116 explicit Network(const NetworkFormat format = NetworkFormat::APPROX8);
117 virtual ~Network() = default;
118
119 [[nodiscard]] NetworkFormat getFormat() const;
121
128 virtual NetOut evaluate(const NetIn &netIn);
129
130 virtual bool isStiff() const { return m_stiff; }
131 virtual void setStiff(const bool stiff) { m_stiff = stiff; }
132
133 protected:
134 serif::config::Config& m_config;
136 quill::Logger* m_logger;
137
140
141 bool m_stiff = false;
142 };
143
144 class ReaclibNetwork final : public Network {
145 public:
147
149
150 NetOut evaluate(const NetIn &netIn) override;
151 private:
152 serif::network::reaclib::REACLIBReactionSet m_reactions;
153 };
154
155 serif::network::reaclib::REACLIBReactionSet build_reaclib_nuclear_network(const serif::composition::Composition &composition);
156 serif::network::reaclib::REACLIBReactionSet build_reaclib_nuclear_network(const serif::composition::Composition &composition, double culling, double T9 = 1.0);
157
158
159} // namespace nuclearNetwork
Manages the composition of elements.
Class to manage a collection of constants.
Definition const.h:63
virtual ~Network()=default
virtual NetOut evaluate(const NetIn &netIn)
Evaluate the network based on the input parameters.
Definition network.cpp:54
NetworkFormat setFormat(const NetworkFormat format)
Definition network.cpp:48
serif::probe::LogManager & m_logManager
Log manager instance.
Definition network.h:135
NetworkFormat m_format
Format of the network.
Definition network.h:138
NetworkFormat getFormat() const
Definition network.cpp:44
virtual bool isStiff() const
Definition network.h:130
bool m_stiff
Flag indicating if the network is stiff.
Definition network.h:141
Network(const NetworkFormat format=NetworkFormat::APPROX8)
Definition network.cpp:32
serif::constant::Constants & m_constants
Definition network.h:139
quill::Logger * m_logger
Logger instance.
Definition network.h:136
serif::config::Config & m_config
Configuration instance.
Definition network.h:134
virtual void setStiff(const bool stiff)
Definition network.h:131
NetOut evaluate(const NetIn &netIn) override
Evaluate the network based on the input parameters.
serif::network::reaclib::REACLIBReactionSet m_reactions
Set of REACLIB reactions.
Definition network.h:152
ReaclibNetwork(serif::composition::Composition composition, const NetworkFormat format=NetworkFormat::APPROX8)
ReaclibNetwork(const NetworkFormat format=NetworkFormat::APPROX8)
Class to manage logging operations.
Definition probe.h:79
@ REACLIB
General REACLIB nuclear reaction network format.
Definition network.h:38
@ APPROX8
Approx8 nuclear reaction network format.
Definition network.h:37
serif::network::reaclib::REACLIBReactionSet build_reaclib_nuclear_network(const serif::composition::Composition &composition)
Definition network.cpp:74
static std::unordered_map< NetworkFormat, std::string > FormatStringLookup
Definition network.h:42
Input structure for the network evaluation.
Definition network.h:65
double temperature
Temperature in Kelvin.
Definition network.h:69
double dt0
Initial time step.
Definition network.h:68
double tMax
Maximum time.
Definition network.h:67
double culling
Culling threshold for reactions (default is 0.0, meaning no culling)
Definition network.h:72
double energy
Energy in ergs.
Definition network.h:71
serif::composition::Composition composition
Composition of the network.
Definition network.h:66
double density
Density in g/cm^3.
Definition network.h:70
Output structure for the network evaluation.
Definition network.h:89
double energy
Energy in ergs after evaluation.
Definition network.h:92
friend std::ostream & operator<<(std::ostream &os, const NetOut &netOut)
Definition network.h:94
int num_steps
Number of steps taken in the evaluation.
Definition network.h:91
serif::composition::Composition composition
Composition of the network after evaluation.
Definition network.h:90