add 07 figures

This commit is contained in:
Valentin Boettcher 2022-05-16 18:13:48 +02:00
parent 72b798e448
commit 7f7fd6afab
3 changed files with 101223 additions and 326 deletions

File diff suppressed because it is too large Load diff

After

Width:  |  Height:  |  Size: 1.2 MiB

View file

@ -22,7 +22,7 @@ Init ray and silence stocproc.
#+end_src
#+RESULTS:
| node_ip_address | : | 141.30.17.221 | raylet_ip_address | : | 141.30.17.221 | redis_address | : | hline | object_store_address | : | /tmp/ray/session_2022-04-26_13-48-04_707851_3943264/sockets/plasma_store | raylet_socket_name | : | /tmp/ray/session_2022-04-26_13-48-04_707851_3943264/sockets/raylet | webui_url | : | hline | session_dir | : | /tmp/ray/session_2022-04-26_13-48-04_707851_3943264 | metrics_export_port | : | 43755 | gcs_address | : | 141.30.17.221:63388 | address | : | 141.30.17.221:63388 | node_id | : | 8f7d9d5436973542899392aff75eb0d3d44de720533318bb5fd08fa0 |
: RayContext(dashboard_url='', python_version='3.9.12', ray_version='1.12.0', ray_commit='f18fc31c7562990955556899090f8e8656b48d2d', address_info={'node_ip_address': '141.30.17.221', 'raylet_ip_address': '141.30.17.221', 'redis_address': None, 'object_store_address': '/tmp/ray/session_2022-05-11_19-35-36_875869_38685/sockets/plasma_store', 'raylet_socket_name': '/tmp/ray/session_2022-05-11_19-35-36_875869_38685/sockets/raylet', 'webui_url': '', 'session_dir': '/tmp/ray/session_2022-05-11_19-35-36_875869_38685', 'metrics_export_port': 59149, 'gcs_address': '141.30.17.221:61235', 'address': '141.30.17.221:61235', 'node_id': '2d5374c53f7c14cbfa36dff1f62247d1d327a1acfea62021878d000a'})
#+begin_src jupyter-python :results none :tangle scripts/integrate_slip.py
from hops.util.logging_setup import logging_setup
@ -43,8 +43,8 @@ We use a logspaced time to resolve the initial slip.
#+RESULTS:
:RESULTS:
| <matplotlib.lines.Line2D | at | 0x7f952bb1aac0> |
[[file:./.ob-jupyter/93227274c92b68cad6a202f7cfa582dde1bf50f6.svg]]
| <matplotlib.lines.Line2D | at | 0x7f664ff037c0> |
[[file:./.ob-jupyter/c358a499ec28802a0a461028cbcf2f52eedcb151.svg]]
:END:
* Convergence Woes
@ -71,121 +71,17 @@ We could try the same with another truncation scheme.
aux.integrate_multi(alt_tol_models, 400_000)
#+end_src
#+RESULTS:
:RESULTS:
: [INFO hops.core.integration 3943264] Choosing the nonlinear integrator.
: [INFO hops.core.integration 3943264] Using 4 integrators.
# [goto error]
#+begin_example
---------------------------------------------------------------------------
KeyboardInterrupt Traceback (most recent call last)
Input In [12], in <cell line: 1>()
----> 1 aux.integrate_multi(alt_tol_models, 400_000)
File ~/src/two_qubit_model/hiro_models/model_auxiliary.py:81, in integrate_multi(models, *args, **kwargs)
 74 """Integrate the hops equations for the ``models``.
 75 Like :any:`integrate` just for many models.
 76
 77 A call to :any:`ray.init` may be required.
 78 """
 80 for model in models:
---> 81 integrate(model, *args, **kwargs)
File ~/src/two_qubit_model/hiro_models/model_auxiliary.py:105, in integrate(model, n, data_path, clear_pd)
 95 # with model_db(data_path) as db:
 96 # if hash in db and "data" db[hash]
 98 supervisor = HOPSSupervisor(
 99 model.hops_config,
 100 n,
 101 data_path=data_path,
 102 data_name=hash,
 103 )
--> 105 supervisor.integrate(clear_pd)
 107 with supervisor.get_data(True) as data:
 108 with model_db(data_path) as db:
File ~/src/hops/hops/core/integration.py:1245, in HOPSSupervisor.integrate(self, clear_pd)
 1241 raise RuntimeError("No cpu available for integration!")
 1243 log.info(f"Using {num_integrators} integrators.")
