03 lgtm, unfortunately not within variance

This commit is contained in:
Valentin Boettcher 2022-01-19 15:36:24 +01:00
parent 6dc9574e17
commit 3661930d8f
10 changed files with 45 additions and 29 deletions

View file

@ -1 +1,2 @@
use_flake
eval "$shellHook"

View file

@ -82,6 +82,9 @@ This will be tangled into the [[file:config.py][config file]] that can be used w
from hopsflow import util, hopsflow
import utilities as ut
from hops.core.hierarchyData import HIMetaData
import logging
logger = logging.getLogger()
logger.setLevel(logging.INFO)
#+end_src
** Loading the Data
@ -89,7 +92,7 @@ Now we can load the data.
#+begin_src jupyter-python
class result:
hd = HIMetaData("data", ".").get_HIData(params, read_only=True)
N = 50
N = hd.samples
τ = hd.get_time()
ψ_1 = hd.aux_states
ψ = hd.stoc_traj
@ -98,7 +101,7 @@ Now we can load the data.
#+end_src
#+RESULTS:
: 50
: 10000
We calculate the sytem energy just for fun.
#+begin_src jupyter-python
@ -107,12 +110,12 @@ We calculate the sytem energy just for fun.
system.H_sys,
result.N,
params.HiP.nonlinear,
save="system_energy",
)
#+end_src
#+RESULTS:
: 100% 49/49 [00:00<00:00, 320.67it/s]
: INFO:root:Loading cache from: results/system_energy_sandwhich_operator_10000_None_80a7565ff3435ccbd1441b90db4c1574f2fff17a482b2e19fb409bcb57834356.npy
#+begin_src jupyter-python
plt.errorbar(result.τ, e_sys.real, yerr=σ_e_sys.real, ecolor="yellow")
@ -121,8 +124,9 @@ We calculate the sytem energy just for fun.
#+RESULTS:
:RESULTS:
: <ErrorbarContainer object of 3 artists>
[[file:./.ob-jupyter/1b0d328de6200b9d791112df06036efd111e92c1.svg]]
[[file:./.ob-jupyter/e343cdd6804e900e806468abf5a397b8110048dd.svg]]
:END:
:RESULTS:
** Heat Flow
First we set up some parameter objects for the alogrithm.
@ -135,20 +139,22 @@ First we set up some parameter objects for the alogrithm.
And then we calculate the flow.
#+begin_src jupyter-python
full_flow = hopsflow.heat_flow_ensemble(
iter(result.ψ), iter(result.ψ_1), hf_system, result.N, every=int(result.N // 6)
iter(result.ψ), iter(result.ψ_1), hf_system, result.N, every=500, save="heat_flow"
)
#+end_src
#+RESULTS:
: 100% 49/49 [00:00<00:00, 79.80it/s]
: 100% 9999/9999 [02:56<00:00, 56.60it/s]
: INFO:root:Writing cache to: results/heat_flow__heat_flow_ensemble_body_10000_500_d1cac423a375f1e0f938b4b34ad4bd79b682a617506460d7b0735849d74ac9da.npy
#+begin_src jupyter-python
with ut.hiro_style():
ut.plot_convergence(result.τ, full_flow, transform=lambda y: -y)
_, ax = ut.plot_convergence(result.τ, full_flow, transform=lambda y: -y)
ax.legend()
#+end_src
#+RESULTS:
[[file:./.ob-jupyter/3f69afd9746a0d8b1834872653cb6718705f5315.svg]]
[[file:./.ob-jupyter/23c1f43b72822aab508e52b4473ccb7ba92f7965.svg]]
** Analytic
#+begin_src jupyter-python :results none
@ -159,16 +165,20 @@ Setting up the BCFs.
#+begin_src jupyter-python :results none
α_0 = gf.BCF(
params.IntP.t_max,
hops_bcf,
num_terms=4,
resolution=0.001,
factors=params.SysP.g,
exponents=params.SysP.w,
# hops_bcf,
# num_terms=6,
# resolution=0.001,
)
α_0_dot = gf.BCF(
params.IntP.t_max,
lambda t: 2 / (1j * np.pi) * (wc / (1 + 1j * wc * t)) ** 3,
num_terms=5,
resolution=0.001,
factors=-params.SysP.w * params.SysP.g,
exponents=params.SysP.w,
# lambda t: 2 / (1j * np.pi) * (wc / (1 + 1j * wc * t)) ** 3,
# num_terms=6,
# resolution=0.001,
)
#+end_src
@ -180,22 +190,19 @@ We can now initialize the parameter object for the alogrithm.
Now we can define the flow:
#+begin_src jupyter-python :results none
flow = gf.Flow(sys, α_0, α_0_dot, n=1)
flow_τ = flow.flow_therm_zero(result.τ) + flow.flow_nontherm(result.τ)
flow_τ = flow(result.τ)
#+end_src
And plot it against the numerically obtained flow.
#+begin_src jupyter-python
with ut.hiro_style():
fig, ax = ut.plot_convergence(result.τ, full_flow, transform=lambda y: -y)
ax.plot(result.τ, flow_τ, label="analytic", color="blue", linestyle="-.")
ax.legend()
#+end_src
#+RESULTS:
:RESULTS:
: <matplotlib.legend.Legend at 0x7f63ad61afa0>
[[file:./.ob-jupyter/9997d86dd7ca08d28df98277c986888f8e4d1e39.svg]]
:END:
[[file:./.ob-jupyter/16c12481f732e64fff702a2919da8c5bed1e4e5c.svg]]
#+begin_src jupyter-python
for n, flow, flow_std in full_flow[:-1]:
@ -208,8 +215,8 @@ And plot it against the numerically obtained flow.
#+RESULTS:
:RESULTS:
: <matplotlib.legend.Legend at 0x7f63addc3790>
[[file:./.ob-jupyter/21546601d62462b4554bdb1b43ecc11c3563d970.svg]]
: <matplotlib.legend.Legend at 0x7f63d74df370>
[[file:./.ob-jupyter/1a8f9cb60ad50edda813cf32832f0a469c04f69a.svg]]
:END:
#+begin_src jupyter-python
@ -219,7 +226,7 @@ And plot it against the numerically obtained flow.
#+end_src
#+RESULTS:
[[file:./.ob-jupyter/c18e8f9fdc74df6ae1357f5198960c18672e7135.svg]]
[[file:./.ob-jupyter/e563b17110269de6e8791f0ecf48387d4b390d0e.svg]]
* Close the Data File
We need to release the hold on the file.

View file

@ -10,6 +10,11 @@
(utils.lib.poetry2nixWrapper nixpkgs {
name = "01_zero_temp";
shellPackages = pkgs: with pkgs; [ pyright python3Packages.jupyter ];
shellOverride = (oldAttrs: {
shellHook = ''
export PYTHONPATH=/home/hiro/src/hopsflow/:$PYTHONPATH
'';
});
noPackage = true;
poetryArgs = {
projectDir = ./.;

View file

@ -315,7 +315,7 @@ resolved_reference = "b18016185092da74b00581c3925e912b3f59ef18"
[[package]]
name = "hopsflow"
version = "1.0.2"
version = "1.0.3"
description = "Calculating open system bath energy changes with HOPS and analytically."
category = "main"
optional = false
@ -334,7 +334,7 @@ tqdm = "^4.62.3"
type = "git"
url = "https://github.com/vale981/hopsflow"
reference = "main"
resolved_reference = "9e33c9ca5085cba3f082ca37f0847db4af741ffa"
resolved_reference = "cb6fa535f80d87661988e789fe5e84c132e91b74"
[[package]]
name = "ipykernel"

View file

@ -0,0 +1 @@
{"N": 500, "every": 500, "const_args": ["<not-hashed>", null, false], "const_kwargs": {}, "function_name": "_heat_flow_ensemble_body", "first_iterator_value": "[ 0. -0.03789517 -0.07573306 ... 0.00236136 0.00226609\n 0.00217951]"}