Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Added a framework for accurate and efficient simulation of SiDB logic #105

Merged
merged 131 commits into from
Feb 3, 2023
Merged
Show file tree
Hide file tree
Changes from 121 commits
Commits
Show all changes
131 commits
Select commit Hold shift + click to select a range
7e924d0
feat: Added data structures to represent fabrication defects on the H…
marcelwa Mar 7, 2022
cc2e125
Distinction between charged and uncharged defects
marcelwa Mar 28, 2022
bc81d4b
Spacing values and RST documentation
marcelwa Mar 28, 2022
b1c7497
docs: Fixed doxygenenum directive (does not support the 'members' ope…
marcelwa Mar 28, 2022
e809358
Added a function to compute the extent of single SiDB defects in a la…
marcelwa Mar 29, 2022
8269472
Added a function to compute all SiDBs on a surface that are affected …
marcelwa Mar 29, 2022
d5ad572
feat: Added a simple parser to read printed Python arrays of integers…
marcelwa Mar 30, 2022
e4963b2
fix: Variable assignment fix under Windows
marcelwa Mar 30, 2022
307e184
fix: Underflow in for loop with negative values
marcelwa Mar 30, 2022
042c616
fix: Changed data types for loop variables
marcelwa Mar 30, 2022
1c99e03
fix: Windows underflow issue while comparing signed and unsigned inte…
marcelwa Mar 31, 2022
4f48a08
feat: Added a blacklisting mechanism for exact to disable certain gat…
marcelwa Apr 1, 2022
14eaa6f
fix: 'reference to local binding declared in enclosing function' comp…
marcelwa Apr 1, 2022
56e3ac3
feat: Added an interface to extract functional information from gate …
marcelwa Apr 6, 2022
895f48e
docs: Added RST documentation for truth table utils, SiDB surface ana…
marcelwa Apr 7, 2022
5b19158
:sparkles: Added SiDB defect support to the SQD writer
marcelwa Jun 22, 2022
0e89425
Changed the defects layer specification with respect to Samuel's input
marcelwa Jun 23, 2022
06372b1
:label: Added an sidb_defect type that encapsulates the sidb_defect_t…
marcelwa Jun 23, 2022
c91845f
:green_heart: Switched to single-threaded build for Coverage CI to co…
marcelwa Jun 23, 2022
564dcb4
:green_heart: Fixed Window's "unexpected token 'attribute specifier'"…
marcelwa Jun 23, 2022
5207818
:heavy_plus_sign: Added tinyXML2 as a submodule
marcelwa Jun 23, 2022
ecc7d8a
:sparkles: Added an SQD file reader to parse SiDB layouts
marcelwa Jun 23, 2022
86b238d
:white_check_mark: Added an SQD file reader tests to check for parsin…
marcelwa Jun 24, 2022
5296a7d
:white_check_mark: Added more SQD file reader tests to check for vali…
marcelwa Jun 24, 2022
4612605
:art: Simplified bounding box implementation
marcelwa Jun 24, 2022
8abc64a
:sparkles: Adjusted write_sqd_layout and read_sqd_layout to process S…
marcelwa Jun 24, 2022
aaa935f
:white_check_mark: Updated a test case for the SQD reader to validate…
marcelwa Jun 24, 2022
e0fe1e0
:white_check_mark: Added a test file for the SQD writer that incorpor…
marcelwa Jun 24, 2022
e2be547
:memo: Reflect SQD reader/writer changes in documentation
marcelwa Jun 24, 2022
988cd4d
:art: Adjust sqd file writer with respect to Samuel's feedback: leave…
marcelwa Jul 8, 2022
72ce3b0
:white_check_mark: Fix failing test in read_sqd_layout.cpp
marcelwa Jul 8, 2022
e0a3e54
:building_construction: Added the possibility to blacklist gates base…
marcelwa Jul 25, 2022
31e218b
:test_tube: Added a failing test for exact's functionality to respect…
marcelwa Jul 25, 2022
0aa137c
:sparkles: Added the ability to exact to blacklist gates based on the…
marcelwa Jul 26, 2022
416791b
:white_check_mark: Added EQ tests for blacklisted exact and functiona…
marcelwa Jul 26, 2022
86175eb
:sparkles: Enabled sidb_surface_analysis to determine port orientatio…
marcelwa Jul 28, 2022
0af23a3
:memo: Added documentation for the new optional fcn_gate_library inte…
marcelwa Jul 28, 2022
3c1b5ae
:memo: Just fixed a c&p error [skip ci]
marcelwa Jul 28, 2022
5ee05d8
:memo: Added more documentation on the Bestagon gate library
marcelwa Jul 28, 2022
403093c
:green_heart: Removed a static_assert that was too strict
marcelwa Jul 28, 2022
e736f8e
:bug: Prevent writing defect layer headers if the given cell layout t…
marcelwa Sep 2, 2022
e7abfab
:building_construction: Allow exact to specify x- and y-dimensions fo…
marcelwa Sep 2, 2022
fe1881b
:bug: Fixed layer order which is apparently very important for SiQAD
marcelwa Sep 2, 2022
2e7a5f9
Merge branch 'main' into sidb_defects
marcelwa Sep 8, 2022
c0154ab
:bug: Unknown defects are neutral
marcelwa Sep 16, 2022
48ca01a
:white_check_mark: Added a test case for the SiDB surface analysis
marcelwa Sep 16, 2022
009c4a7
:sparkles: Added the possibility to ignore specified defect types on …
marcelwa Sep 19, 2022
c8f847b
:sparkles: Added in-place overloads for read_sqd_layout
marcelwa Sep 19, 2022
27ae4cc
Updated the Bestagon library with three tiles that are more stable ag…
marcelwa Sep 20, 2022
047e512
:sparkles: Support for step edges and residual gunk surface defects
marcelwa Sep 20, 2022
090c1f8
:art: More generic test case for defect extend
marcelwa Sep 21, 2022
da5453e
:recycle: Cleaned up code
marcelwa Sep 21, 2022
a72d517
Merge branch 'main' into sidb_defects
marcelwa Sep 28, 2022
b7bd725
Merge branch 'main' into sidb_defects
marcelwa Oct 4, 2022
1dec56a
Merge branch 'main' into sidb_defects
marcelwa Oct 5, 2022
7149c20
💚 Fixed MSVC's `C1001: internal compiler error` (#62)
marcelwa Oct 11, 2022
98b03af
:memo: Fixed Read the Docs compilation
marcelwa Oct 13, 2022
4531cb9
Merge branch 'main' into sidb_defects
marcelwa Oct 24, 2022
8b6e4f9
:bug: Fixed merge artifacts
marcelwa Oct 24, 2022
ead1d40
:art: clang-tidy fixes
marcelwa Oct 24, 2022
1c74f98
:green_heart: Replace operators `and`, `or`, `not` with `&&`, `||`, `…
marcelwa Oct 24, 2022
852f546
Merge branch 'main' into sidb_defects
marcelwa Nov 11, 2022
06fd3e9
:art: Applied clang-tidy
marcelwa Nov 14, 2022
2255128
Incorporated remaining resilient Bestagon gates
marcelwa Nov 15, 2022
d112834
Added resilient Bestagon gates as SQD resources
marcelwa Nov 15, 2022
a7d197e
:rotating_light: Applied clang-tidy
marcelwa Nov 15, 2022
50ffedb
:white_check_mark: Fix sidb_surface_analysis tests which were failing…
marcelwa Nov 15, 2022
efe19c7
:rotating_light: Fix compiler warning
marcelwa Nov 16, 2022
8027ba8
:alembic: Changed charged defect exclusion spacing to 10nm in accorda…
marcelwa Nov 16, 2022
968f4d4
new coordinate-converter function
Nov 22, 2022
6ceb741
function to convert siqad-coordinates
Nov 22, 2022
26b660f
:sparkles: function to convert siqad-coordinates and tests added
Nov 23, 2022
ba98ce1
second iteration of coordinate-converter-functions and documentation …
Nov 24, 2022
d6c8eb7
Delete siqad_to_cartesian.hpp
Drewniok Nov 24, 2022
ab4c7d7
:alembic: Defect-aware physical design experiment
marcelwa Nov 24, 2022
736dfab
:alembic: Python script to create defective surfaces
marcelwa Nov 24, 2022
d033b06
:sparkles: added siqad namespace to enable negative coordinates
Nov 24, 2022
9682a1f
:sparkles: added tests for negative coordinates
Nov 25, 2022
f31b7ee
:bug: if-else no required in "to_siqad_coord"
Nov 25, 2022
a38e848
:art: d and z-coordinate as bool
Nov 28, 2022
6b58706
:art: z-coordinate type changed from bool to uint8_t : 1
Nov 29, 2022
6eaaa56
Siqad coordinates (#4)
Drewniok Nov 29, 2022
1fc5002
:bug: added "const" for return iterator of find function
Dec 2, 2022
c4e880f
Merge branch 'sidb_defects' into sidb_defects
marcelwa Dec 2, 2022
ed3ae1f
:bug: added "const" for return iterator of find function (#80)
Drewniok Dec 2, 2022
077d969
Merge branch 'marcelwa:sidb_defects' into sidb_defects
Drewniok Dec 5, 2022
ea803ae
:sparkles: new constructor for sidb_surface to generate surface with …
Dec 5, 2022
0489cb0
Merge branch 'main' into sidb_defects
marcelwa Dec 5, 2022
45ae6fe
:art: added missing docu for SiQAD coordinates
Dec 5, 2022
634608c
:art: Adjusted code based on advancements in main
marcelwa Dec 5, 2022
5ff3599
Merge
marcelwa Dec 5, 2022
12b21b0
Merge branch 'sidb_defects' into sidb_defects
marcelwa Dec 6, 2022
cdf457b
new constructor for sidb_surface.cpp added (#84)
Drewniok Dec 6, 2022
1a55997
:art: Marcel's suggestions updated
Dec 6, 2022
ad0c346
Merge branch 'groundstate_simulation_sidb' into siqad_coordinates
marcelwa Dec 7, 2022
7475e1f
Merge pull request #7 from Drewniok/siqad_coordinates
marcelwa Dec 7, 2022
505c7b5
Merge branch 'main' into sidb_defects
marcelwa Dec 8, 2022
cbc6f53
Merge branch 'sidb_defects' of github.com:marcelwa/fiction into sidb_…
marcelwa Dec 8, 2022
b5cad93
Merge branch 'sidb_defects' into groundstate_simulation_sidb
Dec 8, 2022
90b0dfa
:green_heart: Workaround for MSVC being petty
marcelwa Dec 8, 2022
a295f97
:green_heart: Prevent experiment from being built if Z3 is disabled
marcelwa Dec 8, 2022
6732859
:green_heart: Workaround for MSVC being petty
marcelwa Dec 8, 2022
1ba93d8
Merge branch 'main' into sidb_defects
marcelwa Dec 8, 2022
9da0607
Merge remote-tracking branch 'origin/sidb_defects' into sidb_defects
Dec 8, 2022
749f438
Merge branch 'sidb_defects' into groundstate_simulation_sidb
Dec 8, 2022
87f82e1
new layer to store charge states of SiDBs, tests included (#6)
Drewniok Dec 12, 2022
625bb5c
Fiction structure (#13)
Drewniok Jan 31, 2023
d35c124
:hammer: new function to get all SiDB positions in nm (x,y).
Jan 31, 2023
c7a661f
:hammer: two functions which are useful for the integration into SiQAD
Jan 31, 2023
6c50d0f
Merge branch 'main' into groundstate_simulation_sidb
Feb 1, 2023
cfd77ef
:hammer: main merged in groundstate_simulation_sidb
Feb 1, 2023
de19058
:fire: Removed artifact files
marcelwa Feb 1, 2023
3919d26
:art: Applied ClangFormat
marcelwa Feb 1, 2023
f0b88ab
:art: Code formatting
marcelwa Feb 1, 2023
9412b1d
:art: Code formatting
marcelwa Feb 1, 2023
4e29776
:art: Code formatting
marcelwa Feb 1, 2023
038729f
:art: Code formatting
marcelwa Feb 2, 2023
066af15
:hammer: test for time-to-solution added
Feb 2, 2023
9cb8843
:hammer: test for time-to-solution added
Feb 2, 2023
057ba01
:hammer: test for check_groundstate.cpp added
Feb 2, 2023
f26ddc4
:hammer: reformat code
Feb 2, 2023
f825ada
:art: Moved files and fixed documentation
marcelwa Feb 2, 2023
f6e0f54
:art: Adjusted simulation algorithms to construct their own `charge_d…
marcelwa Feb 2, 2023
df6bfe8
Merge branch 'main' into groundstate_simulation_sidb
marcelwa Feb 2, 2023
4292465
:hammer: pop_stability added to "is_groundstate.hpp"
Feb 2, 2023
44e05c8
:green_heart: Fixed compiler errors on template deduction
marcelwa Feb 2, 2023
9193281
Merge remote-tracking branch 'origin/groundstate_simulation_sidb' int…
marcelwa Feb 2, 2023
0cf436c
Merge remote-tracking branch 'origin/groundstate_simulation_sidb' int…
Feb 2, 2023
4c6663f
:hammer: tts_acc_tss gets cell-level-layout as input.
Feb 3, 2023
48c0740
:hammer: tts_acc_tss gets quicksim_params as input (includes physical…
Feb 3, 2023
bed1fad
:rotating_light: Addressed linter warnings regarding `std::rand()` (w…
marcelwa Feb 3, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ Let there be a *fiction*

technology/cell_technologies.rst
technology/defects.rst
technology/simulation.rst
technology/gate_libraries.rst
technology/properties.rst

Expand Down
10 changes: 10 additions & 0 deletions docs/layouts/coordinates.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,18 @@ At the same time, they can be used to address 3-dimensional grids.

.. doxygenstruct:: fiction::cube::coord_t

SiQAD coordinates
----------------

SiQAD coordinates are used to describe locations of Silicon Dangling Bonds on the H-Si(100) 2x1 surface were dimer columns and rows are identified by x and y values, respecitvely,
while the z value (0,1) points to the top or bottom Si atom in the dimer. The coordinates are originally used in the SiQAD simulator (https://github.com/siqad).

.. doxygenstruct:: fiction::siqad::coord_t

Utility functions
-----------------

.. doxygenfunction:: fiction::area(const CoordinateType& coord) noexcept
.. doxygenfunction:: fiction::volume(const CoordinateType& coord) noexcept
.. doxygenfunction:: fiction::to_fiction_coord(const fiction::offset::ucoord_t& coord) noexcept
.. doxygenfunction:: fiction::to_siqad_coord(const CoordinateType& coord) noexcept
17 changes: 17 additions & 0 deletions docs/technology/simulation.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Physical Simulation of SiDBs
===================

Layout to store and read charge states of a SiDB layout

SiDB charge states
------------

**Header:** ``fiction/technology/sidb_charge_state.hpp``

.. doxygenenum:: fiction::sidb_charge_state

**Header:** ``fiction/technology/charge_distribution_surface.hpp``

.. doxygenclass:: fiction::charge_distribution_surface
:members:

Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
# this one treats each H-Si as an array value


import random
import sys

import matplotlib.pyplot as plt
import numpy as np
import random
import sys

np.set_printoptions(threshold=sys.maxsize)
from matplotlib.axes._axes import _log as matplotlib_axes_logger
Expand Down
28 changes: 28 additions & 0 deletions include/fiction/algorithms/path_finding/distance.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#ifndef FICTION_DISTANCE_HPP
#define FICTION_DISTANCE_HPP

#include "fiction/technology/sidb_nm_position.hpp"
#include "fiction/traits.hpp"

#include <cmath>
Expand Down Expand Up @@ -61,6 +62,33 @@ template <typename Lyt, typename Dist = double>

return static_cast<Dist>(std::hypot(x, y));
}
/**
* Computes the distance between two SiDB cells in nanometers.
*
* @tparam Lyt SiDB cell-level layout type.
* @tparam Dist Floating-point type for the distance.
* @param c1 The first cell.
* @param c2 The second cell.
* @return The distance between the two cells in nanometers.
*/
template <typename Lyt, typename Dist = double>
[[nodiscard]] constexpr Dist
sidb_nanometer_distance([[maybe_unused]] const Lyt& lyt, const coordinate<Lyt>& source, const coordinate<Lyt>& target,
const sidb_simulation_parameters& sp = sidb_simulation_parameters{}) noexcept
{
static_assert(is_cell_level_layout_v<Lyt>, "Lyt is not a cell-level layout");
static_assert(has_sidb_technology_v<Lyt>, "Lyt is not based on SiDB technology");
static_assert(has_siqad_coord_v<Lyt>, "Lyt is not based on SiQAD coordinates");
static_assert(std::is_floating_point_v<Dist>, "Dist is not a floating-point type");

const auto pos_c1 = sidb_nm_position<Lyt>(sp, source);
const auto pos_c2 = sidb_nm_position<Lyt>(sp, target);

const auto x = static_cast<Dist>(pos_c1.first) - static_cast<double>(pos_c2.first);
const auto y = static_cast<Dist>(pos_c1.second) - static_cast<double>(pos_c2.second);

return static_cast<Dist>(std::hypot(x, y));
}

// NOLINTBEGIN(*-special-member-functions): virtual destructor is prudent

Expand Down
49 changes: 49 additions & 0 deletions include/fiction/algorithms/simulation_sidb/check_groundstate.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
//
// Created by Jan Drewniok on 18.01.23.
//

#ifndef FICTION_CHECK_GROUNDSTATE_HPP
#define FICTION_CHECK_GROUNDSTATE_HPP

#include "fiction/algorithms/simulation_sidb/exhaustive_ground_state_simulation.hpp"
#include "fiction/algorithms/simulation_sidb/minimum_energy.hpp"
#include "fiction/algorithms/simulation_sidb/quicksim.hpp"
#include "fiction/traits.hpp"

#include <cmath>

namespace fiction
{

/**
* This function checks if the ground state is found by the quicksim algorithm.
*
* @tparam Lyt Cell-level layout type.
* @param quicksim_results All found physically valid charge distribution surfaces obtained with the new quicksim
* algorithm (see quicksim.hpp).
* @param exhaustive_results All valid charge distribution surfaces (ExGS, see ExGS.hpp).
* @return Returns `true` if the relative difference between the lowest energies of the two sets is less than 0.00001,
* `false` otherwise.
*/
template <typename Lyt>
[[nodiscard]] bool check_groundstate(const quicksim_stats<Lyt>& quicksim_results,
const exgs_stats<Lyt>& exhaustive_results)
{
static_assert(is_cell_level_layout_v<Lyt>, "Lyt is not a cell-level layout");
static_assert(has_sidb_technology_v<Lyt>, "Lyt is not an SiDB layout");
static_assert(has_siqad_coord_v<Lyt>, "Lyt is not based on SiQAD coordinates");

if (exhaustive_results.valid_lyts.empty())
{
return false;
}

const auto min_energy_exact = minimum_energy(exhaustive_results.valid_lyts);
const auto min_energy_new_ap = minimum_energy(quicksim_results.valid_lyts);

return std::abs(min_energy_exact - min_energy_new_ap) / min_energy_exact < 0.00001;
marcelwa marked this conversation as resolved.
Show resolved Hide resolved
}

} // namespace fiction

#endif // FICTION_CHECK_GROUNDSTATE_HPP
48 changes: 48 additions & 0 deletions include/fiction/algorithms/simulation_sidb/energy_distribution.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
//
// Created by Jan Drewniok on 17.01.23.
//

#ifndef FICTION_ENERGY_DISTRIBUTION_HPP
#define FICTION_ENERGY_DISTRIBUTION_HPP

#include "fiction/technology/charge_distribution_surface.hpp"

#include <cmath>
#include <cstdint>
#include <map>
#include <vector>

namespace fiction
{

/**
* This function takes in a vector of charge_distribution_surface objects and returns a map containing the system energy
* and the number of occurrences of that energy in the input vector.
*
* @tparam Lyt Cell-level layout type.
* @param input_vec A vector of charge_distribution_surface objects for which statistics are to be computed.
* @return A map containing the system energy as the key and the number of occurrences of that energy in the input
* vector as the value.
*/
template <typename Lyt>
std::map<double, uint64_t> energy_distribution(const std::vector<charge_distribution_surface<Lyt>>& input_vec)
{
static_assert(is_cell_level_layout_v<Lyt>, "Lyt is not a cell-level layout");
static_assert(has_sidb_technology_v<Lyt>, "Lyt is not an SiDB layout");

std::map<double, uint64_t> distribution{};

for (const auto& lyt : input_vec)
{
const auto energy =
std::round(lyt.get_system_energy() * 1'000'000) / 1'000'000; // rounding to 6 decimal places.

distribution[energy]++;
}

return distribution;
}

} // namespace fiction

#endif // FICTION_ENERGY_DISTRIBUTION_HPP
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
//
// Created by Jan Drewniok on 18.12.22.
//

#ifndef FICTION_EXHAUSTIVE_GROUND_STATE_SIMULATION_HPP
#define FICTION_EXHAUSTIVE_GROUND_STATE_SIMULATION_HPP

#include "fiction/algorithms/simulation_sidb/energy_distribution.hpp"
#include "fiction/algorithms/simulation_sidb/minimum_energy.hpp"
#include "fiction/algorithms/simulation_sidb/sidb_simulation_parameters.hpp"
#include "fiction/technology/charge_distribution_surface.hpp"

#include <fmt/format.h>
#include <mockturtle/utils/stopwatch.hpp>

#include <iostream>
#include <vector>

namespace fiction
{

template <typename Lyt>
struct exgs_stats
{
mockturtle::stopwatch<>::duration time_total{0};
std::vector<charge_distribution_surface<Lyt>> valid_lyts{};

void report(std::ostream& out = std::cout) const
{
out << fmt::format("total time = {:.2f} secs\n", mockturtle::to_seconds(time_total));
if (!valid_lyts.empty())
{
for (const auto& [energy, count] : energy_distribution<Lyt>(valid_lyts))
{
out << fmt::format("energy: {} | occurance: {} \n", energy, count);
}
out << fmt::format("the ground state energy is = {:.4f} \n", minimum_energy(valid_lyts));
}
else
{
std::cout << "no state found | if two state simulation is used, continue with three state" << std::endl;
}

out << fmt::format("{} phyiscally valid charge states were found \n", valid_lyts.size());
std::cout << "_____________________________________________________ \n";
}
};

/**
* All metastable and physically valid charge distribution layouts are computed, stored in a vector and returned.
*
* @tparam Lyt Cell-level layout type.
* @param lyt Charge distribution layout.
* @param params Simulation parameters.
* @param ps Simulation statistics.
*/
template <typename Lyt>
void exhaustive_ground_state_simulation(charge_distribution_surface<Lyt>& lyt,
const sidb_simulation_parameters& params = sidb_simulation_parameters{},
exgs_stats<Lyt>* ps = nullptr)
{
static_assert(is_cell_level_layout_v<Lyt>, "Lyt is not a cell-level layout");
static_assert(has_sidb_technology_v<Lyt>, "Lyt is not an SiDB layout");

exgs_stats<Lyt> st{};

{
mockturtle::stopwatch stop{st.time_total};
lyt.set_physical_parameters(params);
lyt.set_all_charge_states(sidb_charge_state::NEGATIVE);
lyt.update_after_charge_change();

while (lyt.get_charge_index().first < lyt.get_max_charge_index())
{

if (lyt.is_physically_valid())
{
charge_distribution_surface<Lyt> lyt_new{lyt};
st.valid_lyts.push_back(lyt_new);
}

lyt.increase_charge_index_by_one();
}

if (lyt.is_physically_valid())
{
charge_distribution_surface<Lyt> lyt_new{lyt};
st.valid_lyts.push_back(lyt_new);
}
}

if (ps)
{
*ps = st;
}
}

} // namespace fiction

#endif // FICTION_EXHAUSTIVE_GROUND_STATE_SIMULATION_HPP
36 changes: 36 additions & 0 deletions include/fiction/algorithms/simulation_sidb/minimum_energy.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
//
// Created by Jan Drewniok on 18.01.23.
//

#ifndef FICTION_MINIMUM_ENERGY_HPP
#define FICTION_MINIMUM_ENERGY_HPP

#include "fiction/technology/charge_distribution_surface.hpp"

#include <algorithm>
#include <limits>
#include <vector>

namespace fiction
{

/**
* Computes the minimum energy of a vector of charge_distribution_surface objects.
*
* @tparam Lyt Cell-level layout type.
* @param result Vector of charge_distribution_surface objects.
* @return Value of the minimum energy found in the input vector.
*/
template <typename Lyt>
double minimum_energy(const std::vector<charge_distribution_surface<Lyt>>& charge_lyts)
{
static_assert(is_cell_level_layout_v<Lyt>, "Lyt is not a cell-level layout");
static_assert(has_sidb_technology_v<Lyt>, "Lyt is not an SiDB layout");

return std::accumulate(charge_lyts.begin(), charge_lyts.end(), std::numeric_limits<double>::max(),
[](double a, const auto& lyt) { return std::min(a, lyt.get_system_energy()); });
}

} // namespace fiction

#endif // FICTION_MINIMUM_ENERGY_HPP
Loading