From facb9c50333091bf3d0196eef985457b49890712 Mon Sep 17 00:00:00 2001 From: Drewniok Date: Tue, 3 Sep 2024 08:59:53 +0200 Subject: [PATCH 01/32] :art: make it easier to create layouts with positive sides. --- .../sidb/random_sidb_layout_generator.hpp | 12 +- .../random_sidb_layout_generation.cpp | 27 +++- .../sidb/random_sidb_layout_generator.hpp | 74 ++++----- .../charge_distribution_surface.hpp | 41 +++-- include/fiction/utils/layout_utils.hpp | 100 ++++++++++++ .../sidb/random_sidb_layout_generator.cpp | 143 +++++------------- test/utils/layout_utils.cpp | 70 +++++++++ 7 files changed, 290 insertions(+), 177 deletions(-) diff --git a/bindings/pyfiction/include/pyfiction/algorithms/simulation/sidb/random_sidb_layout_generator.hpp b/bindings/pyfiction/include/pyfiction/algorithms/simulation/sidb/random_sidb_layout_generator.hpp index b55bfe179..2518a4505 100644 --- a/bindings/pyfiction/include/pyfiction/algorithms/simulation/sidb/random_sidb_layout_generator.hpp +++ b/bindings/pyfiction/include/pyfiction/algorithms/simulation/sidb/random_sidb_layout_generator.hpp @@ -42,11 +42,14 @@ inline void random_sidb_layout_generator(pybind11::module& m) namespace py = pybind11; using namespace pybind11::literals; + // todo update docu py::enum_::positive_charges>( m, "positive_charges", DOC(fiction_generate_random_sidb_layout_params_positive_charges)) - .value("ON", fiction::generate_random_sidb_layout_params::positive_charges::ALLOWED) - .value("OFF", - fiction::generate_random_sidb_layout_params::positive_charges::FORBIDDEN); + .value("ALLOWED", fiction::generate_random_sidb_layout_params::positive_charges::ALLOWED) + .value("FORBIDDEN", + fiction::generate_random_sidb_layout_params::positive_charges::FORBIDDEN) + .value("CAN_OCCUR", + fiction::generate_random_sidb_layout_params::positive_charges::CAN_OCCUR); /** * Parameters. @@ -63,9 +66,6 @@ inline void random_sidb_layout_generator(pybind11::module& m) .def_readwrite("positive_sidbs", &fiction::generate_random_sidb_layout_params::positive_sidbs, DOC(fiction_generate_random_sidb_layout_params_positive_sidbs)) - .def_readwrite("minimal_spacing", - &fiction::generate_random_sidb_layout_params::minimal_spacing, - DOC(fiction_generate_random_sidb_layout_params_minimal_spacing)) .def_readwrite("maximal_attempts", &fiction::generate_random_sidb_layout_params::maximal_attempts, DOC(fiction_generate_random_sidb_layout_params_maximal_attempts)) diff --git a/experiments/random_sidb_layout_generation/random_sidb_layout_generation.cpp b/experiments/random_sidb_layout_generation/random_sidb_layout_generation.cpp index 63f9fdd0b..2c8918e83 100644 --- a/experiments/random_sidb_layout_generation/random_sidb_layout_generation.cpp +++ b/experiments/random_sidb_layout_generation/random_sidb_layout_generation.cpp @@ -35,7 +35,7 @@ using namespace fiction; * --SE_x Sets the x coordinate of the south-east cell corner in SiQAD coordinates. * --SE_y Sets the y coordinate of the south-east cell corner in SiQAD coordinates. * --positive_charges Specifies whether positively charged SiDBs are allowed ("ALLOWED") or forbidden - * ("FORBIDDEN"). + * ("FORBIDDEN") for default physical parameters. * --lower Sets the number of SiDBs for the first bunch of layouts. * --upper Sets the number of SiDBs for the last bunch of layouts. * --num_layouts Sets the number of layouts to generate for each SiDB count. @@ -95,10 +95,23 @@ int main(int argc, const char* argv[]) // NOLINT const int32_t se_y = std::stoi(options["--SE_y"]); // specifies whether positively charged SiDBs are allowed ("ALLOWED") or forbidden ("FORBIDDEN") const std::string charges_str = options["--positive_charges"]; - // specifies whether positively charged SiDBs are allowed ("ALLOWED") or forbidden ("FORBIDDEN") - const generate_random_sidb_layout_params::positive_charges charges = - (charges_str == "ALLOWED") ? generate_random_sidb_layout_params::positive_charges::ALLOWED : - generate_random_sidb_layout_params::positive_charges::FORBIDDEN; + + // specifies whether positively charged SiDBs are allowed ("ALLOWED"), forbidden ("FORBIDDEN") or can occur + // ("CAN_OCCUR") + generate_random_sidb_layout_params::positive_charges charges; + if (charges_str == "ALLOWED") + { + charges = generate_random_sidb_layout_params::positive_charges::ALLOWED; + } + else if (charges_str == "CAN_OCCUR") + { + charges = generate_random_sidb_layout_params::positive_charges::CAN_OCCUR; + } + else + { + charges = generate_random_sidb_layout_params::positive_charges::FORBIDDEN; + } + // sets the number of SiDBs for the first bunch of layouts const uint64_t lower_limit = std::stoull(options["--lower"]); // sets the number of SiDBs for the last bunch of layouts @@ -165,8 +178,8 @@ int main(int argc, const char* argv[]) // NOLINT } const generate_random_sidb_layout_params params{ - {{nw_x, nw_y}, {se_x, se_y}}, number_of_placed_sidbs, charges, 2, - static_cast(10E6), number_of_layouts}; + {{nw_x, nw_y}, {se_x, se_y}}, number_of_placed_sidbs, charges, + sidb_simulation_parameters{3, -0.32}, static_cast(10E6), number_of_layouts}; const auto unique_lyts = generate_multiple_random_sidb_layouts(sidb_100_cell_clk_lyt{}, params); for (auto i = 0u; i < unique_lyts.size(); i++) { diff --git a/include/fiction/algorithms/simulation/sidb/random_sidb_layout_generator.hpp b/include/fiction/algorithms/simulation/sidb/random_sidb_layout_generator.hpp index 44372bd6d..e723d8957 100644 --- a/include/fiction/algorithms/simulation/sidb/random_sidb_layout_generator.hpp +++ b/include/fiction/algorithms/simulation/sidb/random_sidb_layout_generator.hpp @@ -6,6 +6,7 @@ #define FICTION_RANDOM_SIDB_LAYOUT_GENERATOR_HPP #include "fiction/algorithms/path_finding/distance.hpp" +#include "fiction/algorithms/simulation/sidb/can_positive_charges_occur.hpp" #include "fiction/technology/sidb_defects.hpp" #include "fiction/traits.hpp" #include "fiction/utils/layout_utils.hpp" @@ -37,7 +38,11 @@ struct generate_random_sidb_layout_params /** * Positive charges are not allowed to occur (i.e. SiDBs need to be seperated by a few lattice points). */ - FORBIDDEN + FORBIDDEN, + /** + * Positive charges can occur, which means that the `can_positive_charges_occur` function returns `true`. + */ + CAN_OCCUR }; /** * Two coordinates that span the region where SiDBs may be placed (order is not important). The first coordinate is @@ -52,11 +57,8 @@ struct generate_random_sidb_layout_params * If positively charged SiDBs should be prevented, SiDBs are not placed closer than the minimal_spacing. */ positive_charges positive_sidbs = positive_charges::ALLOWED; - /** - * If positively charged SiDBs should be prevented, SiDBs are not placed closer than this value (Euclidean distance - * of two cells). - */ - double minimal_spacing = 2.0; + + sidb_simulation_parameters sim_params{}; /** * Maximum number of steps to place the specified number of SiDBs. Example: If the area, where SiDBs can be placed, * is small and many SiDBs are to be placed, several tries are required to generate a layout with no positively @@ -110,22 +112,7 @@ Lyt generate_random_sidb_layout(const Lyt& { // random coordinate within given area const auto random_coord = random_coordinate(params.coordinate_pair.first, params.coordinate_pair.second); - bool next_to_neutral_defect = false; - bool constraint_violation_positive_sidbs = false; - - if (params.positive_sidbs == generate_random_sidb_layout_params>::positive_charges::FORBIDDEN) - { - // checks if the new coordinate is not closer than 2 cells (Euclidean distance) to an already - // placed SiDB - lyt.foreach_cell( - [&lyt, &random_coord, &constraint_violation_positive_sidbs, ¶ms](const auto& c1) - { - if (euclidean_distance(lyt, c1, random_coord) < params.minimal_spacing) - { - constraint_violation_positive_sidbs = true; - } - }); - } + bool next_to_neutral_defect = false; if (sidbs_affected_by_defects.count(random_coord) > 0) { @@ -141,13 +128,28 @@ Lyt generate_random_sidb_layout(const Lyt& // if the constraints that no positive SiDBs occur and the cell is not yet occupied by a defect are satisfied, // the SiDB is added to the layout - if (!constraint_violation_positive_sidbs && !random_cell_is_identical_wih_defect && !next_to_neutral_defect) + if (!random_cell_is_identical_wih_defect && !next_to_neutral_defect) { + lyt.assign_cell_type(random_coord, technology::cell_type::NORMAL); + + if (params.positive_sidbs == + generate_random_sidb_layout_params>::positive_charges::FORBIDDEN && + can_positive_charges_occur(lyt, params.sim_params)) + { + lyt.assign_cell_type(random_coord, technology::cell_type::EMPTY); + } } attempt_counter += 1; } + if (params.positive_sidbs == + generate_random_sidb_layout_params>::positive_charges::CAN_OCCUR && + !can_positive_charges_occur(lyt, params.sim_params)) + { + return generate_random_sidb_layout(lyt_skeleton, params); + } + return lyt; } @@ -181,30 +183,8 @@ generate_multiple_random_sidb_layouts(const Lyt& const auto random_lyt = generate_random_sidb_layout(lyt_skeleton, params); // indicates if a found SiDB layout is identical to an already found one. - bool identical_layout = false; - for (const auto& old_lyt : unique_lyts) - { - // checks if two layouts have an SiDB at the same position - uint64_t identical_cell_counter = 0; - old_lyt.foreach_cell( - [&identical_cell_counter, random_lyt](const auto& cell_old) - { - random_lyt.foreach_cell( - [&identical_cell_counter, &cell_old](const auto& cell_new) - { - if (cell_new == cell_old) - { - identical_cell_counter += 1; - } - }); - }); - - // all cells are identical, so the new layout is a duplicate - if (identical_cell_counter == random_lyt.num_cells()) - { - identical_layout = true; - } - } + const auto identical_layout = std::any_of(unique_lyts.begin(), unique_lyts.end(), [&](const auto& old_lyt) + { return are_layouts_identical(random_lyt, old_lyt); }); // if the randomly generated SiDB layout is not identical to a previously generated one, it is added to the // collection of all unique SiDB layouts (unique_lyts) diff --git a/include/fiction/technology/charge_distribution_surface.hpp b/include/fiction/technology/charge_distribution_surface.hpp index 7c39cc0dc..098368064 100644 --- a/include/fiction/technology/charge_distribution_surface.hpp +++ b/include/fiction/technology/charge_distribution_surface.hpp @@ -126,7 +126,9 @@ enum class charge_index_mode /** * The charge state is assigned to the cell but the old charge index is kept. */ - KEEP_CHARGE_INDEX + KEEP_CHARGE_INDEX, + + WORKING_WITH_CHARGE_INDEX }; /** @@ -287,15 +289,17 @@ class charge_distribution_surface : public Lyt * @param params Physical parameters used for the simulation (µ_minus, base number, ...). * @param cs The charge state used for the initialization of all SiDBs, default is a negative charge. */ - explicit charge_distribution_surface(const sidb_simulation_parameters& params = sidb_simulation_parameters{}, - const sidb_charge_state cs = sidb_charge_state::NEGATIVE) : + explicit charge_distribution_surface( + const sidb_simulation_parameters& params = sidb_simulation_parameters{}, + const sidb_charge_state cs = sidb_charge_state::NEGATIVE, + const charge_index_mode cs_mode = charge_index_mode::WORKING_WITH_CHARGE_INDEX) : Lyt(), strg{std::make_shared(params)} { static_assert(is_cell_level_layout_v, "Lyt is not a cell-level layout"); static_assert(has_sidb_technology_v, "Lyt is not an SiDB layout"); - initialize(cs); + initialize(cs, cs_mode); } /** @@ -307,16 +311,17 @@ class charge_distribution_surface : public Lyt * @param variable_cells SiDB which charge state is variable (called dependent-cell). * @param external_potential Externally applied local electrostatic potential. */ - explicit charge_distribution_surface(const Lyt& lyt, - const sidb_simulation_parameters& params = sidb_simulation_parameters{}, - const sidb_charge_state cs = sidb_charge_state::NEGATIVE) : + explicit charge_distribution_surface( + const Lyt& lyt, const sidb_simulation_parameters& params = sidb_simulation_parameters{}, + const sidb_charge_state cs = sidb_charge_state::NEGATIVE, + const charge_index_mode cs_mode = charge_index_mode::WORKING_WITH_CHARGE_INDEX) : Lyt(lyt), strg{std::make_shared(params)} { static_assert(is_cell_level_layout_v, "Lyt is not a cell-level layout"); static_assert(has_sidb_technology_v, "Lyt is not an SiDB layout"); - initialize(cs); + initialize(cs, cs_mode); }; /** * Copy constructor. @@ -1856,7 +1861,8 @@ class charge_distribution_surface : public Lyt * * @param cs The charge state assigned to all SiDBs. */ - void initialize(const sidb_charge_state cs = sidb_charge_state::NEGATIVE) noexcept + void initialize(const sidb_charge_state cs = sidb_charge_state::NEGATIVE, + const charge_index_mode cs_mode = charge_index_mode::WORKING_WITH_CHARGE_INDEX) noexcept { strg->sidb_order = {}; strg->cell_charge = {}; @@ -1866,18 +1872,21 @@ class charge_distribution_surface : public Lyt std::sort(strg->sidb_order.begin(), strg->sidb_order.end()); this->foreach_cell([this, &cs](const auto&) { strg->cell_charge.push_back(cs); }); - assert((((this->num_cells() < 41) && (strg->simulation_parameters.base == 3)) || - ((strg->simulation_parameters.base == 2) && (this->num_cells() < 64))) && - "number of SiDBs is too large"); - - this->charge_distribution_to_index(); this->initialize_nm_distance_matrix(); this->initialize_potential_matrix(); - strg->max_charge_index = static_cast( - std::pow(static_cast(strg->simulation_parameters.base), this->num_cells()) - 1); this->update_local_potential(); this->recompute_system_energy(); this->validity_check(); + + if (cs_mode == charge_index_mode::WORKING_WITH_CHARGE_INDEX) + { + assert((((this->num_cells() < 41) && (strg->simulation_parameters.base == 3)) || + ((strg->simulation_parameters.base == 2) && (this->num_cells() < 64))) && + "number of SiDBs is too large"); + strg->max_charge_index = static_cast( + std::pow(static_cast(strg->simulation_parameters.base), this->num_cells()) - 1); + this->charge_distribution_to_index(); + }; }; /** * This function is used when three state simulations are required (i.e., is_three_state_simulation_required = true) diff --git a/include/fiction/utils/layout_utils.hpp b/include/fiction/utils/layout_utils.hpp index cc5e79514..80d26a4b6 100644 --- a/include/fiction/utils/layout_utils.hpp +++ b/include/fiction/utils/layout_utils.hpp @@ -12,6 +12,7 @@ #include "fiction/technology/sidb_lattice.hpp" #include "fiction/traits.hpp" #include "fiction/types.hpp" +#include "fiction/algorithms/simulation/sidb/can_positive_charges_occur.hpp" #include #include @@ -687,6 +688,105 @@ template } #pragma GCC diagnostic pop +/** + * This function checks whether the given layouts `first_lyt` and `second_lyt` are identical by comparing various + * properties such as the number of cells, the types of cells, defects (if applicable), and charge states (if + * applicable). The comparison is done in a detailed manner depending on the specific layout type. + * + * @tparam Lyt The layout type. Must be a cell-level layout. + * @param first_lyt The first layout to compare. + * @param second_lyt The second layout to compare. + * @return `true` if the layouts are identical, `false` otherwise. + */ +template +[[nodiscard]] inline bool are_layouts_identical(const Lyt& first_lyt, const Lyt& second_lyt) noexcept +{ + static_assert(is_cell_level_layout_v, "Lyt is not a cell-level layout"); + + if (first_lyt.num_cells() != second_lyt.num_cells()) + { + return false; + } + + bool different_cells = false; + + first_lyt.foreach_cell( + [&first_lyt, &second_lyt, &different_cells](const auto& c) + { + if (first_lyt.get_cell_type(c) != second_lyt.get_cell_type(c)) + { + different_cells = true; + return; + } + }); + + if (different_cells) + { + return false; + } + + if constexpr (is_sidb_defect_surface_v) + { + if (second_lyt.num_defects() != first_lyt.num_defects()) + { + return false; + } + + bool different_defects = false; + + first_lyt.foreach_sidb_defect( + [&first_lyt, &second_lyt, &different_defects](const auto& defect_old) + { + if (first_lyt.get_sidb_defect(defect_old.first) != second_lyt.get_sidb_defect(defect_old.first)) + { + different_defects = true; + return; + } + }); + + if (different_defects) + { + return false; + } + } + + if constexpr (is_charge_distribution_surface_v) + { + if (second_lyt.num_neutral_sidbs() != first_lyt.num_neutral_sidbs()) + { + return false; + } + + if (second_lyt.num_negative_sidbs() != first_lyt.num_negative_sidbs()) + { + return false; + } + + if (second_lyt.num_positive_sidbs() != first_lyt.num_positive_sidbs()) + { + return false; + } + + bool different_charge_state = false; + first_lyt.foreach_cell( + [&different_charge_state, &first_lyt, &second_lyt](const auto& c) + { + if (first_lyt.get_charge_state(c) != second_lyt.get_charge_state(c)) + { + different_charge_state = true; + return; + } + }); + + if (different_charge_state) + { + return false; + } + } + + return true; +} + } // namespace fiction #endif // FICTION_LAYOUT_UTILS_HPP diff --git a/test/algorithms/simulation/sidb/random_sidb_layout_generator.cpp b/test/algorithms/simulation/sidb/random_sidb_layout_generator.cpp index fa4aa2303..960271996 100644 --- a/test/algorithms/simulation/sidb/random_sidb_layout_generator.cpp +++ b/test/algorithms/simulation/sidb/random_sidb_layout_generator.cpp @@ -119,40 +119,29 @@ TEST_CASE("Random cube::coord_t layout generation", "[generate-random-sidb-layou { const generate_random_sidb_layout_params params{ {{0, 0, 0}, {90, 90, 0}}, - 100, + 50, generate_random_sidb_layout_params::positive_charges::FORBIDDEN}; const auto result_lyt = generate_random_sidb_layout(sidb_cell_clk_lyt_cube{}, params); - CHECK(result_lyt.num_cells() == 100); + CHECK(result_lyt.num_cells() == 50); result_lyt.foreach_cell( [](const auto& cell) { CHECK(cell.x < 91); CHECK(cell.y < 91); }); - // check if all cells are not closer than two cells (Euclidean distance). - result_lyt.foreach_cell( - [&result_lyt](const auto& cell_one) - { - result_lyt.foreach_cell( - [&cell_one, &result_lyt](const auto& cell_two) - { - if (cell_one != cell_two) - { - CHECK(euclidean_distance(result_lyt, cell_one, cell_two) >= 2); - } - }); - }); + + CHECK(!can_positive_charges_occur(result_lyt, sidb_simulation_parameters{})); } SECTION("given previous layouts") { const generate_random_sidb_layout_params params{ - {{-5, -2}, {9, 9}}, - 10, + {{-5, -2}, {20, 20}}, + 6, generate_random_sidb_layout_params::positive_charges::FORBIDDEN, - 2, + sidb_simulation_parameters{}, static_cast(10E6), 3}; const auto result_lyts = generate_multiple_random_sidb_layouts(sidb_cell_clk_lyt_cube{}, params); @@ -163,9 +152,9 @@ TEST_CASE("Random cube::coord_t layout generation", "[generate-random-sidb-layou lyt.foreach_cell( [](const auto& cell) { - CHECK(cell.x < 10); + CHECK(cell.x <= 20); CHECK(cell.x > -6); - CHECK(cell.y < 10); + CHECK(cell.y <= 20); CHECK(cell.y > -3); }); } @@ -174,32 +163,21 @@ TEST_CASE("Random cube::coord_t layout generation", "[generate-random-sidb-layou SECTION("Check uniqueness of two layouts") { const generate_random_sidb_layout_params params{ - {{0, 0}, {9, 9}}, - 10, + {{0, 0}, {20, 20}}, + 8, generate_random_sidb_layout_params::positive_charges::FORBIDDEN, - 2, + sidb_simulation_parameters{}, static_cast(10E6), 2}; + const auto result_lyts = generate_multiple_random_sidb_layouts(sidb_cell_clk_lyt_cube{}, params); + REQUIRE(result_lyts.size() == 2); const auto& first_lyt = result_lyts.front(); const auto& second_lyt = result_lyts.back(); - uint64_t counter_different_cell = 0; - first_lyt.foreach_cell( - [&second_lyt, &counter_different_cell](const auto& cell_first) - { - second_lyt.foreach_cell( - [&cell_first, &counter_different_cell](const auto& cell_second) - { - if (cell_first != cell_second) - { - counter_different_cell += 1; - }; - }); - }); - CHECK(counter_different_cell != 0); + CHECK(!are_layouts_identical(first_lyt, second_lyt)); } SECTION("Check all pairwise distances") @@ -208,7 +186,7 @@ TEST_CASE("Random cube::coord_t layout generation", "[generate-random-sidb-layou {{0, 0}, {30, 30}}, 10, generate_random_sidb_layout_params::positive_charges::FORBIDDEN, - 2, + sidb_simulation_parameters{}, static_cast(10E6), 10}; const auto result_lyts = generate_multiple_random_sidb_layouts(sidb_cell_clk_lyt_cube{}, params); @@ -216,23 +194,7 @@ TEST_CASE("Random cube::coord_t layout generation", "[generate-random-sidb-layou for (const auto& lyt : result_lyts) { - bool all_cells_fulfill_distance = true; - lyt.foreach_cell( - [&lyt, ¶ms, &all_cells_fulfill_distance](const auto& cell_first) - { - lyt.foreach_cell( - [&lyt, &cell_first, ¶ms, &all_cells_fulfill_distance](const auto& cell_second) - { - if (cell_first != cell_second) - { - if (euclidean_distance(lyt, cell_first, cell_second) < params.minimal_spacing) - { - all_cells_fulfill_distance = false; - }; - } - }); - }); - CHECK(all_cells_fulfill_distance); + CHECK(!can_positive_charges_occur(lyt, sidb_simulation_parameters{})); } } } @@ -322,7 +284,7 @@ TEST_CASE("Random offset::ucoord_t layout generation", "[generate-random-sidb-la SECTION("given corner coordinates and number of placed SiDBs, and allow positive charges") { const generate_random_sidb_layout_params params{ - {{0, 0, 0}, {90, 90, 0}}, + {{0, 0, 0}, {200, 200, 0}}, 100, generate_random_sidb_layout_params::positive_charges::FORBIDDEN}; @@ -332,31 +294,20 @@ TEST_CASE("Random offset::ucoord_t layout generation", "[generate-random-sidb-la result_lyt.foreach_cell( [](const auto& cell) { - CHECK(cell.x < 91); - CHECK(cell.y < 91); - }); - // check if all cells are not closer than two cells (Euclidean distance). - result_lyt.foreach_cell( - [&result_lyt](const auto& cell_one) - { - result_lyt.foreach_cell( - [&cell_one, &result_lyt](const auto& cell_two) - { - if (cell_one != cell_two) - { - CHECK(euclidean_distance(result_lyt, cell_one, cell_two) >= 2); - } - }); + CHECK(cell.x <= 200); + CHECK(cell.y <= 200); }); + + CHECK(!can_positive_charges_occur(result_lyt, sidb_simulation_parameters{})); } SECTION("given previous layouts") { const generate_random_sidb_layout_params params{ - {{0, 0}, {9, 9, 2}}, + {{0, 0}, {20, 20}}, 10, generate_random_sidb_layout_params::positive_charges::FORBIDDEN, - 2, + sidb_simulation_parameters{}, static_cast(10E6), 3}; const auto result_lyts = generate_multiple_random_sidb_layouts(sidb_100_cell_clk_lyt{}, params); @@ -367,8 +318,8 @@ TEST_CASE("Random offset::ucoord_t layout generation", "[generate-random-sidb-la lyt.foreach_cell( [](const auto& cell) { - CHECK(cell.x < 10); - CHECK(cell.y < 10); + CHECK(cell.x <= 20); + CHECK(cell.y <= 20); }); } } @@ -376,10 +327,10 @@ TEST_CASE("Random offset::ucoord_t layout generation", "[generate-random-sidb-la SECTION("Check uniqueness of two layouts") { const generate_random_sidb_layout_params params{ - {{0, 0}, {9, 9}}, + {{0, 0}, {20, 20}}, 10, generate_random_sidb_layout_params::positive_charges::FORBIDDEN, - 2, + sidb_simulation_parameters{}, static_cast(10E6), 2}; const auto result_lyts = generate_multiple_random_sidb_layouts(sidb_100_cell_clk_lyt{}, params); @@ -388,20 +339,7 @@ TEST_CASE("Random offset::ucoord_t layout generation", "[generate-random-sidb-la const auto& first_lyt = result_lyts.front(); const auto& second_lyt = result_lyts.back(); - uint64_t counter_different_cell = 0; - first_lyt.foreach_cell( - [&second_lyt, &counter_different_cell](const auto& cell_first) - { - second_lyt.foreach_cell( - [&cell_first, &counter_different_cell](const auto& cell_second) - { - if (cell_first != cell_second) - { - counter_different_cell += 1; - }; - }); - }); - CHECK(counter_different_cell != 0); + CHECK(!are_layouts_identical(first_lyt, second_lyt)); } SECTION("Check correct use of skeleton layout when generating only one random layout") @@ -419,16 +357,19 @@ TEST_CASE("Random offset::ucoord_t layout generation", "[generate-random-sidb-la SECTION("Check correct use of skeleton layout when generating multiple random layouts") { const generate_random_sidb_layout_params params{ - {{0, 0}, {9, 9}}, + {{0, 0}, {20, 20}}, 10, generate_random_sidb_layout_params::positive_charges::FORBIDDEN, - 2, + sidb_simulation_parameters{}, static_cast(10E6), 2}; + sidb_100_cell_clk_lyt skeleton_layout{}; + skeleton_layout.assign_cell_type({0, 0}, sidb_100_cell_clk_lyt::technology::NORMAL); skeleton_layout.assign_cell_type({3, 0}, sidb_100_cell_clk_lyt::technology::NORMAL); skeleton_layout.assign_cell_type({9, 1}, sidb_100_cell_clk_lyt::technology::NORMAL); + const auto result_lyts = generate_multiple_random_sidb_layouts(skeleton_layout, params); REQUIRE(result_lyts.size() == 2); @@ -553,10 +494,10 @@ TEST_CASE("Random siqad::coord_t layout generation", "[generate-random-sidb-layo SECTION("given previous layouts") { const generate_random_sidb_layout_params params{ - {{0, 0, 1}, {9, 9, 1}}, + {{0, 0, 1}, {20, 20, 1}}, 10, generate_random_sidb_layout_params::positive_charges::FORBIDDEN, - 2, + sidb_simulation_parameters{}, static_cast(10E6), 3}; const auto result_lyts = generate_multiple_random_sidb_layouts(sidb_cell_clk_lyt_siqad{}, params); @@ -567,9 +508,9 @@ TEST_CASE("Random siqad::coord_t layout generation", "[generate-random-sidb-layo lyt.foreach_cell( [](const auto& cell) { - CHECK(cell.x < 10); + CHECK(cell.x <= 20); CHECK(cell.x >= 0); - CHECK(cell.y < 10); + CHECK(cell.y <= 20); CHECK(cell.y >= 0); CHECK(cell.z <= 1); }); @@ -604,7 +545,7 @@ TEMPLATE_TEST_CASE("Random siqad::coord_t layout generation with defects", "[gen {{2, 1, 1}, {2, 1, 1}}, 1, generate_random_sidb_layout_params>::positive_charges::FORBIDDEN, - 2, + sidb_simulation_parameters{}, 5u}; auto defect_layout = TestType{}; @@ -624,7 +565,7 @@ TEMPLATE_TEST_CASE("Random siqad::coord_t layout generation with defects", "[gen {{2, 1, 1}, {2, 1, 1}}, 1, generate_random_sidb_layout_params>::positive_charges::FORBIDDEN, - 2, + sidb_simulation_parameters{}, 5u}; auto defect_layout = TestType{}; @@ -647,7 +588,7 @@ TEMPLATE_TEST_CASE("Random siqad::coord_t layout generation with defects", "[gen {{0, 0, 0}, {10, 2, 0}}, 10, generate_random_sidb_layout_params>::positive_charges::ALLOWED, - 2}; + sidb_simulation_parameters{}}; auto defect_layout = TestType{}; defect_layout.assign_sidb_defect({2, 2, 0}, sidb_defect{sidb_defect_type::DB, -1, 5.6, 5}); @@ -683,7 +624,7 @@ TEST_CASE("Random cube::coord_t layout generation with defects", "[generate-rand siqad::to_fiction_coord(siqad::coord_t{10, 2, 0})}, 10, generate_random_sidb_layout_params::positive_charges::ALLOWED, - 2}; + sidb_simulation_parameters{}}; lyt layout{}; diff --git a/test/utils/layout_utils.cpp b/test/utils/layout_utils.cpp index 5b607f60f..db96cb27e 100644 --- a/test/utils/layout_utils.cpp +++ b/test/utils/layout_utils.cpp @@ -853,3 +853,73 @@ TEST_CASE("Generate all cells in area spanned by two cells, using offset coordin CHECK(final_cell.z == 0); } } + +TEST_CASE("Test identity of two layouts", "[layout-utils]") +{ + sidb_cell_clk_lyt_siqad lyt_first{{5, 3}}; + + lyt_first.assign_cell_type({5, 3}, sidb_cell_clk_lyt::cell_type::NORMAL); + lyt_first.assign_cell_type({0, 0}, sidb_cell_clk_lyt::cell_type::INPUT); + lyt_first.assign_cell_type({1, 1}, sidb_cell_clk_lyt::cell_type::INPUT); + lyt_first.assign_cell_type({2, 2}, sidb_cell_clk_lyt::cell_type::OUTPUT); + + auto lyt_second{lyt_first.clone()}; + + SECTION("cell-level layout") + { + SECTION("identical layouts") + { + CHECK(are_layouts_identical(lyt_first, lyt_second)); + } + SECTION("different cell type") + { + lyt_second.assign_cell_type({5, 3}, sidb_cell_clk_lyt::cell_type::INPUT); + CHECK(!are_layouts_identical(lyt_first, lyt_second)); + } + } + + const charge_distribution_surface cds_first{lyt_first}; + charge_distribution_surface cds_second{lyt_second}; + + SECTION("charge distribution surface") + { + SECTION("identical layouts") + { + CHECK(are_layouts_identical(cds_first, cds_second)); + } + SECTION("different charge state") + { + cds_second.assign_charge_state({5, 3}, sidb_charge_state::POSITIVE); + CHECK(!are_layouts_identical(cds_first, cds_second)); + } + } + + SECTION("SiDB defect surface on top of the charge distribution surface") + { + sidb_defect_surface defect_first{cds_first}; + defect_first.assign_sidb_defect({1, 1}, sidb_defect{sidb_defect_type::UNKNOWN}); + defect_first.assign_sidb_defect({1, 2}, sidb_defect{sidb_defect_type::SI_VACANCY}); + + sidb_defect_surface defect_second{cds_second}; + defect_second.assign_sidb_defect({1, 1}, sidb_defect{sidb_defect_type::UNKNOWN}); + defect_second.assign_sidb_defect({1, 2}, sidb_defect{sidb_defect_type::SI_VACANCY}); + + SECTION("identical layouts") + { + CHECK(are_layouts_identical(defect_first, defect_second)); + } + SECTION("different layouts") + { + SECTION("different number of defects") + { + defect_second.assign_sidb_defect({1, 2}, sidb_defect{sidb_defect_type::NONE}); + CHECK(!are_layouts_identical(defect_first, defect_second)); + } + SECTION("different defect type") + { + defect_second.assign_sidb_defect({1, 2}, sidb_defect{sidb_defect_type::DB}); + CHECK(!are_layouts_identical(defect_first, defect_second)); + } + } + } +} From 7ebdfcc485a96933e1714bb6ba03b94a2abb10ee Mon Sep 17 00:00:00 2001 From: Drewniok Date: Tue, 3 Sep 2024 09:01:57 +0200 Subject: [PATCH 02/32] :alembic: add experiment script. --- ...pp => runtime_analysis_bestagon_gates.cpp} | 0 ...s_layouts_with_possible_positive_sidbs.cpp | 85 +++++++++++++++++++ 2 files changed, 85 insertions(+) rename experiments/sidb_simulation/{runtime_analysis.cpp => runtime_analysis_bestagon_gates.cpp} (100%) create mode 100644 experiments/sidb_simulation/runtime_analysis_layouts_with_possible_positive_sidbs.cpp diff --git a/experiments/sidb_simulation/runtime_analysis.cpp b/experiments/sidb_simulation/runtime_analysis_bestagon_gates.cpp similarity index 100% rename from experiments/sidb_simulation/runtime_analysis.cpp rename to experiments/sidb_simulation/runtime_analysis_bestagon_gates.cpp diff --git a/experiments/sidb_simulation/runtime_analysis_layouts_with_possible_positive_sidbs.cpp b/experiments/sidb_simulation/runtime_analysis_layouts_with_possible_positive_sidbs.cpp new file mode 100644 index 000000000..f66679ba9 --- /dev/null +++ b/experiments/sidb_simulation/runtime_analysis_layouts_with_possible_positive_sidbs.cpp @@ -0,0 +1,85 @@ +// +// Created by Jan Drewniok on 02.09.24. +// + +#include "fiction/algorithms/simulation/sidb/determine_groundstate_from_simulation_results.hpp" +#include "fiction/algorithms/simulation/sidb/exhaustive_ground_state_simulation.hpp" +#include "fiction/algorithms/simulation/sidb/quickexact.hpp" +#include "fiction/algorithms/simulation/sidb/random_sidb_layout_generator.hpp" +#include "fiction/algorithms/simulation/sidb/sidb_simulation_parameters.hpp" +#include "fiction_experiments.hpp" +#include "mockturtle/utils/stopwatch.hpp" + +#include + +using namespace fiction; + +// This script compares the simulation runtime of the exhaustive and QuickExact simulation algorithms for randomly +// generated layouts that may contain positively charged SiDBs (`can_positive_charges_occur` returns `true`). The number +// of SiDBs in the layout is varied from 5 to 20. + +int main() // NOLINT +{ + using Lyt = sidb_100_cell_clk_lyt; + + experiments::experiment simulation_exp{ + "Benchmark", + "Number SiDBs", + "#Instances", + "Exhaustive Runtime [s]", + "QuickExact Runtime [s]", + "Average #positive SiDBs of ground state"}; + + const sidb_simulation_parameters sim_params{3, -0.32}; + + const quickexact_params> qe_params{sim_params, + quickexact_params>::automatic_base_number_detection::OFF}; + + auto random_layouts_params = generate_random_sidb_layout_params>{ + {{0, 0}, {10, 10}}, + 0, + generate_random_sidb_layout_params>::positive_charges::CAN_OCCUR, + sim_params, + static_cast(10E6), + 10}; + + for (auto num_sidbs = 5u; num_sidbs < 20; num_sidbs++) + { + random_layouts_params.number_of_sidbs = num_sidbs; + + const auto random_layouts = generate_multiple_random_sidb_layouts(Lyt{}, random_layouts_params); + + double runtime_exhaustive = 0; + double runtime_quickexact = 0; + + std::vector number_of_positive_sidbs_of_gs_per_layout{}; + number_of_positive_sidbs_of_gs_per_layout.reserve(random_layouts_params.number_of_unique_generated_layouts); + + for (const auto& layout : random_layouts) + { + const auto exhaustive_results_layout = exhaustive_ground_state_simulation(layout, sim_params); + + const auto quickexact_results_layout = quickexact(layout, qe_params); + + const auto gs = determine_groundstate_from_simulation_results(exhaustive_results_layout); + + // determine the number of positive SiDBs in the ground state + number_of_positive_sidbs_of_gs_per_layout.push_back(gs.at(0).num_positive_sidbs()); + + runtime_exhaustive += mockturtle::to_seconds(exhaustive_results_layout.simulation_runtime); + runtime_quickexact += mockturtle::to_seconds(quickexact_results_layout.simulation_runtime); + } + + const auto average_pos_sibs_of_gs = std::accumulate(number_of_positive_sidbs_of_gs_per_layout.cbegin(), + number_of_positive_sidbs_of_gs_per_layout.cend(), 0) / + static_cast(number_of_positive_sidbs_of_gs_per_layout.size()); + + simulation_exp(random_layouts_params.number_of_sidbs, random_layouts.size(), runtime_exhaustive, + runtime_quickexact, average_pos_sibs_of_gs); + + simulation_exp.save(); + simulation_exp.table(); + } + + return EXIT_SUCCESS; +} From 5a937d4e9c069cfa21fa1144dc8cc281f973386e Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Tue, 3 Sep 2024 07:03:35 +0000 Subject: [PATCH 03/32] :memo: Update pyfiction docstrings Signed-off-by: GitHub Actions --- .../pyfiction/pybind11_mkdoc_docstrings.hpp | 33 ++++++++++++++++--- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/bindings/pyfiction/include/pyfiction/pybind11_mkdoc_docstrings.hpp b/bindings/pyfiction/include/pyfiction/pybind11_mkdoc_docstrings.hpp index 90f7ab620..b0f107350 100644 --- a/bindings/pyfiction/include/pyfiction/pybind11_mkdoc_docstrings.hpp +++ b/bindings/pyfiction/include/pyfiction/pybind11_mkdoc_docstrings.hpp @@ -295,6 +295,25 @@ Parameter ``params``: A cell-level layout that implements `lyt`'s gate types with building blocks defined in `GateLibrary`.)doc"; +static const char *__doc_fiction_are_layouts_identical = +R"doc(This function checks whether the given layouts `first_lyt` and +`second_lyt` are identical by comparing various properties such as the +number of cells, the types of cells, defects (if applicable), and +charge states (if applicable). The comparison is done in a detailed +manner depending on the specific layout type. + +Template parameter ``Lyt``: + The layout type. Must be a cell-level layout. + +Parameter ``first_lyt``: + The first layout to compare. + +Parameter ``second_lyt``: + The second layout to compare. + +Returns: + `true` if the layouts are identical, `false` otherwise.)doc"; + static const char *__doc_fiction_area = R"doc(Computes the area of a given coordinate assuming its origin is (0, 0, 0). Calculates :math:`(|x| + 1) \cdot (|y| + 1)` by default. The @@ -1948,6 +1967,10 @@ static const char *__doc_fiction_charge_index_mode_UPDATE_CHARGE_INDEX = R"doc(The charge state is assigned to the cell and the charge index is updated.)doc"; +static const char *__doc_fiction_charge_index_mode_WORKING_WITH_CHARGE_INDEX = +R"doc(The charge state is assigned to the cell but the old charge index is +kept.)doc"; + static const char *__doc_fiction_charge_index_recomputation = R"doc(An enumeration of modes to specifying if the charge index should be recomputed fully.)doc"; @@ -10752,10 +10775,6 @@ be difficult or even impossible to find several unique (given by number_of_unique_generated_layouts) layouts. Therefore, this parameter sets a limit for the maximum number of tries.)doc"; -static const char *__doc_fiction_generate_random_sidb_layout_params_minimal_spacing = -R"doc(If positively charged SiDBs should be prevented, SiDBs are not placed -closer than this value (Euclidean distance of two cells).)doc"; - static const char *__doc_fiction_generate_random_sidb_layout_params_number_of_sidbs = R"doc(Number of SiDBs that are placed on the layout.)doc"; static const char *__doc_fiction_generate_random_sidb_layout_params_number_of_unique_generated_layouts = R"doc(The desired number of unique layouts to be generated.)doc"; @@ -10768,6 +10787,10 @@ static const char *__doc_fiction_generate_random_sidb_layout_params_positive_cha R"doc(Positive charges can occur (i.e. SiDBs can be placed right next to each other).)doc"; +static const char *__doc_fiction_generate_random_sidb_layout_params_positive_charges_CAN_OCCUR = +R"doc(Positive charges can occur, which means that the +`can_positive_charges_occur` function returns `true`.)doc"; + static const char *__doc_fiction_generate_random_sidb_layout_params_positive_charges_FORBIDDEN = R"doc(Positive charges are not allowed to occur (i.e. SiDBs need to be seperated by a few lattice points).)doc"; @@ -10776,6 +10799,8 @@ static const char *__doc_fiction_generate_random_sidb_layout_params_positive_sid R"doc(If positively charged SiDBs should be prevented, SiDBs are not placed closer than the minimal_spacing.)doc"; +static const char *__doc_fiction_generate_random_sidb_layout_params_sim_params = R"doc()doc"; + static const char *__doc_fiction_geometric_temperature_schedule = R"doc(A logarithmically decreasing temperature schedule. The temperature is altered by multiplying it with `0.99`. From c8f496882e08edb87b9c6da2dcc43bdabbb90d48 Mon Sep 17 00:00:00 2001 From: Drewniok Date: Tue, 3 Sep 2024 10:51:42 +0200 Subject: [PATCH 04/32] :art: small changes. --- .../charge_distribution_surface.hpp | 29 ++++++------------- ...eck_simulation_results_for_equivalence.cpp | 6 ++-- .../sidb/random_sidb_layout_generator.cpp | 16 +++++----- 3 files changed, 20 insertions(+), 31 deletions(-) diff --git a/include/fiction/technology/charge_distribution_surface.hpp b/include/fiction/technology/charge_distribution_surface.hpp index 098368064..ba15e7928 100644 --- a/include/fiction/technology/charge_distribution_surface.hpp +++ b/include/fiction/technology/charge_distribution_surface.hpp @@ -127,8 +127,6 @@ enum class charge_index_mode * The charge state is assigned to the cell but the old charge index is kept. */ KEEP_CHARGE_INDEX, - - WORKING_WITH_CHARGE_INDEX }; /** @@ -291,15 +289,14 @@ class charge_distribution_surface : public Lyt */ explicit charge_distribution_surface( const sidb_simulation_parameters& params = sidb_simulation_parameters{}, - const sidb_charge_state cs = sidb_charge_state::NEGATIVE, - const charge_index_mode cs_mode = charge_index_mode::WORKING_WITH_CHARGE_INDEX) : + const sidb_charge_state cs = sidb_charge_state::NEGATIVE) : Lyt(), strg{std::make_shared(params)} { static_assert(is_cell_level_layout_v, "Lyt is not a cell-level layout"); static_assert(has_sidb_technology_v, "Lyt is not an SiDB layout"); - initialize(cs, cs_mode); + initialize(cs); } /** @@ -313,15 +310,14 @@ class charge_distribution_surface : public Lyt */ explicit charge_distribution_surface( const Lyt& lyt, const sidb_simulation_parameters& params = sidb_simulation_parameters{}, - const sidb_charge_state cs = sidb_charge_state::NEGATIVE, - const charge_index_mode cs_mode = charge_index_mode::WORKING_WITH_CHARGE_INDEX) : + const sidb_charge_state cs = sidb_charge_state::NEGATIVE) : Lyt(lyt), strg{std::make_shared(params)} { static_assert(is_cell_level_layout_v, "Lyt is not a cell-level layout"); static_assert(has_sidb_technology_v, "Lyt is not an SiDB layout"); - initialize(cs, cs_mode); + initialize(cs); }; /** * Copy constructor. @@ -1861,8 +1857,7 @@ class charge_distribution_surface : public Lyt * * @param cs The charge state assigned to all SiDBs. */ - void initialize(const sidb_charge_state cs = sidb_charge_state::NEGATIVE, - const charge_index_mode cs_mode = charge_index_mode::WORKING_WITH_CHARGE_INDEX) noexcept + void initialize(const sidb_charge_state cs = sidb_charge_state::NEGATIVE) noexcept { strg->sidb_order = {}; strg->cell_charge = {}; @@ -1872,21 +1867,15 @@ class charge_distribution_surface : public Lyt std::sort(strg->sidb_order.begin(), strg->sidb_order.end()); this->foreach_cell([this, &cs](const auto&) { strg->cell_charge.push_back(cs); }); + strg->max_charge_index = static_cast( + std::pow(static_cast(strg->simulation_parameters.base), this->num_cells()) - 1); + this->charge_distribution_to_index(); + this->initialize_nm_distance_matrix(); this->initialize_potential_matrix(); this->update_local_potential(); this->recompute_system_energy(); this->validity_check(); - - if (cs_mode == charge_index_mode::WORKING_WITH_CHARGE_INDEX) - { - assert((((this->num_cells() < 41) && (strg->simulation_parameters.base == 3)) || - ((strg->simulation_parameters.base == 2) && (this->num_cells() < 64))) && - "number of SiDBs is too large"); - strg->max_charge_index = static_cast( - std::pow(static_cast(strg->simulation_parameters.base), this->num_cells()) - 1); - this->charge_distribution_to_index(); - }; }; /** * This function is used when three state simulations are required (i.e., is_three_state_simulation_required = true) diff --git a/test/algorithms/simulation/sidb/check_simulation_results_for_equivalence.cpp b/test/algorithms/simulation/sidb/check_simulation_results_for_equivalence.cpp index a7e584291..078053c6c 100644 --- a/test/algorithms/simulation/sidb/check_simulation_results_for_equivalence.cpp +++ b/test/algorithms/simulation/sidb/check_simulation_results_for_equivalence.cpp @@ -61,9 +61,9 @@ TEST_CASE("Several tests", "[check-equivalence-simulation-result]") auto lyt2{lyt1.clone()}; lyt2.assign_cell_type({4, 2}, sidb_100_cell_clk_lyt::cell_type::NORMAL); lyt2.assign_cell_type({4, 3}, sidb_100_cell_clk_lyt::cell_type::NORMAL); - results2.charge_distributions = { - charge_distribution_surface{lyt2, sidb_simulation_parameters{}, sidb_charge_state::NEUTRAL}, - charge_distribution_surface{lyt2}}; + results2.charge_distributions = {charge_distribution_surface{lyt2, sidb_simulation_parameters{}, + sidb_charge_state::NEUTRAL}, + charge_distribution_surface{lyt2}}; CHECK(!check_simulation_results_for_equivalence(results1, results2)); } diff --git a/test/algorithms/simulation/sidb/random_sidb_layout_generator.cpp b/test/algorithms/simulation/sidb/random_sidb_layout_generator.cpp index 960271996..c7f607ca0 100644 --- a/test/algorithms/simulation/sidb/random_sidb_layout_generator.cpp +++ b/test/algorithms/simulation/sidb/random_sidb_layout_generator.cpp @@ -118,7 +118,7 @@ TEST_CASE("Random cube::coord_t layout generation", "[generate-random-sidb-layou SECTION("given corner coordinates and number of placed SiDBs, and allow positive charges") { const generate_random_sidb_layout_params params{ - {{0, 0, 0}, {90, 90, 0}}, + {{0, 0, 0}, {200, 200, 0}}, 50, generate_random_sidb_layout_params::positive_charges::FORBIDDEN}; @@ -128,8 +128,8 @@ TEST_CASE("Random cube::coord_t layout generation", "[generate-random-sidb-layou result_lyt.foreach_cell( [](const auto& cell) { - CHECK(cell.x < 91); - CHECK(cell.y < 91); + CHECK(cell.x <= 200); + CHECK(cell.y <= 200); }); CHECK(!can_positive_charges_occur(result_lyt, sidb_simulation_parameters{})); @@ -183,7 +183,7 @@ TEST_CASE("Random cube::coord_t layout generation", "[generate-random-sidb-layou SECTION("Check all pairwise distances") { const generate_random_sidb_layout_params params{ - {{0, 0}, {30, 30}}, + {{0, 0}, {40, 40}}, 10, generate_random_sidb_layout_params::positive_charges::FORBIDDEN, sidb_simulation_parameters{}, @@ -304,7 +304,7 @@ TEST_CASE("Random offset::ucoord_t layout generation", "[generate-random-sidb-la SECTION("given previous layouts") { const generate_random_sidb_layout_params params{ - {{0, 0}, {20, 20}}, + {{0, 0}, {40, 40}}, 10, generate_random_sidb_layout_params::positive_charges::FORBIDDEN, sidb_simulation_parameters{}, @@ -318,8 +318,8 @@ TEST_CASE("Random offset::ucoord_t layout generation", "[generate-random-sidb-la lyt.foreach_cell( [](const auto& cell) { - CHECK(cell.x <= 20); - CHECK(cell.y <= 20); + CHECK(cell.x <= 40); + CHECK(cell.y <= 40); }); } } @@ -357,7 +357,7 @@ TEST_CASE("Random offset::ucoord_t layout generation", "[generate-random-sidb-la SECTION("Check correct use of skeleton layout when generating multiple random layouts") { const generate_random_sidb_layout_params params{ - {{0, 0}, {20, 20}}, + {{0, 0}, {40, 40}}, 10, generate_random_sidb_layout_params::positive_charges::FORBIDDEN, sidb_simulation_parameters{}, From bb723eb42398cc92a706714118be27f64ab3ba68 Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Tue, 3 Sep 2024 08:52:49 +0000 Subject: [PATCH 05/32] :memo: Update pyfiction docstrings Signed-off-by: GitHub Actions --- .../pyfiction/include/pyfiction/pybind11_mkdoc_docstrings.hpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/bindings/pyfiction/include/pyfiction/pybind11_mkdoc_docstrings.hpp b/bindings/pyfiction/include/pyfiction/pybind11_mkdoc_docstrings.hpp index b0f107350..7aca2e377 100644 --- a/bindings/pyfiction/include/pyfiction/pybind11_mkdoc_docstrings.hpp +++ b/bindings/pyfiction/include/pyfiction/pybind11_mkdoc_docstrings.hpp @@ -1967,10 +1967,6 @@ static const char *__doc_fiction_charge_index_mode_UPDATE_CHARGE_INDEX = R"doc(The charge state is assigned to the cell and the charge index is updated.)doc"; -static const char *__doc_fiction_charge_index_mode_WORKING_WITH_CHARGE_INDEX = -R"doc(The charge state is assigned to the cell but the old charge index is -kept.)doc"; - static const char *__doc_fiction_charge_index_recomputation = R"doc(An enumeration of modes to specifying if the charge index should be recomputed fully.)doc"; From 2faea27c1da83f2343191de265efb0ad60147d96 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 3 Sep 2024 08:59:57 +0000 Subject: [PATCH 06/32] =?UTF-8?q?=F0=9F=8E=A8=20Incorporated=20pre-commit?= =?UTF-8?q?=20fixes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sidb/random_sidb_layout_generator.hpp | 3 ++- .../sidb/random_sidb_layout_generator.hpp | 3 +-- .../technology/charge_distribution_surface.hpp | 13 ++++++------- include/fiction/utils/layout_utils.hpp | 2 +- .../check_simulation_results_for_equivalence.cpp | 6 +++--- 5 files changed, 13 insertions(+), 14 deletions(-) diff --git a/bindings/pyfiction/include/pyfiction/algorithms/simulation/sidb/random_sidb_layout_generator.hpp b/bindings/pyfiction/include/pyfiction/algorithms/simulation/sidb/random_sidb_layout_generator.hpp index 2518a4505..186e3acf9 100644 --- a/bindings/pyfiction/include/pyfiction/algorithms/simulation/sidb/random_sidb_layout_generator.hpp +++ b/bindings/pyfiction/include/pyfiction/algorithms/simulation/sidb/random_sidb_layout_generator.hpp @@ -45,7 +45,8 @@ inline void random_sidb_layout_generator(pybind11::module& m) // todo update docu py::enum_::positive_charges>( m, "positive_charges", DOC(fiction_generate_random_sidb_layout_params_positive_charges)) - .value("ALLOWED", fiction::generate_random_sidb_layout_params::positive_charges::ALLOWED) + .value("ALLOWED", + fiction::generate_random_sidb_layout_params::positive_charges::ALLOWED) .value("FORBIDDEN", fiction::generate_random_sidb_layout_params::positive_charges::FORBIDDEN) .value("CAN_OCCUR", diff --git a/include/fiction/algorithms/simulation/sidb/random_sidb_layout_generator.hpp b/include/fiction/algorithms/simulation/sidb/random_sidb_layout_generator.hpp index e723d8957..52203feeb 100644 --- a/include/fiction/algorithms/simulation/sidb/random_sidb_layout_generator.hpp +++ b/include/fiction/algorithms/simulation/sidb/random_sidb_layout_generator.hpp @@ -143,8 +143,7 @@ Lyt generate_random_sidb_layout(const Lyt& attempt_counter += 1; } - if (params.positive_sidbs == - generate_random_sidb_layout_params>::positive_charges::CAN_OCCUR && + if (params.positive_sidbs == generate_random_sidb_layout_params>::positive_charges::CAN_OCCUR && !can_positive_charges_occur(lyt, params.sim_params)) { return generate_random_sidb_layout(lyt_skeleton, params); diff --git a/include/fiction/technology/charge_distribution_surface.hpp b/include/fiction/technology/charge_distribution_surface.hpp index ba15e7928..fe5f43ab1 100644 --- a/include/fiction/technology/charge_distribution_surface.hpp +++ b/include/fiction/technology/charge_distribution_surface.hpp @@ -287,9 +287,8 @@ class charge_distribution_surface : public Lyt * @param params Physical parameters used for the simulation (µ_minus, base number, ...). * @param cs The charge state used for the initialization of all SiDBs, default is a negative charge. */ - explicit charge_distribution_surface( - const sidb_simulation_parameters& params = sidb_simulation_parameters{}, - const sidb_charge_state cs = sidb_charge_state::NEGATIVE) : + explicit charge_distribution_surface(const sidb_simulation_parameters& params = sidb_simulation_parameters{}, + const sidb_charge_state cs = sidb_charge_state::NEGATIVE) : Lyt(), strg{std::make_shared(params)} { @@ -308,9 +307,9 @@ class charge_distribution_surface : public Lyt * @param variable_cells SiDB which charge state is variable (called dependent-cell). * @param external_potential Externally applied local electrostatic potential. */ - explicit charge_distribution_surface( - const Lyt& lyt, const sidb_simulation_parameters& params = sidb_simulation_parameters{}, - const sidb_charge_state cs = sidb_charge_state::NEGATIVE) : + explicit charge_distribution_surface(const Lyt& lyt, + const sidb_simulation_parameters& params = sidb_simulation_parameters{}, + const sidb_charge_state cs = sidb_charge_state::NEGATIVE) : Lyt(lyt), strg{std::make_shared(params)} { @@ -1857,7 +1856,7 @@ class charge_distribution_surface : public Lyt * * @param cs The charge state assigned to all SiDBs. */ - void initialize(const sidb_charge_state cs = sidb_charge_state::NEGATIVE) noexcept + void initialize(const sidb_charge_state cs = sidb_charge_state::NEGATIVE) noexcept { strg->sidb_order = {}; strg->cell_charge = {}; diff --git a/include/fiction/utils/layout_utils.hpp b/include/fiction/utils/layout_utils.hpp index 80d26a4b6..1b5c71a68 100644 --- a/include/fiction/utils/layout_utils.hpp +++ b/include/fiction/utils/layout_utils.hpp @@ -5,6 +5,7 @@ #ifndef FICTION_LAYOUT_UTILS_HPP #define FICTION_LAYOUT_UTILS_HPP +#include "fiction/algorithms/simulation/sidb/can_positive_charges_occur.hpp" #include "fiction/layouts/coordinates.hpp" #include "fiction/technology/cell_ports.hpp" #include "fiction/technology/charge_distribution_surface.hpp" @@ -12,7 +13,6 @@ #include "fiction/technology/sidb_lattice.hpp" #include "fiction/traits.hpp" #include "fiction/types.hpp" -#include "fiction/algorithms/simulation/sidb/can_positive_charges_occur.hpp" #include #include diff --git a/test/algorithms/simulation/sidb/check_simulation_results_for_equivalence.cpp b/test/algorithms/simulation/sidb/check_simulation_results_for_equivalence.cpp index 078053c6c..a7e584291 100644 --- a/test/algorithms/simulation/sidb/check_simulation_results_for_equivalence.cpp +++ b/test/algorithms/simulation/sidb/check_simulation_results_for_equivalence.cpp @@ -61,9 +61,9 @@ TEST_CASE("Several tests", "[check-equivalence-simulation-result]") auto lyt2{lyt1.clone()}; lyt2.assign_cell_type({4, 2}, sidb_100_cell_clk_lyt::cell_type::NORMAL); lyt2.assign_cell_type({4, 3}, sidb_100_cell_clk_lyt::cell_type::NORMAL); - results2.charge_distributions = {charge_distribution_surface{lyt2, sidb_simulation_parameters{}, - sidb_charge_state::NEUTRAL}, - charge_distribution_surface{lyt2}}; + results2.charge_distributions = { + charge_distribution_surface{lyt2, sidb_simulation_parameters{}, sidb_charge_state::NEUTRAL}, + charge_distribution_surface{lyt2}}; CHECK(!check_simulation_results_for_equivalence(results1, results2)); } From a03a196c171cc157408626eacc9489e8bb8d181e Mon Sep 17 00:00:00 2001 From: Drewniok Date: Tue, 3 Sep 2024 16:39:14 +0200 Subject: [PATCH 07/32] :rotating_light: implement clang-tidy warnings. --- .../random_sidb_layout_generation.cpp | 3 ++- .../simulation/sidb/random_sidb_layout_generator.hpp | 7 +++++-- .../simulation/sidb/random_sidb_layout_generator.cpp | 2 ++ 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/experiments/random_sidb_layout_generation/random_sidb_layout_generation.cpp b/experiments/random_sidb_layout_generation/random_sidb_layout_generation.cpp index 2c8918e83..0d61396de 100644 --- a/experiments/random_sidb_layout_generation/random_sidb_layout_generation.cpp +++ b/experiments/random_sidb_layout_generation/random_sidb_layout_generation.cpp @@ -4,6 +4,7 @@ #include #include +#include #include #include @@ -98,7 +99,7 @@ int main(int argc, const char* argv[]) // NOLINT // specifies whether positively charged SiDBs are allowed ("ALLOWED"), forbidden ("FORBIDDEN") or can occur // ("CAN_OCCUR") - generate_random_sidb_layout_params::positive_charges charges; + generate_random_sidb_layout_params::positive_charges charges{}; if (charges_str == "ALLOWED") { charges = generate_random_sidb_layout_params::positive_charges::ALLOWED; diff --git a/include/fiction/algorithms/simulation/sidb/random_sidb_layout_generator.hpp b/include/fiction/algorithms/simulation/sidb/random_sidb_layout_generator.hpp index 52203feeb..7125d83de 100644 --- a/include/fiction/algorithms/simulation/sidb/random_sidb_layout_generator.hpp +++ b/include/fiction/algorithms/simulation/sidb/random_sidb_layout_generator.hpp @@ -7,6 +7,7 @@ #include "fiction/algorithms/path_finding/distance.hpp" #include "fiction/algorithms/simulation/sidb/can_positive_charges_occur.hpp" +#include "fiction/algorithms/simulation/sidb/sidb_simulation_parameters.hpp" #include "fiction/technology/sidb_defects.hpp" #include "fiction/traits.hpp" #include "fiction/utils/layout_utils.hpp" @@ -57,8 +58,10 @@ struct generate_random_sidb_layout_params * If positively charged SiDBs should be prevented, SiDBs are not placed closer than the minimal_spacing. */ positive_charges positive_sidbs = positive_charges::ALLOWED; - - sidb_simulation_parameters sim_params{}; + /** + * Simulation parameters. + */ + sidb_simulation_parameters sim_params; /** * Maximum number of steps to place the specified number of SiDBs. Example: If the area, where SiDBs can be placed, * is small and many SiDBs are to be placed, several tries are required to generate a layout with no positively diff --git a/test/algorithms/simulation/sidb/random_sidb_layout_generator.cpp b/test/algorithms/simulation/sidb/random_sidb_layout_generator.cpp index c7f607ca0..1a8465aa3 100644 --- a/test/algorithms/simulation/sidb/random_sidb_layout_generator.cpp +++ b/test/algorithms/simulation/sidb/random_sidb_layout_generator.cpp @@ -12,6 +12,8 @@ #include #include #include +#include +#include #include From 1fface69ca5c741d8cca4f281629507996e0f295 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 3 Sep 2024 14:39:42 +0000 Subject: [PATCH 08/32] =?UTF-8?q?=F0=9F=8E=A8=20Incorporated=20pre-commit?= =?UTF-8?q?=20fixes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../algorithms/simulation/sidb/random_sidb_layout_generator.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/algorithms/simulation/sidb/random_sidb_layout_generator.cpp b/test/algorithms/simulation/sidb/random_sidb_layout_generator.cpp index 1a8465aa3..04c509cc7 100644 --- a/test/algorithms/simulation/sidb/random_sidb_layout_generator.cpp +++ b/test/algorithms/simulation/sidb/random_sidb_layout_generator.cpp @@ -5,6 +5,7 @@ #include #include +#include #include #include #include @@ -12,7 +13,6 @@ #include #include #include -#include #include #include From 01bae3a08bbb60c212d1c3980c2b291c04d6690c Mon Sep 17 00:00:00 2001 From: Drewniok Date: Tue, 3 Sep 2024 16:51:21 +0200 Subject: [PATCH 09/32] :art: small fix. --- .../fiction/algorithms/physical_design/design_sidb_gates.hpp | 3 +-- .../simulation/sidb/random_sidb_layout_generator.hpp | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/include/fiction/algorithms/physical_design/design_sidb_gates.hpp b/include/fiction/algorithms/physical_design/design_sidb_gates.hpp index 908f07ad8..709b2488c 100644 --- a/include/fiction/algorithms/physical_design/design_sidb_gates.hpp +++ b/include/fiction/algorithms/physical_design/design_sidb_gates.hpp @@ -229,8 +229,7 @@ class design_sidb_gates_impl const is_operational_params params_is_operational{params.simulation_parameters, params.sim_engine}; const generate_random_sidb_layout_params> parameter_random_layout{ - params.canvas, params.number_of_sidbs, - generate_random_sidb_layout_params>::positive_charges::FORBIDDEN}; + params.canvas, params.number_of_sidbs, generate_random_sidb_layout_params>::positive_charges::FORBIDDEN}; std::vector threads{}; threads.reserve(num_threads); diff --git a/include/fiction/algorithms/simulation/sidb/random_sidb_layout_generator.hpp b/include/fiction/algorithms/simulation/sidb/random_sidb_layout_generator.hpp index b1db0a5ac..60a5b93bb 100644 --- a/include/fiction/algorithms/simulation/sidb/random_sidb_layout_generator.hpp +++ b/include/fiction/algorithms/simulation/sidb/random_sidb_layout_generator.hpp @@ -61,7 +61,7 @@ struct generate_random_sidb_layout_params /** * Simulation parameters. */ - sidb_simulation_parameters sim_params; + sidb_simulation_parameters sim_params{}; /** * Maximum number of steps to place the specified number of SiDBs. Example: If the area, where SiDBs can be placed, * is small and many SiDBs are to be placed, several tries are required to generate a layout with no positively @@ -133,7 +133,6 @@ Lyt generate_random_sidb_layout(const Lyt& // the SiDB is added to the layout if (!random_cell_is_identical_wih_defect && !next_to_neutral_defect) { - lyt.assign_cell_type(random_coord, technology::cell_type::NORMAL); if (params.positive_sidbs == From a2f897ee03aae59bdc9309f54441716f64420e04 Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Tue, 3 Sep 2024 14:52:28 +0000 Subject: [PATCH 10/32] :memo: Update pyfiction docstrings Signed-off-by: GitHub Actions --- .../pyfiction/include/pyfiction/pybind11_mkdoc_docstrings.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bindings/pyfiction/include/pyfiction/pybind11_mkdoc_docstrings.hpp b/bindings/pyfiction/include/pyfiction/pybind11_mkdoc_docstrings.hpp index 7aca2e377..041f42c64 100644 --- a/bindings/pyfiction/include/pyfiction/pybind11_mkdoc_docstrings.hpp +++ b/bindings/pyfiction/include/pyfiction/pybind11_mkdoc_docstrings.hpp @@ -10795,7 +10795,7 @@ static const char *__doc_fiction_generate_random_sidb_layout_params_positive_sid R"doc(If positively charged SiDBs should be prevented, SiDBs are not placed closer than the minimal_spacing.)doc"; -static const char *__doc_fiction_generate_random_sidb_layout_params_sim_params = R"doc()doc"; +static const char *__doc_fiction_generate_random_sidb_layout_params_sim_params = R"doc(Simulation parameters.)doc"; static const char *__doc_fiction_geometric_temperature_schedule = R"doc(A logarithmically decreasing temperature schedule. The temperature is From bd5ca78d8e1db9f6fd6f52416a38e0fbe6df1708 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 3 Sep 2024 14:52:35 +0000 Subject: [PATCH 11/32] =?UTF-8?q?=F0=9F=8E=A8=20Incorporated=20pre-commit?= =?UTF-8?q?=20fixes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fiction/algorithms/physical_design/design_sidb_gates.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/fiction/algorithms/physical_design/design_sidb_gates.hpp b/include/fiction/algorithms/physical_design/design_sidb_gates.hpp index 709b2488c..908f07ad8 100644 --- a/include/fiction/algorithms/physical_design/design_sidb_gates.hpp +++ b/include/fiction/algorithms/physical_design/design_sidb_gates.hpp @@ -229,7 +229,8 @@ class design_sidb_gates_impl const is_operational_params params_is_operational{params.simulation_parameters, params.sim_engine}; const generate_random_sidb_layout_params> parameter_random_layout{ - params.canvas, params.number_of_sidbs, generate_random_sidb_layout_params>::positive_charges::FORBIDDEN}; + params.canvas, params.number_of_sidbs, + generate_random_sidb_layout_params>::positive_charges::FORBIDDEN}; std::vector threads{}; threads.reserve(num_threads); From 81d1dbdacbfa914e1fef1ace33fc8454a8dce293 Mon Sep 17 00:00:00 2001 From: Drewniok Date: Wed, 4 Sep 2024 07:43:15 +0200 Subject: [PATCH 12/32] :art: small fix to avoid window compile issue. --- .../algorithms/simulation/sidb/random_sidb_layout_generator.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/fiction/algorithms/simulation/sidb/random_sidb_layout_generator.hpp b/include/fiction/algorithms/simulation/sidb/random_sidb_layout_generator.hpp index 60a5b93bb..6adf440ee 100644 --- a/include/fiction/algorithms/simulation/sidb/random_sidb_layout_generator.hpp +++ b/include/fiction/algorithms/simulation/sidb/random_sidb_layout_generator.hpp @@ -78,7 +78,7 @@ struct generate_random_sidb_layout_params * even impossible to find several unique (given by number_of_unique_generated_layouts) layouts. Therefore, this * parameter sets a limit for the maximum number of tries. */ - uint64_t maximal_attempts_for_multiple_layouts = 10E6; + uint64_t maximal_attempts_for_multiple_layouts = 1'000'0000; }; /** From 17a7330fbbc5525a69d67483fe1b49e7e59ac7c2 Mon Sep 17 00:00:00 2001 From: Drewniok Date: Wed, 4 Sep 2024 07:44:05 +0200 Subject: [PATCH 13/32] :art: small fix. --- .../runtime_analysis_layouts_with_possible_positive_sidbs.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/experiments/sidb_simulation/runtime_analysis_layouts_with_possible_positive_sidbs.cpp b/experiments/sidb_simulation/runtime_analysis_layouts_with_possible_positive_sidbs.cpp index f66679ba9..92282c5d8 100644 --- a/experiments/sidb_simulation/runtime_analysis_layouts_with_possible_positive_sidbs.cpp +++ b/experiments/sidb_simulation/runtime_analysis_layouts_with_possible_positive_sidbs.cpp @@ -14,9 +14,9 @@ using namespace fiction; -// This script compares the simulation runtime of the exhaustive and QuickExact simulation algorithms for randomly +// This script compares the simulation runtime of ExGS and QuickExact for randomly // generated layouts that may contain positively charged SiDBs (`can_positive_charges_occur` returns `true`). The number -// of SiDBs in the layout is varied from 5 to 20. +// of SiDBs in the layout varies from 5 to 20. int main() // NOLINT { From 73e29df326aaccf44c4768678e12b7f4faa36b65 Mon Sep 17 00:00:00 2001 From: Drewniok Date: Wed, 4 Sep 2024 08:14:13 +0200 Subject: [PATCH 14/32] :art: small fix. --- .../algorithms/simulation/sidb/random_sidb_layout_generator.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/fiction/algorithms/simulation/sidb/random_sidb_layout_generator.hpp b/include/fiction/algorithms/simulation/sidb/random_sidb_layout_generator.hpp index 6adf440ee..b634fb37c 100644 --- a/include/fiction/algorithms/simulation/sidb/random_sidb_layout_generator.hpp +++ b/include/fiction/algorithms/simulation/sidb/random_sidb_layout_generator.hpp @@ -184,7 +184,7 @@ generate_multiple_random_sidb_layouts(const Lyt& const auto random_lyt = generate_random_sidb_layout(lyt_skeleton, params); // indicates if a found SiDB layout is identical to an already found one. - const auto identical_layout = std::any_of(unique_lyts.begin(), unique_lyts.end(), [&](const auto& old_lyt) + const auto identical_layout = std::any_of(unique_lyts.cbegin(), unique_lyts.cend(), [&](const auto& old_lyt) { return are_layouts_identical(random_lyt, old_lyt); }); // if the randomly generated SiDB layout is not identical to a previously generated one, it is added to the From 415c9eac1ca0b386c786d322c7e13dd93c5aaab7 Mon Sep 17 00:00:00 2001 From: Drewniok Date: Thu, 5 Sep 2024 08:09:37 +0200 Subject: [PATCH 15/32] :art: small fix. --- .../algorithms/simulation/sidb/random_sidb_layout_generator.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/fiction/algorithms/simulation/sidb/random_sidb_layout_generator.hpp b/include/fiction/algorithms/simulation/sidb/random_sidb_layout_generator.hpp index b634fb37c..3ce036236 100644 --- a/include/fiction/algorithms/simulation/sidb/random_sidb_layout_generator.hpp +++ b/include/fiction/algorithms/simulation/sidb/random_sidb_layout_generator.hpp @@ -113,7 +113,7 @@ Lyt generate_random_sidb_layout(const Lyt& // stops if either all SiDBs are placed or the maximum number of attempts was performed while (lyt.num_cells() < number_of_sidbs_of_final_layout && attempt_counter < params.maximal_attempts) { - // random coordinate within given area + // random coordinate within the area specified by two coordinates const auto random_coord = random_coordinate(params.coordinate_pair.first, params.coordinate_pair.second); bool next_to_neutral_defect = false; From 6893c2bfa72e1a09ccf219cdffac68b840a2f449 Mon Sep 17 00:00:00 2001 From: Drewniok Date: Sun, 8 Sep 2024 13:59:53 +0200 Subject: [PATCH 16/32] :art: move files. --- .../runtime_analysis_bestagon_gates.cpp | 0 .../runtime_analysis_layouts_with_possible_positive_sidbs.cpp | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename experiments/sidb_simulation/{ => electrostatic_ground_state}/runtime_analysis_bestagon_gates.cpp (100%) rename experiments/sidb_simulation/{ => electrostatic_ground_state}/runtime_analysis_layouts_with_possible_positive_sidbs.cpp (100%) diff --git a/experiments/sidb_simulation/runtime_analysis_bestagon_gates.cpp b/experiments/sidb_simulation/electrostatic_ground_state/runtime_analysis_bestagon_gates.cpp similarity index 100% rename from experiments/sidb_simulation/runtime_analysis_bestagon_gates.cpp rename to experiments/sidb_simulation/electrostatic_ground_state/runtime_analysis_bestagon_gates.cpp diff --git a/experiments/sidb_simulation/runtime_analysis_layouts_with_possible_positive_sidbs.cpp b/experiments/sidb_simulation/electrostatic_ground_state/runtime_analysis_layouts_with_possible_positive_sidbs.cpp similarity index 100% rename from experiments/sidb_simulation/runtime_analysis_layouts_with_possible_positive_sidbs.cpp rename to experiments/sidb_simulation/electrostatic_ground_state/runtime_analysis_layouts_with_possible_positive_sidbs.cpp From f716b78e1f899ee18ffb7c2157fe93b18eb951dd Mon Sep 17 00:00:00 2001 From: Drewniok Date: Sun, 8 Sep 2024 16:45:04 +0200 Subject: [PATCH 17/32] :art: simplify params. --- .../physical_design/design_sidb_gates.hpp | 10 +-- .../physical_design/design_sidb_gates.hpp | 21 ++--- .../physical_design/design_sidb_gates.cpp | 79 ++++++++----------- 3 files changed, 45 insertions(+), 65 deletions(-) diff --git a/bindings/pyfiction/include/pyfiction/algorithms/physical_design/design_sidb_gates.hpp b/bindings/pyfiction/include/pyfiction/algorithms/physical_design/design_sidb_gates.hpp index 56618ee37..5497b7dd5 100644 --- a/bindings/pyfiction/include/pyfiction/algorithms/physical_design/design_sidb_gates.hpp +++ b/bindings/pyfiction/include/pyfiction/algorithms/physical_design/design_sidb_gates.hpp @@ -50,18 +50,16 @@ inline void design_sidb_gates(pybind11::module& m) py::class_>(m, "design_sidb_gates_params", DOC(fiction_design_sidb_gates_params)) .def(py::init<>()) - .def_readwrite("simulation_parameters", - &fiction::design_sidb_gates_params::simulation_parameters, - DOC(fiction_design_sidb_gates_params)) + .def_readwrite("is_operational_params", + &fiction::design_sidb_gates_params::operational_params, + DOC(fiction_design_sidb_gates_params_operational_params)) .def_readwrite("design_mode", &fiction::design_sidb_gates_params::design_mode, DOC(fiction_design_sidb_gates_params_design_mode)) .def_readwrite("canvas", &fiction::design_sidb_gates_params::canvas, DOC(fiction_design_sidb_gates_params_canvas)) .def_readwrite("number_of_sidbs", &fiction::design_sidb_gates_params::number_of_sidbs, - DOC(fiction_design_sidb_gates_params_number_of_sidbs)) - .def_readwrite("sim_engine", &fiction::design_sidb_gates_params::sim_engine, - DOC(fiction_design_sidb_gates_params_sim_engine)); + DOC(fiction_design_sidb_gates_params_number_of_sidbs)); detail::design_sidb_gates(m); detail::design_sidb_gates(m); diff --git a/include/fiction/algorithms/physical_design/design_sidb_gates.hpp b/include/fiction/algorithms/physical_design/design_sidb_gates.hpp index 820589baf..a1f35acb9 100644 --- a/include/fiction/algorithms/physical_design/design_sidb_gates.hpp +++ b/include/fiction/algorithms/physical_design/design_sidb_gates.hpp @@ -43,7 +43,6 @@ namespace fiction template struct design_sidb_gates_params { - // TODO (Jan Drewniok): After PR481 is merged, add bdl_input_iterator_params. /** * Selector for the different termination conditions for the SiDB gate design process. */ @@ -73,9 +72,9 @@ struct design_sidb_gates_params RANDOM }; /** - * All Parameters for physical SiDB simulations. + * Parameter for the `is_operational` function. */ - sidb_simulation_parameters simulation_parameters{}; + is_operational_params operational_params{}; /** * Gate design mode. */ @@ -88,10 +87,6 @@ struct design_sidb_gates_params * Number of SiDBs placed in the canvas to create a working gate. */ std::size_t number_of_sidbs = 1; - /** - * The simulation engine to be used for the operational domain computation. - */ - sidb_simulation_engine sim_engine{sidb_simulation_engine::QUICKEXACT}; /** * The design process is terminated after a valid SiDB gate design is found. * @@ -132,8 +127,6 @@ class design_sidb_gates_impl */ [[nodiscard]] std::vector run_exhaustive_design() noexcept { - const is_operational_params params_is_operational{params.simulation_parameters, params.sim_engine}; - auto all_combinations = determine_all_combinations_of_distributing_k_entities_on_n_positions( params.number_of_sidbs, static_cast(all_sidbs_in_canvas.size())); std::unordered_set> sidbs_affected_by_defects = {}; @@ -153,7 +146,7 @@ class design_sidb_gates_impl std::default_random_engine(std::random_device{}())); const auto add_combination_to_layout_and_check_operation = - [this, &mutex_to_protect_designed_gate_layouts, ¶ms_is_operational, &designed_gate_layouts, + [this, &mutex_to_protect_designed_gate_layouts, &designed_gate_layouts, &sidbs_affected_by_defects, &solution_found](const auto& combination) noexcept { for (const auto& comb : combination) @@ -165,7 +158,7 @@ class design_sidb_gates_impl auto layout_with_added_cells = add_canvas_sidbs_to_skeleton_layout(comb); if (const auto [status, sim_calls] = - is_operational(layout_with_added_cells, truth_table, params_is_operational); + is_operational(layout_with_added_cells, truth_table, params.operational_params); status == operational_status::OPERATIONAL) { { @@ -227,8 +220,6 @@ class design_sidb_gates_impl { std::vector randomly_designed_gate_layouts = {}; - const is_operational_params params_is_operational{params.simulation_parameters, params.sim_engine}; - const generate_random_sidb_layout_params> parameter_random_layout{ params.canvas, params.number_of_sidbs, generate_random_sidb_layout_params>::positive_charges::FORBIDDEN}; @@ -244,7 +235,7 @@ class design_sidb_gates_impl { threads.emplace_back( [this, &gate_layout_is_found, &mutex_to_protect_designed_gate_layouts, ¶meter_random_layout, - ¶ms_is_operational, &randomly_designed_gate_layouts] + &randomly_designed_gate_layouts] { while (!gate_layout_is_found) { @@ -261,7 +252,7 @@ class design_sidb_gates_impl }); } if (const auto [status, sim_calls] = - is_operational(result_lyt, truth_table, params_is_operational); + is_operational(result_lyt, truth_table, params.operational_params); status == operational_status::OPERATIONAL) { const std::lock_guard lock{mutex_to_protect_designed_gate_layouts}; diff --git a/test/algorithms/physical_design/design_sidb_gates.cpp b/test/algorithms/physical_design/design_sidb_gates.cpp index 537433438..b44c04f51 100644 --- a/test/algorithms/physical_design/design_sidb_gates.cpp +++ b/test/algorithms/physical_design/design_sidb_gates.cpp @@ -53,11 +53,10 @@ TEST_CASE("Use SiQAD XNOR skeleton and generate SiQAD XNOR gate, exhaustive", "[ CHECK(lyt.num_cells() == 13); design_sidb_gates_params> params{ - sidb_simulation_parameters{2, -0.32}, + is_operational_params{sidb_simulation_parameters{2, -0.32}}, design_sidb_gates_params>::design_sidb_gates_mode::EXHAUSTIVE, {{10, 4, 0}, {10, 4, 0}}, - 1, - sidb_simulation_engine::QUICKEXACT}; + 1}; SECTION("One cell in canvas") { @@ -70,12 +69,11 @@ TEST_CASE("Use SiQAD XNOR skeleton and generate SiQAD XNOR gate, exhaustive", "[ // using cube coordinates const auto lyt_in_cube_coord = convert_layout_to_fiction_coordinates(lyt); const design_sidb_gates_params> params_cube{ - sidb_simulation_parameters{2, -0.32}, + is_operational_params{sidb_simulation_parameters{2, -0.32}}, design_sidb_gates_params>::design_sidb_gates_mode::EXHAUSTIVE, {siqad::to_fiction_coord(siqad::coord_t{10, 4, 0}), siqad::to_fiction_coord(siqad::coord_t{10, 4, 0})}, - 1, - sidb_simulation_engine::QUICKEXACT}; + 1}; const auto found_gate_layouts_cube = design_sidb_gates(lyt_in_cube_coord, std::vector{create_xnor_tt()}, params_cube); @@ -88,12 +86,11 @@ TEST_CASE("Use SiQAD XNOR skeleton and generate SiQAD XNOR gate, exhaustive", "[ // using offset coordinates const auto lyt_in_offset_coord = convert_layout_to_fiction_coordinates(lyt); const design_sidb_gates_params> params_offset{ - sidb_simulation_parameters{2, -0.32}, + is_operational_params{sidb_simulation_parameters{2, -0.32}}, design_sidb_gates_params>::design_sidb_gates_mode::EXHAUSTIVE, {siqad::to_fiction_coord(siqad::coord_t{10, 4, 0}), siqad::to_fiction_coord(siqad::coord_t{10, 4, 0})}, - 1, - sidb_simulation_engine::QUICKEXACT}; + 1}; const auto found_gate_layouts_offset = design_sidb_gates(lyt_in_offset_coord, std::vector{create_xnor_tt()}, params_offset); @@ -106,11 +103,10 @@ TEST_CASE("Use SiQAD XNOR skeleton and generate SiQAD XNOR gate, exhaustive", "[ SECTION("Four cells in canvas, design all gates") { params = design_sidb_gates_params>{ - sidb_simulation_parameters{2, -0.32}, + is_operational_params{sidb_simulation_parameters{2, -0.32}}, design_sidb_gates_params>::design_sidb_gates_mode::EXHAUSTIVE, {{10, 4, 0}, {13, 4, 0}}, - 1, - sidb_simulation_engine::QUICKEXACT}; + 1}; const auto found_gate_layouts = design_sidb_gates(lyt, std::vector{create_xnor_tt()}, params); @@ -119,11 +115,10 @@ TEST_CASE("Use SiQAD XNOR skeleton and generate SiQAD XNOR gate, exhaustive", "[ SECTION("Four cells in canvas, design process is terminated after first solution is found") { params = design_sidb_gates_params>{ - sidb_simulation_parameters{2, -0.32}, + is_operational_params{sidb_simulation_parameters{2, -0.32}}, design_sidb_gates_params>::design_sidb_gates_mode::EXHAUSTIVE, {{10, 4, 0}, {10, 4, 0}}, 1, - sidb_simulation_engine::QUICKEXACT, design_sidb_gates_params>::termination_condition::AFTER_FIRST_SOLUTION}; const auto found_gate_layouts = design_sidb_gates(lyt, std::vector{create_xnor_tt()}, params); @@ -156,11 +151,10 @@ TEST_CASE("Use SiQAD's AND gate skeleton to generate all possible AND gates", "[ lyt.assign_cell_type({10, 9, 1}, sidb_technology::cell_type::NORMAL); design_sidb_gates_params> params{ - sidb_simulation_parameters{2, -0.28}, + is_operational_params{sidb_simulation_parameters{2, -0.28}, sidb_simulation_engine::EXGS}, design_sidb_gates_params>::design_sidb_gates_mode::EXHAUSTIVE, {{4, 4, 0}, {14, 5, 1}}, - 1, - sidb_simulation_engine::EXGS}; + 1}; SECTION("Exhaustive Generation") { @@ -214,11 +208,10 @@ TEST_CASE("Use FO2 Bestagon gate without SiDB at {17, 11, 0} and generate origin SECTION("generate original FO2") { const design_sidb_gates_params> params{ - sidb_simulation_parameters{2, -0.32}, + is_operational_params{sidb_simulation_parameters{2, -0.32}}, design_sidb_gates_params>::design_sidb_gates_mode::EXHAUSTIVE, {{17, 11, 0}, {17, 11, 0}}, - 1, - sidb_simulation_engine::QUICKEXACT}; + 1}; CHECK(lyt.get_cell_type({17, 11, 0}) == sidb_100_cell_clk_lyt_siqad::technology::EMPTY); @@ -234,11 +227,10 @@ TEST_CASE("Use FO2 Bestagon gate without SiDB at {17, 11, 0} and generate origin SECTION("replace the output perturbers by equivalent negatively charged defects") { const design_sidb_gates_params> params{ - sidb_simulation_parameters{2, -0.32}, + is_operational_params{sidb_simulation_parameters{2, -0.32}}, design_sidb_gates_params>::design_sidb_gates_mode::EXHAUSTIVE, {{17, 11, 0}, {17, 11, 0}}, - 1, - sidb_simulation_engine::QUICKEXACT}; + 1}; sidb_defect_surface defect_layout{lyt}; defect_layout.assign_cell_type({36, 19, 0}, sidb_100_cell_clk_lyt_siqad::cell_type::EMPTY); @@ -247,11 +239,12 @@ TEST_CASE("Use FO2 Bestagon gate without SiDB at {17, 11, 0} and generate origin CHECK(defect_layout.get_cell_type({2, 19, 0}) == sidb_100_cell_clk_lyt_siqad::cell_type::EMPTY); defect_layout.assign_sidb_defect({36, 19, 0}, - sidb_defect{sidb_defect_type::DB, -1, params.simulation_parameters.epsilon_r, - params.simulation_parameters.lambda_tf}); - defect_layout.assign_sidb_defect({2, 19, 0}, - sidb_defect{sidb_defect_type::DB, -1, params.simulation_parameters.epsilon_r, - params.simulation_parameters.lambda_tf}); + sidb_defect{sidb_defect_type::DB, -1, + params.operational_params.simulation_parameters.epsilon_r, + params.operational_params.simulation_parameters.lambda_tf}); + defect_layout.assign_sidb_defect( + {2, 19, 0}, sidb_defect{sidb_defect_type::DB, -1, params.operational_params.simulation_parameters.epsilon_r, + params.operational_params.simulation_parameters.lambda_tf}); const auto found_gate_layouts = design_sidb_gates(defect_layout, std::vector{create_fan_out_tt()}, params); @@ -293,11 +286,10 @@ TEST_CASE("Design AND Bestagon shaped gate", "[design-sidb-gates]") SECTION("Random Generation") { const design_sidb_gates_params> params{ - sidb_simulation_parameters{2, -0.32}, + is_operational_params{sidb_simulation_parameters{2, -0.32}}, design_sidb_gates_params>::design_sidb_gates_mode::RANDOM, {{14, 6, 0}, {24, 12, 0}}, - 3, - sidb_simulation_engine::QUICKEXACT}; + 3}; const auto found_gate_layouts = design_sidb_gates(lyt, std::vector{create_and_tt()}, params); REQUIRE(!found_gate_layouts.empty()); @@ -309,18 +301,19 @@ TEST_CASE("Design AND Bestagon shaped gate", "[design-sidb-gates]") sidb_defect_surface defect_layout{lyt}; const design_sidb_gates_params> params{ - sidb_simulation_parameters{2, -0.32}, + is_operational_params{sidb_simulation_parameters{2, -0.32}}, design_sidb_gates_params>::design_sidb_gates_mode::RANDOM, {{14, 6, 0}, {24, 12, 0}}, - 3, - sidb_simulation_engine::QUICKEXACT}; + 3}; defect_layout.assign_sidb_defect({15, 10, 0}, - sidb_defect{sidb_defect_type::DB, -1, params.simulation_parameters.epsilon_r, - params.simulation_parameters.lambda_tf}); + sidb_defect{sidb_defect_type::DB, -1, + params.operational_params.simulation_parameters.epsilon_r, + params.operational_params.simulation_parameters.lambda_tf}); defect_layout.assign_sidb_defect({20, 12, 0}, - sidb_defect{sidb_defect_type::DB, -1, params.simulation_parameters.epsilon_r, - params.simulation_parameters.lambda_tf}); + sidb_defect{sidb_defect_type::DB, -1, + params.operational_params.simulation_parameters.epsilon_r, + params.operational_params.simulation_parameters.lambda_tf}); defect_layout.assign_sidb_defect({23, 12, 0}, sidb_defect{sidb_defect_type::GUNK}); const auto found_gate_layouts = design_sidb_gates(defect_layout, std::vector{create_and_tt()}, params); @@ -370,11 +363,10 @@ TEST_CASE("Design AND Bestagon shaped gate on H-Si 111", "[design-sidb-gates]") SECTION("Random Generation") { const design_sidb_gates_params> params{ - sidb_simulation_parameters{2, -0.32}, + is_operational_params{sidb_simulation_parameters{2, -0.32}}, design_sidb_gates_params>::design_sidb_gates_mode::RANDOM, {{10, 11, 0}, {14, 15, 0}}, - 3, - sidb_simulation_engine::QUICKEXACT}; + 3}; const auto found_gate_layouts = design_sidb_gates(lyt, std::vector{create_nor_tt()}, params); REQUIRE(!found_gate_layouts.empty()); @@ -384,11 +376,10 @@ TEST_CASE("Design AND Bestagon shaped gate on H-Si 111", "[design-sidb-gates]") SECTION("Exhaustive Generation") { const design_sidb_gates_params> params{ - sidb_simulation_parameters{2, -0.32}, + is_operational_params{sidb_simulation_parameters{2, -0.32}}, design_sidb_gates_params>::design_sidb_gates_mode::EXHAUSTIVE, {{11, 11, 0}, {14, 16, 0}}, - 3, - sidb_simulation_engine::QUICKEXACT}; + 3}; const auto found_gate_layouts = design_sidb_gates(lyt, std::vector{create_nor_tt()}, params); REQUIRE(found_gate_layouts.size() == 52); From 1f99c790f0186026916ec567a8bcab6211652381 Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Sun, 8 Sep 2024 14:45:50 +0000 Subject: [PATCH 18/32] :memo: Update pyfiction docstrings Signed-off-by: GitHub Actions --- .../include/pyfiction/pybind11_mkdoc_docstrings.hpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/bindings/pyfiction/include/pyfiction/pybind11_mkdoc_docstrings.hpp b/bindings/pyfiction/include/pyfiction/pybind11_mkdoc_docstrings.hpp index fb83ec094..98ca2d807 100644 --- a/bindings/pyfiction/include/pyfiction/pybind11_mkdoc_docstrings.hpp +++ b/bindings/pyfiction/include/pyfiction/pybind11_mkdoc_docstrings.hpp @@ -3514,11 +3514,7 @@ static const char *__doc_fiction_design_sidb_gates_params_design_sidb_gates_mode static const char *__doc_fiction_design_sidb_gates_params_number_of_sidbs = R"doc(Number of SiDBs placed in the canvas to create a working gate.)doc"; -static const char *__doc_fiction_design_sidb_gates_params_sim_engine = -R"doc(The simulation engine to be used for the operational domain -computation.)doc"; - -static const char *__doc_fiction_design_sidb_gates_params_simulation_parameters = R"doc(All Parameters for physical SiDB simulations.)doc"; +static const char *__doc_fiction_design_sidb_gates_params_operational_params = R"doc(Parameter for the `is_operational` function.)doc"; static const char *__doc_fiction_design_sidb_gates_params_termination_cond = R"doc(The design process is terminated after a valid SiDB gate design is From 43ac0bb9affe4beb8509ddfa5ed45cc70c3788da Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 8 Sep 2024 14:45:52 +0000 Subject: [PATCH 19/32] =?UTF-8?q?=F0=9F=8E=A8=20Incorporated=20pre-commit?= =?UTF-8?q?=20fixes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../algorithms/physical_design/design_sidb_gates.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/fiction/algorithms/physical_design/design_sidb_gates.hpp b/include/fiction/algorithms/physical_design/design_sidb_gates.hpp index a1f35acb9..2167791ce 100644 --- a/include/fiction/algorithms/physical_design/design_sidb_gates.hpp +++ b/include/fiction/algorithms/physical_design/design_sidb_gates.hpp @@ -145,9 +145,9 @@ class design_sidb_gates_impl std::shuffle(all_combinations.begin(), all_combinations.end(), std::default_random_engine(std::random_device{}())); - const auto add_combination_to_layout_and_check_operation = - [this, &mutex_to_protect_designed_gate_layouts, &designed_gate_layouts, - &sidbs_affected_by_defects, &solution_found](const auto& combination) noexcept + const auto add_combination_to_layout_and_check_operation = [this, &mutex_to_protect_designed_gate_layouts, + &designed_gate_layouts, &sidbs_affected_by_defects, + &solution_found](const auto& combination) noexcept { for (const auto& comb : combination) { From 2ef53e6dcb03bc74b85abe3352acba3224b78e0a Mon Sep 17 00:00:00 2001 From: Drewniok Date: Mon, 9 Sep 2024 13:07:07 +0200 Subject: [PATCH 20/32] :snake: small fix. --- .../physical_design/design_sidb_gates.hpp | 2 +- .../physical_design/test_design_sidb_gates.py | 16 ++++++++-------- ...ysis_layouts_with_possible_positive_sidbs.cpp | 7 +++++-- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/bindings/pyfiction/include/pyfiction/algorithms/physical_design/design_sidb_gates.hpp b/bindings/pyfiction/include/pyfiction/algorithms/physical_design/design_sidb_gates.hpp index 5497b7dd5..c4fbf1598 100644 --- a/bindings/pyfiction/include/pyfiction/algorithms/physical_design/design_sidb_gates.hpp +++ b/bindings/pyfiction/include/pyfiction/algorithms/physical_design/design_sidb_gates.hpp @@ -50,7 +50,7 @@ inline void design_sidb_gates(pybind11::module& m) py::class_>(m, "design_sidb_gates_params", DOC(fiction_design_sidb_gates_params)) .def(py::init<>()) - .def_readwrite("is_operational_params", + .def_readwrite("operational_params", &fiction::design_sidb_gates_params::operational_params, DOC(fiction_design_sidb_gates_params_operational_params)) .def_readwrite("design_mode", &fiction::design_sidb_gates_params::design_mode, diff --git a/bindings/pyfiction/test/algorithms/physical_design/test_design_sidb_gates.py b/bindings/pyfiction/test/algorithms/physical_design/test_design_sidb_gates.py index 299af40a2..9a0292bf8 100644 --- a/bindings/pyfiction/test/algorithms/physical_design/test_design_sidb_gates.py +++ b/bindings/pyfiction/test/algorithms/physical_design/test_design_sidb_gates.py @@ -26,14 +26,14 @@ def test_siqad_and_gate_skeleton_100(self): layout.assign_cell_type((10, 19), sidb_technology.cell_type.NORMAL) params = design_sidb_gates_params() - params.simulation_parameters.base = 2 - params.simulation_parameters.mu_minus = -0.28 + params.operational_params.simulation_parameters.base = 2 + params.operational_params.simulation_parameters.mu_minus = -0.28 params.design_mode = design_sidb_gates_mode.EXHAUSTIVE params.canvas = [(4, 8), (14, 11)] params.number_of_sidbs = 1 - params.sim_engine = sidb_simulation_engine.QUICKEXACT + params.operational_params.sim_engine = sidb_simulation_engine.QUICKEXACT - self.assertEqual(params.simulation_parameters.mu_minus, -0.28) + self.assertEqual(params.operational_params.simulation_parameters.mu_minus, -0.28) self.assertEqual(params.number_of_sidbs, 1) self.assertEqual(params.canvas[0], (4, 8, 0)) self.assertEqual(params.canvas[1], (14, 11)) @@ -72,14 +72,14 @@ def test_nor_gate_111(self): layout.assign_cell_type((23, 59), sidb_technology.cell_type.NORMAL) params = design_sidb_gates_params() - params.simulation_parameters.base = 2 - params.simulation_parameters.mu_minus = -0.32 + params.operational_params.simulation_parameters.base = 2 + params.operational_params.simulation_parameters.mu_minus = -0.32 params.design_mode = design_sidb_gates_mode.EXHAUSTIVE params.canvas = [(10, 22), (14, 34)] params.number_of_sidbs = 3 - params.sim_engine = sidb_simulation_engine.QUICKEXACT + params.operational_params.sim_engine = sidb_simulation_engine.QUICKEXACT - self.assertEqual(params.simulation_parameters.mu_minus, -0.32) + self.assertEqual(params.operational_params.simulation_parameters.mu_minus, -0.32) self.assertEqual(params.number_of_sidbs, 3) self.assertEqual(params.canvas[0], (10, 22, 0)) self.assertEqual(params.canvas[1], (14, 34)) diff --git a/experiments/sidb_simulation/electrostatic_ground_state/runtime_analysis_layouts_with_possible_positive_sidbs.cpp b/experiments/sidb_simulation/electrostatic_ground_state/runtime_analysis_layouts_with_possible_positive_sidbs.cpp index 92282c5d8..1086d306f 100644 --- a/experiments/sidb_simulation/electrostatic_ground_state/runtime_analysis_layouts_with_possible_positive_sidbs.cpp +++ b/experiments/sidb_simulation/electrostatic_ground_state/runtime_analysis_layouts_with_possible_positive_sidbs.cpp @@ -11,6 +11,9 @@ #include "mockturtle/utils/stopwatch.hpp" #include +#include +#include +#include using namespace fiction; @@ -70,8 +73,8 @@ int main() // NOLINT runtime_quickexact += mockturtle::to_seconds(quickexact_results_layout.simulation_runtime); } - const auto average_pos_sibs_of_gs = std::accumulate(number_of_positive_sidbs_of_gs_per_layout.cbegin(), - number_of_positive_sidbs_of_gs_per_layout.cend(), 0) / + const auto average_pos_sibs_of_gs = static_cast(std::accumulate(number_of_positive_sidbs_of_gs_per_layout.cbegin(), + number_of_positive_sidbs_of_gs_per_layout.cend(), 0)) / static_cast(number_of_positive_sidbs_of_gs_per_layout.size()); simulation_exp(random_layouts_params.number_of_sidbs, random_layouts.size(), runtime_exhaustive, From 7aedb4dfcf9fe716cf0f5e4cfbb697cac0ad6e62 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 9 Sep 2024 11:08:54 +0000 Subject: [PATCH 21/32] =?UTF-8?q?=F0=9F=8E=A8=20Incorporated=20pre-commit?= =?UTF-8?q?=20fixes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ..._analysis_layouts_with_possible_positive_sidbs.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/experiments/sidb_simulation/electrostatic_ground_state/runtime_analysis_layouts_with_possible_positive_sidbs.cpp b/experiments/sidb_simulation/electrostatic_ground_state/runtime_analysis_layouts_with_possible_positive_sidbs.cpp index 1086d306f..5a613364f 100644 --- a/experiments/sidb_simulation/electrostatic_ground_state/runtime_analysis_layouts_with_possible_positive_sidbs.cpp +++ b/experiments/sidb_simulation/electrostatic_ground_state/runtime_analysis_layouts_with_possible_positive_sidbs.cpp @@ -10,10 +10,10 @@ #include "fiction_experiments.hpp" #include "mockturtle/utils/stopwatch.hpp" -#include #include -#include +#include #include +#include using namespace fiction; @@ -73,9 +73,10 @@ int main() // NOLINT runtime_quickexact += mockturtle::to_seconds(quickexact_results_layout.simulation_runtime); } - const auto average_pos_sibs_of_gs = static_cast(std::accumulate(number_of_positive_sidbs_of_gs_per_layout.cbegin(), - number_of_positive_sidbs_of_gs_per_layout.cend(), 0)) / - static_cast(number_of_positive_sidbs_of_gs_per_layout.size()); + const auto average_pos_sibs_of_gs = + static_cast(std::accumulate(number_of_positive_sidbs_of_gs_per_layout.cbegin(), + number_of_positive_sidbs_of_gs_per_layout.cend(), 0)) / + static_cast(number_of_positive_sidbs_of_gs_per_layout.size()); simulation_exp(random_layouts_params.number_of_sidbs, random_layouts.size(), runtime_exhaustive, runtime_quickexact, average_pos_sibs_of_gs); From d6d1cd815925a070adc657194687cd86af38e8ba Mon Sep 17 00:00:00 2001 From: Drewniok Date: Mon, 9 Sep 2024 13:46:23 +0200 Subject: [PATCH 22/32] :art: small fix in the experiment script. --- .../physical_design_with_on_the_fly_gate_design.cpp | 4 ++-- .../technology/sidb_on_the_fly_gate_library.hpp | 12 +++++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/experiments/physical_design_with_on_the_fly_gate_design/physical_design_with_on_the_fly_gate_design.cpp b/experiments/physical_design_with_on_the_fly_gate_design/physical_design_with_on_the_fly_gate_design.cpp index baea44fb1..505e2d715 100644 --- a/experiments/physical_design_with_on_the_fly_gate_design/physical_design_with_on_the_fly_gate_design.cpp +++ b/experiments/physical_design_with_on_the_fly_gate_design/physical_design_with_on_the_fly_gate_design.cpp @@ -48,12 +48,12 @@ int main() // NOLINT using cell_lyt = fiction::sidb_cell_clk_lyt_cube; fiction::design_sidb_gates_params> design_gate_params{}; - design_gate_params.simulation_parameters = fiction::sidb_simulation_parameters{2, -0.32}; + design_gate_params.operational_params.simulation_parameters = fiction::sidb_simulation_parameters{2, -0.32}; // needs to be changed if a different skeleton is used. design_gate_params.canvas = {{24, 17}, {34, 28}}; design_gate_params.number_of_sidbs = 3; - design_gate_params.sim_engine = fiction::sidb_simulation_engine::QUICKEXACT; + design_gate_params.operational_params.sim_engine = fiction::sidb_simulation_engine::QUICKEXACT; design_gate_params.termination_cond = fiction::design_sidb_gates_params>::termination_condition::AFTER_FIRST_SOLUTION; diff --git a/include/fiction/technology/sidb_on_the_fly_gate_library.hpp b/include/fiction/technology/sidb_on_the_fly_gate_library.hpp index a0240eead..6058a2770 100644 --- a/include/fiction/technology/sidb_on_the_fly_gate_library.hpp +++ b/include/fiction/technology/sidb_on_the_fly_gate_library.hpp @@ -431,10 +431,11 @@ class sidb_on_the_fly_gate_library : public fcn_gate_library(status == operational_status::OPERATIONAL); } /** @@ -494,7 +495,8 @@ class sidb_on_the_fly_gate_library : public fcn_gate_library, "CellLyt is not an SiDB layout"); static_assert(has_cube_coord_v, "CellLyt is not based on cube coordinates"); - const auto params = is_sidb_gate_design_impossible_params{parameters.design_gate_params.simulation_parameters}; + const auto params = is_sidb_gate_design_impossible_params{ + parameters.design_gate_params.operational_params.simulation_parameters}; if (spec == create_crossing_wire_tt() || spec == create_double_wire_tt()) { From b4db8b2f7f8fefac5bfb74bc44f1128f01441276 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 9 Sep 2024 11:46:43 +0000 Subject: [PATCH 23/32] =?UTF-8?q?=F0=9F=8E=A8=20Incorporated=20pre-commit?= =?UTF-8?q?=20fixes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../physical_design_with_on_the_fly_gate_design.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/experiments/physical_design_with_on_the_fly_gate_design/physical_design_with_on_the_fly_gate_design.cpp b/experiments/physical_design_with_on_the_fly_gate_design/physical_design_with_on_the_fly_gate_design.cpp index 505e2d715..d72e8b854 100644 --- a/experiments/physical_design_with_on_the_fly_gate_design/physical_design_with_on_the_fly_gate_design.cpp +++ b/experiments/physical_design_with_on_the_fly_gate_design/physical_design_with_on_the_fly_gate_design.cpp @@ -52,8 +52,8 @@ int main() // NOLINT // needs to be changed if a different skeleton is used. design_gate_params.canvas = {{24, 17}, {34, 28}}; - design_gate_params.number_of_sidbs = 3; - design_gate_params.operational_params.sim_engine = fiction::sidb_simulation_engine::QUICKEXACT; + design_gate_params.number_of_sidbs = 3; + design_gate_params.operational_params.sim_engine = fiction::sidb_simulation_engine::QUICKEXACT; design_gate_params.termination_cond = fiction::design_sidb_gates_params>::termination_condition::AFTER_FIRST_SOLUTION; From 6c78be98d8a7ae630be77feb93f5d8e5869a6680 Mon Sep 17 00:00:00 2001 From: Drewniok Date: Mon, 9 Sep 2024 19:46:58 +0200 Subject: [PATCH 24/32] :white_check_mark: add more test cases and small fixes. --- .../runtime_analysis_bestagon_gates.cpp | 116 ++++++++++++++++++ ...s_layouts_with_possible_positive_sidbs.cpp | 16 +-- ...itical_temperature_simulation_bestagon.cpp | 1 - .../simulation/sidb/critical_temperature.hpp | 5 +- test/utils/layout_utils.cpp | 13 +- 5 files changed, 138 insertions(+), 13 deletions(-) create mode 100644 experiments/sidb_simulation/electrostatic_ground_state/runtime_analysis_bestagon_gates.cpp diff --git a/experiments/sidb_simulation/electrostatic_ground_state/runtime_analysis_bestagon_gates.cpp b/experiments/sidb_simulation/electrostatic_ground_state/runtime_analysis_bestagon_gates.cpp new file mode 100644 index 000000000..ca0b8cef2 --- /dev/null +++ b/experiments/sidb_simulation/electrostatic_ground_state/runtime_analysis_bestagon_gates.cpp @@ -0,0 +1,116 @@ +// +// Created by Jan Drewniok on 17.05.24. +// + +#include "fiction_experiments.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include +#include +#include + +using namespace fiction; + +int main() // NOLINT +{ + experiments::experiment simulation_exp{ + "Benchmark", + "Gate Name", + "#Instances", + "Exhaustive Runtime [s]", + "QuickExact Runtime [s]", + "Average QuickSim Accuracy", + "QuickSim Single Runtime [s]", + "Total QuickSim TTS [s]"}; + + static const std::string folder = fmt::format("{}bestagon_gates_type_tags/", EXPERIMENTS_PATH); + + static const std::array>, 12> gates = { + std::make_pair("hourglass", create_crossing_wire_tt()), + std::make_pair("cx", create_crossing_wire_tt()), + std::make_pair("ha", create_half_adder_tt()), + std::make_pair("and", std::vector{create_and_tt()}), + std::make_pair("xor", std::vector{create_xor_tt()}), + std::make_pair("or", std::vector{create_or_tt()}), + std::make_pair("xnor", std::vector{create_xnor_tt()}), + std::make_pair("fo2", std::vector{create_fan_out_tt()}), + std::make_pair("nor", std::vector{create_nor_tt()}), + std::make_pair("nand", std::vector{create_nand_tt()}), + std::make_pair("inv", std::vector{create_not_tt()}), + std::make_pair("wire", std::vector{create_id_tt()})}; + + const sidb_simulation_parameters sim_params{2, -0.32}; + const quicksim_params qs_params{sim_params}; + const quickexact_params qe_params{sim_params}; + const time_to_solution_params tts_params{}; + + for (const auto& [gate, truth_table] : gates) + { + for (const auto& file : std::filesystem::directory_iterator(fmt::format("{}{}", folder, gate))) + { + const auto layout = read_sqd_layout(file.path().string()); + + double runtime_exhaustive = 0; + double runtime_quickexact = 0; + double tts_quicksim = 0; + std::size_t instances = 0; + double quicksim_accuracy_mean = 0.0; + double quicksim_single_runtime = 0.0; + + // simulate layout with no input pattern + const auto exhaustive_results_layout = exhaustive_ground_state_simulation(layout, sim_params); + time_to_solution_stats stats{}; + time_to_solution(layout, qs_params, tts_params, &stats); + const auto quickexact_results_layout = quickexact(layout, qe_params); + + runtime_exhaustive += mockturtle::to_seconds(exhaustive_results_layout.simulation_runtime); + runtime_quickexact += mockturtle::to_seconds(quickexact_results_layout.simulation_runtime); + tts_quicksim += stats.time_to_solution; + instances += 1; + quicksim_accuracy_mean += stats.acc; + quicksim_single_runtime += stats.mean_single_runtime; + + // simulate layout with all input patterns + auto bii = bdl_input_iterator{layout}; + const auto num_input_patterns = truth_table.front().num_bits(); + + for (auto i = 0u; i < num_input_patterns; ++i, ++bii) + { + const auto exhaustive_results = exhaustive_ground_state_simulation(*bii, sim_params); + time_to_solution_stats tts_stats{}; + time_to_solution(*bii, qs_params, tts_params, &tts_stats); + const auto quickexact_results = quickexact(*bii, qe_params); + + runtime_exhaustive += mockturtle::to_seconds(exhaustive_results.simulation_runtime); + runtime_quickexact += mockturtle::to_seconds(quickexact_results.simulation_runtime); + tts_quicksim += stats.time_to_solution; + + instances += 1; + quicksim_accuracy_mean += stats.acc; + quicksim_single_runtime += stats.mean_single_runtime; + } + quicksim_accuracy_mean = quicksim_accuracy_mean / static_cast(instances); + simulation_exp(gate, instances, runtime_exhaustive, runtime_quickexact, quicksim_accuracy_mean, + quicksim_single_runtime, tts_quicksim); + simulation_exp.save(); + simulation_exp.table(); + } + } + return EXIT_SUCCESS; +} diff --git a/experiments/sidb_simulation/electrostatic_ground_state/runtime_analysis_layouts_with_possible_positive_sidbs.cpp b/experiments/sidb_simulation/electrostatic_ground_state/runtime_analysis_layouts_with_possible_positive_sidbs.cpp index 5a613364f..7111e72a4 100644 --- a/experiments/sidb_simulation/electrostatic_ground_state/runtime_analysis_layouts_with_possible_positive_sidbs.cpp +++ b/experiments/sidb_simulation/electrostatic_ground_state/runtime_analysis_layouts_with_possible_positive_sidbs.cpp @@ -2,13 +2,15 @@ // Created by Jan Drewniok on 02.09.24. // -#include "fiction/algorithms/simulation/sidb/determine_groundstate_from_simulation_results.hpp" -#include "fiction/algorithms/simulation/sidb/exhaustive_ground_state_simulation.hpp" -#include "fiction/algorithms/simulation/sidb/quickexact.hpp" -#include "fiction/algorithms/simulation/sidb/random_sidb_layout_generator.hpp" -#include "fiction/algorithms/simulation/sidb/sidb_simulation_parameters.hpp" #include "fiction_experiments.hpp" -#include "mockturtle/utils/stopwatch.hpp" + +#include +#include +#include +#include +#include + +#include #include #include @@ -75,7 +77,7 @@ int main() // NOLINT const auto average_pos_sibs_of_gs = static_cast(std::accumulate(number_of_positive_sidbs_of_gs_per_layout.cbegin(), - number_of_positive_sidbs_of_gs_per_layout.cend(), 0)) / + number_of_positive_sidbs_of_gs_per_layout.cend(), 0u)) / static_cast(number_of_positive_sidbs_of_gs_per_layout.size()); simulation_exp(random_layouts_params.number_of_sidbs, random_layouts.size(), runtime_exhaustive, diff --git a/experiments/sidb_simulation/temperature/critical_temperature_simulation_bestagon.cpp b/experiments/sidb_simulation/temperature/critical_temperature_simulation_bestagon.cpp index 641ada4bf..8c6f62835 100644 --- a/experiments/sidb_simulation/temperature/critical_temperature_simulation_bestagon.cpp +++ b/experiments/sidb_simulation/temperature/critical_temperature_simulation_bestagon.cpp @@ -5,7 +5,6 @@ #include "fiction_experiments.hpp" #include -#include #include #include #include diff --git a/include/fiction/algorithms/simulation/sidb/critical_temperature.hpp b/include/fiction/algorithms/simulation/sidb/critical_temperature.hpp index 246d8de10..75b9b1d93 100644 --- a/include/fiction/algorithms/simulation/sidb/critical_temperature.hpp +++ b/include/fiction/algorithms/simulation/sidb/critical_temperature.hpp @@ -143,9 +143,8 @@ class critical_temperature_impl layout{lyt}, params{ps}, stats{st}, - bii(bdl_input_iterator{layout, params.input_bdl_iterator_params}), - critical_temperature{ps.max_temperature} - + critical_temperature{ps.max_temperature}, + bii(bdl_input_iterator{layout, params.input_bdl_iterator_params}) { stats.simulation_parameters = params.simulation_parameters; stats.algorithm_name = diff --git a/test/utils/layout_utils.cpp b/test/utils/layout_utils.cpp index db96cb27e..26694f6b3 100644 --- a/test/utils/layout_utils.cpp +++ b/test/utils/layout_utils.cpp @@ -876,10 +876,15 @@ TEST_CASE("Test identity of two layouts", "[layout-utils]") lyt_second.assign_cell_type({5, 3}, sidb_cell_clk_lyt::cell_type::INPUT); CHECK(!are_layouts_identical(lyt_first, lyt_second)); } + SECTION("different number of cells") + { + lyt_second.assign_cell_type({5, 3}, sidb_cell_clk_lyt::cell_type::EMPTY); + CHECK(!are_layouts_identical(lyt_first, lyt_second)); + } } - const charge_distribution_surface cds_first{lyt_first}; - charge_distribution_surface cds_second{lyt_second}; + charge_distribution_surface cds_first{lyt_first}; + charge_distribution_surface cds_second{lyt_second}; SECTION("charge distribution surface") { @@ -889,7 +894,11 @@ TEST_CASE("Test identity of two layouts", "[layout-utils]") } SECTION("different charge state") { + cds_first.assign_charge_state({0, 0}, sidb_charge_state::POSITIVE); cds_second.assign_charge_state({5, 3}, sidb_charge_state::POSITIVE); + CHECK(cds_first.num_negative_sidbs() == cds_second.num_negative_sidbs()); + CHECK(cds_first.num_positive_sidbs() == cds_second.num_positive_sidbs()); + CHECK(cds_first.num_neutral_sidbs() == cds_second.num_neutral_sidbs()); CHECK(!are_layouts_identical(cds_first, cds_second)); } } From 8aa6f50981787b74df584cafd41e6a0ecbf25021 Mon Sep 17 00:00:00 2001 From: Drewniok Date: Thu, 12 Sep 2024 08:45:35 +0200 Subject: [PATCH 25/32] :art: implement Marcels feedback. --- .../sidb/random_sidb_layout_generator.hpp | 11 +++++------ .../random_sidb_layout_generation.cpp | 14 +++++++------- ...ysis_layouts_with_possible_positive_sidbs.cpp | 2 +- .../physical_design/design_sidb_gates.hpp | 2 +- .../sidb/random_sidb_layout_generator.hpp | 7 ++++--- include/fiction/utils/layout_utils.hpp | 14 +++++++++----- .../sidb/random_sidb_layout_generator.cpp | 4 ++-- test/utils/layout_utils.cpp | 16 ++++++++-------- 8 files changed, 37 insertions(+), 33 deletions(-) diff --git a/bindings/pyfiction/include/pyfiction/algorithms/simulation/sidb/random_sidb_layout_generator.hpp b/bindings/pyfiction/include/pyfiction/algorithms/simulation/sidb/random_sidb_layout_generator.hpp index 186e3acf9..1c37c7ced 100644 --- a/bindings/pyfiction/include/pyfiction/algorithms/simulation/sidb/random_sidb_layout_generator.hpp +++ b/bindings/pyfiction/include/pyfiction/algorithms/simulation/sidb/random_sidb_layout_generator.hpp @@ -42,15 +42,14 @@ inline void random_sidb_layout_generator(pybind11::module& m) namespace py = pybind11; using namespace pybind11::literals; - // todo update docu py::enum_::positive_charges>( m, "positive_charges", DOC(fiction_generate_random_sidb_layout_params_positive_charges)) .value("ALLOWED", - fiction::generate_random_sidb_layout_params::positive_charges::ALLOWED) + fiction::generate_random_sidb_layout_params::positive_charges::ALLOWED, DOC(fiction_generate_random_sidb_layout_params_positive_charges_ALLOWED)) .value("FORBIDDEN", - fiction::generate_random_sidb_layout_params::positive_charges::FORBIDDEN) - .value("CAN_OCCUR", - fiction::generate_random_sidb_layout_params::positive_charges::CAN_OCCUR); + fiction::generate_random_sidb_layout_params::positive_charges::FORBIDDEN, DOC(fiction_generate_random_sidb_layout_params_positive_charges_FORBIDDEN)) + .value("MAY_OCCUR", + fiction::generate_random_sidb_layout_params::positive_charges::MAY_OCCUR, DOC(fiction_generate_random_sidb_layout_params_positive_charges_CAN_OCCUR)); /** * Parameters. @@ -78,8 +77,8 @@ inline void random_sidb_layout_generator(pybind11::module& m) &fiction::generate_random_sidb_layout_params< fiction::offset::ucoord_t>::maximal_attempts_for_multiple_layouts, DOC(fiction_generate_random_sidb_layout_params_maximal_attempts_for_multiple_layouts)); - // NOTE be careful with the order of the following calls! Python will resolve the first matching overload! + // NOTE be careful with the order of the following calls! Python will resolve the first matching overload! detail::random_layout_generator(m); detail::random_layout_generator(m); } diff --git a/experiments/random_sidb_layout_generation/random_sidb_layout_generation.cpp b/experiments/random_sidb_layout_generation/random_sidb_layout_generation.cpp index 0d61396de..e0f935466 100644 --- a/experiments/random_sidb_layout_generation/random_sidb_layout_generation.cpp +++ b/experiments/random_sidb_layout_generation/random_sidb_layout_generation.cpp @@ -98,19 +98,19 @@ int main(int argc, const char* argv[]) // NOLINT const std::string charges_str = options["--positive_charges"]; // specifies whether positively charged SiDBs are allowed ("ALLOWED"), forbidden ("FORBIDDEN") or can occur - // ("CAN_OCCUR") - generate_random_sidb_layout_params::positive_charges charges{}; + // ("MAY_OCCUR") + generate_random_sidb_layout_params::positive_charges charges{}; if (charges_str == "ALLOWED") { - charges = generate_random_sidb_layout_params::positive_charges::ALLOWED; + charges = generate_random_sidb_layout_params::positive_charges::ALLOWED; } - else if (charges_str == "CAN_OCCUR") + else if (charges_str == "MAY_OCCUR") { - charges = generate_random_sidb_layout_params::positive_charges::CAN_OCCUR; + charges = generate_random_sidb_layout_params::positive_charges::MAY_OCCUR; } else { - charges = generate_random_sidb_layout_params::positive_charges::FORBIDDEN; + charges = generate_random_sidb_layout_params::positive_charges::FORBIDDEN; } // sets the number of SiDBs for the first bunch of layouts @@ -178,7 +178,7 @@ int main(int argc, const char* argv[]) // NOLINT std::cout << "Folder already exists.\n"; } - const generate_random_sidb_layout_params params{ + const generate_random_sidb_layout_params params{ {{nw_x, nw_y}, {se_x, se_y}}, number_of_placed_sidbs, charges, sidb_simulation_parameters{3, -0.32}, static_cast(10E6), number_of_layouts}; const auto unique_lyts = generate_multiple_random_sidb_layouts(sidb_100_cell_clk_lyt{}, params); diff --git a/experiments/sidb_simulation/electrostatic_ground_state/runtime_analysis_layouts_with_possible_positive_sidbs.cpp b/experiments/sidb_simulation/electrostatic_ground_state/runtime_analysis_layouts_with_possible_positive_sidbs.cpp index 7111e72a4..4f8d5a3dd 100644 --- a/experiments/sidb_simulation/electrostatic_ground_state/runtime_analysis_layouts_with_possible_positive_sidbs.cpp +++ b/experiments/sidb_simulation/electrostatic_ground_state/runtime_analysis_layouts_with_possible_positive_sidbs.cpp @@ -43,7 +43,7 @@ int main() // NOLINT auto random_layouts_params = generate_random_sidb_layout_params>{ {{0, 0}, {10, 10}}, 0, - generate_random_sidb_layout_params>::positive_charges::CAN_OCCUR, + generate_random_sidb_layout_params>::positive_charges::MAY_OCCUR, sim_params, static_cast(10E6), 10}; diff --git a/include/fiction/algorithms/physical_design/design_sidb_gates.hpp b/include/fiction/algorithms/physical_design/design_sidb_gates.hpp index 2167791ce..485343fe9 100644 --- a/include/fiction/algorithms/physical_design/design_sidb_gates.hpp +++ b/include/fiction/algorithms/physical_design/design_sidb_gates.hpp @@ -72,7 +72,7 @@ struct design_sidb_gates_params RANDOM }; /** - * Parameter for the `is_operational` function. + * Parameters for the `is_operational` function. */ is_operational_params operational_params{}; /** diff --git a/include/fiction/algorithms/simulation/sidb/random_sidb_layout_generator.hpp b/include/fiction/algorithms/simulation/sidb/random_sidb_layout_generator.hpp index 123930bf8..588380ad7 100644 --- a/include/fiction/algorithms/simulation/sidb/random_sidb_layout_generator.hpp +++ b/include/fiction/algorithms/simulation/sidb/random_sidb_layout_generator.hpp @@ -11,6 +11,7 @@ #include "fiction/technology/sidb_defects.hpp" #include "fiction/traits.hpp" #include "fiction/utils/layout_utils.hpp" +#include "fiction/utils/execution_utils.hpp" #include #include @@ -43,7 +44,7 @@ struct generate_random_sidb_layout_params /** * Positive charges can occur, which means that the `can_positive_charges_occur` function returns `true`. */ - CAN_OCCUR + MAY_OCCUR }; /** * Two coordinates that span the region where SiDBs may be placed (order is not important). The first coordinate is @@ -184,8 +185,8 @@ generate_multiple_random_sidb_layouts(const Lyt& const auto random_lyt = generate_random_sidb_layout(lyt_skeleton, params); // indicates if a found SiDB layout is identical to an already found one. - const auto identical_layout = std::any_of(unique_lyts.cbegin(), unique_lyts.cend(), [&](const auto& old_lyt) - { return are_layouts_identical(random_lyt, old_lyt); }); + const auto identical_layout = std::any_of(FICTION_EXECUTION_POLICY_PAR unique_lyts.cbegin(), unique_lyts.cend(), [&](const auto& old_lyt) + { return are_cell_layouts_identical(random_lyt, old_lyt); }); // if the randomly generated SiDB layout is not identical to a previously generated one, it is added to the // collection of all unique SiDB layouts (unique_lyts) diff --git a/include/fiction/utils/layout_utils.hpp b/include/fiction/utils/layout_utils.hpp index 1b5c71a68..3decbb758 100644 --- a/include/fiction/utils/layout_utils.hpp +++ b/include/fiction/utils/layout_utils.hpp @@ -5,7 +5,6 @@ #ifndef FICTION_LAYOUT_UTILS_HPP #define FICTION_LAYOUT_UTILS_HPP -#include "fiction/algorithms/simulation/sidb/can_positive_charges_occur.hpp" #include "fiction/layouts/coordinates.hpp" #include "fiction/technology/cell_ports.hpp" #include "fiction/technology/charge_distribution_surface.hpp" @@ -693,13 +692,15 @@ template * properties such as the number of cells, the types of cells, defects (if applicable), and charge states (if * applicable). The comparison is done in a detailed manner depending on the specific layout type. * + * @Note The aspect ratios of the cell-level layouts are not compared. + * * @tparam Lyt The layout type. Must be a cell-level layout. * @param first_lyt The first layout to compare. * @param second_lyt The second layout to compare. * @return `true` if the layouts are identical, `false` otherwise. */ template -[[nodiscard]] inline bool are_layouts_identical(const Lyt& first_lyt, const Lyt& second_lyt) noexcept +[[nodiscard]] inline bool are_cell_layouts_identical(const Lyt& first_lyt, const Lyt& second_lyt) noexcept { static_assert(is_cell_level_layout_v, "Lyt is not a cell-level layout"); @@ -716,8 +717,9 @@ template if (first_lyt.get_cell_type(c) != second_lyt.get_cell_type(c)) { different_cells = true; - return; + return false; // abort } + return true; // keep looping }); if (different_cells) @@ -740,8 +742,9 @@ template if (first_lyt.get_sidb_defect(defect_old.first) != second_lyt.get_sidb_defect(defect_old.first)) { different_defects = true; - return; + return false; // abort } + return true; // keep looping }); if (different_defects) @@ -774,8 +777,9 @@ template if (first_lyt.get_charge_state(c) != second_lyt.get_charge_state(c)) { different_charge_state = true; - return; + return false; // abort } + return true; // keep looping }); if (different_charge_state) diff --git a/test/algorithms/simulation/sidb/random_sidb_layout_generator.cpp b/test/algorithms/simulation/sidb/random_sidb_layout_generator.cpp index 04c509cc7..64f19d7c1 100644 --- a/test/algorithms/simulation/sidb/random_sidb_layout_generator.cpp +++ b/test/algorithms/simulation/sidb/random_sidb_layout_generator.cpp @@ -179,7 +179,7 @@ TEST_CASE("Random cube::coord_t layout generation", "[generate-random-sidb-layou const auto& first_lyt = result_lyts.front(); const auto& second_lyt = result_lyts.back(); - CHECK(!are_layouts_identical(first_lyt, second_lyt)); + CHECK(!are_cell_layouts_identical(first_lyt, second_lyt)); } SECTION("Check all pairwise distances") @@ -341,7 +341,7 @@ TEST_CASE("Random offset::ucoord_t layout generation", "[generate-random-sidb-la const auto& first_lyt = result_lyts.front(); const auto& second_lyt = result_lyts.back(); - CHECK(!are_layouts_identical(first_lyt, second_lyt)); + CHECK(!are_cell_layouts_identical(first_lyt, second_lyt)); } SECTION("Check correct use of skeleton layout when generating only one random layout") diff --git a/test/utils/layout_utils.cpp b/test/utils/layout_utils.cpp index 26694f6b3..d266f3f69 100644 --- a/test/utils/layout_utils.cpp +++ b/test/utils/layout_utils.cpp @@ -869,17 +869,17 @@ TEST_CASE("Test identity of two layouts", "[layout-utils]") { SECTION("identical layouts") { - CHECK(are_layouts_identical(lyt_first, lyt_second)); + CHECK(are_cell_layouts_identical(lyt_first, lyt_second)); } SECTION("different cell type") { lyt_second.assign_cell_type({5, 3}, sidb_cell_clk_lyt::cell_type::INPUT); - CHECK(!are_layouts_identical(lyt_first, lyt_second)); + CHECK(!are_cell_layouts_identical(lyt_first, lyt_second)); } SECTION("different number of cells") { lyt_second.assign_cell_type({5, 3}, sidb_cell_clk_lyt::cell_type::EMPTY); - CHECK(!are_layouts_identical(lyt_first, lyt_second)); + CHECK(!are_cell_layouts_identical(lyt_first, lyt_second)); } } @@ -890,7 +890,7 @@ TEST_CASE("Test identity of two layouts", "[layout-utils]") { SECTION("identical layouts") { - CHECK(are_layouts_identical(cds_first, cds_second)); + CHECK(are_cell_layouts_identical(cds_first, cds_second)); } SECTION("different charge state") { @@ -899,7 +899,7 @@ TEST_CASE("Test identity of two layouts", "[layout-utils]") CHECK(cds_first.num_negative_sidbs() == cds_second.num_negative_sidbs()); CHECK(cds_first.num_positive_sidbs() == cds_second.num_positive_sidbs()); CHECK(cds_first.num_neutral_sidbs() == cds_second.num_neutral_sidbs()); - CHECK(!are_layouts_identical(cds_first, cds_second)); + CHECK(!are_cell_layouts_identical(cds_first, cds_second)); } } @@ -915,19 +915,19 @@ TEST_CASE("Test identity of two layouts", "[layout-utils]") SECTION("identical layouts") { - CHECK(are_layouts_identical(defect_first, defect_second)); + CHECK(are_cell_layouts_identical(defect_first, defect_second)); } SECTION("different layouts") { SECTION("different number of defects") { defect_second.assign_sidb_defect({1, 2}, sidb_defect{sidb_defect_type::NONE}); - CHECK(!are_layouts_identical(defect_first, defect_second)); + CHECK(!are_cell_layouts_identical(defect_first, defect_second)); } SECTION("different defect type") { defect_second.assign_sidb_defect({1, 2}, sidb_defect{sidb_defect_type::DB}); - CHECK(!are_layouts_identical(defect_first, defect_second)); + CHECK(!are_cell_layouts_identical(defect_first, defect_second)); } } } From 095cf53f444b9a877e243bff1ad1f1d9fc3554ad Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 12 Sep 2024 06:45:59 +0000 Subject: [PATCH 26/32] =?UTF-8?q?=F0=9F=8E=A8=20Incorporated=20pre-commit?= =?UTF-8?q?=20fixes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../simulation/sidb/random_sidb_layout_generator.hpp | 9 ++++++--- .../simulation/sidb/random_sidb_layout_generator.hpp | 7 ++++--- include/fiction/utils/layout_utils.hpp | 12 ++++++------ 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/bindings/pyfiction/include/pyfiction/algorithms/simulation/sidb/random_sidb_layout_generator.hpp b/bindings/pyfiction/include/pyfiction/algorithms/simulation/sidb/random_sidb_layout_generator.hpp index 1c37c7ced..21edd5593 100644 --- a/bindings/pyfiction/include/pyfiction/algorithms/simulation/sidb/random_sidb_layout_generator.hpp +++ b/bindings/pyfiction/include/pyfiction/algorithms/simulation/sidb/random_sidb_layout_generator.hpp @@ -45,11 +45,14 @@ inline void random_sidb_layout_generator(pybind11::module& m) py::enum_::positive_charges>( m, "positive_charges", DOC(fiction_generate_random_sidb_layout_params_positive_charges)) .value("ALLOWED", - fiction::generate_random_sidb_layout_params::positive_charges::ALLOWED, DOC(fiction_generate_random_sidb_layout_params_positive_charges_ALLOWED)) + fiction::generate_random_sidb_layout_params::positive_charges::ALLOWED, + DOC(fiction_generate_random_sidb_layout_params_positive_charges_ALLOWED)) .value("FORBIDDEN", - fiction::generate_random_sidb_layout_params::positive_charges::FORBIDDEN, DOC(fiction_generate_random_sidb_layout_params_positive_charges_FORBIDDEN)) + fiction::generate_random_sidb_layout_params::positive_charges::FORBIDDEN, + DOC(fiction_generate_random_sidb_layout_params_positive_charges_FORBIDDEN)) .value("MAY_OCCUR", - fiction::generate_random_sidb_layout_params::positive_charges::MAY_OCCUR, DOC(fiction_generate_random_sidb_layout_params_positive_charges_CAN_OCCUR)); + fiction::generate_random_sidb_layout_params::positive_charges::MAY_OCCUR, + DOC(fiction_generate_random_sidb_layout_params_positive_charges_CAN_OCCUR)); /** * Parameters. diff --git a/include/fiction/algorithms/simulation/sidb/random_sidb_layout_generator.hpp b/include/fiction/algorithms/simulation/sidb/random_sidb_layout_generator.hpp index 588380ad7..01b0785a1 100644 --- a/include/fiction/algorithms/simulation/sidb/random_sidb_layout_generator.hpp +++ b/include/fiction/algorithms/simulation/sidb/random_sidb_layout_generator.hpp @@ -10,8 +10,8 @@ #include "fiction/algorithms/simulation/sidb/sidb_simulation_parameters.hpp" #include "fiction/technology/sidb_defects.hpp" #include "fiction/traits.hpp" -#include "fiction/utils/layout_utils.hpp" #include "fiction/utils/execution_utils.hpp" +#include "fiction/utils/layout_utils.hpp" #include #include @@ -185,8 +185,9 @@ generate_multiple_random_sidb_layouts(const Lyt& const auto random_lyt = generate_random_sidb_layout(lyt_skeleton, params); // indicates if a found SiDB layout is identical to an already found one. - const auto identical_layout = std::any_of(FICTION_EXECUTION_POLICY_PAR unique_lyts.cbegin(), unique_lyts.cend(), [&](const auto& old_lyt) - { return are_cell_layouts_identical(random_lyt, old_lyt); }); + const auto identical_layout = + std::any_of(FICTION_EXECUTION_POLICY_PAR unique_lyts.cbegin(), unique_lyts.cend(), + [&](const auto& old_lyt) { return are_cell_layouts_identical(random_lyt, old_lyt); }); // if the randomly generated SiDB layout is not identical to a previously generated one, it is added to the // collection of all unique SiDB layouts (unique_lyts) diff --git a/include/fiction/utils/layout_utils.hpp b/include/fiction/utils/layout_utils.hpp index 3decbb758..23d3ddae5 100644 --- a/include/fiction/utils/layout_utils.hpp +++ b/include/fiction/utils/layout_utils.hpp @@ -717,9 +717,9 @@ template if (first_lyt.get_cell_type(c) != second_lyt.get_cell_type(c)) { different_cells = true; - return false; // abort + return false; // abort } - return true; // keep looping + return true; // keep looping }); if (different_cells) @@ -742,9 +742,9 @@ template if (first_lyt.get_sidb_defect(defect_old.first) != second_lyt.get_sidb_defect(defect_old.first)) { different_defects = true; - return false; // abort + return false; // abort } - return true; // keep looping + return true; // keep looping }); if (different_defects) @@ -777,9 +777,9 @@ template if (first_lyt.get_charge_state(c) != second_lyt.get_charge_state(c)) { different_charge_state = true; - return false; // abort + return false; // abort } - return true; // keep looping + return true; // keep looping }); if (different_charge_state) From 427c5c0cee7b59584eaf6394b38fd432590f0d92 Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Thu, 12 Sep 2024 06:46:54 +0000 Subject: [PATCH 27/32] :memo: Update pyfiction docstrings Signed-off-by: GitHub Actions --- .../pyfiction/pybind11_mkdoc_docstrings.hpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/bindings/pyfiction/include/pyfiction/pybind11_mkdoc_docstrings.hpp b/bindings/pyfiction/include/pyfiction/pybind11_mkdoc_docstrings.hpp index 98ca2d807..68d114bcc 100644 --- a/bindings/pyfiction/include/pyfiction/pybind11_mkdoc_docstrings.hpp +++ b/bindings/pyfiction/include/pyfiction/pybind11_mkdoc_docstrings.hpp @@ -295,13 +295,15 @@ Parameter ``params``: A cell-level layout that implements `lyt`'s gate types with building blocks defined in `GateLibrary`.)doc"; -static const char *__doc_fiction_are_layouts_identical = +static const char *__doc_fiction_are_cell_layouts_identical = R"doc(This function checks whether the given layouts `first_lyt` and `second_lyt` are identical by comparing various properties such as the number of cells, the types of cells, defects (if applicable), and charge states (if applicable). The comparison is done in a detailed manner depending on the specific layout type. +@Note The aspect ratios of the cell-level layouts are not compared. + Template parameter ``Lyt``: The layout type. Must be a cell-level layout. @@ -3514,7 +3516,7 @@ static const char *__doc_fiction_design_sidb_gates_params_design_sidb_gates_mode static const char *__doc_fiction_design_sidb_gates_params_number_of_sidbs = R"doc(Number of SiDBs placed in the canvas to create a working gate.)doc"; -static const char *__doc_fiction_design_sidb_gates_params_operational_params = R"doc(Parameter for the `is_operational` function.)doc"; +static const char *__doc_fiction_design_sidb_gates_params_operational_params = R"doc(Parameters for the `is_operational` function.)doc"; static const char *__doc_fiction_design_sidb_gates_params_termination_cond = R"doc(The design process is terminated after a valid SiDB gate design is @@ -10811,14 +10813,14 @@ static const char *__doc_fiction_generate_random_sidb_layout_params_positive_cha R"doc(Positive charges can occur (i.e. SiDBs can be placed right next to each other).)doc"; -static const char *__doc_fiction_generate_random_sidb_layout_params_positive_charges_CAN_OCCUR = -R"doc(Positive charges can occur, which means that the -`can_positive_charges_occur` function returns `true`.)doc"; - static const char *__doc_fiction_generate_random_sidb_layout_params_positive_charges_FORBIDDEN = R"doc(Positive charges are not allowed to occur (i.e. SiDBs need to be seperated by a few lattice points).)doc"; +static const char *__doc_fiction_generate_random_sidb_layout_params_positive_charges_MAY_OCCUR = +R"doc(Positive charges can occur, which means that the +`can_positive_charges_occur` function returns `true`.)doc"; + static const char *__doc_fiction_generate_random_sidb_layout_params_positive_sidbs = R"doc(If positively charged SiDBs should be prevented, SiDBs are not placed closer than the minimal_spacing.)doc"; From eac49ae25438c90b504e86ab3506a80b5f490680 Mon Sep 17 00:00:00 2001 From: Drewniok Date: Thu, 12 Sep 2024 09:18:05 +0200 Subject: [PATCH 28/32] :memo: small fix. --- .../algorithms/simulation/sidb/random_sidb_layout_generator.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bindings/pyfiction/include/pyfiction/algorithms/simulation/sidb/random_sidb_layout_generator.hpp b/bindings/pyfiction/include/pyfiction/algorithms/simulation/sidb/random_sidb_layout_generator.hpp index 21edd5593..f64aee4d4 100644 --- a/bindings/pyfiction/include/pyfiction/algorithms/simulation/sidb/random_sidb_layout_generator.hpp +++ b/bindings/pyfiction/include/pyfiction/algorithms/simulation/sidb/random_sidb_layout_generator.hpp @@ -52,7 +52,7 @@ inline void random_sidb_layout_generator(pybind11::module& m) DOC(fiction_generate_random_sidb_layout_params_positive_charges_FORBIDDEN)) .value("MAY_OCCUR", fiction::generate_random_sidb_layout_params::positive_charges::MAY_OCCUR, - DOC(fiction_generate_random_sidb_layout_params_positive_charges_CAN_OCCUR)); + DOC(fiction_generate_random_sidb_layout_params_positive_charges_MAY_OCCUR)); /** * Parameters. From cbccaa81daf9864f9d9bb9acba681a3b026ee507 Mon Sep 17 00:00:00 2001 From: Drewniok Date: Fri, 13 Sep 2024 11:21:45 +0200 Subject: [PATCH 29/32] :art: small fix. --- .../algorithms/simulation/sidb/random_sidb_layout_generator.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/fiction/algorithms/simulation/sidb/random_sidb_layout_generator.hpp b/include/fiction/algorithms/simulation/sidb/random_sidb_layout_generator.hpp index 01b0785a1..2384a22cf 100644 --- a/include/fiction/algorithms/simulation/sidb/random_sidb_layout_generator.hpp +++ b/include/fiction/algorithms/simulation/sidb/random_sidb_layout_generator.hpp @@ -146,7 +146,7 @@ Lyt generate_random_sidb_layout(const Lyt& attempt_counter += 1; } - if (params.positive_sidbs == generate_random_sidb_layout_params>::positive_charges::CAN_OCCUR && + if (params.positive_sidbs == generate_random_sidb_layout_params>::positive_charges::MAY_OCCUR && !can_positive_charges_occur(lyt, params.sim_params)) { return generate_random_sidb_layout(lyt_skeleton, params); From 9f4f7ef6085bed8502331a801e474d8719fe6bc8 Mon Sep 17 00:00:00 2001 From: Drewniok Date: Fri, 13 Sep 2024 15:41:47 +0200 Subject: [PATCH 30/32] :art: small update. --- docs/changelog.rst | 8 ++++++++ .../random_sidb_layout_generation.cpp | 10 +++++----- test/algorithms/physical_design/design_sidb_gates.cpp | 3 +-- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index efc11047d..fddd66a46 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -8,6 +8,14 @@ The format is based on `Keep a Changelog ` Unreleased``` ------------- +Added +##### +- Experiments: + - Script to conduct 3-state physical simulation of SiDB layouts. + +Unreleased``` +------------- + Added ##### - Experiments: diff --git a/experiments/random_sidb_layout_generation/random_sidb_layout_generation.cpp b/experiments/random_sidb_layout_generation/random_sidb_layout_generation.cpp index e0f935466..02935feb4 100644 --- a/experiments/random_sidb_layout_generation/random_sidb_layout_generation.cpp +++ b/experiments/random_sidb_layout_generation/random_sidb_layout_generation.cpp @@ -99,18 +99,18 @@ int main(int argc, const char* argv[]) // NOLINT // specifies whether positively charged SiDBs are allowed ("ALLOWED"), forbidden ("FORBIDDEN") or can occur // ("MAY_OCCUR") - generate_random_sidb_layout_params::positive_charges charges{}; + generate_random_sidb_layout_params::positive_charges charges{}; if (charges_str == "ALLOWED") { - charges = generate_random_sidb_layout_params::positive_charges::ALLOWED; + charges = generate_random_sidb_layout_params::positive_charges::ALLOWED; } else if (charges_str == "MAY_OCCUR") { - charges = generate_random_sidb_layout_params::positive_charges::MAY_OCCUR; + charges = generate_random_sidb_layout_params::positive_charges::MAY_OCCUR; } else { - charges = generate_random_sidb_layout_params::positive_charges::FORBIDDEN; + charges = generate_random_sidb_layout_params::positive_charges::FORBIDDEN; } // sets the number of SiDBs for the first bunch of layouts @@ -178,7 +178,7 @@ int main(int argc, const char* argv[]) // NOLINT std::cout << "Folder already exists.\n"; } - const generate_random_sidb_layout_params params{ + const generate_random_sidb_layout_params params{ {{nw_x, nw_y}, {se_x, se_y}}, number_of_placed_sidbs, charges, sidb_simulation_parameters{3, -0.32}, static_cast(10E6), number_of_layouts}; const auto unique_lyts = generate_multiple_random_sidb_layouts(sidb_100_cell_clk_lyt{}, params); diff --git a/test/algorithms/physical_design/design_sidb_gates.cpp b/test/algorithms/physical_design/design_sidb_gates.cpp index b44c04f51..92ea592ea 100644 --- a/test/algorithms/physical_design/design_sidb_gates.cpp +++ b/test/algorithms/physical_design/design_sidb_gates.cpp @@ -11,8 +11,7 @@ #include #include #include -#include -#include +#include #include #include #include From 7143f0a68cf27a9b10bf92db1483d589ddb6638d Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 13 Sep 2024 13:42:30 +0000 Subject: [PATCH 31/32] =?UTF-8?q?=F0=9F=8E=A8=20Incorporated=20pre-commit?= =?UTF-8?q?=20fixes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/algorithms/physical_design/design_sidb_gates.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/algorithms/physical_design/design_sidb_gates.cpp b/test/algorithms/physical_design/design_sidb_gates.cpp index 92ea592ea..f55c02827 100644 --- a/test/algorithms/physical_design/design_sidb_gates.cpp +++ b/test/algorithms/physical_design/design_sidb_gates.cpp @@ -5,13 +5,13 @@ #include #include +#include #include #include #include #include #include #include -#include #include #include #include From b3c057aee5198d8c16d73f62af9da4ef24ad2080 Mon Sep 17 00:00:00 2001 From: Drewniok Date: Mon, 16 Sep 2024 11:15:31 +0200 Subject: [PATCH 32/32] :white_check_mark: add additional test. --- .../sidb/test_random_sidb_layout_generator.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/bindings/pyfiction/test/algorithms/simulation/sidb/test_random_sidb_layout_generator.py b/bindings/pyfiction/test/algorithms/simulation/sidb/test_random_sidb_layout_generator.py index ff8c72d72..d9652c13c 100644 --- a/bindings/pyfiction/test/algorithms/simulation/sidb/test_random_sidb_layout_generator.py +++ b/bindings/pyfiction/test/algorithms/simulation/sidb/test_random_sidb_layout_generator.py @@ -5,7 +5,7 @@ class TestRandomSiDBLayoutGenerator(unittest.TestCase): - def test_area_with_one_coordinate_100_lattice(self): + def test_area_with_one_sidb_100_lattice(self): params = generate_random_sidb_layout_params() params.number_of_sidbs = 1 params.coordinate_pair = ((10,10), (10,10)) @@ -15,6 +15,14 @@ def test_area_with_one_coordinate_100_lattice(self): self.assertEqual(cell.x, 10) self.assertEqual(cell.y, 10) + def test_area_with_five_sidb_100_lattice(self): + params = generate_random_sidb_layout_params() + params.number_of_sidbs = 5 + print(params.number_of_sidbs) + params.coordinate_pair = ((0,0), (10,10)) + result_lyt = generate_random_sidb_layout(sidb_100_lattice(), params) + self.assertEqual(result_lyt.num_cells(), 5) + def test_area_with_one_coordinate_111_lattice(self): params = generate_random_sidb_layout_params() params.number_of_sidbs = 1