Пример #1
0
    def test_create_bath_errors(self):
        Q = sigmaz()
        H = sigmax()
        mixed_types = [
            BathExponent("+", 2, Q=Q, ck=1.1, vk=2.1, sigma_bar_k_offset=1),
            BathExponent("-", 2, Q=Q, ck=1.2, vk=2.2, sigma_bar_k_offset=-1),
            BathExponent("R", 2, Q=Q, ck=1.2, vk=2.2),
        ]
        mixed_q_dims = [
            BathExponent("I", 2, Q=tensor(Q, Q), ck=1.2, vk=2.2),
            BathExponent("R", 2, Q=Q, ck=1.2, vk=2.2),
        ]

        with pytest.raises(ValueError) as err:
            HEOMSolver(H, Bath(mixed_types), 2)
        assert str(err.value) == (
            "Bath exponents are currently restricted to being either all"
            " bosonic or all fermionic, but a mixture of bath exponents was"
            " given.")

        with pytest.raises(ValueError) as err:
            HEOMSolver(H, Bath(mixed_q_dims), 2)
        assert str(err.value) == (
            "All bath exponents must have system coupling operators with the"
            " same dimensions but a mixture of dimensions was given.")
Пример #2
0
    def test_combine(self):
        exp_ix = BathExponent("I", None, Q=sigmax(), ck=2.0, vk=0.5)
        exp_rx = BathExponent("R", None, Q=sigmax(), ck=1.0, vk=0.5)
        exp_rix = BathExponent("RI", None, Q=sigmax(), ck=0.1, vk=0.5, ck2=0.2)
        exp_rz = BathExponent("R", None, Q=sigmaz(), ck=1.0, vk=0.5)

        [exp] = BosonicBath.combine([exp_rx, exp_rx])
        check_exponent(exp, "R", dim=None, Q=sigmax(), ck=2.0, vk=0.5)

        [exp] = BosonicBath.combine([exp_ix, exp_ix])
        check_exponent(exp, "I", dim=None, Q=sigmax(), ck=4.0, vk=0.5)

        [exp] = BosonicBath.combine([exp_rix, exp_rix])
        check_exponent(
            exp,
            "RI",
            dim=None,
            Q=sigmax(),
            ck=0.2,
            vk=0.5,
            ck2=0.4,
        )

        [exp1, exp2] = BosonicBath.combine([exp_rx, exp_rz])
        check_exponent(exp1, "R", dim=None, Q=sigmax(), ck=1.0, vk=0.5)
        check_exponent(exp2, "R", dim=None, Q=sigmaz(), ck=1.0, vk=0.5)

        [exp] = BosonicBath.combine([exp_rx, exp_ix])
        check_exponent(
            exp,
            "RI",
            dim=None,
            Q=sigmax(),
            ck=1.0,
            vk=0.5,
            ck2=2.0,
        )

        [exp] = BosonicBath.combine([exp_rx, exp_ix, exp_rix])
        check_exponent(
            exp,
            "RI",
            dim=None,
            Q=sigmax(),
            ck=1.1,
            vk=0.5,
            ck2=2.2,
        )
Пример #3
0
    def test_create_fermionic(self):
        Q = sigmaz()
        H = sigmax()
        exponents = [
            BathExponent("+", 2, Q=Q, ck=1.1, vk=2.1, sigma_bar_k_offset=1),
            BathExponent("-", 2, Q=Q, ck=1.2, vk=2.2, sigma_bar_k_offset=-1),
        ]
        bath = Bath(exponents)

        hsolver = HEOMSolver(H, bath, 2)
        assert hsolver.ados.exponents == exponents
        assert hsolver.ados.max_depth == 2

        hsolver = HEOMSolver(H, [bath] * 3, 2)
        assert hsolver.ados.exponents == exponents * 3
        assert hsolver.ados.max_depth == 2
Пример #4
0
    def test_create_bosonic(self):
        Q = sigmaz()
        H = sigmax()
        exponents = [
            BathExponent("R", None, Q=Q, ck=1.1, vk=2.1),
            BathExponent("I", None, Q=Q, ck=1.2, vk=2.2),
            BathExponent("RI", None, Q=Q, ck=1.3, vk=2.3, ck2=3.3),
        ]
        bath = Bath(exponents)

        hsolver = HEOMSolver(H, bath, 2)
        assert hsolver.ados.exponents == exponents
        assert hsolver.ados.max_depth == 2

        hsolver = HEOMSolver(H, [bath] * 3, 2)
        assert hsolver.ados.exponents == exponents * 3
        assert hsolver.ados.max_depth == 2