-> 1245 indices = self.get_job_args(data)
 1247 integrator = ray.put(self.actor(t, self.params, data.result_filter))
 1249 integration = tqdm(
 1250 total=len(indices),
 1251 disable=self._hide_progress,
 (...)
 1254 mininterval=1,
 1255 )
File ~/src/hops/hops/core/integration.py:1150, in HOPSSupervisor.get_job_args(self, data)
 1143 """
 1144 :returns: A list of argument tuples for
 1145  :any:`hops.core.integration.HOPSActor.integrate`
 1146  that corresponds to outstanding jobs.
 1147 """
 1149 seeds = self.seeds
-> 1150 args = [
 1151 (int(seeds[index]), index)
 1152 for index in range(
 1153 self.min_sample_index,
 1154 self.min_sample_index + self.number_of_samples,
 1155 )
 1156 if not data.has_sample(idx=index)
 1157 ]
 1159 log.info(f"Some {len(args)} trajectories have to be integrated.")
 1160 log.debug(f"Trajectories to be integrated: %s", args)
File ~/src/hops/hops/core/integration.py:1156, in <listcomp>(.0)
 1143 """
 1144 :returns: A list of argument tuples for
 1145  :any:`hops.core.integration.HOPSActor.integrate`
 1146  that corresponds to outstanding jobs.
 1147 """
 1149 seeds = self.seeds
 1150 args = [
 1151 (int(seeds[index]), index)
 1152 for index in range(
 1153 self.min_sample_index,
 1154 self.min_sample_index + self.number_of_samples,
 1155 )
-> 1156 if not data.has_sample(idx=index)
 1157 ]
 1159 log.info(f"Some {len(args)} trajectories have to be integrated.")
 1160 log.debug(f"Trajectories to be integrated: %s", args)
File ~/src/hops/hops/core/hierarchy_data.py:744, in HIData.has_sample(self, idx)
 741 """Returns whether the sample with the index ``idx`` has been
 742 processed."""
 743 if idx < self._idx_cnt:
--> 744 return bool(self.tracker[idx])
 745 else:
 746 return False
File h5py/_objects.pyx:54, in h5py._objects.with_phil.wrapper()
File h5py/_objects.pyx:55, in h5py._objects.with_phil.wrapper()
File /nix/store/v8al73piyplb4zsr88jnspqc62njjpxq-python3-3.9.10-env/lib/python3.9/site-packages/h5py/_hl/dataset.py:788, in Dataset.__getitem__(self, args, new_dtype)
 785 if selection.nselect == 0:
 786 return numpy.ndarray(selection.array_shape, dtype=new_dtype)
--> 788 arr = numpy.ndarray(selection.array_shape, new_dtype, order='C')
 790 # Perform the actual read
 791 mspace = h5s.create_simple(selection.mshape)
