def test_pt_tempo():
    start_time = -0.3
    end_time = 0.84

    system = tempo.System(0.5 * tempo.operators.sigma("x"))
    correlation_function = lambda t: (np.cos(6.0*t)+1j*np.sin(6.0*t)) \
                                        * np.exp(-12.0*t)
    correlations = tempo.CustomCorrelations(correlation_function,
                                            max_correlation_time=0.5)
    bath = tempo.Bath(0.5 * tempo.operators.sigma("z"), correlations)
    initial_state = tempo.operators.spin_dm("z+")

    tempo_param_A = tempo.PtTempoParameters(0.1, 5, 1.0e-5, name="rough-A")
    pt_tempo_sys_A = tempo.PtTempo(bath=bath,
                                   parameters=tempo_param_A,
                                   start_time=start_time,
                                   end_time=end_time)
    assert pt_tempo_sys_A.dimension == 2
    pt_tempo_sys_A.compute()
    pt_A = pt_tempo_sys_A.get_process_tensor()
    assert len(pt_A.times) == 12

    tempo_param_B = tempo.PtTempoParameters(0.1, None, 1.0e-5, name="rough-B")
    pt_tempo_sys_B = tempo.PtTempo(bath=bath,
                                   parameters=tempo_param_B,
                                   start_time=start_time,
                                   end_time=end_time)
    pt_B = pt_tempo_sys_B.get_process_tensor()
def test_pt_tempo_parameters_bad_input():
    with pytest.raises(AssertionError):
        tempo.PtTempoParameters("x", 42, 1.0e-5, "rough", "bla", {})
    with pytest.raises(AssertionError):
        tempo.PtTempoParameters(0.1, "x", 1.0e-5, "rough", "bla", {})
    with pytest.raises(AssertionError):
        tempo.PtTempoParameters(0.1, 42, "x", "rough", "bla", {})
def test_tempo_bad_input():
    start_time = -0.3
    end_time = 0.84

    correlation_function = lambda t: (np.cos(6.0*t)+1j*np.sin(6.0*t)) \
                                        * np.exp(-12.0*t)
    correlations = tempo.CustomCorrelations(correlation_function,
                                            max_correlation_time=0.5)
    bath = tempo.Bath(0.5 * tempo.operators.sigma("z"), correlations)

    tempo_param = tempo.PtTempoParameters(0.1, 5, 1.0e-5, name="rough-A")

    tempo.PtTempo(bath=bath,
                  parameters=tempo_param,
                  start_time=start_time,
                  end_time=end_time)

    with pytest.raises(AssertionError):
        tempo.PtTempo(bath=bath,
                      parameters=tempo_param,
                      start_time="bla",
                      end_time=end_time)
    with pytest.raises(AssertionError):
        tempo.PtTempo(bath=bath,
                      parameters=tempo_param,
                      start_time=start_time,
                      end_time="bla")
    with pytest.raises(AssertionError):
        tempo.PtTempo(bath=bath,
                      parameters=tempo_param,
                      start_time=0.0,
                      end_time=0.0001)
def generate_pt(temp):

    start_time = 0.0
    end_time = 10.0

    correlations = tempo.PowerLawSD(alpha=alpha,
                                    zeta=3,
                                    cutoff=omega_cutoff,
                                    cutoff_type='gaussian',
                                    temperature=temp)
    bath = tempo.Bath(0.5 * tempo.operators.sigma("z"), correlations)

    dt = 0.1  # 0.01
    dkmax = 20  # 200
    epsrel = 1.0e-6  # 1.0e-7

    tempo_parameters = tempo.TempoParameters(dt=dt, dkmax=dkmax, epsrel=epsrel)

    pt_tempo_parameters = tempo.PtTempoParameters(dt=dt,
                                                  dkmax=dkmax,
                                                  epsrel=epsrel)

    pt = tempo.pt_tempo_compute(bath=bath,
                                start_time=start_time,
                                end_time=end_time,
                                parameters=pt_tempo_parameters,
                                progress_type='bar')
    pt.export("details_pt_tempo_{}K.processTensor".format(temp),
              overwrite=True)
