20 py::class_<serif::eos::EOSio>(eos_submodule,
"EOSio")
21 .def(py::init<std::string>(), py::arg(
"filename"))
25 auto& table_variant = self.
getTable();
29 if (
auto* ptr_to_unique_ptr = std::get_if<std::unique_ptr<serif::eos::helmholtz::HELMTable>>(&table_variant)) {
30 return (*ptr_to_unique_ptr).get();
34 }, py::return_value_policy::reference_internal,
35 "Get the EOS table data.")
40 py::class_<serif::eos::EOSTable>(eos_submodule,
"EOSTable");
42 py::class_<serif::eos::helmholtz::HELMTable>(eos_submodule,
"HELMTable")
49 return "<HELMTable(loaded=" + std::to_string(table.
loaded) +
", imax=" + std::to_string(table.
imax) +
50 ", jmax=" + std::to_string(table.
jmax) +
")>";
55 if (table.
imax <= 0 || table.
jmax <= 0) {
57 throw std::runtime_error(
"HELMTable dimensions (imax, jmax) are non-positive.");
62 if (!table.
f || !table.
f[0]) {
63 throw std::runtime_error(
"HELMTable data buffer 'f' is null or not initialized.");
68 py::ssize_t rows =
static_cast<py::ssize_t
>(table.
imax);
69 py::ssize_t cols =
static_cast<py::ssize_t
>(table.
jmax);
70 double* data_ptr = table.
f[0];
73 std::vector<py::ssize_t> shape = {rows, cols};
74 std::vector<py::ssize_t> strides = {
75 static_cast<py::ssize_t
>(cols *
sizeof(double)),
76 static_cast<py::ssize_t
>(
sizeof(
double))
83 return py::array_t<double>(
89 }, py::return_value_policy::reference_internal);
91 py::class_<serif::eos::helmholtz::HELMEOSOutput>(eos_submodule,
"EOS")
138 return "<EOS (output from helmholtz eos)>";
141 py::class_<serif::eos::helmholtz::HELMEOSInput>(eos_submodule,
"HELMEOSInput")
148 return "<HELMEOSInput(T=" + std::to_string(input.
T) +
149 ", rho=" + std::to_string(input.
rho) +
150 ", abar=" + std::to_string(input.
abar) +
151 ", zbar=" + std::to_string(input.
zbar) +
")>";
154 eos_submodule.def(
"get_helm_eos",
156 py::arg(
"q"), py::arg(
"table"),
157 "Calculate the Helmholtz EOS components based on input parameters and table data.");