KeyboardInterrupt:
#+end_example
:END:
#+begin_src jupyter-python :results none :tangle scripts/integrate_slip.py
ensmeble_arg = dict(
every=1000,
chunk_size=5_000,
chunk_size=500,
)
#+end_src
#+begin_src jupyter-python :tangle scripts/integrate_slip.py
plot_interaction_consistency(
alt_tol_models[:1],
alt_tol_models,
# alt_tol_models[0],
label_fn=lambda m: fr"stocproc=$10^{{{np.log10(m.driving_process_tolerance.integration):.0f}}}$",
,**ensmeble_arg
@ -194,11 +90,8 @@ We could try the same with another truncation scheme.
#+RESULTS:
:RESULTS:
: Loading: 0% 0/80 [00:05<?, ?it/s]
:
: KeyboardInterrupt
:
[[file:./.ob-jupyter/a73a65aeea47f382c5845aaa1378af12f58242e5.svg]]
| <Figure | size | 432x288 | with | 1 | Axes> | <AxesSubplot:xlabel= | $τ$ | ylabel= | $\langle H_\mathrm{I}\rangle$ | > |
[[file:./.ob-jupyter/4d18e7c030d93fef8c85f72b9b1a5a13b645aa66.svg]]
:END:
#+begin_src jupyter-python
@ -210,89 +103,24 @@ We could try the same with another truncation scheme.
#+end_src
#+RESULTS:
:RESULTS:
# [goto error]
#+begin_example
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
Input In [80], in <cell line: 2>()
 2 for model, data in aux.model_data_iterator(alt_tol_models[:3]):
 3 bath = model.bath_energy_flow(data, **ensmeble_arg)
----> 4 fs.plot_with_σ(model.t, bath, bath=0, ax=ax)
File ~/Documents/Projects/UNI/master/masterarb/python/energy_flow_proper/07_one_bath_systematics/figsaver.py:130, in wrap_plot.<locals>.wrapped(ax, setup_function, *args, **kwargs)
 127 if not ax:
 128 fig, ax = setup_function()
--> 130 ret_val = f(*args, ax=ax, **kwargs)
 131 return (fig, ax, ret_val) if ret_val else (fig, ax)
File ~/Documents/Projects/UNI/master/masterarb/python/energy_flow_proper/07_one_bath_systematics/figsaver.py:254, in plot_with_σ(x, y, ax, transform, bath, **kwargs)
 251 err = (y.σ[bath] if bath is not None else y.σ).real
 252 y_final = transform(y.value[bath] if bath is not None else y.value)
--> 254 return fancy_error(x, y_final, err, ax=ax, **kwargs)
File ~/Documents/Projects/UNI/master/masterarb/python/energy_flow_proper/07_one_bath_systematics/figsaver.py:232, in fancy_error(x, y, err, ax, **kwargs)
 231 def fancy_error(x, y, err, ax=None, **kwargs):
--> 232 line = ax.plot(
 233  x,
 234  y,
 235  **kwargs,
 236  )
 238 err = ax.fill_between(
 239 x,
 240 y + err,
 (...)
 243 alpha=0.5,
 244 )
 246 return line, err
File /nix/store/v8al73piyplb4zsr88jnspqc62njjpxq-python3-3.9.10-env/lib/python3.9/site-packages/matplotlib/axes/_axes.py:1632, in Axes.plot(self, scalex, scaley, data, *args, **kwargs)
 1390 """
 1391 Plot y versus x as lines and/or markers.
 1392
 (...)
 1629 (``'green'``) or hex strings (``'#008000'``).
 1630 """
 1631 kwargs = cbook.normalize_kwargs(kwargs, mlines.Line2D)
-> 1632 lines = [*self._get_lines(*args, data=data, **kwargs)]
 1633 for line in lines:
 1634 self.add_line(line)
File /nix/store/v8al73piyplb4zsr88jnspqc62njjpxq-python3-3.9.10-env/lib/python3.9/site-packages/matplotlib/axes/_base.py:312, in _process_plot_var_args.__call__(self, data, *args, **kwargs)
 310 this += args[0],
 311 args = args[1:]
--> 312 yield from self._plot_args(this, kwargs)
File /nix/store/v8al73piyplb4zsr88jnspqc62njjpxq-python3-3.9.10-env/lib/python3.9/site-packages/matplotlib/axes/_base.py:498, in _process_plot_var_args._plot_args(self, tup, kwargs, return_kwargs)
 495 self.axes.yaxis.update_units(y)
 497 if x.shape[0] != y.shape[0]:
--> 498 raise ValueError(f"x and y must have same first dimension, but "
 499 f"have shapes {x.shape} and {y.shape}")
 500 if x.ndim > 2 or y.ndim > 2:
 501 raise ValueError(f"x and y can be no greater than 2D, but have "
 502 f"shapes {x.shape} and {y.shape}")
ValueError: x and y must have same first dimension, but have shapes (500,) and (1,)
#+end_example
[[file:./.ob-jupyter/a2038ed241dfd21af3078c0cbd39629470b58a56.svg]]
:END:
[[file:./.ob-jupyter/9cfb3b83095906621ff0e734eb15b48f529baeaa.svg]]
#+begin_src jupyter-python
plot_interaction_consistency_development(
fig, ax = plot_interaction_consistency_development(
alt_tol_models,
alt_tol_models[0],
label_fn=lambda m: fr"stocproc=$10^{{{np.log10(m.driving_process_tolerance.integration):.0f}}}$",
,**ensmeble_arg
)
#plt.xscale("log")
fig.set_size_inches(20,5)
#+end_src
#+RESULTS:
:RESULTS:
| <Figure | size | 432x288 | with | 1 | Axes> | <AxesSubplot:xlabel= | $N$ | ylabel= | Consistency [$\%$] | > |
[[file:./.ob-jupyter/8b54936957f33d5895787c6f4c55f97f5af8381a.svg]]
:END:
[[file:./.ob-jupyter/dae34b73b4bcf0a4d2fc95ada6b8d81ed38a52a6.svg]]
Stocproc accuracy really modifies convernge.
** Cutoff
#+begin_src jupyter-python :results none :tangle scripts/integrate_slip.py
@ -388,13 +216,6 @@ We could try the same with another truncation scheme.
#+end_example
:END:
#+begin_src jupyter-python :results none :tangle scripts/integrate_slip.py
ensmeble_arg = dict(
every=1000,
chunk_size=1000,
)
#+end_src
#+begin_src jupyter-python :tangle scripts/integrate_slip.py
plot_interaction_consistency(
k_models,
@ -406,134 +227,8 @@ We could try the same with another truncation scheme.
#+RESULTS:
:RESULTS:
: Loading: 0% 0/400 [00:03<?, ?it/s]
# [goto error]
#+begin_example
---------------------------------------------------------------------------
KeyboardInterrupt Traceback (most recent call last)
Input In [10], in <cell line: 1>()
----> 1 plot_interaction_consistency(
 2  k_models,
 3  #k_models[-1],
 4  label_fn=lambda m: fr"k=${m.k_max}$",
 5  **ensmeble_arg
 6  )
File ~/Documents/Projects/UNI/master/masterarb/python/energy_flow_proper/07_one_bath_systematics/figsaver.py:317, in plot_interaction_consistency(models, reference, label_fn, **kwargs)
 315 for model in models:
 316 with aux.get_data(model) as data:
--> 317 energy = model.interaction_energy(data, **kwargs)
 318 interaction_ref = model.interaction_energy_from_conservation(data, **kwargs)
 319 diff = abs(interaction_ref - energy)
File ~/src/two_qubit_model/hiro_models/model_base.py:310, in Model.interaction_energy(self, data, **kwargs)
 299 """Calculates interaction energy from the hierarchy data
 300 ``data``.
 301
 (...)
 305 :returns: See :any:`hopsflow.util.interaction_energy_ensemble`.
 306 """
 308 N, kwargs = _get_N_kwargs(kwargs, data)
--> 310 return hopsflow.hopsflow.interaction_energy_ensemble(
 311  data.valid_sample_iterator(data.stoc_traj), # type: ignore
 312  data.valid_sample_iterator(data.aux_states), # type: ignore
 313  self.hopsflow_system,
 314  (data.valid_sample_iterator(data.rng_seed), self.hopsflow_therm(data.time[:])), # type: ignore
 315  N=N,
 316  save=f"interaction_{self.hexhash}",
 317  **kwargs,
 318 )
File ~/src/hopsflow/hopsflow/hopsflow.py:485, in interaction_energy_ensemble(ψ_0s, ψ_1s, params, therm_args, **kwargs)
 481 energy += interaction_energy_therm(run, therm_run)
 483 return energy
--> 485 return util.ensemble_mean(
 486  iter(zip(ψ_0s, ψ_1s, therm_args[0]))
 487  if therm_args
 488  else iter(zip(ψ_0s, ψ_1s, itertools.repeat(0))),
 489  interaction_energy_task,
 490  **kwargs,
 491 )
File ~/src/hopsflow/hopsflow/util.py:655, in ensemble_mean(arg_iter, function, N, every, save, overwrite_cache, chunk_size)
 651 @ray.remote
 652 def remote_function(chunk: tuple):
 653 return [function(arg) for arg in chunk]
--> 655 handles = [
 656 remote_function.remote(chunk)
 657 for chunk in tqdm(
 658 _grouper(
 659 chunk_size, itertools.islice(arg_iter, None, N - 1 if N else None)
 660 ),
 661 total=int((N - 1) / chunk_size + 1) if N is not None else None,
 662 desc="Loading",
 663 )
 664 ]
 666 progress = tqdm(total=len(handles), desc="Processing")
 668 for ref in handles:
File ~/src/hopsflow/hopsflow/util.py:655, in <listcomp>(.0)
 651 @ray.remote
 652 def remote_function(chunk: tuple):
 653 return [function(arg) for arg in chunk]
--> 655 handles = [
 656 remote_function.remote(chunk)
 657 for chunk in tqdm(
 658 _grouper(
 659 chunk_size, itertools.islice(arg_iter, None, N - 1 if N else None)
 660 ),
 661 total=int((N - 1) / chunk_size + 1) if N is not None else None,
 662 desc="Loading",
 663 )
 664 ]
 666 progress = tqdm(total=len(handles), desc="Processing")
 668 for ref in handles:
File /nix/store/v8al73piyplb4zsr88jnspqc62njjpxq-python3-3.9.10-env/lib/python3.9/site-packages/tqdm/std.py:1195, in tqdm.__iter__(self)
 1192 time = self._time
 1194 try:
-> 1195 for obj in iterable:
 1196 yield obj
 1197 # Update and possibly print the progressbar.
 1198 # Note: does not call self.update(1) for speed optimisation.
File ~/src/hopsflow/hopsflow/util.py:587, in _grouper(n, iterable)
 584 """Groups the iteartor into tuples of at most length ``n``."""
 586 while True:
--> 587 chunk = tuple(itertools.islice(iterable, n))
 588 if not chunk:
 589 return
File ~/src/hops/hops/core/hierarchy_data.py:1223, in HIData.valid_sample_iterator(self, iterator)
 1216 def valid_sample_iterator(self, iterator: Iterator[T]) -> Iterator[T]:
 1217 """
 1218  Takes an ``iterator`` that yields a sequence of items related to
 1219  the sequence of samples and yields them if the sample is
 1220  actually present in the data.
 1221  """
-> 1223 for i, item in enumerate(iterator):
 1224 if self.has_sample(i):
 1225 yield item
File /nix/store/v8al73piyplb4zsr88jnspqc62njjpxq-python3-3.9.10-env/lib/python3.9/site-packages/h5py/_hl/dataset.py:664, in Dataset.__iter__(self)
 662 raise TypeError("Can't iterate over a scalar dataset")
 663 for i in range(shape[0]):
--> 664 yield self[i]
File h5py/_objects.pyx:54, in h5py._objects.with_phil.wrapper()
File h5py/_objects.pyx:55, in h5py._objects.with_phil.wrapper()
File /nix/store/v8al73piyplb4zsr88jnspqc62njjpxq-python3-3.9.10-env/lib/python3.9/site-packages/h5py/_hl/dataset.py:793, in Dataset.__getitem__(self, args, new_dtype)
 791 mspace = h5s.create_simple(selection.mshape)
 792 fspace = selection.id
--> 793 self.id.read(mspace, fspace, arr, mtype, dxpl=self._dxpl)
 795 # Patch up the output for NumPy
 796 if arr.shape == ():
KeyboardInterrupt:
#+end_example
[[file:./.ob-jupyter/d81cd0cee8f06820ba9fdad3107ae9833dcff026.svg]]
| <Figure | size | 432x288 | with | 1 | Axes> | <AxesSubplot:xlabel= | $τ$ | ylabel= | $\langle H_\mathrm{I}\rangle$ | > |
[[file:./.ob-jupyter/f594d6229b908607d0c38db3b06860a758679103.svg]]
:END:
#+begin_src jupyter-python
@ -546,11 +241,9 @@ We could try the same with another truncation scheme.
#+end_src
#+RESULTS:
[[file:./.ob-jupyter/9e634499e8f3ff92f542cbfd461189dcca25ee31.svg]]
[[file:./.ob-jupyter/ea78f4382a8b8edc415fa918b10305558ee5300d.svg]]
No cauchy sequence. HA LOL. This was a bug. Stil no cauchy.
Interesting that consistency is that weird. We see the one ver square
root development clearly.
Ok this is interesting. For longer memory stocproc has to still more accurate it appears.
#+begin_src jupyter-python
fig, ax = plt.subplots()
@ -565,7 +258,7 @@ root development clearly.
#+RESULTS:
:RESULTS:
| 0.0 | 1.0 |
[[file:./.ob-jupyter/c0967591b335e645c36e304065600e883dcee7bf.svg]]
[[file:./.ob-jupyter/4e42c5e70e08ea25036789b8c98a6e319f12fd2c.svg]]
:END:
#+begin_src jupyter-python
@ -576,7 +269,7 @@ root development clearly.
#+end_src
#+RESULTS:
[[file:./.ob-jupyter/1b43b7b801fe70101b68e251547723a01c23dbfb.svg]]
[[file:./.ob-jupyter/fbb339bd2e6b71d0b2e6af08d8d21c0a07e49358.svg]]
* Initial Slip Cutoff Frequency