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_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.TempoParameters(dt=0.1,
                                                 dkmax=30,
                                                 epsrel=10**(-5))

        dynamics = tempo.tempo_compute(system=system,
                                       bath=bath,
                                       initial_state=base["init_state"],
                                       start_time=0.0,
                                       end_time=1.0,
                                       parameters=tempo_parameters,
                                       backend=backend)

        _, 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_tempo_dynamics_reference():
    system = tempo.System(0.5 * tempo.operators.sigma("x"))
    correlations = tempo.PowerLawSD(alpha=0.1,
                                    zeta=1,
                                    cutoff=1.0,
                                    cutoff_type='exponential',
                                    max_correlation_time=0.5)
    bath = tempo.Bath(0.5 * tempo.operators.sigma("z"), correlations)
    tempo_parameters = tempo.TempoParameters(dt=0.1, dkmax=10, epsrel=10**(-4))
    tempo_A = tempo.Tempo(system=system,
                          bath=bath,
                          parameters=tempo_parameters,
                          initial_state=tempo.operators.spin_dm("up"),
                          start_time=0.0)
    dynamics_1 = tempo_A.compute(end_time=0.2)
    t_1, sz_1 = dynamics_1.expectations(tempo.operators.sigma("z"))
    tempo_A.compute(end_time=0.4)
    dynamics_2 = tempo_A.get_dynamics()
    t_2, sz_2 = dynamics_2.expectations(tempo.operators.sigma("z"))
    assert dynamics_1 == dynamics_2
    assert len(t_2) > len(t_1)
plt.legend()

# ### B.3: Create time dependent system object

# In[6]:


def hamiltonian_t(t):
    return detuning(t) / 2.0 * tempo.operators.sigma("z") + gaussian_shape(
        t, area=np.pi / 2.0, tau=0.245) / 2.0 * tempo.operators.sigma("x")


system = tempo.TimeDependentSystem(hamiltonian_t)
correlations = tempo.PowerLawSD(alpha=alpha,
                                zeta=3,
                                cutoff=omega_cutoff,
                                cutoff_type='gaussian',
                                max_correlation_time=5.0,
                                temperature=temperature)
bath = tempo.Bath(tempo.operators.sigma("z") / 2.0, correlations)

# ### B.4: TEMPO computation

# With all physical objects defined, we are now ready to compute the dynamics of the quantum dot using TEMPO (using quite rough convergence parameters):

# In[7]:

tempo_parameters = tempo.TempoParameters(dt=0.05, dkmax=40, epsrel=10**(-5))

tempo_sys = tempo.Tempo(system=system,
                        bath=bath,
                        initial_state=initial_state,
Exemple #5
0
# exact result:
def exact_result(t):
    x = (t*cutoff_E)**2
    phi = 2 * alpha_E * (1 + (x-1)/(x+1)**2)
    y_plus = np.exp(-phi)
    dm = (1 - y_plus) * tempo.operators.spin_dm("mixed") \
         + y_plus * tempo.operators.spin_dm("y+")
    return dm

rho_E = exact_result(t_end_E)

correlations_E = tempo.PowerLawSD(alpha=alpha_E,
                                  zeta=3.0,
                                  cutoff=cutoff_E,
                                  cutoff_type="exponential",
                                  temperature=temperature_E,
                                  name="superohmic",
                        )
bath_E = tempo.Bath(coupling_operator_E,
                    correlations_E,
                    name="superohmic phonon bath")
system_E = tempo.System(h_sys_E)

# -----------------------------------------------------------------------------

@pytest.mark.parametrize('backend,backend_config',
                        [("tensor-network", {"backend":"numpy"}),])
def test_tensor_network_tempo_backend_E(backend, backend_config):
    tempo_params_E = tempo.TempoParameters(dt=0.4,
                                           dkmax=5,
Exemple #6
0
"""

import pytest

import time_evolving_mpo as tempo


TEMP_FILE = "tests/data/temp.processTensor"

# -- 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
# -------------------------------------------------
# ## Example A - The Spin Boson Model
#
# As a first example let's try to reconstruct one of the lines in figure 2a of [Strathearn2018] ([Nat. Comm. 9, 3322 (2018)](https://doi.org/10.1038/s41467-018-05617-3) / [arXiv:1711.09641v3](https://arxiv.org/abs/1711.09641)). In this example we compute the time evolution of a spin which is strongly coupled to an ohmic bath (spin-boson model). Before we go through this step by step below, let's have a brief look at the script that will do the job - just to have an idea where we are going:

# In[3]:

Omega = 1.0
omega_cutoff = 5.0
alpha = 0.3

system = tempo.System(0.5 * Omega * tempo.operators.sigma("x"))
correlations = tempo.PowerLawSD(alpha=alpha,
                                zeta=1,
                                cutoff=omega_cutoff,
                                cutoff_type='exponential',
                                max_correlation_time=8.0)
bath = tempo.Bath(0.5 * tempo.operators.sigma("z"), correlations)
tempo_parameters = tempo.TempoParameters(dt=0.1, dkmax=30, epsrel=10**(-4))

dynamics = tempo.tempo_compute(system=system,
                               bath=bath,
                               initial_state=tempo.operators.spin_dm("up"),
                               start_time=0.0,
                               end_time=15.0,
                               parameters=tempo_parameters)
t, s_z = dynamics.expectations(0.5 * tempo.operators.sigma("z"), real=True)

plt.plot(t, s_z, label=r'$\alpha=0.3$')
plt.xlabel(r'$t\,\Omega$')
Exemple #8
0
alpha_C = 0.3
cutoff_C = 5.0
temperature_C = 0.0

# end time
t_end_C = 1.0

# result obtained with release code (made hermitian, dkmax=10):
rho_C = np.array(
    [[ 0.12576653+0.j        ,-0.11739956-0.14312036j, 0.12211454-0.05963583j],
     [-0.11739956+0.14312036j, 0.61315893+0.j        ,-0.06636825+0.26917271j],
     [ 0.12211454+0.05963583j,-0.06636825-0.26917271j, 0.26107455+0.j        ]])

correlations_C = tempo.PowerLawSD(alpha=alpha_C,
                                  zeta=1.0,
                                  cutoff=cutoff_C,
                                  cutoff_type="exponential",
                                  temperature=temperature_C,
                                  name="ohmic")
bath_C = tempo.Bath(coupling_operator_C,
                    correlations_C,
                    name="phonon bath")
system_C = tempo.System(h_sys_C,
                        gammas=[gamma_C_1, gamma_C_2],
                        lindblad_operators=[lindblad_operators_C_1,
                                            lindblad_operators_C_2])


# -----------------------------------------------------------------------------

@pytest.mark.parametrize('backend',["tensor-network"])
def test_tensor_network_tempo_backend_C(backend):