Skip to content

Commit

Permalink
🎨 rename function and update docu.
Browse files Browse the repository at this point in the history
  • Loading branch information
Drewniok committed Apr 12, 2024
1 parent 59a455e commit 76c2d4d
Show file tree
Hide file tree
Showing 16 changed files with 134 additions and 76 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,14 @@ namespace detail
{

template <typename Lyt>
void assess_physical_population_stability(pybind11::module& m)
void assess_physical_population_stability(pybind11::module& m, const std::string& lattice = "")
{
namespace py = pybind11;
using namespace pybind11::literals;

py::class_<fiction::population_stability_information<Lyt>>(m, "population_stability_information",
DOC(fiction_population_stability_information))
py::class_<fiction::population_stability_information<Lyt>>(
m, fmt::format("population_stability_information{}", lattice).c_str(),
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))
Expand All @@ -41,7 +42,8 @@ void assess_physical_population_stability(pybind11::module& m)
.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,
m.def(fmt::format("assess_physical_population_stability{}", lattice).c_str(),
&fiction::assess_physical_population_stability<Lyt>, "lyt"_a,
"params"_a = fiction::assess_physical_population_stability_params{},
DOC(fiction_assess_physical_population_stability));
}
Expand Down Expand Up @@ -78,9 +80,8 @@ inline void assess_physical_population_stability(pybind11::module& m)

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

detail::assess_physical_population_stability<py_sidb_layout>(m);
// detail::assess_physical_population_stability<py_sidb_100_lattice>(m);
// detail::assess_physical_population_stability<py_sidb_111_lattice>(m);
detail::assess_physical_population_stability<py_sidb_100_lattice>(m, "_100");
detail::assess_physical_population_stability<py_sidb_111_lattice>(m, "_111");
}

} // namespace pyfiction
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6548,13 +6548,13 @@ algorithm.)doc";
static const char *__doc_fiction_detail_yen_k_shortest_paths_impl_yen_k_shortest_paths_impl = R"doc()doc";

static const char *__doc_fiction_detect_bdl_pairs =
R"doc(This algorithm detects BDL pairs in an SiDB layout. It does so by
R"doc(This algorithm detects BDL pairs in an SiDB layout. It does so by
first collecting all dots of the given type and then uniquely pairing
them up based on their distance. Lower and upper distance thresholds
can be defined (defaults = 0.75 nm and 1.5 nm, respectively) to narrow
down the range in which SiDBs could be considered a BDL pair. The
distance between two dots is computed using the
`sidb_nanometer_distance` function. The algorithm returns a vector of
`sidb_nm_distance` function. The algorithm returns a vector of
BDL pairs.

Template parameter ``Lyt``:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ void nanometer_distance(pybind11::module& m, const std::string& lattice = "")
{
using namespace pybind11::literals;

m.def(fmt::format("sidb_nanometer_distance{}", lattice).c_str(), &fiction::sidb_nanometer_distance<Lyt>, "lyt"_a,
"source"_a, "target"_a);
m.def(fmt::format("sidb_nm_distance{}", lattice).c_str(), &fiction::sidb_nm_distance<Lyt>, "lyt"_a, "source"_a,
"target"_a, DOC(fiction_sidb_nanometer_distance));
}

} // namespace detail
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,39 @@

class TestAssessPhysicalPopulationStability(unittest.TestCase):

def test_three_DBs(self):
layout = sidb_layout((2, 3))
def test_three_DBs_100_lattice(self):
layout = sidb_lattice_100((2, 3))
layout.assign_cell_type((0, 1), sidb_technology.cell_type.NORMAL)
layout.assign_cell_type((0, 3), sidb_technology.cell_type.NORMAL)
layout.assign_cell_type((1, 1), sidb_technology.cell_type.NORMAL)
params = assess_physical_population_stability_params()
params.simulation_parameters.mu_minus = -0.25
cds = charge_distribution_surface(layout)
result = assess_physical_population_stability(layout, params)
cds = charge_distribution_surface_100(layout)
result = assess_physical_population_stability_100(layout, params)
self.assertEqual(len(result), 5)
self.assertLessEqual(result[0].system_energy, result[1].system_energy)
self.assertLessEqual(result[1].system_energy, result[2].system_energy)

