GridFire 0.0.1a
General Purpose Nuclear Network
Loading...
Searching...
No Matches
error_engine.h
Go to the documentation of this file.
1#pragma once
2
3#include <exception>
4#include <string>
5#include <iostream>
6
8 class EngineError : public std::exception {};
9
10 class StaleEngineTrigger final : public EngineError {
11 public:
12 struct state {
13 double m_T9;
14 double m_rho;
15 std::vector<double> m_Y;
16 double m_t;
18 double m_eps_nuc;
19 };
20 explicit StaleEngineTrigger(const state &s)
21 : m_state(s) {}
22
23 const char* what() const noexcept override{
24 return "Engine reports stale state. This means that the caller should trigger a update of the engine state before continuing with the integration. If you as an end user are seeing this error, it is likely a bug in the code that should be reported. Please provide the input parameters and the context in which this error occurred. Thank you for your help!";
25 }
26
27 state getState() const {
28 return m_state;
29 }
30
31 size_t numSpecies() const {
32 return m_state.m_Y.size();
33 }
34
35 size_t totalSteps() const {
36 return m_state.m_total_steps;
37 }
38
39 double energy() const {
40 return m_state.m_eps_nuc;
41 }
42
43 double getMolarAbundance(const size_t index) const {
44 if (index > m_state.m_Y.size() - 1) {
45 throw std::out_of_range("Index out of bounds for molar abundance vector.");
46 }
47 return m_state.m_Y[index];
48 }
49
50 double temperature() const {
51 return m_state.m_T9 * 1e9; // Convert T9 back to Kelvin
52 }
53
54 double density() const {
55 return m_state.m_rho;
56 }
57 private:
59
60 };
61
62 class StaleEngineError final : public EngineError {
63 public:
64 explicit StaleEngineError(const std::string& message)
65 : m_message(message) {}
66
67 const char* what() const noexcept override {
68 return m_message.c_str();
69 }
70
71 private:
72 std::string m_message;
73 };
74
76 public:
77 explicit FailedToPartitionEngineError(const std::string& message)
78 : m_message(message) {}
79
80 const char* what() const noexcept override {
81 return m_message.c_str();
82 }
83 private:
84 std::string m_message;
85 };
86
87 class NetworkResizedError final : public EngineError {
88 public:
89 explicit NetworkResizedError(const std::string& message)
90 : m_message(message) {}
91
92 const char* what() const noexcept override {
93 return m_message.c_str();
94 }
95 private:
96 std::string m_message;
97 };
98
100 public:
101 explicit UnableToSetNetworkReactionsError(const std::string& message)
102 : m_message(message) {}
103
104 const char* what() const noexcept override {
105 return m_message.c_str();
106 }
107
108 private:
109 std::string m_message;
110 };
111
112}
FailedToPartitionEngineError(const std::string &message)
const char * what() const noexcept override
NetworkResizedError(const std::string &message)
const char * what() const noexcept override
const char * what() const noexcept override
StaleEngineError(const std::string &message)
double getMolarAbundance(const size_t index) const
const char * what() const noexcept override
const char * what() const noexcept override
UnableToSetNetworkReactionsError(const std::string &message)