def test_tempo_bad_input(): 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.TempoParameters(0.1, 5, 1.0e-5, name="rough-A") with pytest.raises(AssertionError): tempo_sys_A = tempo.Tempo(system=system, bath=bath, parameters=tempo_param_A, initial_state="bla", start_time=start_time) with pytest.raises(AssertionError): tempo_sys_A = tempo.Tempo(system=system, bath=bath, parameters=tempo_param_A, initial_state=initial_state, start_time="bla") tempo_sys_A = tempo.Tempo(system=system, bath=bath, parameters=tempo_param_A, initial_state=initial_state, start_time=start_time) with pytest.raises(AssertionError): tempo_sys_A.compute(end_time="bla", progress_type="bar")
def test_tempo(): start_time = -0.3 end_time1 = 0.4 end_time2 = 0.6 end_time3 = 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.TempoParameters(0.1, 5, 1.0e-5, name="rough-A") tempo_sys_A = tempo.Tempo(system=system, bath=bath, parameters=tempo_param_A, initial_state=initial_state, start_time=start_time) assert tempo_sys_A.dimension == 2 tempo_sys_A.compute(end_time=end_time1, progress_type="bar") tempo_sys_A.compute(end_time=end_time2, progress_type="silent") tempo_sys_A.compute(end_time=end_time3, progress_type="simple") dyn_A = tempo_sys_A.get_dynamics() assert len(dyn_A.times) == 13
def test_tensor_network_tempo_backend_C(backend): tempo_params_C = tempo.TempoParameters(dt=0.05, dkmax=10, epsrel=10**(-7)) tempo_C = tempo.Tempo(system_C, bath_C, tempo_params_C, initial_state_C, start_time=0.0, backend=backend) tempo_C.compute(end_time=1.0) dyn_C = tempo_C.get_dynamics() assert dyn_C.times[-1] == 1.0 np.testing.assert_almost_equal(dyn_C.states[-1], rho_C, decimal=4)
def test_tensor_network_tempo_backend_E(backend, backend_config): tempo_params_E = tempo.TempoParameters(dt=0.4, dkmax=5, epsrel=1.0e-6) tempo_E = tempo.Tempo(system_E, bath_E, tempo_params_E, initial_state_E, start_time=t_start_E, backend=backend, backend_config=backend_config) tempo_E.compute(end_time=t_end_E) dyn_E = tempo_E.get_dynamics() np.testing.assert_almost_equal(dyn_E.states[-1], rho_E, decimal=4)
def test_tensor_network_tempo_backend_A(backend, backend_config): tempo_params_A = tempo.TempoParameters(dt=0.05, dkmax=None, epsrel=10**(-7)) tempo_A = tempo.Tempo(system_A, bath_A, tempo_params_A, initial_state_A, start_time=0.0, backend=backend, backend_config=backend_config) tempo_A.compute(end_time=1.0) dyn_A = tempo_A.get_dynamics() np.testing.assert_almost_equal(dyn_A.states[-1], rho_A, decimal=4)
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)
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, start_time=-2.0, parameters=tempo_parameters) dynamics = tempo_sys.compute(end_time=3.0) # and extract the expectation values $\langle\sigma_{xy}\rangle = \sqrt{\langle\sigma_x\rangle^2 + \langle\sigma_y\rangle^2}$ for plotting: # In[8]: 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))
print(tempo_parameters_A) # and check again with the helper function: # In[15]: tempo.helpers.plot_correlations_with_parameters(bath_A.correlations, tempo_parameters_A) # We could feed this object into the `tempo.tempo_compute()` function to get the dynamics of the system. However, instead of that, we can split up the work that `tempo.tempo_compute()` does into several steps, which allows us to resume a computation to get later system dynamics without having to start over. For this we start with creating a `Tempo` object: # In[16]: tempo_A = tempo.Tempo(system=system_A, bath=bath_A, parameters=tempo_parameters_A, initial_state=tempo.operators.spin_dm("up"), start_time=0.0) # We can start by computing the dynamics up to time $5.0\,\Omega^{-1}$, # In[17]: tempo_A.compute(end_time=5.0) # then get and plot the dynamics of expecatation values, # In[18]: dynamics_A_2 = tempo_A.get_dynamics() plt.plot(*dynamics_A_2.expectations(0.5 * tempo.operators.sigma("z"),