update cycle shift

This commit is contained in:
valentin.boettcher@mailbox.tu-dresden.de 2023-03-06 11:22:06 -05:00
parent e6a0eb62e6
commit 8e704330b3
No known key found for this signature in database
GPG key ID: E034E12B7AF56ACE
2 changed files with 306 additions and 80 deletions

View file

@ -38,8 +38,9 @@ strength to demonstrate strong coupling effects and to limit the cycle time.
#+begin_src jupyter-python
T = 50
switch_time = 3. / T
def make_model(shift_c, shift_h):
def make_model(shift_c, shift_h, switch_t=3.):
switch_time = switch_t / T
(p_H, p_L) = ot.timings(switch_time, switch_time)
return OttoEngine(
δ=[.7, .7],
@ -72,14 +73,14 @@ We start with one dimension and may add another later / dimension.
We shift so that we just overlap with coupling/decoupling and one above.
#+begin_src jupyter-python
N = 3
N_over = 1
step = switch_time / (N-N_over)
N_over = 2
step = 3. / (T*(N-N_over))
shifts = [round(shift * step, 3) for shift in range(-N, N+1)]
shifts
#+end_src
#+RESULTS:
| -0.09 | -0.06 | -0.03 | 0.0 | 0.03 | 0.06 | 0.09 |
| -0.18 | -0.12 | -0.06 | 0.0 | 0.06 | 0.12 | 0.18 |
#+begin_src jupyter-python
import itertools
@ -95,94 +96,254 @@ We shift so that we just overlap with coupling/decoupling and one above.
#+RESULTS:
:RESULTS:
| <Figure | size | 1200x400 | with | 1 | Axes> | <AxesSubplot: | xlabel= | $\tau$ | ylabel= | Operator Norm | > |
[[file:./.ob-jupyter/19f62f210b59f479bd493c49dedc0e2ba1ec8c00.svg]]
[[file:./.ob-jupyter/c73172c3276a9720f26dd513bff58352bcf807ed.svg]]
:END:
* Integrate
** Integrate
#+begin_src jupyter-python :tangle no
ot.integrate_online_multi(models, 50_000, increment=10_000, analyze_kwargs=dict(every=10_000))
#+end_src
** Analysis
#+begin_src jupyter-python
ot.integrate_online_multi(models, 100_000, increment=10_000, analyze_kwargs=dict(every=10_000))
for model in models:
print(model.power(steady_idx=1).value / models[3].power(steady_idx=1).value, model.efficiency(steady_idx=1).value * 100)
#+end_src
#+RESULTS:
: -2.7704455654085876 -252.19916727767804
: -2.034015641972767 -166.75487518853186
: 0.571544457513159 19.650010500179352
: 1.0 30.20953730879978
: 1.1652434363371367 32.393489928809124
: 1.6245889921167371 33.021523773544054
: 1.6841939173993579 31.91460252999856
#+begin_src jupyter-python
ot.plot_power_eff_convergence(models)
#+end_src
#+RESULTS:
[[file:./.ob-jupyter/2ff8db3bb8190dab3fb0d849e3e08e61069da5a3.svg]]
We see that we get a pretty good picture after about 30k-40k samples.
#+begin_src jupyter-python
ot.plot_powers_and_efficiencies(shifts, models)
#+end_src
#+RESULTS:
:RESULTS:
| <matplotlib.lines.Line2D | at | 0x7f557e50b340> |
[[file:./.ob-jupyter/9a3bec09d003106d1215f0be556ece64f7802787.svg]]
:END:
* Explore Coupling Length Dimension for The best performing state
The best shift:
#+begin_src jupyter-python
best_shift = shifts[-2]
best_shift_model = make_model(best_shift, best_shift)
#+end_src
#+RESULTS:
#+begin_src jupyter-python
def overlap(shift_model, N, step, switch_t=3.):
switch_time = switch_t / T
(p_H, p_L) = ot.timings(switch_time, switch_time)
next_model = shift_model.copy()
#next_model.timings_H=p_H
next_model.timings_L=p_L
(a, b, c, d) = next_model.timings_L[0]
(e, f, g, h) = next_model.timings_L[1]
next_step = step * N
(s1, s2) = next_model.L_shift
next_model.L_shift = (s1 + next_step, s2 - next_step)
next_model.timings_L = (
(a - 2 * next_step, b - 2 * next_step, c, d),
(e, f, g + 2 * next_step, h + 2 * next_step),
)
return next_model
def overlap_cold(shift_model, N, step):
next_model = shift_model.copy()
(a, b, c, d) = next_model.timings_L[0]
(e, f, g, h) = next_model.timings_L[1]
next_step = step * N
(s1, s2) = next_model.L_shift
next_model.L_shift = (s1 + next_step, s2 - next_step)
next_model.timings_L = (
(a - 2 * next_step, b - 2 * next_step, c - next_step, d - next_step),
(e + next_step, f + next_step, g + 2 * next_step, h + 2 * next_step),
)
return next_model
Ns = list(range(1, 4))
overlap_models = [overlap(best_shift_model, N, step) for N in Ns]
overlap_models = [overlap_cold(best_shift_model, N, step) for N in Ns]
new_step_size = 6
mini_step = (new_step_size / (N-N_over) / T)
overlap_models = [overlap(best_shift_model, N, mini_step, new_step_size) for N in Ns]
#+end_src
#+RESULTS:
#+begin_src jupyter-python :tangle no
ot.plot_cycles([overlap_models[0]], legend=True)
#+end_src
#+RESULTS:
:RESULTS:
| <Figure | size | 1200x400 | with | 1 | Axes> | <AxesSubplot: | xlabel= | $\tau$ | ylabel= | Operator Norm | > |
[[file:./.ob-jupyter/da2f676618a9cc61b975c93dd31f9eedb118d916.svg]]
:END:
** Integrate
#+begin_src jupyter-python
ot.integrate_online_multi(overlap_models, 50_000, increment=10_000, analyze_kwargs=dict(every=10_000))
#+end_src
#+RESULTS:
#+begin_example
[INFO hops.core.integration 65100] Choosing the nonlinear integrator.
[INFO root 65100] Starting analysis process.
[INFO root 65100] Started analysis process with pid 66265.
[INFO hops.core.hierarchy_data 65100] Creating the streaming fifo at: /home/hiro/Documents/Projects/UNI/master/eflow_paper/python/otto_motor/subprojects/cycle_shift/results_f9bc66cc2b4cb7ba3371882ad9ee50d48460546af0eca71f7c01b081415f5d14.fifo
[INFO hops.core.integration 65100] Using 16 integrators.
[INFO hops.core.integration 65100] Some 10000 trajectories have to be integrated.
[INFO hops.core.integration 65100] Using 1001 hierarchy states.
1% 61/10000 [01:36<4:21:15, 1.58s/it][INFO hops.core.signal_delay 65100] caught sig 'SIGINT'
1% 64/10000 [01:48<4:39:54, 1.69s/it]
2023-02-25 12:46:53,879 WARNING worker.py:1404 -- A worker died or was killed while executing a task by an unexpected system error. To troubleshoot the problem, check the logs for the dead worker. RayTask ID: 99d25236ee4cd74b12aa2eea44f4fd9e79a9439801000000 Worker ID: 6954a0683bf80bbcf18b6f6300bde11b52e9018e100cf3b6cbc519a9 Node ID: afe7814ecf0191651ed8a09d4c5df11440975f8facd16c7e843c2bd7 Worker IP address: 192.168.100.170 Worker port: 38229 Worker PID: 66005
2023-02-25 12:46:54,342 ERROR worker.py:94 -- Unhandled error (suppress with 'RAY_IGNORE_UNHANDLED_ERRORS=1'): The worker died unexpectedly while executing this task. Check python-core-worker-*.log files for more information.
2023-02-25 12:46:54,343 ERROR worker.py:94 -- Unhandled error (suppress with 'RAY_IGNORE_UNHANDLED_ERRORS=1'): The worker died unexpectedly while executing this task. Check python-core-worker-*.log files for more information.
2023-02-25 12:46:54,344 ERROR worker.py:94 -- Unhandled error (suppress with 'RAY_IGNORE_UNHANDLED_ERRORS=1'): The worker died unexpectedly while executing this task. Check python-core-worker-*.log files for more information.
2023-02-25 12:46:54,344 ERROR worker.py:94 -- Unhandled error (suppress with 'RAY_IGNORE_UNHANDLED_ERRORS=1'): The worker died unexpectedly while executing this task. Check python-core-worker-*.log files for more information.
2023-02-25 12:46:54,345 ERROR worker.py:94 -- Unhandled error (suppress with 'RAY_IGNORE_UNHANDLED_ERRORS=1'): The worker died unexpectedly while executing this task. Check python-core-worker-*.log files for more information.
2023-02-25 12:46:54,346 ERROR worker.py:94 -- Unhandled error (suppress with 'RAY_IGNORE_UNHANDLED_ERRORS=1'): The worker died unexpectedly while executing this task. Check python-core-worker-*.log files for more information.
2023-02-25 12:46:54,347 ERROR worker.py:94 -- Unhandled error (suppress with 'RAY_IGNORE_UNHANDLED_ERRORS=1'): The worker died unexpectedly while executing this task. Check python-core-worker-*.log files for more information.
[INFO hops.core.signal_delay 65100] caught 1 signal(s)
2023-02-25 12:46:54,347 ERROR worker.py:94 -- Unhandled error (suppress with 'RAY_IGNORE_UNHANDLED_ERRORS=1'): The worker died unexpectedly while executing this task. Check python-core-worker-*.log files for more information.
[INFO hops.core.signal_delay 65100] emit signal 'SIGINT'
2023-02-25 12:46:54,348 ERROR worker.py:94 -- Unhandled error (suppress with 'RAY_IGNORE_UNHANDLED_ERRORS=1'): The worker died unexpectedly while executing this task. Check python-core-worker-*.log files for more information.
[INFO hops.core.signal_delay 65100] caught sig 'SIGINT'
2023-02-25 12:46:54,349 ERROR worker.py:94 -- Unhandled error (suppress with 'RAY_IGNORE_UNHANDLED_ERRORS=1'): The worker died unexpectedly while executing this task. Check python-core-worker-*.log files for more information.
2023-02-25 12:46:54,350 ERROR worker.py:94 -- Unhandled error (suppress with 'RAY_IGNORE_UNHANDLED_ERRORS=1'): The worker died unexpectedly while executing this task. Check python-core-worker-*.log files for more information.
2023-02-25 12:46:54,350 ERROR worker.py:94 -- Unhandled error (suppress with 'RAY_IGNORE_UNHANDLED_ERRORS=1'): The worker died unexpectedly while executing this task. Check python-core-worker-*.log files for more information.
2023-02-25 12:46:54,351 ERROR worker.py:94 -- Unhandled error (suppress with 'RAY_IGNORE_UNHANDLED_ERRORS=1'): The worker died unexpectedly while executing this task. Check python-core-worker-*.log files for more information.
2023-02-25 12:46:54,352 ERROR worker.py:94 -- Unhandled error (suppress with 'RAY_IGNORE_UNHANDLED_ERRORS=1'): The worker died unexpectedly while executing this task. Check python-core-worker-*.log files for more information.
2023-02-25 12:46:54,353 ERROR worker.py:94 -- Unhandled error (suppress with 'RAY_IGNORE_UNHANDLED_ERRORS=1'): The worker died unexpectedly while executing this task. Check python-core-worker-*.log files for more information.
2023-02-25 12:46:54,354 ERROR worker.py:94 -- Unhandled error (suppress with 'RAY_IGNORE_UNHANDLED_ERRORS=1'): The worker died unexpectedly while executing this task. Check python-core-worker-*.log files for more information.
[INFO hops.core.signal_delay 65100] caught 1 signal(s)
[INFO hops.core.signal_delay 65100] emit signal 'SIGINT'
[INFO hops.core.integration 3664] Choosing the nonlinear integrator.
[INFO root 3664] Starting analysis process.
[INFO root 3664] Started analysis process with pid 7756.
[INFO hops.core.hierarchy_data 3664] Creating the streaming fifo at: /home/hiro/Documents/Projects/UNI/master/eflow_paper/python/otto_motor/subprojects/cycle_shift/results_cfad63977aad412a4d035ea4122d748504bc638b4df70749bf6a9f0a0ecbcf4b.fifo
[INFO hops.core.integration 3664] Using 16 integrators.
[INFO hops.core.integration 3664] Some 1 trajectories have to be integrated.
[INFO hops.core.integration 3664] Using 1001 hierarchy states.
100% 1/1 [00:13<00:00, 13.21s/it]
[INFO hops.core.integration 3664] Choosing the nonlinear integrator.
[INFO root 3664] Starting analysis process.
[INFO root 3664] Started analysis process with pid 7978.
[INFO hops.core.hierarchy_data 3664] Creating the streaming fifo at: /home/hiro/Documents/Projects/UNI/master/eflow_paper/python/otto_motor/subprojects/cycle_shift/results_fcf52e28de29cab5e6962849767ead5e754ba33e96dabf2d95d5fbc0b0c2488d.fifo
[INFO hops.core.integration 3664] Using 16 integrators.
[INFO hops.core.integration 3664] Some 1 trajectories have to be integrated.
[INFO hops.core.integration 3664] Using 1001 hierarchy states.
100% 1/1 [00:14<00:00, 14.27s/it]
[INFO hops.core.integration 3664] Choosing the nonlinear integrator.
[INFO root 3664] Starting analysis process.
[INFO root 3664] Started analysis process with pid 7988.
[INFO hops.core.hierarchy_data 3664] Creating the streaming fifo at: /home/hiro/Documents/Projects/UNI/master/eflow_paper/python/otto_motor/subprojects/cycle_shift/results_f59d5e1c4b003307fdb6496ba3a22a283b5e68974725996eb14aac2901ac04da.fifo
[INFO hops.core.integration 3664] Using 16 integrators.
[INFO hops.core.integration 3664] Some 1 trajectories have to be integrated.
[INFO hops.core.integration 3664] Using 1001 hierarchy states.
100% 1/1 [00:15<00:00, 15.74s/it]
#+end_example
** Analysis
#+begin_src jupyter-julia
all_overlap_models = [best_shift_model, *overlap_models]
#+end_src
#+RESULTS:
#+begin_src jupyter-python
ot.plot_power_eff_convergence(all_overlap_models, 1)
#+end_src
#+RESULTS:
:RESULTS:
# [goto error]
#+begin_example
---------------------------------------------------------------------------
KeyboardInterrupt Traceback (most recent call last)
Cell In[11], line 1
----> 1 ot.integrate_online_multi(models, 100_000, increment=10_000, analyze_kwargs=dict(every=10_000))
RuntimeError Traceback (most recent call last)
Cell In[14], line 1
----> 1 ot.plot_power_eff_convergence(all_overlap_models, 1)
File ~/Documents/Projects/UNI/master/eflow_paper/python/otto_motor/subprojects/cycle_shift/otto_utilities.py:171, in integrate_online_multi(models, n, increment, *args, **kwargs)
 169 while target < (n + target):
 170 for model in models:
--> 171 integrate_online(model, min([n, target]), *args, **kwargs)
 173 target += increment
File ~/Documents/Projects/UNI/master/eflow_paper/python/otto_motor/subprojects/cycle_shift/otto_utilities.py:15, in plot_power_eff_convergence(models, steady_idx)
 13 a_efficiency.set_yscale("log")
 14 for model in models:
---> 15 Ns = model.power(steady_idx=steady_idx).Ns
 16 a_power.plot(Ns, model.power(steady_idx=steady_idx).values)
 17 a_efficiency.plot(Ns, np.abs(model.efficiency(steady_idx=steady_idx).values))
File ~/Documents/Projects/UNI/master/eflow_paper/python/otto_motor/subprojects/cycle_shift/otto_utilities.py:156, in integrate_online(model, n, stream_folder, **kwargs)
 155 def integrate_online(model, n, stream_folder=None, **kwargs):
--> 156 aux.integrate(
 157  model,
 158  n,
 159  stream_file=("" if stream_folder is None else stream_folder)
 160  + f"results_{model.hexhash}.fifo",
 161  analyze=True,
 162  **kwargs,
 163  )
File <@beartype(hiro_models.otto_cycle.OttoEngine.power) at 0x7ff6254db790>:31, in power(__beartype_func, __beartype_conf, __beartype_get_violation, *args, **kwargs)
File ~/src/two_qubit_model/hiro_models/model_auxiliary.py:201, in integrate(model, n, data_path, clear_pd, single_process, stream_file, analyze, results_path, analyze_kwargs)
 199 supervisor.integrate_single_process(clear_pd)
 200 else:
--> 201 supervisor.integrate(clear_pd)
 203 cleanup(0)
File ~/src/two_qubit_model/hiro_models/otto_cycle.py:482, in OttoEngine.power(self, steady_idx, *args, **kwargs)
 475 """
 476 Calculate the mean steady state power. For the arguments see
 477 :any:`steady_energy_change`.
 478 """
 480 _, indices = self.strobe
--> 482 return self.total_power().slice(slice(indices[steady_idx], None, 1)).mean
File ~/src/hops/hops/core/signal_delay.py:87, in sig_delay.__exit__(self, exc_type, exc_val, exc_tb)
 84 if len(self.sigh.sigs_caught) > 0 and self.handler is not None:
 85 self.handler(self.sigh.sigs_caught)
---> 87 self._restore()
File ~/src/two_qubit_model/hiro_models/model_base.py:649, in Model.total_power(self, data, **kwargs)
 638 def total_power(self, data: Optional[HIData] = None, **kwargs) -> EnsembleValue:
 639 """Calculates the total power from the trajectories in
 640  ``data`` or, if not supplied, tries to load
 641  the online results from ``results_path``.
 (...)
 646  :returns: The total power.
 647  """
--> 649 power = self.interaction_power(data, **kwargs).sum_baths()
 650 system_power = self.system_power(data, **kwargs)
 652 if system_power is not None:
File ~/src/hops/hops/core/signal_delay.py:68, in sig_delay._restore(self)
 66 for i, s in enumerate(self.sigs):
 67 signal.signal(s, self.old_handlers[i])
---> 68 self.sigh.emit()
File ~/src/two_qubit_model/hiro_models/model_base.py:560, in Model.interaction_power(self, data, results_path, **kwargs)
 550 """Calculates interaction power from the hierarchy data
 551 ``data`` or, if not supplied, tries to load the online results from ``results_path``.
 552
 (...)
 556 :returns: See :any:`hopsflow.util.interaction_energy_ensemble`.
 557 """
 559 if data is None:
--> 560 return self.try_get_online_data(
 561  results_path, self.online_interaction_power_name
 562  )
 564 N, kwargs = _get_N_kwargs(kwargs, data)
 566 return hopsflow.hopsflow.interaction_energy_ensemble(
 567 data.valid_sample_iterator(data.stoc_traj), # type: ignore
 568 data.valid_sample_iterator(data.aux_states), # type: ignore
 (...)
 574 **kwargs,
 575 )
File ~/src/hops/hops/core/signal_delay.py:42, in SigHandler.emit(self)
 40 for s in self.sigs_caught:
 41 log.info("emit signal '{}'".format(SIG_MAP[s]))
---> 42 os.kill(os.getpid(), s)
File ~/src/two_qubit_model/hiro_models/model_base.py:298, in Model.try_get_online_data(self, path, results_path)
 296 file_path = os.path.join(path, results_path)
 297 if not os.path.exists(file_path):
--> 298 raise RuntimeError(f"No data found under '{file_path}'.")
 300 return hopsflow.util.get_online_values_from_cache(file_path)
KeyboardInterrupt:
RuntimeError: No data found under 'results/interaction_power_cfad63977aad412a4d035ea4122d748504bc638b4df70749bf6a9f0a0ecbcf4b.npz'.
#+end_example
[[file:./.ob-jupyter/b558c35b08a532e347de25d93e5aa133d5b6e6ff.svg]]
:END:
#+begin_src jupyter-julia
[model.efficiency(steady_idx=2).value / best_shift_model.efficiency(steady_idx=2).value for model in all_overlap_models]
#+end_src
#+RESULTS:
| 1.0 | 1.0214351243995223 | 0.5705103160098187 | 0.3967276370979822 |
#+begin_src jupyter-python
ot.plot_powers_and_efficiencies(Ns, overlap_models)
#+end_src
#+RESULTS:
:RESULTS:
| <Figure | size | 1200x400 | with | 2 | Axes> | <AxesSubplot: | > |
[[file:./.ob-jupyter/11463950153d8f27d2734c7ae3d213b127aaf350.svg]]
:END:
#+begin_src jupyter-python
f, a = plt.subplots()
a.axhline(0)
for model in all_overlap_models:
pu.plot_with_σ(model.t, model.interaction_power().sum_baths().integrate(model.t), ax=a)
#+end_src
#+RESULTS:
[[file:./.ob-jupyter/c14627fd66e3c1c812fa240ebc2f765344f3290e.svg]]
** Findings
- coupling overlap doesn't help much
- with these parameters the earlier obeservation does not recur
- more scan needed
- maybe slower coupling/decoupling will help

View file

@ -21,8 +21,9 @@ logging_setup(logging.INFO)
plt.rcParams['figure.figsize'] = (12,4)
T = 50
switch_time = 3. / T
def make_model(shift_c, shift_h):
def make_model(shift_c, shift_h, switch_t=3.):
switch_time = switch_t / T
(p_H, p_L) = ot.timings(switch_time, switch_time)
return OttoEngine(
δ=[.7, .7],
@ -48,12 +49,76 @@ def make_model(shift_c, shift_h):
)
N = 3
N_over = 1
step = switch_time / (N-N_over)
N_over = 2
step = 3. / (T*(N-N_over))
shifts = [round(shift * step, 3) for shift in range(-N, N+1)]
shifts
import itertools
models = [make_model(shift, shift) for shift in shifts]
ot.integrate_online_multi(models, 100_000, increment=10_000, analyze_kwargs=dict(every=10_000))
for model in models:
print(model.power(steady_idx=1).value / models[3].power(steady_idx=1).value, model.efficiency(steady_idx=1).value * 100)
ot.plot_power_eff_convergence(models)
ot.plot_powers_and_efficiencies(shifts, models)
best_shift = shifts[-2]
best_shift_model = make_model(best_shift, best_shift)
def overlap(shift_model, N, step, switch_t=3.):
switch_time = switch_t / T
(p_H, p_L) = ot.timings(switch_time, switch_time)
next_model = shift_model.copy()
#next_model.timings_H=p_H
next_model.timings_L=p_L
(a, b, c, d) = next_model.timings_L[0]
(e, f, g, h) = next_model.timings_L[1]
next_step = step * N
(s1, s2) = next_model.L_shift
next_model.L_shift = (s1 + next_step, s2 - next_step)
next_model.timings_L = (
(a - 2 * next_step, b - 2 * next_step, c, d),
(e, f, g + 2 * next_step, h + 2 * next_step),
)
return next_model
def overlap_cold(shift_model, N, step):
next_model = shift_model.copy()
(a, b, c, d) = next_model.timings_L[0]
(e, f, g, h) = next_model.timings_L[1]
next_step = step * N
(s1, s2) = next_model.L_shift
next_model.L_shift = (s1 + next_step, s2 - next_step)
next_model.timings_L = (
(a - 2 * next_step, b - 2 * next_step, c - next_step, d - next_step),
(e + next_step, f + next_step, g + 2 * next_step, h + 2 * next_step),
)
return next_model
Ns = list(range(1, 4))
overlap_models = [overlap(best_shift_model, N, step) for N in Ns]
overlap_models = [overlap_cold(best_shift_model, N, step) for N in Ns]
new_step_size = 6
mini_step = (new_step_size / (N-N_over) / T)
overlap_models = [overlap(best_shift_model, N, mini_step, new_step_size) for N in Ns]
ot.integrate_online_multi(overlap_models, 50_000, increment=10_000, analyze_kwargs=dict(every=10_000))
all_overlap_models = [best_shift_model, *overlap_models]
ot.plot_power_eff_convergence(all_overlap_models, 1)
[model.efficiency(steady_idx=2).value / best_shift_model.efficiency(steady_idx=2).value for model in all_overlap_models]
ot.plot_powers_and_efficiencies(Ns, overlap_models)
f, a = plt.subplots()
a.axhline(0)
for model in all_overlap_models:
pu.plot_with_σ(model.t, model.interaction_power().sum_baths().integrate(model.t), ax=a)