tangle anti zeno

This commit is contained in:
Valentin Boettcher 2022-06-09 16:52:56 +02:00
parent be88145405
commit 122ac5fe97

View file

@ -0,0 +1,147 @@
import figsaver as fs
from hiro_models.one_qubit_model import QubitModelMutliBath, StocProcTolerances
import hiro_models.model_auxiliary as aux
from hops.util.utilities import relative_entropy, relative_entropy_single, entropy, trace_distance
from hopsflow.util import EnsembleValue
import numpy as np
import qutip as qt
import scipy
import utilities as ut
from hops.util.dynamic_matrix import SmoothStep, Periodic, Harmonic, ConstantMatrix, Piecewise
import ray
ray.shutdown()
ray.init(address="auto")
from hops.util.logging_setup import logging_setup
import logging
logging_setup(logging.INFO, show_stocproc=False)
Δ = 7
ω_c = 2
τ_bath = 1 / ω_c
τ_mod = 2 * np.pi / Δ
cycle_scale = 15 # 12
cycles = int(np.around(τ_bath / τ_mod * cycle_scale))
τ_c = cycles * τ_mod
τ_off = τ_c * 5
detune = 0
γ = 0.1 / 2
ω_0 = 10
H_mat = 1 / 2 * (qt.sigmaz().full()) * ω_0
Δ_switch = τ_mod * 1
n = 10
t_max = n * (τ_c + τ_off)
H = ConstantMatrix(H_mat) + γ * Δ * (
Harmonic(H_mat, Δ)
@ (
Periodic(
ConstantMatrix(np.eye(2))
- SmoothStep(np.eye(2), τ_c, τ_c + Δ_switch, 2)
+ SmoothStep(np.eye(2), τ_c + τ_off - Δ_switch, τ_c + τ_off, 2),
τ_c + τ_off,
)
)
)
L_mat = qt.sigmax().full()
L = Periodic(
ConstantMatrix(L_mat)
- SmoothStep(L_mat, τ_c, τ_c + Δ_switch, 2)
+ SmoothStep(L_mat, τ_c + τ_off - Δ_switch, τ_c + τ_off, 2),
τ_c + τ_off,
)
model = QubitModelMutliBath(
δ=[1, 1],
ω_c=[ω_c, ω_c],
ω_s=[ω_0 - Δ - ω_c - detune, ω_0 + Δ - ω_c + detune],
t=ut.linspace_with_strobe(0, t_max, n * 1000, Δ),
ψ_0=(0 * qt.basis([2], [0]) + qt.basis([2], [1])),
description=f"Building the anti-zento-engine",
k_max=4,
bcf_terms=[5, 5],
truncation_scheme="simplex",
driving_process_tolerances=[StocProcTolerances(1e-3, 1e-3)] * 2,
thermal_process_tolerances=[StocProcTolerances(1e-3, 1e-3)] * 2,
T=[2, 12],
L=[L] * 2,
H=H,
therm_methods=["tanhsinh", "fft"],
)
τ_mod, τ_c, τ_bath, cycles, model.ω_s, 1 / τ_c, model.T, ω_0 - Δ
def thermal_bcf(t):
return model.bcf(1)(t) + 2 * (model.thermal_correlations(1)(t).real)
plt.plot(model.t, np.abs(thermal_bcf(model.t))/np.abs(thermal_bcf(0)))
plt.plot(model.t, model.L[0].operator_norm(model.t))
plt.plot(model.t, model.H.operator_norm(model.t) - 5)
plt.plot(model.t, np.exp(- model.t * np.min(np.array(model.bcf_coefficients()[1][0]).real)))
ωs = np.linspace(0, 20, 1000)
plt.plot(ωs, model.spectral_density(0)(ωs))
plt.plot(ωs, model.spectral_density(1)(ωs))
aux.integrate(model, 50)
_, ax = fs.plot_energy_overview(model, markersize=1)
# with aux.get_data(model) as data:
# fs.plot_with_σ(model.t, model.total_energy(data), ax=ax)
ax.legend()
with aux.get_data(model) as data:
fs.plot_with_σ(
model.t,
EnsembleValue(
(data.rho_t_accum.mean[:, 0, 0], data.rho_t_accum.ensemble_std[:, 0, 0])
),
)
ρ_ee = data.rho_t_accum.mean[:, 0, 0].real
plt.plot(model.t, ρ_ee)
from statsmodels.nonparametric.smoothers_lowess import lowess
filtered = lowess(ρ_ee, model.t, is_sorted=True, return_sorted=False, frac=0.1, it=0)
plt.plot(model.t, filtered)
with aux.get_data(model) as data:
_, ax = plt.subplots()
#fs.plot_with_σ(model.t, model.bath_energy(data), bath=1, ax=ax)
fs.plot_with_σ(model.t, model.total_energy(data), ax=ax)
#fs.plot_with_σ(model.t, model.system_energy(data), ax=ax)
#fs.plot_with_σ(model.t, model.system_energy(data) + model.bath_energy(data).sum_baths() , ax=ax)
with aux.get_data(model) as data:
_, ax = plt.subplots()
#fs.plot_with_σ(model.t, model.bath_energy(data), bath=1, ax=ax)
fs.plot_diff_vs_sigma(model.t, model.total_energy(data, every=50)[:-1], model.total_energy(data, every=50)[-1], ax=ax)
ax.legend()
mean_norm = np.zeros_like(model.t)
with aux.get_data(model) as data:
for i in range(data.samples):
aux_state = data.aux_states[i, :]
# plt.plot(model.t, np.linalg.norm(aux_state, axis=1))
mean_norm += np.linalg.norm(aux_state, axis=1)
mean_norm /= data.samples
plt.plot(model.t, mean_norm)