diff --git a/docs/io/visualization.rst b/docs/io/visualization.rst index 6b5c5b053..add7bca68 100644 --- a/docs/io/visualization.rst +++ b/docs/io/visualization.rst @@ -10,7 +10,7 @@ Layout Printing .. doxygenfunction:: fiction::print_gate_level_layout .. doxygenfunction:: fiction::print_cell_level_layout -.. doxygenfunction:: fiction::print_charge_layout +.. doxygenfunction:: fiction::print_sidb_layout .. doxygenfunction:: fiction::print_layout Graphviz (DOT) Drawers diff --git a/include/fiction/io/print_layout.hpp b/include/fiction/io/print_layout.hpp index 06d5ec51f..7e9dfffb9 100644 --- a/include/fiction/io/print_layout.hpp +++ b/include/fiction/io/print_layout.hpp @@ -7,8 +7,11 @@ #include "fiction/layouts/bounding_box.hpp" #include "fiction/technology/charge_distribution_surface.hpp" +#include "fiction/technology/sidb_defects.hpp" +#include "fiction/technology/sidb_surface.hpp" #include "fiction/traits.hpp" #include "fiction/types.hpp" +#include "fiction/utils/layout_utils.hpp" #include #include @@ -45,6 +48,13 @@ static const auto SIDB_POS_COLOR = fmt::fg(fmt::color::red); static const auto SIDB_NEUT_COLOR = fmt::fg(fmt::color::white); // Escape color sequence for lattice background colors (grey). static const auto SIDB_LAT_COLOR = fmt::fg(fmt::color::gray); + +// Escape color sequence for positively charged defect colors (red). +static const auto SIDB_DEF_POS_COLOR = fmt::fg(fmt::color::red); +// Escape color sequence for negatively charged defect colors (blue). +static const auto SIDB_DEF_NEG_COLOR = fmt::fg(fmt::color::blue); +// Escape color sequence for neutrally charged defect colors (yellow). +static const auto SIDB_DEF_NEU_COLOR = fmt::fg(fmt::color::yellow); // Empty escape color sequence inline constexpr auto NO_COLOR = fmt::text_style{}; @@ -325,90 +335,178 @@ void print_cell_level_layout(std::ostream& os, const Lyt& layout, const bool io_ os << std::endl; } /** - * Writes a simplified 2D representation of an SiDB charge layout to an output stream. + * Writes a simplified 2D representation of an SiDB layout (SiDB and defect charges are supported) to an output stream. * - * @tparam Lyt SiDB cell-level layout with charge-information based on SiQAD coordinates, e.g., a - * charge_distribution_surface object. + * @tparam Lyt SiDB cell-level layout with charge-information based on SiQAD coordinates or defect-information, e.g., a + * `charge_distribution_surface` or `sidb_surface`. * @param os Output stream to write into. - * @param lyt The layout of which the charge distribution is to be printed. + * @param lyt The layout of which the information is to be printed. * @param cs_color Flag to utilize color escapes for charge states. * @param crop_layout Flag to print the 2D bounding box of the layout, while leaving a maximum padding of one dimer row * and two columns. * @param draw_lattice Flag to enable lattice background drawing. */ template -void print_charge_layout(std::ostream& os, const Lyt& lyt, const bool cs_color = true, const bool crop_layout = false, - const bool draw_lattice = true) +void print_sidb_layout(std::ostream& os, const Lyt& lyt, const bool cs_color = true, const bool crop_layout = false, + const bool draw_lattice = true) { 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"); static_assert(has_siqad_coord_v, "Lyt is not based on SiQAD coordinates"); - static_assert(has_get_charge_state_v, "Lyt does not implement the get_charge_state function"); // empty layout if (lyt.is_empty()) { - os << "[i] empty layout" << std::endl; - return; + if constexpr (has_get_sidb_defect_v) + { + if (lyt.num_defects() == 0) + { + os << "[i] empty layout" << std::endl; + return; + } + } + else + { + os << "[i] empty layout" << std::endl; + return; + } } - coordinate min{}; - coordinate max{lyt.x(), lyt.y(), 1}; + const bounding_box_2d bb{lyt}; - if (crop_layout) + auto min_nw = bb.get_min(); + auto max_se = bb.get_max(); + + std::vector defects{}; + + // if defects exist in the layout + if constexpr (has_get_sidb_defect_v) { - const auto bb = bounding_box_2d{lyt}; + if (lyt.num_defects() != 0) + { + defects.reserve(lyt.num_defects()); + lyt.foreach_sidb_defect([&defects](const auto& c) { defects.push_back(c.first); }); + + std::sort(defects.begin(), defects.end()); + min_nw = min_nw > defects.front() ? + defects.front() : + min_nw; // if a defect is more north-west than nw, this position is used as min + max_se = max_se < defects.back() ? + defects.back() : + max_se; // if a defect is more south-east than se, this position is used as max + } + } + + if (crop_layout) + { // apply padding of maximally one dimer row and two columns - min = bb.get_min() - coordinate{2, 1}; - max = bb.get_max() + coordinate{2, 1}; + min_nw = min_nw - coordinate{2, 1}; + max_se = max_se + coordinate{2, 1}; // ensure only full dimer rows are printed - min.z = 0; - max.z = 1; + min_nw.z = 0; + max_se.z = 1; } - // iterate over all coordinates in the rows determined by the vertical crop - lyt.foreach_coordinate( - [&](const coordinate& c) - { - if (crop_layout && (c.x < min.x || c.x > max.x)) // apply horizontal crop - { - return; - } + // loop coordinate is initialized with the north-west coordinate + auto loop_coordinate = min_nw; - switch (lyt.get_charge_state(c)) // switch over the charge state of the SiDB at the current coordinate + while (loop_coordinate <= max_se) + { + // Is set to true if either charge or defect is printed at loop coordinate + bool already_printed = false; + + // Check if layout is only a charge distribution surface + if constexpr (has_get_charge_state_v) + { + switch (lyt.get_charge_state( + loop_coordinate)) // switch over the charge state of the SiDB at the current coordinate { case sidb_charge_state::NEGATIVE: { os << fmt::format(cs_color ? detail::SIDB_NEG_COLOR : detail::NO_COLOR, " ● "); + already_printed = true; break; } case sidb_charge_state::POSITIVE: { os << fmt::format(cs_color ? detail::SIDB_POS_COLOR : detail::NO_COLOR, " ⨁ "); + already_printed = true; break; } case sidb_charge_state::NEUTRAL: { os << fmt::format(cs_color ? detail::SIDB_NEUT_COLOR : detail::NO_COLOR, " ◯ "); + already_printed = true; break; } - default: // NONE charge state case -> empty cell + case sidb_charge_state::NONE: { - os << (draw_lattice || !lyt.is_empty_cell(c) ? - fmt::format(cs_color ? detail::SIDB_LAT_COLOR : detail::NO_COLOR, " · ") : - " "); + break; } } + } - if (c.x == max.x) + if constexpr (has_get_sidb_defect_v) + { + if (lyt.get_sidb_defect(loop_coordinate) != sidb_defect{sidb_defect_type::NONE}) { - os << (c.z == 1 ? "\n\n" : "\n"); + if (is_negatively_charged_defect(lyt.get_sidb_defect(loop_coordinate))) + { + os << fmt::format(cs_color ? detail::SIDB_DEF_NEG_COLOR : detail::NO_COLOR, " ⊟ "); + already_printed = true; + } + else if (is_positively_charged_defect(lyt.get_sidb_defect(loop_coordinate))) + { + os << fmt::format(cs_color ? detail::SIDB_DEF_POS_COLOR : detail::NO_COLOR, " ⊞ "); + already_printed = true; + } + else if (is_neutrally_charged_defect(lyt.get_sidb_defect(loop_coordinate))) + { + os << fmt::format(cs_color ? detail::SIDB_DEF_NEU_COLOR : detail::NO_COLOR, " ⊡ "); + already_printed = true; + } } - }, - min, max + coordinate{1, 0}); + } + + if (!already_printed && lyt.get_cell_type(loop_coordinate) != sidb_technology::cell_type::EMPTY) + { + os << fmt::format(cs_color ? detail::SIDB_DEF_NEU_COLOR : detail::NO_COLOR, " o "); + already_printed = true; + } + + if (!already_printed) + { + os << (draw_lattice ? fmt::format(cs_color ? detail::SIDB_LAT_COLOR : detail::NO_COLOR, " · ") : " "); + } + // if the x-coordinate of loop_coordinate is still less than the x-coordinate of the south-west cell, the + // x-coordinate is increased by 1 + if (loop_coordinate.x < max_se.x) + { + loop_coordinate.x += 1; + } + else if (loop_coordinate.x == max_se.x && loop_coordinate != max_se) + { + if (loop_coordinate.z == 1) + { + os << "\n\n"; // gap between two dimers + } + else + { + os << "\n"; + } + loop_coordinate.x = min_nw.x; + loop_coordinate.y += (loop_coordinate.z == 1) ? 1 : 0; + loop_coordinate.z = (loop_coordinate.z == 0) ? 1 : 0; + } + else if (loop_coordinate == max_se) + { + os << "\n\n"; // add a gap between two dimers + break; + } + } // flush stream os << std::endl; } @@ -433,9 +531,9 @@ void print_layout(const Lyt& lyt, std::ostream& os = std::cout) } else if constexpr (is_cell_level_layout_v) { - if constexpr (has_sidb_technology_v && has_siqad_coord_v && has_get_charge_state_v) + if constexpr (has_sidb_technology_v) { - print_charge_layout(os, lyt); + print_sidb_layout(os, lyt); } else { diff --git a/include/fiction/layouts/bounding_box.hpp b/include/fiction/layouts/bounding_box.hpp index bf380be5e..a2c57a368 100644 --- a/include/fiction/layouts/bounding_box.hpp +++ b/include/fiction/layouts/bounding_box.hpp @@ -5,7 +5,12 @@ #ifndef FICTION_BOUNDING_BOX_HPP #define FICTION_BOUNDING_BOX_HPP +#include "fiction/layouts/cell_level_layout.hpp" +#include "fiction/layouts/coordinates.hpp" +#include "fiction/technology/cell_ports.hpp" #include "fiction/traits.hpp" +#include "fiction/types.hpp" +#include "fiction/utils/layout_utils.hpp" // data types cannot properly be converted to bit field types #pragma GCC diagnostic push @@ -53,35 +58,85 @@ class bounding_box_2d return; } - // set min to max coordinate in the layout - min = {layout.x(), layout.y()}; + // the layout is based on SiQAD coordinates + if constexpr (has_siqad_coord_v) + { + int32_t min_x = std::numeric_limits::max(); + int32_t max_x = std::numeric_limits::min(); + + int32_t min_y = std::numeric_limits::max(); + int32_t max_y = std::numeric_limits::min(); - layout.foreach_coordinate( - [this](const auto& c) - { - if (!is_empty_coordinate(c)) + uint8_t min_z = 0; + uint8_t max_z = 0; + + layout.foreach_cell( + [&min_x, &max_x, &min_y, &max_y, &min_z, &max_z](const auto& c) { - if (c.x < min.x) + if (c.x < min_x) + { + min_x = c.x; + } + if (c.x > max_x) + { + max_x = c.x; + } + + if (c.y == min_y && c.z < min_z) { - min.x = c.x; + min_z = c.z; } - if (c.y < min.y) + if (c.y < min_y) { - min.y = c.y; + min_y = c.y; + min_z = c.z; } - if (c.x > max.x) + + if (c.y == max_y && c.z > max_z) + { + max_z = c.z; + } + if (c.y > max_y) { - max.x = c.x; + max_y = c.y; + max_z = c.z; } - if (c.y > max.y) + }); + min = {min_x, min_y, min_z}; + max = {max_x, max_y, max_z}; + } + else + { + // set min to max coordinate in the layout + min = {layout.x(), layout.y()}; + + layout.foreach_coordinate( + [this](const auto& c) + { + if (!is_empty_coordinate(c)) { - max.y = c.y; + if (c.x < min.x) + { + min.x = c.x; + } + if (c.y < min.y) + { + min.y = c.y; + } + if (c.x > max.x) + { + max.x = c.x; + } + if (c.y > max.y) + { + max.y = c.y; + } } - } - }); + }); - x_size = max.x - min.x; - y_size = max.y - min.y; + x_size = max.x - min.x; + y_size = max.y - min.y; + } } /** * Returns the minimum corner of the bounding box. diff --git a/include/fiction/technology/sidb_defects.hpp b/include/fiction/technology/sidb_defects.hpp index 22d3becb0..52ea6fbc9 100644 --- a/include/fiction/technology/sidb_defects.hpp +++ b/include/fiction/technology/sidb_defects.hpp @@ -5,6 +5,7 @@ #ifndef FICTION_SIDB_DEFECTS_HPP #define FICTION_SIDB_DEFECTS_HPP +#include #include #include #include @@ -56,8 +57,6 @@ struct sidb_defect epsilon_r{relative_permittivity}, lambda_tf{screening_distance} { - - assert(((std::fmod(charge, 1) == 0)) && "charge value has to be an integer"); assert((epsilon_r >= 0) && "epsilon_r has to be >= 0.0"); assert((lambda_tf >= 0.0) && "lambda_tf has to be >= 0.0 nanometer"); } @@ -77,6 +76,22 @@ struct sidb_defect * Thomas-Fermi screening distance in nm. */ const double lambda_tf; + /** + * This operator compares two sidb_defect instances for equality. It checks if the type, charge, + * epsilon_r, and lambda_tf members of the two instances are equal. + */ + constexpr bool operator==(const sidb_defect& rhs) const noexcept + { + return type == rhs.type && charge == rhs.charge && epsilon_r == rhs.epsilon_r && lambda_tf == rhs.lambda_tf; + } + /** + * This operator compares two sidb_defect instances for inequality. It uses the operator== to check + * if the two instances are equal and returns the negation of the result. + */ + constexpr bool operator!=(const sidb_defect& rhs) const noexcept + { + return !(*this == rhs); + } }; /** * Checks whether the given defect is charged. Charged defects are to be avoided by a larger distance. @@ -88,6 +103,36 @@ struct sidb_defect { return defect.type == sidb_defect_type::DB || defect.type == sidb_defect_type::SI_VACANCY; } +/** + * Checks whether the given defect is positively charged. + * + * @param defect Defect to check. + * @return `true` iff defect is positively charged. + */ +[[nodiscard]] static constexpr bool is_positively_charged_defect(const sidb_defect& defect) noexcept +{ + return defect.charge > 0; +} +/** + * Checks whether the given defect is negatively charged. + * + * @param defect Defect to check. + * @return `true` iff defect is negatively charged. + */ +[[nodiscard]] static constexpr bool is_negatively_charged_defect(const sidb_defect& defect) noexcept +{ + return defect.charge < 0; +} +/** + * Checks whether the given defect is neutrally charged. + * + * @param defect Defect to check. + * @return `true` iff defect is neutrally charged. + */ +[[nodiscard]] static constexpr bool is_neutrally_charged_defect(const sidb_defect& defect) noexcept +{ + return defect.charge == 0; +} /** * Checks whether the given defect is not charged. Neutral defects are to be avoided but not by such a large distance. * Even though the `NONE` defect type is technically neutral, it is not a defect per se which is why this function diff --git a/test/io/print_layout.cpp b/test/io/print_layout.cpp index 328d2d453..27fe6212f 100644 --- a/test/io/print_layout.cpp +++ b/test/io/print_layout.cpp @@ -15,6 +15,7 @@ #include #include #include +#include #include @@ -221,7 +222,7 @@ TEST_CASE("Print empty charge layout", "[print-charge-layout]") std::stringstream print_stream{}; - print_charge_layout(print_stream, layout, false); + print_sidb_layout(print_stream, layout, false); CHECK(print_stream.str() == layout_print); @@ -232,7 +233,28 @@ TEST_CASE("Print empty charge layout", "[print-charge-layout]") CHECK(print_stream.str() == layout_print); } -TEST_CASE("Print Bestagon OR-gate", "[print-charge-layout]") +TEST_CASE("layout which is sidb_surface and charge distribution surface but empty", "[print-charge-layout]") +{ + const sidb_surface sidb_layout{{2, 2}}; + + const charge_distribution_surface> layout{sidb_layout}; + + constexpr const char* layout_print = "[i] empty layout\n"; + + std::stringstream print_stream{}; + + print_sidb_layout(print_stream, layout, false); + + CHECK(print_stream.str() == layout_print); + + print_stream = {}; + + print_layout(layout, print_stream); + + CHECK(print_stream.str() == layout_print); +} + +TEST_CASE("Print Bestagon OR-gate without defect", "[print-charge-layout]") { using hex_gate_lyt = hex_odd_row_gate_clk_lyt; @@ -246,7 +268,7 @@ TEST_CASE("Print Bestagon OR-gate", "[print-charge-layout]") cl.assign_charge_state({16, 3, 0}, sidb_charge_state::NEUTRAL); cl.assign_charge_state({42, 3, 0}, sidb_charge_state::NEGATIVE); - cl.assign_charge_state({18, 4, 0}, sidb_charge_state::NONE); + cl.assign_charge_state({18, 4, 0}, sidb_charge_state::NEGATIVE); cl.assign_charge_state({40, 4, 0}, sidb_charge_state::NEGATIVE); cl.assign_charge_state({22, 5, 0}, sidb_charge_state::NEGATIVE); cl.assign_charge_state({36, 5, 0}, sidb_charge_state::NEUTRAL); @@ -254,7 +276,7 @@ TEST_CASE("Print Bestagon OR-gate", "[print-charge-layout]") cl.assign_charge_state({34, 6, 0}, sidb_charge_state::POSITIVE); cl.assign_charge_state({27, 9, 0}, sidb_charge_state::NEGATIVE); cl.assign_charge_state({32, 10, 0}, sidb_charge_state::POSITIVE); - cl.assign_charge_state({27, 10, 1}, sidb_charge_state::NONE); + cl.assign_charge_state({27, 10, 1}, sidb_charge_state::NEGATIVE); cl.assign_charge_state({29, 11, 1}, sidb_charge_state::NEGATIVE); cl.assign_charge_state({29, 14, 0}, sidb_charge_state::NEGATIVE); cl.assign_charge_state({30, 15, 0}, sidb_charge_state::NEGATIVE); @@ -267,7 +289,7 @@ TEST_CASE("Print Bestagon OR-gate", "[print-charge-layout]") SECTION("Cropped") { - print_charge_layout(print_stream, cl, false, true, true); + print_sidb_layout(print_stream, cl, false, true, true); constexpr const char* layout_print = " · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · \n" @@ -276,7 +298,7 @@ TEST_CASE("Print Bestagon OR-gate", "[print-charge-layout]") " · · ◯ · · · · · · · · · · · · · · · · · · · · · · · · · ● · · \n" " · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · \n" "\n" - " · · · · · · · · · · · · · · · · · · · · · · · · · · ● · · · · \n" + " · · · · ● · · · · · · · · · · · · · · · · · · · · · ● · · · · \n" " · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · \n" "\n" " · · · · · · · · ● · · · · · · · · · · · · · ◯ · · · · · · · · \n" @@ -295,7 +317,7 @@ TEST_CASE("Print Bestagon OR-gate", "[print-charge-layout]") " · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · \n" "\n" " · · · · · · · · · · · · · · · · · · ⨁ · · · · · · · · · · · · \n" - " · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · \n" + " · · · · · · · · · · · · · ● · · · · · · · · · · · · · · · · · \n" "\n" " · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · \n" " · · · · · · · · · · · · · · · ● · · · · · · · · · · · · · · · \n" @@ -335,126 +357,290 @@ TEST_CASE("Print Bestagon OR-gate", "[print-charge-layout]") { print_stream.clear(); - print_charge_layout(print_stream, cl, false); + print_sidb_layout(print_stream, cl, false); constexpr const char* layout_print = - " · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · " - "· · · · · · · · · · · · · · · · · · · · · · · · · \n" - " · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · " - "· · · · · · · · · · · · · · · · · · · · · · · · · \n" - "\n" - " · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · " - "· · · · · · · · · · · · · · · · · · · · · · · · · \n" - " · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · " - "· · · · · · · · · · · · · · · · · · · · · · · · · \n" - "\n" - " · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · " - "· · · · · · · · · · · · · · · · · · · · · · · · · \n" - " · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · " - "· · · · · · · · · · · · · · · · · · · · · · · · · \n" - "\n" - " · · · · · · · · · · · · · · · · ◯ · · · · · · · · · · · · · · · · · · " - "· · · · · · · ● · · · · · · · · · · · · · · · · · \n" - " · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · " - "· · · · · · · · · · · · · · · · · · · · · · · · · \n" - "\n" - " · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · " - "· · · · · ● · · · · · · · · · · · · · · · · · · · \n" - " · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · " - "· · · · · · · · · · · · · · · · · · · · · · · · · \n" - "\n" - " · · · · · · · · · · · · · · · · · · · · · · ● · · · · · · · · · · · · " - "· ◯ · · · · · · · · · · · · · · · · · · · · · · · \n" - " · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · " - "· · · · · · · · · · · · · · · · · · · · · · · · · \n" - "\n" - " · · · · · · · · · · · · · · · · · · · · · · · · ● · · · · · · · · · ⨁ " - "· · · · · · · · · · · · · · · · · · · · · · · · · \n" - " · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · " - "· · · · · · · · · · · · · · · · · · · · · · · · · \n" - "\n" - " · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · " - "· · · · · · · · · · · · · · · · · · · · · · · · · \n" - " · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · " - "· · · · · · · · · · · · · · · · · · · · · · · · · \n" - "\n" - " · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · " - "· · · · · · · · · · · · · · · · · · · · · · · · · \n" - " · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · " - "· · · · · · · · · · · · · · · · · · · · · · · · · \n" - "\n" - " · · · · · · · · · · · · · · · · · · · · · · · · · · · ● · · · · · · · " - "· · · · · · · · · · · · · · · · · · · · · · · · · \n" - " · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · " - "· · · · · · · · · · · · · · · · · · · · · · · · · \n" - "\n" - " · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · ⨁ · · " - "· · · · · · · · · · · · · · · · · · · · · · · · · \n" - " · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · " - "· · · · · · · · · · · · · · · · · · · · · · · · · \n" - "\n" - " · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · " - "· · · · · · · · · · · · · · · · · · · · · · · · · \n" - " · · · · · · · · · · · · · · · · · · · · · · · · · · · · · ● · · · · · " - "· · · · · · · · · · · · · · · · · · · · · · · · · \n" - "\n" - " · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · " - "· · · · · · · · · · · · · · · · · · · · · · · · · \n" - " · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · " - "· · · · · · · · · · · · · · · · · · · · · · · · · \n" - "\n" - " · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · " - "· · · · · · · · · · · · · · · · · · · · · · · · · \n" - " · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · " - "· · · · · · · · · · · · · · · · · · · · · · · · · \n" - "\n" - " · · · · · · · · · · · · · · · · · · · · · · · · · · · · · ● · · · · · " - "· · · · · · · · · · · · · · · · · · · · · · · · · \n" - " · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · " - "· · · · · · · · · · · · · · · · · · · · · · · · · \n" - "\n" - " · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · ● · · · · " - "· · · · · · · · · · · · · · · · · · · · · · · · · \n" - " · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · " - "· · · · · · · · · · · · · · · · · · · · · · · · · \n" - "\n" - " · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · ⨁ " - "· · · · · · · · · · · · · · · · · · · · · · · · · \n" - " · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · " - "· · · · · · · · · · · · · · · · · · · · · · · · · \n" - "\n" - " · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · " - "· ◯ · · · · · · · · · · · · · · · · · · · · · · · \n" - " · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · " - "· · · · · · · · · · · · · · · · · · · · · · · · · \n" - "\n" - " · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · " - "· · · · · ● · · · · · · · · · · · · · · · · · · · \n" - " · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · " - "· · · · · · · · · · · · · · · · · · · · · · · · · \n" - "\n" - " · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · " - "· · · · · · · ● · · · · · · · · · · · · · · · · · \n" - " · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · " - "· · · · · · · · · · · · · · · · · · · · · · · · · \n" - "\n" - " · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · " - "· · · · · · · · · · · · · · · · · · · · · · · · · \n" - " · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · " - "· · · · · · · · · · · · · · · · · · · · · · · · · \n" - "\n" - " · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · " - "· · · · · · · · · · · · · · · · · · · · · · · · · \n" - " · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · " - "· · · · · · · · · · · · · · · · · · · · · · · · · \n" - "\n" - " · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · " - "· · · · · · · · · · · · · · · · · · · · · · · · · \n" - " · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · " - "· · · · · · · · · · · · · · · · · · · · · · · · · \n" + " ◯ · · · · · · · · · · · · · · · · · · · · · · · · · ● \n" + " · · · · · · · · · · · · · · · · · · · · · · · · · · · \n" + "\n" + " · · ● · · · · · · · · · · · · · · · · · · · · · ● · · \n" + " · · · · · · · · · · · · · · · · · · · · · · · · · · · \n" + "\n" + " · · · · · · ● · · · · · · · · · · · · · ◯ · · · · · · \n" + " · · · · · · · · · · · · · · · · · · · · · · · · · · · \n" + "\n" + " · · · · · · · · ● · · · · · · · · · ⨁ · · · · · · · · \n" + " · · · · · · · · · · · · · · · · · · · · · · · · · · · \n" + "\n" + " · · · · · · · · · · · · · · · · · · · · · · · · · · · \n" + " · · · · · · · · · · · · · · · · · · · · · · · · · · · \n" + "\n" + " · · · · · · · · · · · · · · · · · · · · · · · · · · · \n" + " · · · · · · · · · · · · · · · · · · · · · · · · · · · \n" + "\n" + " · · · · · · · · · · · ● · · · · · · · · · · · · · · · \n" + " · · · · · · · · · · · · · · · · · · · · · · · · · · · \n" + "\n" + " · · · · · · · · · · · · · · · · ⨁ · · · · · · · · · · \n" + " · · · · · · · · · · · ● · · · · · · · · · · · · · · · \n" + "\n" + " · · · · · · · · · · · · · · · · · · · · · · · · · · · \n" + " · · · · · · · · · · · · · ● · · · · · · · · · · · · · \n" + "\n" + " · · · · · · · · · · · · · · · · · · · · · · · · · · · \n" + " · · · · · · · · · · · · · · · · · · · · · · · · · · · \n" + "\n" + " · · · · · · · · · · · · · · · · · · · · · · · · · · · \n" + " · · · · · · · · · · · · · · · · · · · · · · · · · · · \n" + "\n" + " · · · · · · · · · · · · · ● · · · · · · · · · · · · · \n" + " · · · · · · · · · · · · · · · · · · · · · · · · · · · \n" + "\n" + " · · · · · · · · · · · · · · ● · · · · · · · · · · · · \n" + " · · · · · · · · · · · · · · · · · · · · · · · · · · · \n" + "\n" + " · · · · · · · · · · · · · · · · · · ⨁ · · · · · · · · \n" + " · · · · · · · · · · · · · · · · · · · · · · · · · · · \n" + "\n" + " · · · · · · · · · · · · · · · · · · · · ◯ · · · · · · \n" + " · · · · · · · · · · · · · · · · · · · · · · · · · · · \n" + "\n" + " · · · · · · · · · · · · · · · · · · · · · · · · ● · · \n" + " · · · · · · · · · · · · · · · · · · · · · · · · · · · \n" + "\n" + " · · · · · · · · · · · · · · · · · · · · · · · · · · ● \n" "\n" "\n"; + CHECK(layout_print == print_stream.str()); + } +} + +TEST_CASE("Print Bestagon OR-gate with defect", "[print-charge-layout]") +{ + using hex_gate_lyt = hex_odd_row_gate_clk_lyt; + + hex_gate_lyt layout{aspect_ratio{0, 0}}; + + layout.create_or({}, {}, {0, 0}); + + charge_distribution_surface> cl{ + sidb_surface{ + convert_to_siqad_coordinates(apply_gate_library(layout))}, + sidb_simulation_parameters{3, -0.32}, sidb_charge_state::NEGATIVE}; + + cl.assign_sidb_defect({18, 3, 0}, sidb_defect{sidb_defect_type::UNKNOWN, 1}); + cl.assign_sidb_defect({40, 3, 0}, sidb_defect{sidb_defect_type::UNKNOWN, -1}); + cl.assign_sidb_defect({40, 5, 1}, sidb_defect{sidb_defect_type::UNKNOWN, 0}); + + cl.assign_charge_state({42, 3, 0}, sidb_charge_state::NEGATIVE); + + cl.assign_charge_state({16, 3, 0}, sidb_charge_state::NEUTRAL); + cl.assign_charge_state({42, 3, 0}, sidb_charge_state::NEGATIVE); + cl.assign_charge_state({18, 4, 0}, sidb_charge_state::NEGATIVE); + cl.assign_charge_state({40, 4, 0}, sidb_charge_state::NEGATIVE); + cl.assign_charge_state({22, 5, 0}, sidb_charge_state::NEGATIVE); + cl.assign_charge_state({36, 5, 0}, sidb_charge_state::NEUTRAL); + cl.assign_charge_state({24, 6, 0}, sidb_charge_state::NEGATIVE); + cl.assign_charge_state({34, 6, 0}, sidb_charge_state::POSITIVE); + cl.assign_charge_state({27, 9, 0}, sidb_charge_state::NEGATIVE); + cl.assign_charge_state({32, 10, 0}, sidb_charge_state::POSITIVE); + cl.assign_charge_state({27, 10, 1}, sidb_charge_state::NEGATIVE); + cl.assign_charge_state({29, 11, 1}, sidb_charge_state::NEGATIVE); + cl.assign_charge_state({29, 14, 0}, sidb_charge_state::NEGATIVE); + cl.assign_charge_state({30, 15, 0}, sidb_charge_state::NEGATIVE); + cl.assign_charge_state({34, 16, 0}, sidb_charge_state::POSITIVE); + cl.assign_charge_state({36, 17, 0}, sidb_charge_state::NEUTRAL); + cl.assign_charge_state({40, 18, 0}, sidb_charge_state::NEGATIVE); + cl.assign_charge_state({42, 19, 0}, sidb_charge_state::NEGATIVE); + + std::stringstream print_stream{}; + + print_sidb_layout(print_stream, cl, false, true, true); + + constexpr const char* layout_print = + " · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · \n" + " · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · \n" + "\n" + " · · ◯ · ⊞ · · · · · · · · · · · · · · · · · · · · · ⊟ · ● · · \n" + " · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · \n" + "\n" + " · · · · ● · · · · · · · · · · · · · · · · · · · · · ● · · · · \n" + " · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · \n" + "\n" + " · · · · · · · · ● · · · · · · · · · · · · · ◯ · · · · · · · · \n" + " · · · · · · · · · · · · · · · · · · · · · · · · · · ⊡ · · · · \n" + "\n" + " · · · · · · · · · · ● · · · · · · · · · ⨁ · · · · · · · · · · \n" + " · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · \n" + "\n" + " · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · \n" + " · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · \n" + "\n" + " · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · \n" + " · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · \n" + "\n" + " · · · · · · · · · · · · · ● · · · · · · · · · · · · · · · · · \n" + " · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · \n" + "\n" + " · · · · · · · · · · · · · · · · · · ⨁ · · · · · · · · · · · · \n" + " · · · · · · · · · · · · · ● · · · · · · · · · · · · · · · · · \n" + "\n" + " · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · \n" + " · · · · · · · · · · · · · · · ● · · · · · · · · · · · · · · · \n" + "\n" + " · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · \n" + " · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · \n" + "\n" + " · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · \n" + " · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · \n" + "\n" + " · · · · · · · · · · · · · · · ● · · · · · · · · · · · · · · · \n" + " · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · \n" + "\n" + " · · · · · · · · · · · · · · · · ● · · · · · · · · · · · · · · \n" + " · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · \n" + "\n" + " · · · · · · · · · · · · · · · · · · · · ⨁ · · · · · · · · · · \n" + " · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · \n" + "\n" + " · · · · · · · · · · · · · · · · · · · · · · ◯ · · · · · · · · \n" + " · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · \n" + "\n" + " · · · · · · · · · · · · · · · · · · · · · · · · · · ● · · · · \n" + " · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · \n" + "\n" + " · · · · · · · · · · · · · · · · · · · · · · · · · · · · ● · · \n" + " · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · \n" + "\n" + " · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · \n" + " · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · \n" + "\n" + "\n"; + + CHECK(layout_print == print_stream.str()); +} + +TEST_CASE("Print layout without charges but defects", "[print-charge-layout]") +{ + const sidb_cell_clk_lyt layout{{2, 2}}; + + sidb_surface cl{convert_to_siqad_coordinates(layout)}; + + cl.assign_cell_type({0, 0, 0}, sidb_cell_clk_lyt_siqad::technology::NORMAL); + cl.assign_cell_type({1, 0, 1}, sidb_cell_clk_lyt_siqad::technology::NORMAL); + cl.assign_cell_type({4, 0, 1}, sidb_cell_clk_lyt_siqad::technology::NORMAL); + + cl.assign_sidb_defect({0, 0, 0}, sidb_defect{sidb_defect_type::UNKNOWN, 1}); + cl.assign_sidb_defect({1, 0, 1}, sidb_defect{sidb_defect_type::UNKNOWN, 0}); + cl.assign_sidb_defect({4, 0, 1}, sidb_defect{sidb_defect_type::UNKNOWN, -1}); + + std::stringstream print_stream{}; + + SECTION("crop_layout option activated") + { + print_sidb_layout(print_stream, cl, false, true, true); + // + constexpr const char* layout_print = " · · · · · · · · · \n" + " · · · · · · · · · \n" + "\n" + " · · ⊞ · · · · · · \n" + " · · · ⊡ · · ⊟ · · \n" + "\n" + " · · · · · · · · · \n" + " · · · · · · · · · \n" + "\n" + "\n"; + + CHECK(layout_print == print_stream.str()); + } + + SECTION("crop_layout option deactivated") + { + print_sidb_layout(print_stream, cl, false, false, true); + // + constexpr const char* layout_print = " ⊞ · · · · \n" + " · ⊡ · · ⊟ \n" + "\n" + "\n"; CHECK(layout_print == print_stream.str()); } } + +TEST_CASE("Print Bestagon OR-gate", "[print-charge-layout]") +{ + using hex_gate_lyt = hex_odd_row_gate_clk_lyt; + + hex_gate_lyt layout{aspect_ratio{0, 0}}; + + layout.create_or({}, {}, {0, 0}); + + const auto cell_layout_or = apply_gate_library(layout); + const auto cell_layout_or_siqad = convert_to_siqad_coordinates(cell_layout_or); + + std::stringstream print_stream{}; + + print_sidb_layout(print_stream, cell_layout_or_siqad, false, true, true); + + constexpr const char* layout_print = + " · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · \n" + " · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · \n" + "\n" + " · · o · · · · · · · · · · · · · · · · · · · · · · · · · o · · \n" + " · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · \n" + "\n" + " · · · · o · · · · · · · · · · · · · · · · · · · · · o · · · · \n" + " · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · \n" + "\n" + " · · · · · · · · o · · · · · · · · · · · · · o · · · · · · · · \n" + " · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · \n" + "\n" + " · · · · · · · · · · o · · · · · · · · · o · · · · · · · · · · \n" + " · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · \n" + "\n" + " · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · \n" + " · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · \n" + "\n" + " · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · \n" + " · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · \n" + "\n" + " · · · · · · · · · · · · · o · · · · · · · · · · · · · · · · · \n" + " · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · \n" + "\n" + " · · · · · · · · · · · · · · · · · · o · · · · · · · · · · · · \n" + " · · · · · · · · · · · · · o · · · · · · · · · · · · · · · · · \n" + "\n" + " · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · \n" + " · · · · · · · · · · · · · · · o · · · · · · · · · · · · · · · \n" + "\n" + " · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · \n" + " · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · \n" + "\n" + " · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · \n" + " · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · \n" + "\n" + " · · · · · · · · · · · · · · · o · · · · · · · · · · · · · · · \n" + " · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · \n" + "\n" + " · · · · · · · · · · · · · · · · o · · · · · · · · · · · · · · \n" + " · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · \n" + "\n" + " · · · · · · · · · · · · · · · · · · · · o · · · · · · · · · · \n" + " · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · \n" + "\n" + " · · · · · · · · · · · · · · · · · · · · · · o · · · · · · · · \n" + " · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · \n" + "\n" + " · · · · · · · · · · · · · · · · · · · · · · · · · · o · · · · \n" + " · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · \n" + "\n" + " · · · · · · · · · · · · · · · · · · · · · · · · · · · · o · · \n" + " · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · \n" + "\n" + " · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · \n" + " · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · \n" + "\n" + "\n"; + + CHECK(layout_print == print_stream.str()); +} \ No newline at end of file diff --git a/test/layouts/bounding_box.cpp b/test/layouts/bounding_box.cpp index c270265fa..51abf287e 100644 --- a/test/layouts/bounding_box.cpp +++ b/test/layouts/bounding_box.cpp @@ -132,3 +132,92 @@ TEST_CASE("Update 2D cell-level bounding box", "[bounding-box]") CHECK(bb_and.get_x_size() == 4); CHECK(bb_and.get_y_size() == 5); } + +TEST_CASE("2D bounding box for siqad layout", "[bounding-box]") +{ + SECTION("empyt layout") + { + const sidb_cell_clk_lyt_siqad lyt{}; + + const bounding_box_2d bb{lyt}; + const auto nw = bb.get_min(); + const auto se = bb.get_max(); + + CHECK(nw == siqad::coord_t(0, 0, 0)); + CHECK(se == siqad::coord_t(0, 0, 0)); + } + + SECTION("one cell") + { + sidb_cell_clk_lyt_siqad lyt{}; + lyt.assign_cell_type({1, 0, 0}, sidb_cell_clk_lyt_siqad::technology::NORMAL); + + const bounding_box_2d bb{lyt}; + const auto nw = bb.get_min(); + const auto se = bb.get_max(); + + CHECK(nw == siqad::coord_t{1, 0, 0}); + CHECK(se == siqad::coord_t{1, 0, 0}); + } + + SECTION("three cells as input, switched correct order") + { + sidb_cell_clk_lyt_siqad lyt{}; + lyt.assign_cell_type({0, 1, 0}, sidb_cell_clk_lyt_siqad::technology::NORMAL); + lyt.assign_cell_type({10, 0, 1}, sidb_cell_clk_lyt_siqad::technology::NORMAL); + lyt.assign_cell_type({5, 8, 0}, sidb_cell_clk_lyt_siqad::technology::NORMAL); + + const bounding_box_2d bb{lyt}; + const auto nw = bb.get_min(); + const auto se = bb.get_max(); + + CHECK(nw == siqad::coord_t{0, 0, 1}); + CHECK(se == siqad::coord_t{10, 8, 0}); + } + + SECTION("two cells as input, on the same height in y-direction") + { + sidb_cell_clk_lyt_siqad lyt{}; + lyt.assign_cell_type({-3, 0, 1}, sidb_cell_clk_lyt_siqad::technology::NORMAL); + lyt.assign_cell_type({3, 0, 1}, sidb_cell_clk_lyt_siqad::technology::NORMAL); + + const bounding_box_2d bb{lyt}; + const auto nw = bb.get_min(); + const auto se = bb.get_max(); + + CHECK(nw == siqad::coord_t{-3, 0, 1}); + CHECK(se == siqad::coord_t{3, 0, 1}); + } + + SECTION("four cells as input, three on the same dimer") + { + sidb_cell_clk_lyt_siqad lyt{}; + lyt.assign_cell_type({3, 0, 0}, sidb_cell_clk_lyt_siqad::technology::NORMAL); + lyt.assign_cell_type({0, 3, 1}, sidb_cell_clk_lyt_siqad::technology::NORMAL); + lyt.assign_cell_type({5, 3, 0}, sidb_cell_clk_lyt_siqad::technology::NORMAL); + lyt.assign_cell_type({10, 3, 1}, sidb_cell_clk_lyt_siqad::technology::NORMAL); + + const bounding_box_2d bb{lyt}; + const auto nw = bb.get_min(); + const auto se = bb.get_max(); + + CHECK(nw == siqad::coord_t{0, 0, 0}); + CHECK(se == siqad::coord_t{10, 3, 1}); + } + + SECTION("four cells as input, two on the same dimer") + { + sidb_cell_clk_lyt_siqad lyt{}; + lyt.assign_cell_type({0, 0, 0}, sidb_cell_clk_lyt_siqad::technology::NORMAL); + lyt.assign_cell_type({1, 0, 1}, sidb_cell_clk_lyt_siqad::technology::NORMAL); + lyt.assign_cell_type({-2, 4, 0}, sidb_cell_clk_lyt_siqad::technology::NORMAL); + lyt.assign_cell_type({2, 4, 1}, sidb_cell_clk_lyt_siqad::technology::NORMAL); + + const bounding_box_2d bb{lyt}; + const auto nw = bb.get_min(); + const auto se = bb.get_max(); + + CHECK(nw == siqad::coord_t{-2, 0, 0}); + CHECK(se == siqad::coord_t{2, 4, 1}); + } +} diff --git a/test/technology/sidb_defects.cpp b/test/technology/sidb_defects.cpp index b1fe8b171..577159b7f 100644 --- a/test/technology/sidb_defects.cpp +++ b/test/technology/sidb_defects.cpp @@ -73,12 +73,59 @@ TEST_CASE("Test for units", "[sidb-defects]") CHECK(defect.lambda_tf == 0.0); const sidb_defect defect_two{sidb_defect_type::NONE, 2}; + CHECK(is_positively_charged_defect(defect_two)); CHECK(defect_two.charge == 2); CHECK(defect_two.epsilon_r == 0); CHECK(defect_two.lambda_tf == 0.0); - const sidb_defect defect_three{sidb_defect_type::NONE, 2, 5}; - CHECK(defect_three.charge == 2); + const sidb_defect defect_three{sidb_defect_type::NONE, -2, 5}; + CHECK(is_negatively_charged_defect(defect_three)); + CHECK(defect_three.charge == -2); CHECK(defect_three.epsilon_r == 5); CHECK(defect_three.lambda_tf == 0.0); } + +TEST_CASE("Compare Defect", "[sidb-defects]") +{ + SECTION("Different types") + { + const sidb_defect defect_one{sidb_defect_type::GUNK}; + const sidb_defect defect_two{sidb_defect_type::UNKNOWN}; + CHECK(defect_one != defect_two); + } + + SECTION("Different charge") + { + const sidb_defect defect_one{sidb_defect_type::UNKNOWN, -5}; + const sidb_defect defect_two{sidb_defect_type::UNKNOWN, -1}; + CHECK(defect_one != defect_two); + } + + SECTION("Different epsilon_r") + { + const sidb_defect defect_one{sidb_defect_type::UNKNOWN, -1, 2}; + const sidb_defect defect_two{sidb_defect_type::UNKNOWN, -1, 5}; + CHECK(defect_one != defect_two); + } + + SECTION("Different lambda_tf") + { + const sidb_defect defect_one{sidb_defect_type::UNKNOWN, -1, 2, 4}; + const sidb_defect defect_two{sidb_defect_type::UNKNOWN, -1, 2, 5}; + CHECK(defect_one != defect_two); + } + + SECTION("Completely different") + { + const sidb_defect defect_one{sidb_defect_type::UNKNOWN, -1, 2, 4}; + const sidb_defect defect_two{sidb_defect_type::DB, 5, 5, 0.3}; + CHECK(defect_one != defect_two); + } + + SECTION("Identical Defects") + { + const sidb_defect defect_one{sidb_defect_type::UNKNOWN, -1, 2, 4}; + const sidb_defect defect_two{sidb_defect_type::UNKNOWN, -1, 2, 4}; + CHECK(defect_one == defect_two); + } +} diff --git a/test/utils/layout_utils.cpp b/test/utils/layout_utils.cpp index a41d278dc..dc3dc6d83 100644 --- a/test/utils/layout_utils.cpp +++ b/test/utils/layout_utils.cpp @@ -10,8 +10,6 @@ #include #include -#include - using namespace fiction; TEMPLATE_TEST_CASE("Port directions to coordinates", "[layout-utils]", (cartesian_layout),