def test_tensor_network_pt_tempo_backend_non_diag(backend):
    Omega = 1.0
    omega_cutoff = 5.0
    alpha = 0.3

    sx = tempo.operators.sigma("x")
    sy = tempo.operators.sigma("y")
    sz = tempo.operators.sigma("z")

    bases = [{"sys_op":sx, "coupling_op":sz, \
                "init_state":tempo.operators.spin_dm("y+")},
             {"sys_op":sy, "coupling_op":sx, \
                "init_state":tempo.operators.spin_dm("z+")},
             {"sys_op":sz, "coupling_op":sy, \
                "init_state":tempo.operators.spin_dm("x+")}]

    results = []
    for i, base in enumerate(bases):
        system = tempo.System(0.5 * base["sys_op"])
        correlations = tempo.PowerLawSD(alpha=alpha,
                                        zeta=1,
                                        cutoff=omega_cutoff,
                                        cutoff_type='exponential',
                                        max_correlation_time=8.0)
        bath = tempo.Bath(0.5 * base["coupling_op"], correlations)
        tempo_parameters = tempo.PtTempoParameters(dt=0.1,
                                                   dkmax=30,
                                                   epsrel=10**(-5))

        pt = tempo.pt_tempo_compute(bath=bath,
                                    start_time=0.0,
                                    end_time=1.0,
                                    parameters=tempo_parameters,
                                    backend=backend)
        dynamics = pt.compute_dynamics_from_system(
            system=system, initial_state=base["init_state"])
        _, s_x = dynamics.expectations(0.5 * tempo.operators.sigma("x"),
                                       real=True)
        _, s_y = dynamics.expectations(0.5 * tempo.operators.sigma("y"),
                                       real=True)
        _, s_z = dynamics.expectations(0.5 * tempo.operators.sigma("z"),
                                       real=True)
        if i == 0:
            results.append(np.array([s_x, s_y, s_z]))
        elif i == 1:
            results.append(np.array([s_y, s_z, s_x]))
        elif i == 2:
            results.append(np.array([s_z, s_x, s_y]))

    assert np.allclose(results[0], results[1], atol=tempo_parameters.epsrel)
    assert np.allclose(results[0], results[2], atol=tempo_parameters.epsrel)
def test_pt_tempo_parameters():
    tempo_param = tempo.PtTempoParameters(0.1, None, 1.0e-5, "rough", "bla",
                                          {})
    str(tempo_param)
    assert tempo_param.dt == 0.1
    assert tempo_param.dkmax == None
    assert tempo_param.epsrel == 1.0e-5
    tempo_param.dt = 0.05
    tempo_param.dkmax = 42
    tempo_param.epsrel = 1.0e-6
    assert tempo_param.dt == 0.05
    assert tempo_param.dkmax == 42
    assert tempo_param.epsrel == 1.0e-6
    del tempo_param.dkmax
    assert tempo_param.dkmax == None
def test_tensor_network_pt_tempo_backend_C(backend):
    tempo_params_C = tempo.PtTempoParameters(dt=0.05,
                                             dkmax=10,
                                             epsrel=10**(-7))
    pt = tempo.pt_tempo_compute(bath_C,
                                start_time=0.0,
                                end_time=1.0,
                                parameters=tempo_params_C,
                                backend=backend)
    state = pt.compute_final_state_from_system(system=system_C,
                                               initial_state=initial_state_C)
    np.testing.assert_almost_equal(state, rho_C, decimal=4)

    dyn = pt.compute_dynamics_from_system(system=system_C,
                                          initial_state=initial_state_C)
    assert dyn.times[-1] == 1.0
    np.testing.assert_almost_equal(dyn.states[-1], rho_C, decimal=4)