params.simulation_parameters.mu_minus = -0.32
result = assess_physical_population_stability(cds, params)
result = assess_physical_population_stability_100(cds, params)
self.assertEqual(len(result), 1)

def test_three_DBs_111_lattice(self):
layout = sidb_lattice_111((2, 3))
layout.assign_cell_type((0, 1), sidb_technology.cell_type.NORMAL)
layout.assign_cell_type((0, 3), sidb_technology.cell_type.NORMAL)
layout.assign_cell_type((1, 1), sidb_technology.cell_type.NORMAL)
params = assess_physical_population_stability_params()
params.simulation_parameters.mu_minus = -0.25
cds = charge_distribution_surface_111(layout)
result = assess_physical_population_stability_111(layout, params)
self.assertEqual(len(result), 5)
self.assertLessEqual(result[0].system_energy, result[1].system_energy)
self.assertLessEqual(result[1].system_energy, result[2].system_energy)

params.simulation_parameters.mu_minus = -0.32
result = assess_physical_population_stability_111(cds, params)
self.assertEqual(len(result), 2)

if __name__ == '__main__':
unittest.main()
20 changes: 10 additions & 10 deletions bindings/pyfiction/test/technology/test_sidb_nm_distance.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,25 @@ def test_sidb_nm_distance_100_lattice(self):
layout_one = sidb_lattice_100((10, 10))

# Replace the placeholders with actual values or function calls
self.assertEqual(sidb_nanometer_distance_100(layout_one, (0, 0), (0, 0)), 0)
self.assertEqual(sidb_nanometer_distance_100(layout_one, (1, 0), (1, 0)), 0)
self.assertEqual(sidb_nanometer_distance_100(layout_one, (1, 1), (1, 1)), 0)
self.assertEqual(sidb_nm_distance_100(layout_one, (0, 0), (0, 0)), 0)
self.assertEqual(sidb_nm_distance_100(layout_one, (1, 0), (1, 0)), 0)
self.assertEqual(sidb_nm_distance_100(layout_one, (1, 1), (1, 1)), 0)

# Replace the placeholders with actual values or function calls
self.assertAlmostEqual(sidb_nanometer_distance_100(layout_one, (0, 0), (2, 0)), 2 * 0.384)
self.assertAlmostEqual(sidb_nanometer_distance_100(layout_one, (0, 0), (0, 1)), 0.225)
self.assertAlmostEqual(sidb_nm_distance_100(layout_one, (0, 0), (2, 0)), 2 * 0.384)
self.assertAlmostEqual(sidb_nm_distance_100(layout_one, (0, 0), (0, 1)), 0.225)

def test_sidb_nm_distance_100_lattice(self):
layout_one = sidb_lattice_111((10, 10))

# Replace the placeholders with actual values or function calls
self.assertEqual(sidb_nanometer_distance_111(layout_one, (0, 0), (0, 0)), 0)
self.assertEqual(sidb_nanometer_distance_111(layout_one, (1, 0), (1, 0)), 0)
self.assertEqual(sidb_nanometer_distance_111(layout_one, (1, 1), (1, 1)), 0)
self.assertEqual(sidb_nm_distance_111(layout_one, (0, 0), (0, 0)), 0)
self.assertEqual(sidb_nm_distance_111(layout_one, (1, 0), (1, 0)), 0)
self.assertEqual(sidb_nm_distance_111(layout_one, (1, 1), (1, 1)), 0)

# Replace the placeholders with actual values or function calls
self.assertAlmostEqual(sidb_nanometer_distance_111(layout_one, (0, 0), (2, 0)), 1.33)
self.assertAlmostEqual(sidb_nanometer_distance_111(layout_one, (0, 0), (0, 1)), 0.3839967)
self.assertAlmostEqual(sidb_nm_distance_111(layout_one, (0, 0), (2, 0)), 1.33)
self.assertAlmostEqual(sidb_nm_distance_111(layout_one, (0, 0), (0, 1)), 0.3839967)


