Skip to content

Commit

Permalink
✨ Added assess_physical_population_stability and convert_potential_to…
Browse files Browse the repository at this point in the history
…_distance to pyfiction
  • Loading branch information
marcelwa committed Nov 21, 2023
1 parent 53abc2a commit d5c1f71
Show file tree
Hide file tree
Showing 4 changed files with 165 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
//
// Created by marcel on 21.11.23.
//

#ifndef PYFICTION_ASSESS_PHYSICAL_POPULATION_STABILITY_HPP
#define PYFICTION_ASSESS_PHYSICAL_POPULATION_STABILITY_HPP

#include "pyfiction/documentation.hpp"
#include "pyfiction/types.hpp"

#include <fiction/algorithms/simulation/sidb/assess_physical_population_stability.hpp>

#include <pybind11/pybind11.h>
#include <pybind11/stl.h>

namespace pyfiction
{

namespace detail
{

template <typename Lyt>
void assess_physical_population_stability(pybind11::module& m)
{
namespace py = pybind11;
using namespace pybind11::literals;

py::class_<fiction::population_stability_information<Lyt>>(m, "population_stability_information",
DOC(fiction_population_stability_information))
.def(py::init<>())
.def_readwrite("critical_cell", &fiction::population_stability_information<Lyt>::critical_cell,
DOC(fiction_population_stability_information_critical_cell))
.def_readwrite("transition_from_to", &fiction::population_stability_information<Lyt>::transition_from_to,
DOC(fiction_population_stability_information_transition_from_to))
.def_readwrite("minimum_potential_difference_to_transition",
&fiction::population_stability_information<Lyt>::minimum_potential_difference_to_transition,
DOC(fiction_population_stability_information_minimum_potential_difference_to_transition))
.def_readwrite("distance_corresponding_to_potential",
&fiction::population_stability_information<Lyt>::distance_corresponding_to_potential,
DOC(fiction_population_stability_information_distance_corresponding_to_potential))
.def_readwrite("system_energy", &fiction::population_stability_information<Lyt>::system_energy,
DOC(fiction_population_stability_information_system_energy))

;

m.def("assess_physical_population_stability", &fiction::assess_physical_population_stability<Lyt>, "lyt"_a,
"params"_a = fiction::assess_physical_population_stability_params{},
DOC(fiction_assess_physical_population_stability));
}

} // namespace detail

inline void assess_physical_population_stability(pybind11::module& m)
{
namespace py = pybind11;

py::enum_<fiction::transition_type>(m, "transition_type", DOC(fiction_transition_type))
.value("NEUTRAL_TO_NEGATIVE", fiction::transition_type::NEUTRAL_TO_NEGATIVE,
DOC(fiction_transition_type_NEUTRAL_TO_NEGATIVE))
.value("NEGATIVE_TO_NEUTRAL", fiction::transition_type::NEGATIVE_TO_NEUTRAL,
DOC(fiction_transition_type_NEGATIVE_TO_NEUTRAL))
.value("NEUTRAL_TO_POSITIVE", fiction::transition_type::NEUTRAL_TO_POSITIVE,
DOC(fiction_transition_type_NEUTRAL_TO_POSITIVE))
.value("POSITIVE_TO_NEUTRAL", fiction::transition_type::POSITIVE_TO_NEUTRAL,
DOC(fiction_transition_type_POSITIVE_TO_NEUTRAL))

;

/**
* Parameters.
*/
py::class_<fiction::assess_physical_population_stability_params>(
m, "assess_physical_population_stability_params", DOC(fiction_assess_physical_population_stability_params))
.def(py::init<>())
.def_readwrite("physical_parameters",
&fiction::assess_physical_population_stability_params::physical_parameters,
DOC(fiction_assess_physical_population_stability_params_physical_parameters))
.def_readwrite(
"precision_for_distance_corresponding_to_potential",
&fiction::assess_physical_population_stability_params::precision_for_distance_corresponding_to_potential,
DOC(fiction_assess_physical_population_stability_params_precision_for_distance_corresponding_to_potential))

;

// NOTE be careful with the order of the following calls! Python will resolve the first matching overload!

detail::assess_physical_population_stability<py_charge_distribution_surface>(m);
}

} // namespace pyfiction

#endif // PYFICTION_ASSESS_PHYSICAL_POPULATION_STABILITY_HPP
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//
// Created by marcel on 21.11.23.
//

#ifndef PYFICTION_CONVERT_POTENTIAL_TO_DISTANCE_HPP
#define PYFICTION_CONVERT_POTENTIAL_TO_DISTANCE_HPP

#include "pyfiction/documentation.hpp"
#include "pyfiction/types.hpp"

#include <fiction/algorithms/simulation/sidb/convert_potential_to_distance.hpp>

#include <pybind11/pybind11.h>
#include <pybind11/stl.h>

namespace pyfiction
{

inline void convert_potential_to_distance(pybind11::module& m)
{
using namespace pybind11::literals;

m.def("convert_potential_to_distance", &fiction::convert_potential_to_distance, "potential"_a, "params"_a,
"precision"_a, DOC(fiction_convert_potential_to_distance));
}

} // namespace pyfiction

