From 0ea031837c0ef9998d1f30323c517a50f56200be Mon Sep 17 00:00:00 2001 From: Valentin Boettcher Date: Mon, 7 Mar 2022 09:42:26 +0100 Subject: [PATCH] begin scan code --- poetry.lock | 2 +- two_qubit_scan.py | 68 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 two_qubit_scan.py diff --git a/poetry.lock b/poetry.lock index 842efc4..2647043 100644 --- a/poetry.lock +++ b/poetry.lock @@ -293,7 +293,7 @@ typer = "^0.4.0" type = "git" url = "git@gitlab.hrz.tu-chemnitz.de:s8896854--tu-dresden.de/hops.git" reference = "BathMemoryTruncation" -resolved_reference = "17e7671e42891b52b9fd76262bedfa2a26e5f1f7" +resolved_reference = "22ee9b9365203d32f0a755123b678f54237ecfd4" [[package]] name = "humanfriendly" diff --git a/two_qubit_scan.py b/two_qubit_scan.py new file mode 100644 index 0000000..80919bb --- /dev/null +++ b/two_qubit_scan.py @@ -0,0 +1,68 @@ +from two_qubit_model import TwoQubitModel +from typing import Optional +import tempfile +from hops.core.integration import HOPSSupervisor +from hops.core.hierarchy_parameters import HIParams +from dataclasses import dataclass +import numpy as np + + +@dataclass +class TruncationToleranceData: + tol: float + """The tolerance parameter for ``BathMemory`` truncation scheme.""" + + number_of_indices: int + """The number of indices given by the ``BathMemory`` truncation scheme""" + + number_of_indices_ref: int + """The reference number of indices given by the ``Simplex`` truncation scheme""" + + relative_error: float + """The maximum norm deviation of the ``BathMemory`` trajectory + from the reference ``Simplex`` trajectory divided by the maximum + of the norm of the reverence trajectory.""" + + k_max_ref: int + """The depth of the reference ``Simplex`` truncation scheme.""" + + +def get_one_trajctory(config: HIParams) -> np.ndarray: + """The""" + + +def find_tol( + model: TwoQubitModel, + k_max_ref: int = 6, + start_tol: int = 4, + relative_error: float = 0.1, +) -> Optional[float]: + """Find the tolerance for the ``BathMemory`` truncation scheme. + + :param model: The model configuration. + :param k_max_ref: The depth of the reference ``Simplex`` + truncation scheme. + :param start_tol: The start tolerance of the ``BathMemory`` + truncation scheme. + :param relative_error: The maximum allowed norm deviation of the + ``BathMemory`` trajectory from the reference ``Simplex`` + trajectory divided by the maximum of the norm of the + reverence trajectory. + + :returns: The required tolerance parameter for ``BathMemory`` + truncation scheme or ``None`` if none could be found. + """ + + simplex_model = model.copy() + simplex_model.truncation_scheme = "simplex" + simplex_model.k_max = k_max_ref + + simplex_config = simplex_model.hops_config + + with tempfile.TemporaryDirectory() as data_dir: + simplex_sup = HOPSSupervisor( + simplex_config, + number_of_samples=1, + data_path=data_dir, + data_name="data_conv", + )