if __name__ == '__main__':
Expand Down
3 changes: 3 additions & 0 deletions docs/algorithms/exact.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ network specifications under constraints. This approach finds exact results but
.. doxygenstruct:: fiction::exact_physical_design_stats
:members:
.. doxygenfunction:: fiction::exact(const Ntk& ntk, const exact_physical_design_params<Lyt>& ps = {}, exact_physical_design_stats* pst = nullptr)
.. doxygenfunction:: exact_with_blacklist(const Ntk& ntk, const surface_black_list<Lyt, port_direction>& black_list,
exact_physical_design_params ps = {},
exact_physical_design_stats* pst = nullptr)

.. tab:: Python
.. autoclass:: mnt.pyfiction.exact_params
Expand Down
4 changes: 2 additions & 2 deletions docs/algorithms/one_pass_synthesis.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ opportunity to generate even smaller layouts than ``exact``. Consequently, this
:members:
.. doxygenstruct:: fiction::one_pass_synthesis_stats
:members:
.. doxygenfunction:: fiction::one_pass_synthesis(const std::vector<TT>& tts, one_pass_synthesis_params<Lyt>& ps = {}, one_pass_synthesis_stats* pst = nullptr)
.. doxygenfunction:: fiction::one_pass_synthesis(const Ntk& ntk, const one_pass_synthesis_params<Lyt>& ps = {}, one_pass_synthesis_stats* pst = nullptr)
.. doxygenfunction:: fiction::one_pass_synthesis(const std::vector<TT>& tts, one_pass_synthesis_params& ps = {}, one_pass_synthesis_stats* pst = nullptr)
.. doxygenfunction:: fiction::one_pass_synthesis(const Ntk& ntk, const one_pass_synthesis_params& ps = {}, one_pass_synthesis_stats* pst = nullptr)
90 changes: 63 additions & 27 deletions docs/algorithms/sidb_simulation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ Simulation Result
:members:

.. tab:: Python
.. autoclass:: mnt.pyfiction.sidb_simulation_result
.. autoclass:: mnt.pyfiction.sidb_simulation_result_100
:members:
.. autoclass:: mnt.pyfiction.sidb_simulation_result_111
:members:


Expand All @@ -52,7 +54,8 @@ Heuristic Ground State Simulation
.. autoclass:: mnt.pyfiction.quicksim_params
:members:

.. autofunction:: mnt.pyfiction.quicksim
.. autofunction:: mnt.pyfiction.quicksim_100
.. autofunction:: mnt.pyfiction.quicksim_111


Exhaustive Ground State Simulation
Expand All @@ -73,11 +76,15 @@ Exhaustive Ground State Simulation
.. doxygenfunction:: fiction::exhaustive_ground_state_simulation

.. tab:: Python
.. autoclass:: mnt.pyfiction.quickexact_params
.. autoclass:: mnt.pyfiction.quickexact_params_100
:members:
.. autoclass:: mnt.pyfiction.quickexact_params_111
:members:
.. autofunction:: mnt.pyfiction.quickexact
.. autofunction:: mnt.pyfiction.quickexact_100
.. autofunction:: mnt.pyfiction.quickexact_111

.. autofunction:: mnt.pyfiction.exhaustive_ground_state_simulation
.. autofunction:: mnt.pyfiction.exhaustive_ground_state_simulation_100
.. autofunction:: mnt.pyfiction.exhaustive_ground_state_simulation_111


Engine Selectors
Expand Down Expand Up @@ -121,14 +128,11 @@ Energy Calculation
.. tab:: Python
.. autofunction:: mnt.pyfiction.energy_distribution

.. autofunction:: mnt.pyfiction.minimum_energy

.. autofunction:: mnt.pyfiction.is_ground_state

.. autofunction:: mnt.pyfiction.minimum_energy_100
.. autofunction:: mnt.pyfiction.minimum_energy_111

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

