From a144caad39c374e3f546309b84778acdcd644d8f Mon Sep 17 00:00:00 2001 From: Valentin Boettcher Date: Mon, 20 Jun 2022 16:30:34 +0200 Subject: [PATCH] add init time --- .../10_antizeno_engine/10_first_anti_zeno.py | 53 +++++++++-- .../10_antizeno_engine/anti_zeno_engine.org | 95 ++++++++++++------- 2 files changed, 107 insertions(+), 41 deletions(-) diff --git a/python/energy_flow_proper/10_antizeno_engine/10_first_anti_zeno.py b/python/energy_flow_proper/10_antizeno_engine/10_first_anti_zeno.py index 23a1a3e..3d48059 100644 --- a/python/energy_flow_proper/10_antizeno_engine/10_first_anti_zeno.py +++ b/python/energy_flow_proper/10_antizeno_engine/10_first_anti_zeno.py @@ -7,7 +7,7 @@ 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 +from hops.util.dynamic_matrix import SmoothStep, Periodic, Harmonic, ConstantMatrix, Piecewise, Shift import matplotlib.pyplot as plt import numpy as np @@ -34,8 +34,10 @@ def anti_zeno_engine( T_h=5, therm_initial_state=False, s=1, - dt=.1, - T_c=0, + dt=0.1, + T_c=0, + ε_init=0, + δ_init=1 ): # τ_bath = 1 / ω_c τ_mod = 2 * np.pi / Δ @@ -77,6 +79,37 @@ def anti_zeno_engine( τ_c + τ_off, ) + if ε_init > 0: + initializing_period = -np.log(ε_init) / smallest_exponent + t_max += initializing_period + H = Piecewise( + [ + ConstantMatrix(H_mat), + Shift( + H, + initializing_period, + ), + ], + [0, initializing_period, np.inf], + ) + + L = Piecewise( + [ + (ConstantMatrix(L_mat) + - SmoothStep( + L_mat, + initializing_period - τ_off - Δ_switch, + initializing_period - τ_off, + 2, + )) * np.sqrt(δ_init), + Shift( + L, + initializing_period, + ), + ], + [0, initializing_period, np.inf], + ) + model = QubitModelMutliBath( δ=δ, ω_c=[ω_c, ω_c], @@ -101,7 +134,11 @@ def anti_zeno_engine( s=s, ) - return model, Δ, (τ_mod, τ_c, τ_bath, cycles, model.ω_s, ω_0, τ_mod, τ_off, n, Δ_switch) + return ( + model, + Δ, + (τ_mod, τ_c, τ_bath, cycles, model.ω_s, ω_0, τ_mod, τ_off, n, Δ_switch), + ) model, Δ, (τ_mod, τ_c, τ_bath, cycles, model.ω_s, ω_0, τ_s, τ_off, n, Δ_switch) = anti_zeno_engine( Δ=1, @@ -118,6 +155,8 @@ model, Δ, (τ_mod, τ_c, τ_bath, cycles, model.ω_s, ω_0, τ_s, τ_off, n, Δ switch_cycles=1, therm_initial_state=False, s=[1] * 2, + ε_init=.1, + δ_init=5, ) model.k_max = 4 # model, params = anti_zeno_engine(ε=1/2, ε_couple=1e-4, n=1, detune=.5, δ=[.1,.1]) @@ -171,13 +210,13 @@ with aux.get_data(model) as data: _, ax = plt.subplots() # fs.plot_with_σ(model.t, model.bath_energy(data), bath=0, ax=ax) # fs.plot_with_σ(model.t, model.bath_energy(data), bath=1, ax=ax) - # fs.plot_with_σ(model.t, model.bath_energy(data).sum_baths(), ax=ax) + #fs.plot_with_σ(model.t, model.bath_energy(data).sum_baths(), ax=ax) # fs.plot_with_σ(model.t, model.total_energy(data), ax=ax) - fs.plot_with_σ(model.t, model.interaction_energy(data).for_bath(1), ax=ax) + #fs.plot_with_σ(model.t, model.interaction_energy(data).for_bath(1), 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) + fs.plot_with_σ(model.t, model.system_energy(data) + model.bath_energy(data).sum_baths(), ax=ax) # ax.plot(model.t, ut.smoothen(model.t, model.total_energy(data).value, frac=.1)) # ax.plot(model.t, np.gradient(model.total_energy(data).value)) diff --git a/python/energy_flow_proper/10_antizeno_engine/anti_zeno_engine.org b/python/energy_flow_proper/10_antizeno_engine/anti_zeno_engine.org index fa74e14..1043612 100644 --- a/python/energy_flow_proper/10_antizeno_engine/anti_zeno_engine.org +++ b/python/energy_flow_proper/10_antizeno_engine/anti_zeno_engine.org @@ -12,7 +12,7 @@ Here we try to reproduce the anti zeno engine from the paper. import qutip as qt import scipy import utilities as ut - from hops.util.dynamic_matrix import SmoothStep, Periodic, Harmonic, ConstantMatrix, Piecewise + from hops.util.dynamic_matrix import SmoothStep, Periodic, Harmonic, ConstantMatrix, Piecewise, Shift import matplotlib.pyplot as plt import numpy as np #+end_src @@ -25,7 +25,7 @@ Init ray and silence stocproc. #+end_src #+RESULTS: -: RayContext(dashboard_url='', python_version='3.9.12', ray_version='1.12.1', ray_commit='4863e33856b54ccf8add5cbe75e41558850a1b75', address_info={'node_ip_address': '141.30.17.225', 'raylet_ip_address': '141.30.17.225', 'redis_address': None, 'object_store_address': '/tmp/ray/session_2022-06-20_11-11-50_409350_1559734/sockets/plasma_store', 'raylet_socket_name': '/tmp/ray/session_2022-06-20_11-11-50_409350_1559734/sockets/raylet', 'webui_url': '', 'session_dir': '/tmp/ray/session_2022-06-20_11-11-50_409350_1559734', 'metrics_export_port': 48028, 'gcs_address': '141.30.17.225:57122', 'address': '141.30.17.225:57122', 'node_id': '4e032ba66cd47b05f939f5a1a89a9b5ecd50a752e9f61b648868067b'}) +: RayContext(dashboard_url='', python_version='3.9.12', ray_version='1.12.1', ray_commit='4863e33856b54ccf8add5cbe75e41558850a1b75', address_info={'node_ip_address': '141.30.17.225', 'raylet_ip_address': '141.30.17.225', 'redis_address': None, 'object_store_address': '/tmp/ray/session_2022-06-20_16-04-05_747504_1622147/sockets/plasma_store', 'raylet_socket_name': '/tmp/ray/session_2022-06-20_16-04-05_747504_1622147/sockets/raylet', 'webui_url': '', 'session_dir': '/tmp/ray/session_2022-06-20_16-04-05_747504_1622147', 'metrics_export_port': 64315, 'gcs_address': '141.30.17.225:45941', 'address': '141.30.17.225:45941', 'node_id': 'f8e5ee19d6c4bb61c86fcbf2ad3d4eb02d0f22821152e4a65bab8302'}) #+begin_src jupyter-python :results none from hops.util.logging_setup import logging_setup @@ -50,8 +50,10 @@ Init ray and silence stocproc. T_h=5, therm_initial_state=False, s=1, - dt=.1, - T_c=0, + dt=0.1, + T_c=0, + ε_init=0, + δ_init=1 ): # τ_bath = 1 / ω_c τ_mod = 2 * np.pi / Δ @@ -93,6 +95,37 @@ Init ray and silence stocproc. τ_c + τ_off, ) + if ε_init > 0: + initializing_period = -np.log(ε_init) / smallest_exponent + t_max += initializing_period + H = Piecewise( + [ + ConstantMatrix(H_mat), + Shift( + H, + initializing_period, + ), + ], + [0, initializing_period, np.inf], + ) + + L = Piecewise( + [ + (ConstantMatrix(L_mat) + - SmoothStep( + L_mat, + initializing_period - τ_off - Δ_switch, + initializing_period - τ_off, + 2, + )) * np.sqrt(δ_init), + Shift( + L, + initializing_period, + ), + ], + [0, initializing_period, np.inf], + ) + model = QubitModelMutliBath( δ=δ, ω_c=[ω_c, ω_c], @@ -117,7 +150,11 @@ Init ray and silence stocproc. s=s, ) - return model, Δ, (τ_mod, τ_c, τ_bath, cycles, model.ω_s, ω_0, τ_mod, τ_off, n, Δ_switch) + return ( + model, + Δ, + (τ_mod, τ_c, τ_bath, cycles, model.ω_s, ω_0, τ_mod, τ_off, n, Δ_switch), + ) #+end_src @@ -138,6 +175,8 @@ Init ray and silence stocproc. switch_cycles=1, therm_initial_state=False, s=[1] * 2, + ε_init=.1, + δ_init=5, ) model.k_max = 4 # model, params = anti_zeno_engine(ε=1/2, ε_couple=1e-4, n=1, detune=.5, δ=[.1,.1]) @@ -168,8 +207,8 @@ Let's test the assumptions of the paper. #+RESULTS: :RESULTS: -| | -[[file:./.ob-jupyter/b5058d982594e3c04b37fe39843ac77068575bd6.svg]] +| | +[[file:./.ob-jupyter/756fc4868ff15b727fe451ef7edd626f6fac267a.svg]] :END: #+begin_src jupyter-python :tangle nil @@ -188,7 +227,7 @@ Let's test the assumptions of the paper. #+RESULTS: :RESULTS: | 2.75 | 3.2 | -[[file:./.ob-jupyter/9b687202bdbd2222a968384feea3b7a1cfac5af4.svg]] +[[file:./.ob-jupyter/867ddd4e8f5b15b75dc0293d1e626fd26279ec9a.svg]] :END: #+begin_src jupyter-python @@ -200,8 +239,8 @@ Let's test the assumptions of the paper. #+RESULTS: :RESULTS: |
| | -[[file:./.ob-jupyter/4c53103cb8c40d42c350d174bcba82f9eb89326d.svg]] -[[file:./.ob-jupyter/a97d825bfa17726c6cb33b4169eb9e47ad68f5fc.svg]] +[[file:./.ob-jupyter/f377ba31bfd3b2c137b8867c6d7e3920e1d9da09.svg]] +[[file:./.ob-jupyter/06b24d015c4513312e089b3bf76dd8406bd4f491.svg]] :END: #+begin_src jupyter-python @@ -215,7 +254,7 @@ Let's test the assumptions of the paper. #+RESULTS: :RESULTS: |
| | -[[file:./.ob-jupyter/07ad687ed4242e118fe10e9994e767ff655a0a5d.svg]] +[[file:./.ob-jupyter/42a6b32dc296978e6e491d29c340d522dbf2fa1e.svg]] :END: @@ -256,8 +295,8 @@ Let's test the assumptions of the paper. #+RESULTS: :RESULTS: -: -[[file:./.ob-jupyter/8a49649ab76a2e7cceab3136ef1a47aec4dbd046.svg]] +: +[[file:./.ob-jupyter/03d799944bfd6428a9dde1bd29dc69eaaf066383.svg]] :END: - **too fast decoupling kills it** @@ -279,19 +318,7 @@ Let's test the assumptions of the paper. #+end_src #+RESULTS: -:RESULTS: -: /nix/store/pwhaggpgvxhy410r6vlx448v9lp8n08s-python3-3.9.12-env/lib/python3.9/site-packages/matplotlib/cbook/__init__.py:1298: ComplexWarning: Casting complex values to real discards the imaginary part -: return np.asarray(x, float) -: /nix/store/pwhaggpgvxhy410r6vlx448v9lp8n08s-python3-3.9.12-env/lib/python3.9/site-packages/matplotlib/axes/_axes.py:5218: ComplexWarning: Casting complex values to real discards the imaginary part -: pts[0] = start -: /nix/store/pwhaggpgvxhy410r6vlx448v9lp8n08s-python3-3.9.12-env/lib/python3.9/site-packages/matplotlib/axes/_axes.py:5219: ComplexWarning: Casting complex values to real discards the imaginary part -: pts[N + 1] = end -: /nix/store/pwhaggpgvxhy410r6vlx448v9lp8n08s-python3-3.9.12-env/lib/python3.9/site-packages/matplotlib/axes/_axes.py:5222: ComplexWarning: Casting complex values to real discards the imaginary part -: pts[1:N+1, 1] = dep1slice -: /nix/store/pwhaggpgvxhy410r6vlx448v9lp8n08s-python3-3.9.12-env/lib/python3.9/site-packages/matplotlib/axes/_axes.py:5224: ComplexWarning: Casting complex values to real discards the imaginary part -: pts[N+2:, 1] = dep2slice[::-1] -[[file:./.ob-jupyter/a365ba2355e7f4d1d260b557aad9ec771b7e45a0.svg]] -:END: +[[file:./.ob-jupyter/8eae8f664adef59ed6a98a7a67e37d440b01d028.svg]] - no steady state ... but we have to average... @@ -304,8 +331,8 @@ Let's test the assumptions of the paper. #+RESULTS: :RESULTS: -| | -[[file:./.ob-jupyter/6fa097dddc1db3a222e646106b94269eac3bc844.svg]] +| | +[[file:./.ob-jupyter/6cb93ce5aefd3b291f4901919b5459ffee4d0b63.svg]] :END: ** TODO Power and Efficiency @@ -318,19 +345,19 @@ We need the time points where we sample the total energy. _, ax = plt.subplots() # fs.plot_with_σ(model.t, model.bath_energy(data), bath=0, ax=ax) # fs.plot_with_σ(model.t, model.bath_energy(data), bath=1, ax=ax) - # fs.plot_with_σ(model.t, model.bath_energy(data).sum_baths(), ax=ax) + #fs.plot_with_σ(model.t, model.bath_energy(data).sum_baths(), ax=ax) # fs.plot_with_σ(model.t, model.total_energy(data), ax=ax) - fs.plot_with_σ(model.t, model.interaction_energy(data).for_bath(1), ax=ax) + #fs.plot_with_σ(model.t, model.interaction_energy(data).for_bath(1), 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) + fs.plot_with_σ(model.t, model.system_energy(data) + model.bath_energy(data).sum_baths(), ax=ax) # ax.plot(model.t, ut.smoothen(model.t, model.total_energy(data).value, frac=.1)) # ax.plot(model.t, np.gradient(model.total_energy(data).value)) #+end_src #+RESULTS: -[[file:./.ob-jupyter/0a54c6e1264f39ecb1e5e6febfa88ff11eb31f91.svg]] +[[file:./.ob-jupyter/050e6865a23ef19d197a61c8c544e55c8e85c600.svg]] @@ -364,8 +391,8 @@ One cycle power. #+RESULTS: :RESULTS: -: -0.00047898251459689074 -[[file:./.ob-jupyter/db74d50ce5db826ead3350c2087e8b3ec016985b.svg]] +: 8.593886729920876e-05 +[[file:./.ob-jupyter/ad56687b7247b3ba97ee566373fda4b0f7d7804f.svg]] :END: