|
| 1 | +// |
| 2 | +// Created by marcel on 21.11.23. |
| 3 | +// |
| 4 | + |
| 5 | +#ifndef PYFICTION_CLUSTERCOMPLETE_HPP |
| 6 | +#define PYFICTION_CLUSTERCOMPLETE_HPP |
| 7 | + |
| 8 | +#if (FICTION_ALGLIB_ENABLED) |
| 9 | + |
| 10 | +#include "pyfiction/documentation.hpp" |
| 11 | +#include "pyfiction/types.hpp" |
| 12 | + |
| 13 | +#include <fiction/algorithms/simulation/sidb/clustercomplete.hpp> |
| 14 | +#include <fiction/layouts/coordinates.hpp> |
| 15 | + |
| 16 | +#include <pybind11/pybind11.h> |
| 17 | +#include <pybind11/stl.h> |
| 18 | + |
| 19 | +namespace pyfiction |
| 20 | +{ |
| 21 | + |
| 22 | +namespace detail |
| 23 | +{ |
| 24 | + |
| 25 | +template <typename Lyt> |
| 26 | +void clustercomplete(pybind11::module& m) |
| 27 | +{ |
| 28 | + namespace py = pybind11; |
| 29 | + |
| 30 | + m.def("clustercomplete", &fiction::clustercomplete<Lyt>, py::arg("lyt"), |
| 31 | + py::arg("params") = fiction::clustercomplete_params<>{}, DOC(fiction_clustercomplete)); |
| 32 | +} |
| 33 | + |
| 34 | +} // namespace detail |
| 35 | + |
| 36 | +inline void clustercomplete(pybind11::module& m) |
| 37 | +{ |
| 38 | + namespace py = pybind11; |
| 39 | + |
| 40 | + /** |
| 41 | + * Report *Ground State Space* stats. |
| 42 | + */ |
| 43 | + py::enum_<fiction::clustercomplete_params<>::ground_state_space_reporting>( |
| 44 | + m, "ground_state_space_reporting", DOC(fiction_clustercomplete_params_ground_state_space_reporting)) |
| 45 | + .value("ON", fiction::clustercomplete_params<>::ground_state_space_reporting::ON, |
| 46 | + DOC(fiction_clustercomplete_params_ground_state_space_reporting_ON)) |
| 47 | + .value("OFF", fiction::clustercomplete_params<>::ground_state_space_reporting::OFF, |
| 48 | + DOC(fiction_clustercomplete_params_ground_state_space_reporting_OFF)); |
| 49 | + |
| 50 | + /** |
| 51 | + * ClusterComplete parameters. |
| 52 | + */ |
| 53 | + py::class_<fiction::clustercomplete_params<>>(m, "clustercomplete_params", DOC(fiction_clustercomplete_params)) |
| 54 | + .def(py::init<>()) |
| 55 | + .def_readwrite("simulation_parameters", &fiction::clustercomplete_params<>::simulation_parameters, |
| 56 | + DOC(fiction_clustercomplete_params_simulation_parameters)) |
| 57 | + .def_readwrite("local_external_potential", &fiction::clustercomplete_params<>::local_external_potential, |
| 58 | + DOC(fiction_clustercomplete_params_local_external_potential)) |
| 59 | + .def_readwrite("global_potential", &fiction::clustercomplete_params<>::global_potential, |
| 60 | + DOC(fiction_clustercomplete_params_global_potential)) |
| 61 | + .def_readwrite("validity_witness_partitioning_max_cluster_size_gss", |
| 62 | + &fiction::clustercomplete_params<>::validity_witness_partitioning_max_cluster_size_gss, |
| 63 | + DOC(fiction_clustercomplete_params_validity_witness_partitioning_max_cluster_size_gss)) |
| 64 | + .def_readwrite("num_overlapping_witnesses_limit_gss", |
| 65 | + &fiction::clustercomplete_params<>::num_overlapping_witnesses_limit_gss, |
| 66 | + DOC(fiction_clustercomplete_params_num_overlapping_witnesses_limit_gss)) |
| 67 | + .def_readwrite("available_threads", &fiction::clustercomplete_params<>::available_threads, |
| 68 | + DOC(fiction_clustercomplete_params_available_threads)) |
| 69 | + .def_readwrite("report_gss_stats", &fiction::clustercomplete_params<>::report_gss_stats, |
| 70 | + DOC(fiction_clustercomplete_params_report_gss_stats)); |
| 71 | + |
| 72 | + // NOTE be careful with the order of the following calls! Python will resolve the first matching overload! |
| 73 | + |
| 74 | + detail::clustercomplete<py_sidb_100_lattice>(m); |
| 75 | + detail::clustercomplete<py_sidb_111_lattice>(m); |
| 76 | +} |
| 77 | + |
| 78 | +} // namespace pyfiction |
| 79 | + |
| 80 | +#else // FICTION_ALGLIB_ENABLED |
| 81 | + |
| 82 | +#include <pybind11/pybind11.h> |
| 83 | + |
| 84 | +namespace pyfiction |
| 85 | +{ |
| 86 | + |
| 87 | +/** |
| 88 | + * Disable ClusterComplete. |
| 89 | + */ |
| 90 | +inline void clustercomplete([[maybe_unused]] pybind11::module& m) {} |
| 91 | + |
| 92 | +} // namespace pyfiction |
| 93 | + |
| 94 | +#endif // FICTION_ALGLIB_ENABLED |
| 95 | + |
| 96 | +#endif // PYFICTION_CLUSTERCOMPLETE_HPP |
0 commit comments