Пример #5
0
 def test_repr(self):
     exp1 = BathExponent("R", None, Q=sigmax(), ck=1.0, vk=2.0)
     assert repr(exp1) == ("<BathExponent type=R dim=None Q.dims=[[2], [2]]"
                           " ck=1.0 vk=2.0 ck2=None"
                           " sigma_bar_k_offset=None tag=None>")
     exp2 = BathExponent(
         "+",
         None,
         Q=None,
         ck=1.0,
         vk=2.0,
         sigma_bar_k_offset=-1,
         tag="bath1",
     )
     assert repr(exp2) == ("<BathExponent type=+ dim=None Q.dims=None"
                           " ck=1.0 vk=2.0 ck2=None"
                           " sigma_bar_k_offset=-1 tag='bath1'>")
Пример #6
0
    def test_create_progress_bar(self):
        Q = sigmaz()
        H = sigmax()
        bath = Bath([
            BathExponent("R", None, Q=Q, ck=1.1, vk=2.1),
        ])

        hsolver = HEOMSolver(H, bath, 2)
        assert isinstance(hsolver.progress_bar, BaseProgressBar)

        hsolver = HEOMSolver(H, bath, 2, progress_bar=True)
        assert isinstance(hsolver.progress_bar, TextProgressBar)
Пример #7
0
 def mk_exponents(self, dims):
     return [BathExponent("I", dim, Q=None, ck=1.0, vk=2.0) for dim in dims]
Пример #8
0
 def mk_ados(self, bath_dims, max_depth):
     exponents = [
         BathExponent("I", dim, Q=None, ck=1.0, vk=2.0) for dim in bath_dims
     ]
     ados = HierarchyADOs(exponents, max_depth=max_depth)
     return ados
Пример #9
0
    def test_create(self):
        exp_r = BathExponent("R", None, Q=None, ck=1.0, vk=2.0)
        check_exponent(exp_r, "R", None, Q=None, ck=1.0, vk=2.0)

        exp_i = BathExponent("I", None, Q=None, ck=1.0, vk=2.0)
        check_exponent(exp_i, "I", None, Q=None, ck=1.0, vk=2.0)

        exp_ri = BathExponent("RI", None, Q=None, ck=1.0, vk=2.0, ck2=3.0)
        check_exponent(exp_ri, "RI", None, Q=None, ck=1.0, vk=2.0, ck2=3.0)

        exp_p = BathExponent(
            "+",
            2,
            Q=None,
            ck=1.0,
            vk=2.0,
            sigma_bar_k_offset=-1,
        )
        check_exponent(
            exp_p,
            "+",
            2,
            Q=None,
            ck=1.0,
            vk=2.0,
            sigma_bar_k_offset=-1,
        )

        exp_m = BathExponent(
            "-",
            2,
            Q=None,
            ck=1.0,
            vk=2.0,
            sigma_bar_k_offset=+1,
        )
        check_exponent(
            exp_m,
            "-",
            2,
            Q=None,
            ck=1.0,
            vk=2.0,
            sigma_bar_k_offset=+1,
        )

        exp_tag = BathExponent("R", None, Q=None, ck=1.0, vk=2.0, tag="tag1")
        check_exponent(exp_tag, "R", None, Q=None, ck=1.0, vk=2.0, tag="tag1")

        for exp_type, kw in [
            ("R", {}),
            ("I", {}),
            ("+", {
                "sigma_bar_k_offset": 1
            }),
            ("-", {
                "sigma_bar_k_offset": -1
            }),
        ]:
            with pytest.raises(ValueError) as err:
                BathExponent(
                    exp_type,
                    None,
                    Q=None,
                    ck=1.0,
                    vk=2.0,
                    ck2=3.0,
                    **kw,
                )
            assert str(err.value) == (
                "Second co-efficient (ck2) should only be specified for RI"
                " bath exponents")

        for exp_type, kw in [("R", {}), ("I", {}), ("RI", {"ck2": 3.0})]:
            with pytest.raises(ValueError) as err:
                BathExponent(
                    exp_type,
                    None,
                    Q=None,
                    ck=1.0,
                    vk=2.0,
                    sigma_bar_k_offset=1,
                    **kw,
                )
            assert str(err.value) == (
                "Offset of sigma bar (sigma_bar_k_offset) should only be"
                " specified for + and - bath exponents")
Пример #10
0
 def test_create(self):
     exp_r = BathExponent("R", None, Q=None, ck=1.0, vk=2.0)
     exp_i = BathExponent("I", None, Q=None, ck=1.0, vk=2.0)
     bath = Bath([exp_r, exp_i])
     assert bath.exponents == [exp_r, exp_i]