#endif // PYFICTION_CONVERT_POTENTIAL_TO_DISTANCE_HPP
4 changes: 4 additions & 0 deletions bindings/pyfiction/pyfiction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
#include "pyfiction/algorithms/simulation/sidb/quickexact.hpp"
#include "pyfiction/algorithms/simulation/sidb/quicksim.hpp"
// #include "pyfiction/algorithms/simulation/sidb/random_sidb_layout_generator.hpp"
#include "pyfiction/algorithms/simulation/sidb/assess_physical_population_stability.hpp"
#include "pyfiction/algorithms/simulation/sidb/convert_potential_to_distance.hpp"
#include "pyfiction/algorithms/simulation/sidb/sidb_charge_state.hpp"
#include "pyfiction/algorithms/simulation/sidb/sidb_simulation_engine.hpp"
#include "pyfiction/algorithms/simulation/sidb/sidb_simulation_parameters.hpp"
Expand Down Expand Up @@ -100,6 +102,8 @@ PYBIND11_MODULE(pyfiction, m)
pyfiction::sidb_simulation_parameters(m);
pyfiction::sidb_simulation_result(m);
pyfiction::can_positive_charges_occur(m);
pyfiction::assess_physical_population_stability(m);
pyfiction::convert_potential_to_distance(m);
pyfiction::detect_bdl_pairs(m);
pyfiction::is_operational(m);
pyfiction::operational_domain(m);
Expand Down
57 changes: 40 additions & 17 deletions docs/algorithms/sidb_simulation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -58,20 +58,23 @@ Heuristic Ground State Simulation
Exhaustive Ground State Simulation
##################################

**Header:** ``fiction/algorithms/simulation/sidb/quickexact.hpp``

.. doxygenenum:: fiction::required_simulation_base_number
.. doxygenstruct:: fiction::quickexact_params
:members:
.. doxygenfunction:: fiction::quickexact

.. tabs::
.. tab:: C++
**Header:** ``fiction/algorithms/simulation/sidb/quickexact.hpp``

.. doxygenstruct:: fiction::quickexact_params
:members:
.. doxygenfunction:: fiction::quickexact

**Header:** ``fiction/algorithms/simulation/sidb/exhaustive_ground_state_simulation.hpp``

.. doxygenfunction:: fiction::exhaustive_ground_state_simulation

.. tab:: Python
.. autoclass:: fiction.pyfiction.quickexact_params
:members:
.. autofunction:: fiction.pyfiction.quickexact

.. autofunction:: fiction.pyfiction.exhaustive_ground_state_simulation


Expand Down Expand Up @@ -183,7 +186,11 @@ Time-to-Solution (TTS) Statistics
.. doxygenfunction:: fiction::time_to_solution

.. tab:: Python
.. autofunction:: fiction.pyfiction.sim_acc_tts
.. autoclass:: fiction.pyfiction.time_to_solution_params
:members:
.. autoclass:: fiction.pyfiction.time_to_solution_stats
:members:
.. autofunction:: fiction.pyfiction.time_to_solution


Random SiDB Layout Generator
Expand Down Expand Up @@ -286,19 +293,35 @@ Binary-dot Logic (BDL) Pair Detection
Assess Population Stability
^^^^^^^^^^^^^^^^^^^^^^^^^^^

**Header:** ``fiction/algorithms/simulation/sidb/assess_physical_population_stability.hpp``
.. tabs::
.. tab:: C++
**Header:** ``fiction/algorithms/simulation/sidb/assess_physical_population_stability.hpp``

.. doxygenenum:: fiction::transition_type
.. doxygenstruct:: fiction::population_stability_information
:members:
.. doxygenstruct:: fiction::assess_physical_population_stability_params
:members:
.. doxygenfunction:: fiction::assess_physical_population_stability
.. doxygenenum:: fiction::transition_type
.. doxygenstruct:: fiction::population_stability_information
:members:
.. doxygenstruct:: fiction::assess_physical_population_stability_params
:members:
.. doxygenfunction:: fiction::assess_physical_population_stability

.. tab:: Python
.. autoclass:: fiction.pyfiction.transition_type
:members:
.. autoclass:: fiction.pyfiction.population_stability_information
:members:
.. autoclass:: fiction.pyfiction.assess_physical_population_stability_params
:members:
.. autofunction:: fiction.pyfiction.assess_physical_population_stability


Convert Potential to Distance
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

**Header:** ``fiction/algorithms/simulation/sidb/convert_potential_to_distance.hpp``
.. tabs::
.. tab:: C++
**Header:** ``fiction/algorithms/simulation/sidb/convert_potential_to_distance.hpp``

.. doxygenfunction:: fiction::convert_potential_to_distance

.. doxygenfunction:: fiction::convert_potential_to_distance
.. tab:: Python
.. autofunction:: fiction.pyfiction.convert_potential_to_distance

0 comments on commit d5c1f71

Please sign in to comment.