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
32
33#include "quill/Logger.h"
34
35#include <unordered_map>
36
37
38namespace gridfire {
39
40
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;
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;
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
101 fourdst::constant::Constants& m_constants;
102
103 bool m_stiff = false;
104 };
105
106
107 reaction::LogicalReactionSet build_reaclib_nuclear_network(const fourdst::composition::Composition &composition, bool reverse);
108
109
110} // namespace nuclearNetwork
fourdst::logging::LogManager & m_logManager
Log manager instance.
Definition network.h:97
Network(const NetworkFormat format=NetworkFormat::APPROX8)
Definition network.cpp:41
NetworkFormat getFormat() const
Definition network.cpp:54
NetworkFormat m_format
Format of the network.
Definition network.h:100
NetworkFormat setFormat(const NetworkFormat format)
Definition network.cpp:58
virtual void setStiff(const bool stiff)
Definition network.h:93
quill::Logger * m_logger
Logger instance.
Definition network.h:98
fourdst::config::Config & m_config
Configuration instance.
Definition network.h:96
virtual ~Network()=default
fourdst::constant::Constants & m_constants
Definition network.h:101
virtual bool isStiff() const
Definition network.h:92
bool m_stiff
Flag indicating if the network is stiff.
Definition network.h:103
virtual NetOut evaluate(const NetIn &netIn)=0
Evaluate the network based on the input parameters.
TemplatedReactionSet< LogicalReaction > LogicalReactionSet
A set of logical reactions.
Definition reaction.h:557
NetworkFormat
Definition network.h:41
@ APPROX8
Approx8 nuclear reaction network format.
Definition network.h:42
@ REACLIB
General REACLIB nuclear reaction network format.
Definition network.h:43
@ UNKNOWN
Definition network.h:44
static std::unordered_map< NetworkFormat, std::string > FormatStringLookup
Definition network.h:47
reaction::LogicalReactionSet build_reaclib_nuclear_network(const fourdst::composition::Composition &composition, bool reverse)
Definition network.cpp:64
Defines classes for representing and managing nuclear reactions.
double density
Density in g/cm^3.
Definition network.h:58
double tMax
Maximum time.
Definition network.h:55
fourdst::composition::Composition composition
Composition of the network.
Definition network.h:54
std::vector< double > MolarAbundance() const
Definition network.cpp:30
double dt0
Initial time step.
Definition network.h:56
double temperature
Temperature in Kelvin.
Definition network.h:57
double culling
Culling threshold for reactions (default is 0.0, meaning no culling)
Definition network.h:60
double energy
Energy in ergs.
Definition network.h:59
fourdst::composition::Composition composition
Composition of the network after evaluation.
Definition network.h:66
double energy
Energy in ergs after evaluation.
Definition network.h:68
int num_steps
Number of steps taken in the evaluation.
Definition network.h:67
friend std::ostream & operator<<(std::ostream &os, const NetOut &netOut)
Definition network.h:70