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#include <memory>
7
8#include "bindings.h"
9
11
12PYBIND11_DECLARE_HOLDER_TYPE(T, std::unique_ptr<T>, true) // Declare unique_ptr as a holder type for pybind11
13
14#include "trampoline/py_partition.h"
15
16
17namespace py = pybind11;
18
19
31
32void register_partition_types_bindings(pybind11::module &m) {
33 py::enum_<gridfire::partition::BasePartitionType>(m, "BasePartitionType")
36 .export_values();
37
38 m.def("basePartitionTypeToString", [](gridfire::partition::BasePartitionType type) {
40 }, py::arg("type"), "Convert BasePartitionType to string.");
41
42 m.def("stringToBasePartitionType", [](const std::string &typeStr) {
44 }, py::arg("typeStr"), "Convert string to BasePartitionType.");
45}
46
50 py::class_<GSPF, PF>(m, "GroundStatePartitionFunction")
51 .def(py::init<>())
53 py::arg("z"), py::arg("a"), py::arg("T9"),
54 "Evaluate the ground state partition function for given Z, A, and T9.")
56 py::arg("z"), py::arg("a"), py::arg("T9"),
57 "Evaluate the derivative of the ground state partition function for given Z, A, and T9.")
59 py::arg("z"), py::arg("a"),
60 "Check if the ground state partition function supports given Z and A.")
62 "Get the type of the partition function (should return 'GroundState').");
63}
64
66 py::class_<gridfire::partition::record::RauscherThielemannPartitionDataRecord>(m, "RauscherThielemannPartitionDataRecord")
69 .def_readonly("ground_state_spin", &gridfire::partition::record::RauscherThielemannPartitionDataRecord::ground_state_spin, "Ground state spin")
70 .def_readonly("normalized_g_values", &gridfire::partition::record::RauscherThielemannPartitionDataRecord::normalized_g_values, "Normalized g-values for the first 24 energy levels");
71}
72
73
77 py::class_<RTPF, PF>(m, "RauscherThielemannPartitionFunction")
78 .def(py::init<>())
80 py::arg("z"), py::arg("a"), py::arg("T9"),
81 "Evaluate the Rauscher-Thielemann partition function for given Z, A, and T9.")
83 py::arg("z"), py::arg("a"), py::arg("T9"),
84 "Evaluate the derivative of the Rauscher-Thielemann partition function for given Z, A, and T9.")
86 py::arg("z"), py::arg("a"),
87 "Check if the Rauscher-Thielemann partition function supports given Z and A.")
89 "Get the type of the partition function (should return 'RauscherThielemann').");
90}
91
92void register_composite_partition_bindings(pybind11::module &m) {
93 py::class_<gridfire::partition::CompositePartitionFunction>(m, "CompositePartitionFunction")
94 .def(py::init<const std::vector<gridfire::partition::BasePartitionType>&>(),
95 py::arg("partitionFunctions"),
96 "Create a composite partition function from a list of base partition types.")
97 .def(py::init<const gridfire::partition::CompositePartitionFunction&>(),
98 "Copy constructor for CompositePartitionFunction.")
100 py::arg("z"), py::arg("a"), py::arg("T9"),
101 "Evaluate the composite partition function for given Z, A, and T9.")
103 py::arg("z"), py::arg("a"), py::arg("T9"),
104 "Evaluate the derivative of the composite partition function for given Z, A, and T9.")
106 py::arg("z"), py::arg("a"),
107 "Check if the composite partition function supports given Z and A.")
109 "Get the type of the partition function (should return 'Composite').");
110}
111
112
113
double evaluate(int z, int a, double T9) const override
double evaluateDerivative(int z, int a, double T9) const override
Partition function implementation for nuclear ground states.
double evaluateDerivative(const int z, const int a, const double T9) const override
bool supports(const int z, const int a) const override
double evaluate(const int z, const int a, const double T9) const override
Abstract interface for evaluating nuclear partition functions.
Partition function using Rauscher-Thielemann tabulated normalized G-values.
std::string type() const override
Get type identifier for this partition function.
bool supports(int z, int a) const override
Check if partition data exists for given isotope.
double evaluateDerivative(int z, int a, double T9) const override
Evaluate temperature derivative of partition function.
double evaluate(int z, int a, double T9) const override
Evaluate partition function for isotope at temperature.
std::unordered_map< std::string, BasePartitionType > stringToBasePartitionType
Mapping from string to BasePartitionType enum.
std::unordered_map< BasePartitionType, std::string > basePartitionTypeToString
Mapping from BasePartitionType enum to human-readable string.
BasePartitionType
Enumerates available partition function implementations.
@ RauscherThielemann
Rauscher-Thielemann partition function.
@ GroundState
Ground state partition function.
void register_partition_bindings(pybind11::module &m)
Definition bindings.cpp:20
void register_partition_types_bindings(pybind11::module &m)
Definition bindings.cpp:32
void register_rauscher_thielemann_partition_bindings(pybind11::module &m)
Definition bindings.cpp:74
void register_ground_state_partition_bindings(pybind11::module &m)
Definition bindings.cpp:47
void register_rauscher_thielemann_partition_data_record_bindings(pybind11::module &m)
Definition bindings.cpp:65
void register_composite_partition_bindings(pybind11::module &m)
Definition bindings.cpp:92
double normalized_g_values[24]
Normalized g-values for the first 24 energy levels.