Loading...
Searching...
No Matches
error_engine.h
Go to the documentation of this file.
#pragma once
#include <exception>
#include <string>
#include <iostream>
namespace gridfire::exceptions {
class EngineError : public std::exception {};
class StaleEngineTrigger final : public EngineError {
public:
struct state {
double m_T9;
double m_rho;
std::vector<double> m_Y;
double m_t;
int m_total_steps;
double m_eps_nuc;
};
explicit StaleEngineTrigger(const state &s)
: m_state(s) {}
const char* what() const noexcept override{
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!";
}
state getState() const {
return m_state;
}
size_t numSpecies() const {
return m_state.m_Y.size();
}
size_t totalSteps() const {
return m_state.m_total_steps;
}
double energy() const {
return m_state.m_eps_nuc;
}
double getMolarAbundance(const size_t index) const {
if (index > m_state.m_Y.size() - 1) {
throw std::out_of_range("Index out of bounds for molar abundance vector.");
}
return m_state.m_Y[index];
}
double temperature() const {
return m_state.m_T9 * 1e9; // Convert T9 back to Kelvin
}
double density() const {
return m_state.m_rho;
}
private:
state m_state;
};
class StaleEngineError final : public EngineError {
public:
explicit StaleEngineError(const std::string& message)
: m_message(message) {}
const char* what() const noexcept override {
return m_message.c_str();
}
private:
std::string m_message;
};
class FailedToPartitionEngineError final : public EngineError {
public:
explicit FailedToPartitionEngineError(const std::string& message)
: m_message(message) {}
const char* what() const noexcept override {
return m_message.c_str();
}
private:
std::string m_message;
};
class NetworkResizedError final : public EngineError {
public:
explicit NetworkResizedError(const std::string& message)
: m_message(message) {}
const char* what() const noexcept override {
return m_message.c_str();
}
private:
std::string m_message;
};
class UnableToSetNetworkReactionsError final : public EngineError {
public:
explicit UnableToSetNetworkReactionsError(const std::string& message)
: m_message(message) {}
const char* what() const noexcept override {
return m_message.c_str();
}
private:
std::string m_message;
};
}
gridfire::exceptions::EngineError
Definition error_engine.h:8
gridfire::exceptions::FailedToPartitionEngineError::m_message
std::string m_message
Definition error_engine.h:84
gridfire::exceptions::FailedToPartitionEngineError::FailedToPartitionEngineError
FailedToPartitionEngineError(const std::string &message)
Definition error_engine.h:77
gridfire::exceptions::FailedToPartitionEngineError::what
const char * what() const noexcept override
Definition error_engine.h:80
gridfire::exceptions::NetworkResizedError::m_message
std::string m_message
Definition error_engine.h:96
gridfire::exceptions::NetworkResizedError::NetworkResizedError
NetworkResizedError(const std::string &message)
Definition error_engine.h:89
gridfire::exceptions::NetworkResizedError::what
const char * what() const noexcept override
Definition error_engine.h:92
gridfire::exceptions::StaleEngineError::what
const char * what() const noexcept override
Definition error_engine.h:67
gridfire::exceptions::StaleEngineError::m_message
std::string m_message
Definition error_engine.h:72
gridfire::exceptions::StaleEngineError::StaleEngineError
StaleEngineError(const std::string &message)
Definition error_engine.h:64
gridfire::exceptions::StaleEngineTrigger::getState
state getState() const
Definition error_engine.h:27
gridfire::exceptions::StaleEngineTrigger::totalSteps
size_t totalSteps() const
Definition error_engine.h:35
gridfire::exceptions::StaleEngineTrigger::temperature
double temperature() const
Definition error_engine.h:50
gridfire::exceptions::StaleEngineTrigger::getMolarAbundance
double getMolarAbundance(const size_t index) const
Definition error_engine.h:43
gridfire::exceptions::StaleEngineTrigger::numSpecies
size_t numSpecies() const
Definition error_engine.h:31
gridfire::exceptions::StaleEngineTrigger::m_state
state m_state
Definition error_engine.h:58
gridfire::exceptions::StaleEngineTrigger::what
const char * what() const noexcept override
Definition error_engine.h:23
gridfire::exceptions::StaleEngineTrigger::density
double density() const
Definition error_engine.h:54
gridfire::exceptions::StaleEngineTrigger::energy
double energy() const
Definition error_engine.h:39
gridfire::exceptions::StaleEngineTrigger::StaleEngineTrigger
StaleEngineTrigger(const state &s)
Definition error_engine.h:20
gridfire::exceptions::UnableToSetNetworkReactionsError::what
const char * what() const noexcept override
Definition error_engine.h:104
gridfire::exceptions::UnableToSetNetworkReactionsError::UnableToSetNetworkReactionsError
UnableToSetNetworkReactionsError(const std::string &message)
Definition error_engine.h:101
gridfire::exceptions::UnableToSetNetworkReactionsError::m_message
std::string m_message
Definition error_engine.h:109
gridfire::exceptions
Definition error_engine.h:7
gridfire::exceptions::StaleEngineTrigger::state
Definition error_engine.h:12
gridfire::exceptions::StaleEngineTrigger::state::m_eps_nuc
double m_eps_nuc
Definition error_engine.h:18
gridfire::exceptions::StaleEngineTrigger::state::m_t
double m_t
Definition error_engine.h:16
gridfire::exceptions::StaleEngineTrigger::state::m_T9
double m_T9
Definition error_engine.h:13
gridfire::exceptions::StaleEngineTrigger::state::m_Y
std::vector< double > m_Y
Definition error_engine.h:15
gridfire::exceptions::StaleEngineTrigger::state::m_rho
double m_rho
Definition error_engine.h:14
gridfire::exceptions::StaleEngineTrigger::state::m_total_steps
int m_total_steps
Definition error_engine.h:17