.. doxygenfunction:: fiction::determine_groundstate_from_simulation_results
.. autofunction:: mnt.pyfiction.is_ground_state_100
.. autofunction:: mnt.pyfiction.is_ground_state_111


Temperature Behavior
Expand Down Expand Up @@ -162,8 +166,10 @@ Temperature Behavior
:members:
.. autoclass:: mnt.pyfiction.critical_temperature_params
:members:
.. autofunction:: mnt.pyfiction.critical_temperature_gate_based
.. autofunction:: mnt.pyfiction.critical_temperature_non_gate_based
.. autofunction:: mnt.pyfiction.critical_temperature_gate_based_100
.. autofunction:: mnt.pyfiction.critical_temperature_non_gate_based_100
.. autofunction:: mnt.pyfiction.critical_temperature_gate_based_111
.. autofunction:: mnt.pyfiction.critical_temperature_non_gate_based_111

.. autofunction:: mnt.pyfiction.occupation_probability_gate_based
.. autofunction:: mnt.pyfiction.occupation_probability_non_gate_based
Expand Down Expand Up @@ -199,7 +205,8 @@ Time-to-Solution (TTS) Statistics
:members:
.. autoclass:: mnt.pyfiction.time_to_solution_stats
:members:
.. autofunction:: mnt.pyfiction.time_to_solution
.. autofunction:: mnt.pyfiction.time_to_solution_100
.. autofunction:: mnt.pyfiction.time_to_solution_111


Random SiDB Layout Generator
Expand Down Expand Up @@ -233,7 +240,7 @@ Operational Domain Computation
.. doxygenenum:: fiction::operational_status
.. doxygenstruct:: fiction::is_operational_params
:members:
.. doxygenfunction:: fiction::is_operational
.. doxygenfunction:: fiction::is_operational_100
.. doxygenfunction:: fiction::operational_input_patterns

**Header:** ``fiction/algorithms/simulation/sidb/operational_domain.hpp``
Expand All @@ -256,7 +263,10 @@ Operational Domain Computation
:members:
.. autoclass:: mnt.pyfiction.is_operational_params
:members:
.. autofunction:: mnt.pyfiction.is_operational
.. autofunction:: mnt.pyfiction.is_operational_100
.. autofunction:: mnt.pyfiction.is_operational_111
.. autofunction:: mnt.pyfiction.operational_input_patterns_100
.. autofunction:: mnt.pyfiction.operational_input_patterns_111

.. autoclass:: mnt.pyfiction.sweep_parameter
:members:
Expand All @@ -269,10 +279,14 @@ Operational Domain Computation
.. autoclass:: mnt.pyfiction.operational_domain_stats
:members:

.. autofunction:: mnt.pyfiction.operational_domain_grid_search
.. autofunction:: mnt.pyfiction.operational_domain_random_sampling
.. autofunction:: mnt.pyfiction.operational_domain_flood_fill
.. autofunction:: mnt.pyfiction.operational_domain_contour_tracing
.. autofunction:: mnt.pyfiction.operational_domain_grid_search_100
.. autofunction:: mnt.pyfiction.operational_domain_grid_search_111
.. autofunction:: mnt.pyfiction.operational_domain_random_sampling_100
.. autofunction:: mnt.pyfiction.operational_domain_random_sampling_111
.. autofunction:: mnt.pyfiction.operational_domain_flood_fill_100
.. autofunction:: mnt.pyfiction.operational_domain_flood_fill_111
.. autofunction:: mnt.pyfiction.operational_domain_contour_tracing_100
.. autofunction:: mnt.pyfiction.operational_domain_contour_tracing_111


Utility Functions
Expand All @@ -291,6 +305,20 @@ Simulation Equivalence Checking
.. autofunction:: fiction::check_simulation_results_for_equivalence


Determine the Ground State from Simulation Results
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

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

.. doxygenfunction:: fiction::determine_groundstate_from_simulation_results

