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 an SiDB simulation file writer #176

Merged
merged 23 commits into from
Apr 19, 2023
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
c520e72
:sparkles: Added a new unified return type for SiDB simulation
marcelwa Apr 5, 2023
2be7c73
:sparkles: Added a file writer for SQD simulation runs parsable by SiQAD
marcelwa Apr 5, 2023
a362054
:memo: Added and fixed docstrings
marcelwa Apr 5, 2023
cba290e
:memo: Added RST documentation
marcelwa Apr 5, 2023
4f146c5
:memo: Removed superfluous newlines
marcelwa Apr 5, 2023
caa974a
:art: Incorporated clang-tidy's recommendations
marcelwa Apr 6, 2023
58c8d7d
:art: Rewrote `any_to_string` to be more performant and extensible
marcelwa Apr 6, 2023
594aeae
:bug: Replaced the usage of the custom charge to string function with…
marcelwa Apr 17, 2023
ac487b5
:white_check_mark: Added a test case for positive SiDBs
marcelwa Apr 17, 2023
b21c02d
:white_check_mark: Added test cases for `any_to_string`
marcelwa Apr 17, 2023
6b78ad3
:art: ClangFormat changes
Apr 17, 2023
66dab6f
:bug: Added `inline` to `any_to_string` in order to avoid ODR problems
marcelwa Apr 17, 2023
592154b
Merge remote-tracking branch 'origin/write-sqd-sim-results' into writ…
marcelwa Apr 17, 2023
9e3218f
:white_check_mark: Fixed the test case
marcelwa Apr 17, 2023
d5a013d
:art: ClangFormat changes
Apr 17, 2023
9b20ba0
Merge branch 'main' into write-sqd-sim-results
marcelwa Apr 17, 2023
b35ea5e
Merge branch 'main' into write-sqd-sim-results
marcelwa Apr 18, 2023
c82b935
:alien: Convert nm to Angstrom
marcelwa Apr 18, 2023
dfc5115
:alien: Round distances and energy values to 6 decimal points
marcelwa Apr 18, 2023
a77984b
Merge branch 'main' into write-sqd-sim-results
marcelwa Apr 19, 2023
7eb08d1
:white_check_mark: Added additional tests to cover more lines
marcelwa Apr 19, 2023
6fac6b8
:art: ClangFormat changes
Apr 19, 2023
21f1b56
Merge branch 'main' into write-sqd-sim-results
marcelwa Apr 19, 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
11 changes: 9 additions & 2 deletions docs/algorithms/sidb_simulation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,21 @@ are a crucial step in the physical design flow of SiDB layouts, as they are used
Physical Parameters
###################


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

.. doxygenstruct:: fiction::sidb_simulation_parameters
:members:


Simulation Result
#################

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

.. doxygenstruct:: fiction::sidb_simulation_result
:members:


Heuristic Ground State Simulation
#################################

Expand All @@ -31,7 +39,6 @@ Heuristic Ground State Simulation
Exhaustive Ground State Simulation
##################################


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

.. doxygenfunction:: fiction::exhaustive_ground_state_simulation
Expand Down
5 changes: 5 additions & 0 deletions docs/io/physical_simulation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ SiQAD
.. doxygenfunction:: fiction::write_sqd_layout(const Lyt& lyt, std::ostream& os)
.. doxygenfunction:: fiction::write_sqd_layout(const Lyt& lyt, const std::string_view& filename)

**Header:** ``fiction/io/write_sqd_sim_result.hpp``

.. doxygenfunction:: fiction::write_sqd_sim_result(const sidb_simulation_result<Lyt>& sim_result, std::ostream& os)
.. doxygenfunction:: fiction::write_sqd_sim_result(const sidb_simulation_result<Lyt>& sim_result, const std::string_view& filename)

**Header:** ``fiction/io/read_sqd_layout.hpp``

.. doxygenfunction:: fiction::read_sqd_layout(std::istream& is, const std::string_view& name = "")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
//
// Created by marcel on 05.04.23.
//