Пример #8
0
def test_tensor_network_pt_tempo_backend_A(backend, backend_config):
    tempo_params_A = tempo.PtTempoParameters(dt=0.05,
                                             dkmax=None,
                                             epsrel=10**(-7))
    pt = tempo.pt_tempo_compute(bath_A,
                                start_time=0.0,
                                end_time=1.0,
                                parameters=tempo_params_A,
                                backend=backend,
                                backend_config=backend_config)
    state = pt.compute_final_state_from_system(system=system_A,
                                               initial_state=initial_state_A)
    np.testing.assert_almost_equal(state, rho_A, decimal=4)

    dyn = pt.compute_dynamics_from_system(system=system_A,
                                          initial_state=initial_state_A)
    np.testing.assert_almost_equal(dyn.states[-1], rho_A, decimal=4)
Пример #9
0
def test_tensor_network_pt_tempo_backend_E(backend,backend_config):
    tempo_params_E = tempo.PtTempoParameters(dt=0.4,
                                             dkmax=5,
                                             epsrel=1.0e-6)
    pt = tempo.pt_tempo_compute(
                bath_E,
                start_time=t_start_E,
                end_time=t_end_E,
                parameters=tempo_params_E,
                backend=backend,
                backend_config=backend_config)
    state = pt.compute_final_state_from_system(system=system_E,
                                               initial_state=initial_state_E)
    np.testing.assert_almost_equal(state, rho_E, decimal=4)

    dyn = pt.compute_dynamics_from_system(system=system_E,
                                          initial_state=initial_state_E)
    np.testing.assert_almost_equal(dyn.states[-1], rho_E, decimal=4)
Пример #10
0
t, s_x = dynamics.expectations(tempo.operators.sigma("x"), real=True)
t, s_y = dynamics.expectations(tempo.operators.sigma("y"), real=True)
s_xy = np.sqrt(s_x**2 + s_y**2)
plt.plot(t, s_xy, label=r'$\Delta = 0.0$')
plt.xlabel(r'$t\,\Omega$')
plt.ylabel(r'$<\sigma_xy>$')
plt.ylim((0.0, 1.0))
plt.legend(loc=4)

# ### B.5: Using PT-TEMPO to explore many different laser pulses
# If we want to do the same computation for a set of different laser pulses (and thus different time dependent system Hamiltonians), we could repeate the above procedure. However, for a large number of different system Hamiltonians this is impractical. In such cases one may instead use the process tensor approach (PT-TEMPO) wherein the bath influence tensors are computed separately from the rest of the network. This produces an object known as the process tensor which may then be used with many different system Hamiltonians at relatively little cost.

# In[9]:

pt_tempo_parameters = tempo.PtTempoParameters(dt=0.05,
                                              dkmax=40,
                                              epsrel=10**(-5))

process_tensor = tempo.pt_tempo_compute(bath=bath,
                                        start_time=-2.0,
                                        end_time=3.0,
                                        parameters=pt_tempo_parameters)

# Given we want to calculate $\langle\sigma_{xy}\rangle(t)$ for 5 different laser pulse detunings, we define a seperate system object for each laser pulse:

# In[10]:

deltas = [-10.0, -5.0, 0.0, 5.0, 10.0]
systems = []
for delta in deltas:
    # NOTE: omitting "delta=delta" in the parameter definition below
Пример #11
0
# -- prepare a process tensor -------------------------------------------------

system = tempo.System(tempo.operators.sigma("x"))
initial_state = tempo.operators.spin_dm("z+")
correlations = tempo.PowerLawSD(alpha=0.3,
                                zeta=1.0,
                                cutoff=5.0,
                                cutoff_type="exponential",
                                temperature=0.2,
                                name="ohmic")
bath = tempo.Bath(0.5*tempo.operators.sigma("z"),
                    correlations,
                    name="phonon bath")
tempo_params = tempo.PtTempoParameters(dt=0.1,
                                         dkmax=5,
                                         epsrel=10**(-5))
pt = tempo.pt_tempo_compute(bath,
                            start_time=0.0,
                            end_time=1.0,
                            parameters=tempo_params)
pt.export(TEMP_FILE, overwrite=True)
del pt


def test_process_tensor():
    pt = tempo.import_process_tensor(TEMP_FILE)
    str(pt)
    pt.times
    pt.get_bond_dimensions()
    pt.compute_final_state_from_system(system, initial_state)