-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into legalization
- Loading branch information
Showing
19 changed files
with
690 additions
and
76 deletions.
There are no files selected for viewing
54 changes: 54 additions & 0 deletions
54
...ings/pyfiction/include/pyfiction/algorithms/simulation/sidb/compute_operational_ratio.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// | ||
// Created by Jan Drewniok on 13.09.24. | ||
// | ||
|
||
#ifndef PYFICTION_COMPUTE_OPERATIONAL_RATIO_HPP | ||
#define PYFICTION_COMPUTE_OPERATIONAL_RATIO_HPP | ||
|
||
#include "pyfiction/documentation.hpp" | ||
#include "pyfiction/types.hpp" | ||
|
||
#include <fiction/algorithms/simulation/sidb/compute_operational_ratio.hpp> | ||
|
||
#include <pybind11/operators.h> | ||
#include <pybind11/pybind11.h> | ||
#include <pybind11/stl.h> | ||
|
||
namespace pyfiction | ||
{ | ||
|
||
namespace detail | ||
{ | ||
|
||
template <typename Lyt> | ||
void compute_operational_ratio(pybind11::module& m) | ||
{ | ||
namespace py = pybind11; | ||
using namespace pybind11::literals; | ||
|
||
m.def("compute_operational_ratio", &fiction::compute_operational_ratio<Lyt, py_tt>, "lyt"_a, "spec"_a, "pp"_a, | ||
"params"_a = fiction::operational_domain_params{}, DOC(fiction_compute_operational_ratio)); | ||
} | ||
|
||
} // namespace detail | ||
|
||
inline void compute_operational_ratio(pybind11::module& m) | ||
{ | ||
namespace py = pybind11; | ||
using namespace pybind11::literals; | ||
|
||
py::class_<fiction::compute_operational_ratio_params>(m, "compute_operational_ratio_params", | ||
DOC(fiction_compute_operational_ratio_params)) | ||
.def(py::init<>()) | ||
.def_readwrite("op_domain_params", &fiction::compute_operational_ratio_params::op_domain_params, | ||
DOC(fiction_compute_operational_ratio_params_op_domain_params)); | ||
|
||
// NOTE be careful with the order of the following calls! Python will resolve the first matching overload! | ||
|
||
detail::compute_operational_ratio<py_sidb_100_lattice>(m); | ||
detail::compute_operational_ratio<py_sidb_111_lattice>(m); | ||
} | ||
|
||
} // namespace pyfiction | ||
|
||
#endif // PYFICTION_COMPUTE_OPERATIONAL_RATIO_HPP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
bindings/pyfiction/test/algorithms/simulation/sidb/test_compute_operational_ratio.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import os | ||
import unittest | ||
|
||
from mnt.pyfiction import * | ||
|
||
dir_path = os.path.dirname(os.path.realpath(__file__)) | ||
|
||
class TestComputeOperationalRatioAtPoint(unittest.TestCase): | ||
def test_and_gate_100_lattice(self): | ||
lyt = read_sqd_layout_100(dir_path + "/../../../resources/21_hex_inputsdbp_and_v19.sqd") | ||
|
||
params = operational_domain_params() | ||
params.sim_engine = sidb_simulation_engine.QUICKEXACT | ||
params.simulation_parameters.base = 2 | ||
|
||
params.sweep_dimensions = [operational_domain_value_range(sweep_parameter.EPSILON_R, 5.00, 6.00, 0.1), | ||
operational_domain_value_range(sweep_parameter.LAMBDA_TF, 5.00, 6.00, 0.1)] | ||
|
||
ratio_params = compute_operational_ratio_params() | ||
ratio_params.op_domain_params = params | ||
|
||
self.assertEqual(ratio_params.op_domain_params.simulation_parameters.base, 2) | ||
|
||
operational_domain_ratio = compute_operational_ratio(lyt, [create_and_tt()], parameter_point([5.6, 5.0]), ratio_params) | ||
|
||
self.assertAlmostEqual(operational_domain_ratio, 23/121, delta=10E-6) | ||
|
||
if __name__ == '__main__': | ||
unittest.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.