feat(pythonInterface/polytrope): added initial polytrope implimentation to the python interface

currently this can only interface with polySolver; however, it does work 100% to run a model. The biggest caveat is that at this time there is no way to get the actual results out of the model other than to visualize them in GLVis or use the limited output dumped in the output directory
This commit is contained in:
2025-06-13 09:31:05 -04:00
parent 9de818dd5b
commit 8ee9a6a609
7 changed files with 54 additions and 4 deletions

View File

@@ -9,6 +9,7 @@ py_mod = py_installation.extension_module(
meson.project_source_root() + '/src/python/const/bindings.cpp',
meson.project_source_root() + '/src/python/config/bindings.cpp',
meson.project_source_root() + '/src/python/eos/bindings.cpp',
meson.project_source_root() + '/src/python/polytrope/bindings.cpp',
],
dependencies : [
pybind11_dep,
@@ -16,7 +17,8 @@ py_mod = py_installation.extension_module(
config_dep,
composition_dep,
eos_dep,
species_weight_dep
species_weight_dep,
polysolver_dep,
],
cpp_args : ['-UNDEBUG'], # Example: Ensure assertions are enabled if needed
install : true,

View File

@@ -6,6 +6,7 @@
#include "composition/bindings.h"
#include "config/bindings.h"
#include "eos/bindings.h"
#include "polytrope/bindings.h"
PYBIND11_MODULE(serif, m) {
m.doc() = "Python bindings for the SERiF project";
@@ -21,4 +22,7 @@ PYBIND11_MODULE(serif, m) {
auto eosMod = m.def_submodule("eos", "EOS-module bindings");
register_eos_bindings(eosMod);
auto polytropeMod = m.def_submodule("polytrope", "Polytrope-module bindings");
register_polytrope_bindings(polytropeMod);
}

View File

@@ -5,12 +5,9 @@
#include <string>
#include "helm.h"
// #include "resourceManager.h"
#include "bindings.h"
#include "EOSio.h"
#include "helm.h"
#include "../../eos/public/EOSio.h"
#include "../../eos/public/helm.h"
namespace serif::eos {
class EOSio;

View File

@@ -0,0 +1,15 @@
#include "bindings.h"
#include "EOSio.h"
#include "helm.h"
#include "polySolver.h"
#include "../../polytrope/solver/public/polySolver.h"
#include "../../polytrope/utils/public/polytropeOperator.h"
namespace py = pybind11;
void register_polytrope_bindings(pybind11::module &polytrope_submodule) {
py::class_<serif::polytrope::PolySolver>(polytrope_submodule, "PolySolver")
.def(py::init<double, int>(), py::arg("polytropic_index"), py::arg("FEM_order"))
.def("solve", &serif::polytrope::PolySolver::solve, "Solve the polytrope equation.");
}

View File

@@ -0,0 +1,5 @@
#pragma once
#include <pybind11/pybind11.h>
void register_polytrope_bindings(pybind11::module &polytrope_submodule);

View File

@@ -0,0 +1,19 @@
# Define the library
bindings_sources = files('bindings.cpp')
bindings_headers = files('bindings.h')
dependencies = [
polysolver_dep,
config_dep,
resourceManager_dep,
python3_dep,
pybind11_dep,
]
shared_module('py_polytrope',
bindings_sources,
include_directories: include_directories('.'),
cpp_args: ['-fvisibility=default'],
install : true,
dependencies: dependencies,
)

View File

@@ -0,0 +1,8 @@
from serif import config
from serif.polytrope import PolySolver
config.loadConfig('../../testsConfig.yaml')
n = config.get("Tests:Poly:Index", 0.0)
polytrope = PolySolver(n, 1)
polytrope.solve()