#ifndef FICTION_SIDB_SIMULATION_RESULT_HPP
#define FICTION_SIDB_SIMULATION_RESULT_HPP

#include "fiction/algorithms/simulation/sidb/sidb_simulation_parameters.hpp"
#include "fiction/technology/charge_distribution_surface.hpp"

#include <any>
#include <chrono>
#include <cstdint>
#include <string>
#include <utility>
#include <vector>

namespace fiction
{

/**
* This struct defines a unified return type for all SiDB simulation algorithms. It contains the name of the algorithm,
* the total simulation runtime, the charge distributions determined by the algorithm, the physical parameters used in
* the simulation, and (optional) algorithm-specific named simulation parameters.
*
* @tparam Lyt Cell-level layout type.
*/
template <typename Lyt>
struct sidb_simulation_result
{
/**
* Default constructor. It only exists to allow for the use of `static_assert` statements that restrict the type of
* `Lyt`.
*/
sidb_simulation_result() 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 an SiDB layout");
}
/**
* Name of the algorithm used to determine the charge distributions.
*/
std::string algorithm_name{};
/**
* Total simulation runtime.
*/
std::chrono::duration<double> simulation_runtime{};
/**
* Charge distributions determined by the algorithm.
*/
std::vector<charge_distribution_surface<Lyt>> charge_distributions{};
/**
* Physical parameters used in the simulation.
*/
sidb_simulation_parameters physical_parameters{};
/**
* Additional named simulation parameters. This is used to store algorithm-dependent parameters that are not part of
* the `physical_parameters` struct.
*
* The first element of the pair is the name of the parameter, the second element is the value of the parameter.
*/
std::vector<std::pair<std::string, std::any>> additional_simulation_parameters{};
};

} // namespace fiction

#endif // FICTION_SIMULATION_RESULT_HPP
10 changes: 5 additions & 5 deletions include/fiction/io/write_sqd_layout.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ namespace detail
namespace siqad
{

inline constexpr const char* XML_HEADER = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
inline constexpr const char* SQD_HEADER = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
inline constexpr const char* OPEN_SIQAD = "<siqad>\n";
inline constexpr const char* CLOSE_SIQAD = "</siqad>\n";
inline constexpr const char* PROGRAM_BLOCK = " <program>\n"
Expand Down Expand Up @@ -168,7 +168,7 @@ class write_sqd_layout_impl
{
std::stringstream header{}, gui{}, design{};

header << siqad::XML_HEADER << siqad::OPEN_SIQAD;
header << siqad::SQD_HEADER << siqad::OPEN_SIQAD;

const auto time_str = fmt::format("{:%Y-%m-%d %H:%M:%S}", fmt::localtime(std::time(nullptr)));

Expand Down Expand Up @@ -293,7 +293,7 @@ class write_sqd_layout_impl
* Writes a cell-level SiDB or QCA layout to an sqd file that is used by SiQAD (https://github.com/siqad/siqad),
* a physical simulator for the SiDB technology platform.
*
* If The provided cell-level layout type can represent SiDB defects, they will be written to the file as well.
* If the provided cell-level layout type can represent SiDB defects, they will be written to the file as well.
*
* This overload uses an output stream to write into.
*
Expand All @@ -315,9 +315,9 @@ void write_sqd_layout(const Lyt& lyt, std::ostream& os)
* Writes a cell-level SiDB or QCA layout to an sqd file that is used by SiQAD (https://github.com/siqad/siqad),
* a physical simulator for the SiDB technology platform.
*
* If The provided cell-level layout type can represent SiDB defects, they will be written to the file as well.
* If the provided cell-level layout type can represent SiDB defects, they will be written to the file as well.
*
* This overload uses file name to create and write into.
* This overload uses a file name to create and write into.
*
* @tparam Lyt Cell-level SiDB or QCA layout type.
* @param lyt The layout to be written.
Expand Down
Loading