update 07

This commit is contained in:
Valentin Boettcher 2022-08-13 17:30:24 +02:00
parent 79242cda0a
commit ac0c81db44
7 changed files with 2348 additions and 618 deletions

View file

@ -2,11 +2,11 @@
"nodes": {
"flake-utils": {
"locked": {
"lastModified": 1648297722,
"narHash": "sha256-W+qlPsiZd8F3XkzXOzAoR+mpFqzm3ekQkJNa+PIh1BQ=",
"lastModified": 1656928814,
"narHash": "sha256-RIFfgBuKz6Hp89yRr7+NR5tzIAbn52h8vT6vXkYjZoM=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "0f8662f1319ad6abf89b3380dd2722369fc51ade",
"rev": "7e2a3b3dfd9af950a856d66b0a7d01e3c18aa249",
"type": "github"
},
"original": {
@ -17,11 +17,11 @@
},
"flake-utils_2": {
"locked": {
"lastModified": 1610051610,
"narHash": "sha256-U9rPz/usA1/Aohhk7Cmc2gBrEEKRzcW4nwPWMPwja4Y=",
"lastModified": 1656928814,
"narHash": "sha256-RIFfgBuKz6Hp89yRr7+NR5tzIAbn52h8vT6vXkYjZoM=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "3982c9903e93927c2164caa727cd3f6a0e6d14cc",
"rev": "7e2a3b3dfd9af950a856d66b0a7d01e3c18aa249",
"type": "github"
},
"original": {
@ -32,11 +32,11 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1652082323,
"narHash": "sha256-7GSVLvfCJtH9dJ3om9Lg4fsi9UKvoxxR69gUTcx0ol8=",
"lastModified": 1659981942,
"narHash": "sha256-uCFiP/B/NXOWzhN6TKfMbSxtVMk1bVnCrnJRjCF6RmU=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "2a3aac479caeba0a65b2ad755fe5f284f1fde74d",
"rev": "39d7f929fbcb1446ad7aa7441b04fb30625a4190",
"type": "github"
},
"original": {
@ -47,11 +47,11 @@
},
"nixpkgs_2": {
"locked": {
"lastModified": 1648390671,
"narHash": "sha256-u69opCeHUx3CsdIerD0wVSR+DjfDQjnztObqfk9Trqc=",
"lastModified": 1658161305,
"narHash": "sha256-X/nhnMCa1Wx4YapsspyAs6QYz6T/85FofrI6NpdPDHg=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "ce8cbe3c01fd8ee2de526ccd84bbf9b82397a510",
"rev": "e4d49de45a3b5dbcb881656b4e3986e666141ea9",
"type": "github"
},
"original": {
@ -62,11 +62,11 @@
},
"nixpkgs_3": {
"locked": {
"lastModified": 1610729867,
"narHash": "sha256-bk/SBaBLqZX/PEqal27DMQwAHHl0dcZMp8NNksQr80s=",
"lastModified": 1658311025,
"narHash": "sha256-GqagY5YmaZB3YaO41kKcQhe5RcpS83wnsW8iCu5Znqo=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "04af07c659c6723a2259bb6bc00a47ec53330f20",
"rev": "cd8d1784506a7c7eb0796772b73437e0b82fad57",
"type": "github"
},
"original": {
@ -81,11 +81,11 @@
"nixpkgs": "nixpkgs_3"
},
"locked": {
"lastModified": 1648438095,
"narHash": "sha256-TTZ6mu1IO2YxCxd/FtLMixWwpCcgS9eZ7LfzDeoEMUI=",
"lastModified": 1657626303,
"narHash": "sha256-O/JJ0hSBCmlx0oP8QGAlRrWn0BvlC5cj7/EZ0CCWHTU=",
"owner": "nix-community",
"repo": "poetry2nix",
"rev": "33b5419aa62c88bf890877a8b8c74864b4a41122",
"rev": "920ba682377d5c0d87945c5eb6141ab8447ca509",
"type": "github"
},
"original": {
@ -107,11 +107,11 @@
"poetry2nix": "poetry2nix"
},
"locked": {
"lastModified": 1648546910,
"narHash": "sha256-mb49efdjcFXu1S6EwN4Q+vDYDn2eIIPOEZ8N4zTPMfU=",
"lastModified": 1658314126,
"narHash": "sha256-rEoZSb8bBafEd6m3xu/yQtSFlP8GZxKN15YqMZkeMaQ=",
"owner": "vale981",
"repo": "hiro-flake-utils",
"rev": "02504e6918ff7d9d5e9290ebb7a77b6eba78ad0c",
"rev": "316cd25ffd9d7afd331cbbc1429f62f30567e288",
"type": "github"
},
"original": {

View file

@ -11,9 +11,12 @@
outputs = { self, utils, nixpkgs, ... }:
(utils.lib.poetry2nixWrapper nixpkgs {
name = "07_one_bath_systematics";
shellPackages = pkgs: with pkgs; [ pyright python39Packages.jupyter sshfs ];
shellPackages = pkgs: with pkgs; [ pyright python39Packages.jupyter sshfs (pkgs.texlive.combine {
inherit (pkgs.texlive) scheme-medium
type1cm unicode-math;
})];
python = pkgs: pkgs.python39Full;
shellOverride = (oldAttrs: {
shellOverride = pkgs: (oldAttrs: {
shellHook = ''
export PYTHONPATH=/home/hiro/src/two_qubit_model/:$PYTHONPATH
export PYTHONPATH=/home/hiro/src/hops/:$PYTHONPATH

View file

@ -0,0 +1 @@
../plot_utils.py

File diff suppressed because it is too large Load diff

View file

@ -1,20 +1,22 @@
import figsaver as fs
from figsaver import (
from plot_utils import (
plot_interaction_consistency,
plot_interaction_consistency_development,
plot_flow_bcf,
plot_with_σ,
lighten_color
)
import figsaver as fs
from hiro_models.one_qubit_model import QubitModel, StocProcTolerances
import hiro_models.model_auxiliary as aux
from hopsflow.util import EnsembleValue
import numpy as np
import qutip as qt
import matplotlib
matplotlib.rcParams.update(fs.MPL_RC_POSTER)
import ray
ray.shutdown()
ray.init()
ray.init(address="auto")
from hops.util.logging_setup import logging_setup
import logging
@ -43,12 +45,16 @@ alt_tol_models = [
aux.integrate_multi(alt_tol_models, 450_000)
plot_interaction_consistency(
alt_tol_models,
# alt_tol_models[0],
label_fn=lambda m: fr"stocproc=$10^{{{np.log10(m.driving_process_tolerance.integration):.0f}}}$",
**ensemble_arg
)
f, ax = plot_interaction_consistency(
alt_tol_models,
# alt_tol_models[0],
label_fn=lambda m: fr"$\varsigma=10^{{{np.log10(m.driving_process_tolerance.integration):.0f}}}$",
**ensemble_arg,
inset=(alt_tol_models[0].t > 18, (.3, .52, .6, .4)),
)
fs.export_fig("stocproc_systematics_interaction", y_scaling=.3)
k_models = [
QubitModel(
@ -67,12 +73,15 @@ k_models = [
aux.integrate_multi(k_models, 450_000)
plot_interaction_consistency(
k_models,
#k_models[-1],
label_fn=lambda m: fr"k=${m.k_max}$",
**ensemble_arg
)
f, ax = plot_interaction_consistency(
k_models,
# alt_tol_models[0],
label_fn=lambda m: fr"$k={m.k_max}$",
inset=(np.logical_and(10 < k_models[0].t, k_models[0].t < 12), (0.3, 0.55, 0.6, 0.42)),
**ensemble_arg,
)
fs.export_fig("k_systematics_interaction", x_scaling=1, y_scaling=0.3)
ω_models = [
QubitModel(
@ -97,62 +106,159 @@ for model in ω_models:
ρ = np.array(data.rho_t_accum.mean)
σ_ρ = np.array(data.rho_t_accum.ensemble_std)
t = np.array(data.time)
fs.plot_with_σ(
plot_with_σ(
t,
EnsembleValue((ρ[:, 1, 0].real, σ_ρ[:, 1, 0].real)),
label=f"_c={model.ω_c:.2f}$",
label=fr"$\omega_c={model.ω_c:.2f}$",
ax=ax,
)
ax.legend()
fig, ax = plt.subplots()
fig, ((ax_sys, ax_flow), (ax_inter, ax_bath)) = plt.subplots(
nrows=2, ncols=2, sharex=True
)
flow_ins = ax_flow.inset_axes([0.4, 0.20, 0.5, 0.55])
ax_sys.set_ylabel(r"$\langle H_\mathrm{S}\rangle$")
ax_flow.set_ylabel("$J$")
ax_inter.set_ylabel(r"$\langle H_\mathrm{I}\rangle$")
ax_bath.set_ylabel(r"$\langle H_\mathrm{B}\rangle$")
ax_sys.set_xlabel(r"$\tau$")
ax_flow.set_xlabel(r"$\tau$")
ax_inter.set_xlabel(r"$\tau$")
ax_bath.set_xlabel(r"$\tau$")
handles = []
for model in ω_models:
with aux.get_data(model) as data:
energy = model.system_energy(data, every=50)
fs.plot_with_σ(
sys_energy = model.system_energy(data, **ensemble_arg)
flow = model.bath_energy_flow(data, **ensemble_arg).for_bath(0)
inter = model.interaction_energy(data, **ensemble_arg).for_bath(0)
bath = model.bath_energy(data, **ensemble_arg).for_bath(0)
_, _, (lines, _) = plot_with_σ(
data.time[:],
energy,
transform=lambda y: y.real,
ax=ax,
label=f"$ω_c={model.ω_c:.2f}$",
sys_energy,
ax=ax_sys,
label=fr"$\omega_c={model.ω_c:.1f},\,\alpha(0)={model.bcf(0).real * model.bcf_scale:.2f}$",
)
handles.append(lines[0])
plot_with_σ(
data.time[:],
flow,
ax=ax_flow,
)
ax.legend()
mask = np.logical_and(7 <= data.time[:], data.time[:] <= 9)
plot_with_σ(
data.time[mask],
flow.slice(mask),
ax=flow_ins,
)
fig, ax = plt.subplots()
fig.set_size_inches(fs.get_figsize("poster", .49))
plot_with_σ(
data.time[:],
inter,
ax=ax_inter,
)
plot_with_σ(
data.time[:],
bath,
ax=ax_bath,
)
ax_sys.legend(
# ncol=2,
)
fs.export_fig("omega_energy_overview", y_scaling=0.6, x_scaling=1)
fig, (ax, ax2) = plt.subplots(ncols=2)
drawn_foot = False
for model in ω_models:
with aux.get_data(model) as data:
flow = model.bath_energy_flow(data, **ensemble_arg)
_, _, line = fs.plot_with_σ(
flow = -1 * model.bath_energy_flow(data, **ensemble_arg).for_bath(0)
flow_1 = -1 * model.bath_energy_flow(data, **(ensemble_arg | dict(N=1))).for_bath(0)
inter = -1 * model.interaction_energy(data, **ensemble_arg).for_bath(0)
pure_deph = (
-np.trace(model.L(0) @ model.L(0) @ data.rho_t_accum.mean[0]).real
* 2
* model.bcf_scale
* model.bcf(data.time[:]).imag
)
_, _, line = plot_with_σ(
data.time[:],
flow,
ax=ax,
label=f"$ω_c={model.ω_c:.2f}$",
bath=0,
transform=lambda y: -y,
label=fr"$\omega_c={model.ω_c:.2f}$",
)
print(-np.trace(model.L(0) @ model.L(0) @ data.rho_t_accum.mean[0]).real)
ax.plot(
data.time[:],
-np.trace(model.L(0) @ model.L(0) @ data.rho_t_accum.mean[0]).real * 2
* model.bcf_scale
* model.bcf(data.time[:]).imag,
pure_deph,
linestyle="--",
color=line[0][0].get_color(),
)
plot_with_σ(
data.time[:],
flow_1,
linestyle="dotted",
color=lighten_color(line[0][0].get_color(), .5),
ax=ax
)
ax.axvline(
data.time[np.argmax(abs(inter.value))],
color=lighten_color(line[0][0].get_color()),
)
t_peak = data.time[np.argmax(abs(flow.value))]
flow_peak = abs(flow.value).max()
diff = (flow - pure_deph) * (1 / flow_peak)
diff1 = (flow.value - flow_1.value) * (1 / flow_peak)
t_foot = data.time[np.argmax(abs(diff.value) > 0.01)]
plot_with_σ(
data.time[:], diff, ax=ax2, label=rf"$1-\tau_d/\tau_p={(t_peak - t_foot)/t_peak:.2f}$"
)
# ax2.plot(
# data.time[:], diff1, color=lighten_color(line[0][0].get_color())
# )
ax2.axvline(
t_peak,
color=lighten_color(line[0][0].get_color()),
linestyle="dashed",
)
ax2.axvspan(
t_foot, t_peak, color=lighten_color(line[0][0].get_color(), 0.3), alpha=0.3
)
ax2.axvline(t_foot, color=lighten_color(line[0][0].get_color()))
ax.set_yscale("log")
ax.set_xscale("log")
ax.set_ylabel("$J$")
ax.set_ylabel("$-J$")
ax.set_xlabel(r"$\tau$")
ax2.set_xscale("log")
ax2.set_xlim(1e-3)
ax2.set_xlabel(r"$\tau$")
ax2.set_ylabel(r"$|J-J_\mathrm{p.d.}| / |J|_\mathrm{max}$")
ax2.legend()
# ax.set_ylim(1e-3,2)
ax.tick_params(axis='y', which='major', pad=10)
ax.tick_params(axis="y", which="major", pad=10)
ax.set_xlim(1e-3)
ax.legend()
fs.export_fig("initial_slip")
fs.export_fig("omega_initial_slip")
f, ax = plot_interaction_consistency(
ω_models,
@ -160,8 +266,49 @@ f, ax = plot_interaction_consistency(
label_fn=lambda m: fr"$\omega_c={m.ω_c:.0f}$",
**ensemble_arg
)
f.set_size_inches(fs.get_figsize("poster", .5))
fs.export_fig("omega_interaction")
fs.export_fig("omega_interaction_consistency", y_scaling=.3)
from hops.util.dynamic_matrix import ConstantMatrix, SmoothStep
t_max = 3
L_op = 1 / 2 * (ConstantMatrix(qt.sigmax()) - SmoothStep(qt.sigmax(), t_max - 2, t_max, 2))
shift_models = [
QubitModel(
δ=2,
ω_c=2,
ω_s=ω_s,
H=ConstantMatrix(1/2 * 4 * qt.sigmaz()),
L=L_op,
t=np.linspace(0, t_max, 1000),
ψ_0=qt.basis([2], [0]),
description=f"Testing whether the enhanced flow is a resonance phenomenon.",
k_max=7,
bcf_terms=7,
truncation_scheme="simplex",
driving_process_tolerance=StocProcTolerances(1e-6, 1e-6)
)
for ω_s in [1, 2, 3]
]
from hops.util.dynamic_matrix import ConstantMatrix, SmoothStep
t_max = 7
L_op = 1 / 2 * (ConstantMatrix(qt.sigmax()) - SmoothStep(qt.sigmax(), t_max - 2, t_max, 2))
shift_models_steady = [
QubitModel(
δ=2,
ω_c=2,
ω_s=ω_s,
H=ConstantMatrix(1/2 * 4 * qt.sigmaz()),
L=L_op,
t=np.linspace(0, t_max, 1000),
ψ_0=qt.basis([2], [0]),
description=f"Testing whether the enhanced flow is a resonance phenomenon.",
k_max=7,
bcf_terms=7,
truncation_scheme="simplex",
driving_process_tolerance=StocProcTolerances(1e-6, 1e-6)
)
for ω_s in [1, 2, 3]
]
δ_models = [
QubitModel(
@ -186,5 +333,68 @@ f, ax = plot_interaction_consistency(
label_fn=lambda m: fr"$\alpha(0)={m.bcf(0).real * m.bcf_scale:.1f}$",
**ensemble_arg
)
f.set_size_inches(fs.get_figsize("poster", .49))
fs.export_fig("delta_interaction")
ax[1].legend(fontsize=5)
fs.export_fig("delta_interaction_consistency", y_scaling=.3)
fig, ((ax_sys, ax_flow), (ax_inter, ax_bath)) = plt.subplots(
nrows=2, ncols=2, sharex=True
)
flow_ins = ax_flow.inset_axes([0.4, 0.20, 0.5, 0.55])
ax_sys.set_ylabel(r"$\langle H_\mathrm{S}\rangle$")
ax_flow.set_ylabel("$J$")
ax_inter.set_ylabel(r"$\langle H_\mathrm{I}\rangle$")
ax_bath.set_ylabel(r"$\langle H_\mathrm{B}\rangle$")
ax_sys.set_xlabel(r"$\tau$")
ax_flow.set_xlabel(r"$\tau$")
ax_inter.set_xlabel(r"$\tau$")
ax_bath.set_xlabel(r"$\tau$")
handles = []
for model in δ_models:
with aux.get_data(model) as data:
sys_energy = model.system_energy(data, **ensemble_arg)
flow = model.bath_energy_flow(data, **ensemble_arg).for_bath(0)
inter = model.interaction_energy(data, **ensemble_arg).for_bath(0)
bath = model.bath_energy(data, **ensemble_arg).for_bath(0)
_, _, (lines, _) = plot_with_σ(
data.time[:],
sys_energy,
ax=ax_sys,
label=fr"$\alpha(0)={model.bcf(0).real * model.bcf_scale:.2f}$",
)
handles.append(lines[0])
plot_with_σ(
data.time[:],
flow,
ax=ax_flow,
)
mask = np.logical_and(2.5 <= data.time[:], data.time[:])
plot_with_σ(
data.time[mask],
flow.slice(mask),
ax=flow_ins,
)
plot_with_σ(
data.time[:],
inter,
ax=ax_inter,
)
plot_with_σ(
data.time[:],
bath,
ax=ax_bath,
)
ax_sys.legend(
# ncol=2,
)
fs.export_fig("δ_energy_overview", y_scaling=0.6, x_scaling=1)