GridFire 0.0.1a General Purpose Nuclear Network

Loading...
Searching...
No Matches
bindings.cpp
Go to the documentation of this file.
1#include <pybind11/pybind11.h>
2#include <pybind11/stl.h> // Needed for vectors, maps, sets, strings
3#include <pybind11/stl_bind.h> // Needed for binding std::vector, std::map etc if needed directly
4
5#include <iostream>
6
7#include "bindings.h"
8
9 namespace py = pybind11;
10
11#include "gridfire/exceptions/exceptions.h"
12
13 void register_exception_bindings(py::module &m) {
14 py::register_exception<gridfire::exceptions::EngineError>(m, "GridFireEngineError");
15
16 // TODO: Make it so that we can grab the stale state in python
17 // m.attr("StaleEngineTrigger") = py::register_exception<gridfire::exceptions::StaleEngineTrigger>(m, "StaleEngineTrigger", m.attr("GridFireEngineError"));
18 m.attr("StaleEngineError") = py::register_exception<gridfire::exceptions::StaleEngineError>(m, "StaleEngineError", m.attr("GridFireEngineError"));
19 m.attr("FailedToPartitionEngineError") = py::register_exception<gridfire::exceptions::FailedToPartitionEngineError>(m, "FailedToPartitionEngineError", m.attr("GridFireEngineError"));
20 m.attr("NetworkResizedError") = py::register_exception<gridfire::exceptions::NetworkResizedError>(m, "NetworkResizedError", m.attr("GridFireEngineError"));
21 m.attr("UnableToSetNetworkReactionsError") = py::register_exception<gridfire::exceptions::UnableToSetNetworkReactionsError>(m, "UnableToSetNetworkReactionsError", m.attr("GridFireEngineError"));
22
23 py::class_<gridfire::exceptions::StaleEngineTrigger::state>(m, "StaleEngineState")
24 .def(py::init<>())
25 .def_readwrite("T9", &gridfire::exceptions::StaleEngineTrigger::state::m_T9)
26 .def_readwrite("rho", &gridfire::exceptions::StaleEngineTrigger::state::m_rho)
27 .def_readwrite("Y", &gridfire::exceptions::StaleEngineTrigger::state::m_Y)
28 .def_readwrite("t", &gridfire::exceptions::StaleEngineTrigger::state::m_t)
29 .def_readwrite("total_steps", &gridfire::exceptions::StaleEngineTrigger::state::m_total_steps)
30 .def_readwrite("eps_nuc", &gridfire::exceptions::StaleEngineTrigger::state::m_eps_nuc);
31
32 py::class_<gridfire::exceptions::StaleEngineTrigger>(m, "StaleEngineTrigger")
33 .def(py::init<const gridfire::exceptions::StaleEngineTrigger::state &>())
34 .def("getState", &gridfire::exceptions::StaleEngineTrigger::getState)
35 .def("numSpecies", &gridfire::exceptions::StaleEngineTrigger::numSpecies)
36 .def("totalSteps", &gridfire::exceptions::StaleEngineTrigger::totalSteps)
37 .def("energy", &gridfire::exceptions::StaleEngineTrigger::energy)
38 .def("getMolarAbundance", &gridfire::exceptions::StaleEngineTrigger::getMolarAbundance)
39 .def("temperature", &gridfire::exceptions::StaleEngineTrigger::temperature)
40 .def("density", &gridfire::exceptions::StaleEngineTrigger::density)
41 .def("__repr__", [&](const gridfire::exceptions::StaleEngineTrigger& self) {
42 return self.what();
43 });
44
45}
gridfire::exceptions::StaleEngineTrigger
Definition error_engine.h:10
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::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
register_exception_bindings
void register_exception_bindings(py::module &m)
Definition bindings.cpp:13
bindings.h
exceptions.h
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