.. tab:: Python
.. doxygenfunction:: fiction::determine_groundstate_from_simulation_results_100
.. doxygenfunction:: fiction::determine_groundstate_from_simulation_results_111


Charge Detection
^^^^^^^^^^^^^^^^

Expand All @@ -301,7 +329,8 @@ Charge Detection
.. doxygenfunction:: fiction::can_positive_charges_occur

.. tab:: Python
.. autofunction:: mnt.pyfiction.can_positive_charges_occur
.. autofunction:: mnt.pyfiction.can_positive_charges_occur_100
.. autofunction:: mnt.pyfiction.can_positive_charges_occur_111

Binary-dot Logic (BDL) Pair Detection
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -317,11 +346,14 @@ Binary-dot Logic (BDL) Pair Detection
.. doxygenfunction:: fiction::detect_bdl_pairs

.. tab:: Python
.. autoclass:: mnt.pyfiction.bdl_pair
.. autoclass:: mnt.pyfiction.bdl_pair_100
:members:
.. autoclass:: mnt.pyfiction.bdl_pair_111
:members:
.. autoclass:: mnt.pyfiction.detect_bdl_pairs_params
:members:
.. autofunction:: mnt.pyfiction.detect_bdl_pairs
.. autofunction:: mnt.pyfiction.detect_bdl_pairs_100
.. autofunction:: mnt.pyfiction.detect_bdl_pairs_111


Assess Population Stability
Expand All @@ -343,9 +375,12 @@ Assess Population Stability
:members:
.. autoclass:: mnt.pyfiction.population_stability_information
:members:
.. autoclass:: mnt.pyfiction.assess_physical_population_stability_params
.. autoclass:: mnt.pyfiction.assess_physical_population_stability_params_100
:members:
.. autoclass:: mnt.pyfiction.assess_physical_population_stability_params_111
:members:
.. autofunction:: mnt.pyfiction.assess_physical_population_stability
.. autofunction:: mnt.pyfiction.assess_physical_population_stability_100
.. autofunction:: mnt.pyfiction.assess_physical_population_stability_111


Positive Charge Detection
Expand All @@ -358,7 +393,8 @@ Positive Charge Detection
.. doxygenfunction:: fiction::can_positive_charges_occur

.. tab:: Python
.. autofunction:: fiction::can_positive_charges_occur
.. autofunction:: fiction::can_positive_charges_occur_100
.. autofunction:: fiction::can_positive_charges_occur_111


Convert Potential to Distance
Expand Down
4 changes: 3 additions & 1 deletion docs/technology/sidb_lattice.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,7 @@ The SiDB lattice layout can be layered on top of an SiDB cell-level layout. It i
:members:

.. tab:: Python
.. autoclass:: mnt.pyfiction.sidb_lattice
.. autoclass:: mnt.pyfiction.sidb_lattice_100
:members:
.. autoclass:: mnt.pyfiction.sidb_lattice_111
:members:
4 changes: 2 additions & 2 deletions docs/technology/simulation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ Euclidean distance between two SiDBs in nanometers
.. tab:: C++
**Header:** ``fiction/technology/sidb_nm_distance.hpp``

.. doxygenfunction:: fiction::sidb_nanometer_distance
.. doxygenfunction:: fiction::sidb_nm_distance_100

.. tab:: Python
.. autoclass:: mnt.pyfiction.sidb_nanometer_distance
.. autoclass:: mnt.pyfiction.sidb_nm_distance_111
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,8 @@ class design_sidb_gates_impl
{
for (std::size_t j = i + 1; j < cell_indices.size(); j++)
{
if (sidb_nanometer_distance<Lyt>(Lyt{}, all_sidbs_in_canvas[cell_indices[i]],
all_sidbs_in_canvas[cell_indices[j]]) < 0.5)
if (sidb_nm_distance<Lyt>(Lyt{}, all_sidbs_in_canvas[cell_indices[i]],
all_sidbs_in_canvas[cell_indices[j]]) < 0.5)
{
return true;
}
Expand Down
Loading

0 comments on commit 76c2d4d

Please sign in to comment.