transition 01 to new hops

This commit is contained in:
Valentin Boettcher 2022-01-17 17:40:33 +01:00
parent fda4faa966
commit 3812d88949
6 changed files with 1525 additions and 487 deletions

View file

@ -14,11 +14,11 @@ s = 1
bcf_terms = 6
g, w = get_ohm_g_w(bcf_terms, s, wc)
integration = IntP(t_max=5, t_steps=1000)
integration = IntP(t_max=30, t_steps=int(30 // 0.01))
system = SysP(
H_sys=0.5 * np.array([[1, 0], [0, -1]]),
H_sys=0.5 * np.array([[-1, 0], [0, 1]]),
L=0.5 * np.array([[0, 1], [1, 0]]),
psi0=np.array([1, 1]),
psi0=np.array([0, 1]),
g=g,
w=w,
bcf_scale=0.8,
@ -31,7 +31,7 @@ params = HIParams(
HiP=HiP(
nonlinear=True,
normalized_by_hand=True,
result_type=ResultType.ALL,
result_type=ResultType.ZEROTH_AND_FIRST_ORDER,
truncation_scheme=TruncationScheme_Power_multi.from_g_w(
g=g, w=w, p=1, q=0.5, kfac=1.4
),
@ -52,18 +52,5 @@ params = HIParams(
intpl_tol=1e-3,
negative_frequencies=False,
),
EtaTherm=StocProc_FFT(
spectral_density=hops.util.bcf.Ohmic_StochasticPotentialDensity(
s, 1, wc, beta=1 / system.__non_key__["T"]
),
alpha=hops.util.bcf.Ohmic_StochasticPotentialCorrelations(
s, 1, wc, beta=1 / system.__non_key__["T"]
),
t_max=integration.t_max,
intgr_tol=1e-3,
intpl_tol=1e-3,
negative_frequencies=False,
)
if system.__non_key__["T"]
else None,
EtaTherm=None,
)

View file

@ -9,7 +9,7 @@
outputs = { self, utils, nixpkgs, ... }:
(utils.lib.poetry2nixWrapper nixpkgs {
name = "01_zero_temp";
shellPackages = pkgs: with pkgs; [ pyright ];
shellPackages = pkgs: with pkgs; [ pyright python3Packages.jupyter ];
noPackage = true;
poetryArgs = {
projectDir = ./.;

View file

@ -1,105 +1,127 @@
#+PROPERTY: header-args :session zero_temp_new :kernel python :pandoc t
#+PROPERTY: header-args :session 01_zero_temp :kernel python :pandoc t :async yes
* Configuration and Setup
The main process configuration is to be found [[file:stg.py][here]].
This will be tangled into the [[file:config.py][config file]] that can be used with the HOPS cli.
#+begin_src jupyter-python :results none :tangle config.py
from hops.core.hierarchy_parameters import HIParams, HiP, IntP, SysP, ResultType
from hops.core.hierarchyLib import HI
from hops.util.bcf_fits import get_ohm_g_w
from hops.util.truncation_schemes import TruncationScheme_Power_multi
import hops.util.bcf
import numpy as np
import hops.util.matrixLib as ml
from stocproc import StocProc_FFT
** Stochastic Processes
We then proceed to initialize the stochastic processes.
wc = 5
s = 1
#+begin_src vterm
python ../hops/sp.py -s stg.py
# The BCF fit
bcf_terms = 6
g, w = get_ohm_g_w(bcf_terms, s, wc)
integration = IntP(t_max=30, t_steps=int(30 // 0.01))
system = SysP(
H_sys=0.5 * np.array([[-1, 0], [0, 1]]),
L=0.5 * np.array([[0, 1], [1, 0]]),
psi0=np.array([0, 1]),
g=g,
w=w,
bcf_scale=0.8,
T=0,
)
params = HIParams(
SysP=system,
IntP=integration,
HiP=HiP(
nonlinear=True,
normalized_by_hand=True,
result_type=ResultType.ZEROTH_AND_FIRST_ORDER,
truncation_scheme=TruncationScheme_Power_multi.from_g_w(
g=g, w=w, p=1, q=0.5, kfac=1.4
),
),
Eta=StocProc_FFT(
spectral_density=hops.util.bcf.OhmicSD_zeroTemp(
s,
1,
wc,
),
alpha=hops.util.bcf.OhmicBCF_zeroTemp(
s,
1,
wc,
),
t_max=integration.t_max,
intgr_tol=1e-3,
intpl_tol=1e-3,
negative_frequencies=False,
),
EtaTherm=None,
)
#+end_src
#+RESULTS:
:RESULTS:
Linux ArLeenUX 5.14.15-zen1 x86_64
16:04:51 up 1 day 4:30, 2 users, load average: 0.68, 0.52, 0.89
impure  ~/D/P/U/m/m/p/e/01_zero_temperature  python ../hops/sp.py -s stg.py
StocProc found in database 'SPCache' at '.'
:END:
The stochastic process is initialized and cached in ~./SPCache~.
* Hops Integration
We can use multiple avenues.
** Local Integration
#+begin_src vterm :term-name integration
python ../hops/hi.py -s stg.py
hi 500 integrate
#+end_src
#+RESULTS:
:RESULTS:
Linux ArLeenUX 5.14.14-zen1 x86_64
16:06:15 up 3 days 23:48, 1 user, load average: 1.07, 1.23, 1.22
impure  ~/D/P/U/m/m/p/e/01_zero_temperature  python ../hops/hi.py -s stg.py
run integrate
init Hi class, use 464 equation
is up event is False
wait ...
[in server process] add args to server ...
[in server process] befor bring him up
JobManager started on ArLeenUX:46870 (bytearray(b'HOPS46870'))
hi server is up
[in server process] set is_up
is up event is now True
[TET 12.69ms [0.0c/s] TTG -- 0.0%
#+RESULTS:
:RESULTS:
Linux ArLeenUX 5.15.11-zen1 x86_64
14:45:17 up 2 days 18:10, 1 user, load average: 1.55, 1.48, 1.44
impure  ~/D/P/U/m/m/p/e/01_zero_temperature  hi 500 integrate
Loading the configuration from config.py. This might take a while... /
JobManager started on ArLeenUX:36931 (bytearray(b'HOPS36931'))
[TET 6.88ms [0.0c/s] TTG -- 0.0% ETA -- ORT --]
/nix/store/5v3326rzsryzdkk2q5kimqvf0i20wvzv-python3-3.9.4-env/lib/python3.9/site
anager/jobmanager.py:130: UserWarning: num_threads could not be set, MKL / openb
warnings.warn("num_threads could not be set, MKL / openblas not found")
/nix/store/5v3326rzsryzdkk2q5kimqvf0i20wvzv-python3-3.9.4-env/lib/python3.9/site
anager/jobmanager.py:130: UserWarning: num_threads could not be set, MKL / openb
warnings.warn("num_threads could not be set, MKL / openblas not found")
/nix/store/5v3326rzsryzdkk2q5kimqvf0i20wvzv-python3-3.9.4-env/lib/python3.9/site
anager/jobmanager.py:130: UserWarning: num_threads could not be set, MKL / openb
warnings.warn("num_threads could not be set, MKL / openblas not found")
/nix/store/5v3326rzsryzdkk2q5kimqvf0i20wvzv-python3-3.9.4-env/lib/python3.9/site
[TET 1.01s [0.0c/s] TTG -- 0.0%
res_q #0 0/s 0kB|rem.:500, done:0, failed:0, prog.:0
w1:00:00:46 [14.7c/min] #11 - 2.25s [245.0c/s] [==================>
w2:00:00:46 [15.0c/min] #11 - 1.90s [241.6c/s] [===============>
w1:00:00:47 [14.7c/min] #11 - 3.25s [255.6c/s] [============================>
] TTG 1.00s4.8c/min] #11 - 1.33s [221.7c/s] [=========>
w2:00:00:47 [15.0c/min] #11 - 2.91s [243.3c/s] [========================>
] TTG 2.00s [57.3c/min] TTG 00:07:58 8.8% ETA 20211110_16:15:03
w3:00:00:47 [14.7c/min] #11 - 1.67s [264.0c/s] [==============>
] TTG 3.00sGB/s 315.9GB|rem.:452, done:44, failed:0, prog.:4
w4:00:00:47 [14.8c/min] #11 - 2.33s [231.9c/s] [==================>
w1:00:00:48 [14.8c/min] #12 - 292.64ms [160.6c/s] [=>
] TTG 6.00s326.1GB/s
w2:00:00:48 [15.0c/min] #11 - 3.91s [231.6c/s] [==============================>
] TTG 1.00s [57.3c/min] TTG 00:07:58 8.8% ETA 20211110_16:15:04
w3:00:00:48 [14.7c/min] #11 - 2.67s [238.4c/s] [=====================>
w1:00:08:43 [15.9c/min] #126 - [TET 996.21ms [0.0c/s] TTG -- 0.0% ETA -- ORT --]
w2:00:08:43 [15.7c/min] #125 - [TET 2.26s [0.0c/s] TTG -- 0.0% ETA -- ORT --]
w3:00:08:43 [15.5c/min] #124 - [TET 1.69s [0.0c/s] TTG -- 0.0% ETA -- ORT --]
w4:00:08:43 [16.5c/min] #125 - [TET 667.44ms [0.0c/s] TTG -- 0.0% ETA -- ORT --]
local res_q 0 344GB/s
,********************************.00ms---------100%---------ETA-20211110_16:15:01-ORT-00:08:43]
,********************************0, done:500, failed:0, prog.:0
,** the client has finished early! stop the server
,********************************
,********************************
[TET-00:08:44-----[1.0c/s]-TTG-0.00ms---------100%---------ETA-20211110_16:15:02-ORT-00:08:44]
res_q #0 7.918GB/s 3.506TB|rem.:0, done:500, failed:0, prog.:0
[in server process] server has joined!
/nix/store/h9pzzn81vrj2vzhavbjgv101yc52qpx0-python3-3.9.9-env/lib/python3.9/site-packages/jobmanager/jobmanager.py:130: UserWa
rning: num_threads could not be set, MKL / openblas not found
warnings.warn("num_threads could not be set, MKL / openblas not found")
/nix/store/h9pzzn81vrj2vzhavbjgv101yc52qpx0-python3-3.9.9-env/lib/python3.9/site-packages/jobmanager/jobmanager.py:130: UserWa
rning: num_threads could not be set, MKL / openblas not found
warnings.warn("num_threads could not be set, MKL / openblas not found")
/nix/store/h9pzzn81vrj2vzhavbjgv101yc52qpx0-python3-3.9.9-env/lib/python3.9/site-packages/jobmanager/jobmanager.py:130: UserWa
rning: num_threads could not be set, MKL / openblas not found
warnings.warn("num_threads could not be set, MKL / openblas not found")
/nix/store/h9pzzn81vrj2vzhavbjgv101yc52qpx0-python3-3.9.9-env/lib/python3.9/site-packages/jobmanager/jobmanager.py:130: UserWa
[TET 1.01s [0.0c/s] TTG -- 0.0% ETA -- ORT --]
res_q #0 0/s 0kB|rem.:492, done:0, failed:0, prog.:0
w1:00:00:14 [5.3c/min] #1 - 2.72s [82.5c/s] [==============> ] TTG 00:00:10
w2:00:00:14 [5.0c/min] #1 - 2.09s [82.4c/s] [===========> ] TTG 00:00:11
w3:00:00:14 [5.1c/min] #1 - 2.20s [82.8c/s] [============> ] TTG 00:00:10
w4:00:00:14 [5.0c/min] #1 - 1.97s [82.9c/s] [==========> ] TTG 00:00:11
local res_q 0 285.1GB/s
[TET 00:00:14 [18.4c/min] TTG 00:26:29 0.8% ETA 20220117_15:12:02 ORT 00:26:43]
res_q #0 2.122GB/s 28.72GB|rem.:484, done:4, failed:0, prog.:4
^Ccapi_return is NULL
Call-back cb_f_in_zvode__user__routines failed.
capi_return is NULL
Call-back cb_f_in_zvode__user__routines failed.
capi_return is NULL
Call-back cb_f_in_zvode__user__routines failed.
SystemExit, quit processing, reinsert current argument, please wait
SystemExit, quit processing, reinsert current argument, please wait
capi_return is NULL
Call-back cb_f_in_zvode__user__routines failed.
[TET 00:00:15 [18.4c/min] TTG 00:26:29 0.8% ETA 20220117_15:12:03 ORT 00:26:44]
res_q #0 1.976GB/s 28.72GB|rem.:484, done:4, failed:0, prog.:4
############## in JM SERVER EXIT
############## in JM SERVER EXIT
HI_Server start at 2021-11-10 16:06:18.129421 | runtime 5.260e+02s
HI_Server total number of jobs : 500
| processed : 500
| succeeded : 500
| failed : 0
| timing in sec: min 2.973e+00 | max 7.906e+00 | avr 4.164e+00
| not processed : 0
| queried : 0
| not queried yet : 0
,* has joined
server process is not running anymore (exit with 0)
:END:
HIServer start at 2022-01-17 14:45:19.308956 | runtime 1.500e+01s
HIServer total number of jobs : 492
w1:00:00:15 [5.3c/min] #1 - [TET-3.72s----[74.9c/s]-TTG>00:00:10 27.9% ETA 20220117_14:45:45 ORT 00:00:13]
w2:00:00:15 [5.0c/min] #1 - [TET-3.10s----[72.0c/s] TTG 00:00:11 22.3% ETA 20220117_14:45:46 ORT 00:00:14]
w3:00:00:15 [5.1c/min] #1 - [TET-3.21s----[73.9c/s]>TTG 00:00:11 23.7% ETA 20220117_14:45:46 ORT 00:00:14]
w4:00:00:15 [5.0c/min] #1 - [TET-2.97s----[73.6c/s] TTG 00:00:11 21.9% ETA 20220117_14:45:46 ORT 00:00:13]
local res_q 0 285.1GB/s
impure  ~/D/P/U/m/m/p/e/01_zero_temperature  exit 18.9s
:END:
And there we go. It is better to run the above command in a
vterm-session.
@ -107,125 +129,115 @@ vterm-session.
** Remote/Distributed Integration
We start the server locally.
#+begin_src vterm :term-name local-server
python ../hops/hi.py -s stg.py server
hi 1000 start-server
#+end_src
#+RESULTS:
:RESULTS:
Linux ArLeenUX 5.14.15-zen1 x86_64
16:05:44 up 1 day 4:31, 2 users, load average: 0.80, 0.57, 0.89
impure  ~/D/P/U/m/m/p/e/01_zero_temperature  python ../hops/hi.py -s stg.py server
run server
init Hi class, use 464 equation
JobManager started on ArLeenUX:35254 (bytearray(b'SBM2'))
hi server is running
[TET-00:03:56-----[2.4c/s]-TTG-0.00ms---------100%---------ETA-20211112_16:09:44-ORT-00:03:56]
res_q #0 16.58GB/s 3.506TB|rem.:0, done:500, failed:0, prog.:0
Linux ArLeenUX 5.15.11-zen1 x86_64
16:34:02 up 2 days 19:58, 1 user, load average: 1.08, 1.67, 2.52
impure  ~/D/P/U/m/m/p/e/01_zero_temperature  hi 1000 start-server
Loading the configuration from config.py. This might take a while... /
JobManager started on ArLeenUX:42524 (bytearray(b'hierarchy'))
[TET-00:12:05--[43.6c/min]-TTG-0.00ms-------------------------100%-------------------------ETA-20220117_16:46:11-ORT-00:12:05]
res_q #0 14.84GB/s 10.51TB|rem.:0, done:500, failed:0, prog.:0
############## in JM SERVER EXIT
HI_Server start at 2021-11-12 16:05:47.695696 | runtime 2.380e+02s
HI_Server total number of jobs : 500
| processed : 500
| succeeded : 500
| failed : 0
| timing in sec: min 3.320e+00 | max 6.207e+00 | avr 4.835e+00
| not processed : 0
| queried : 0
| not queried yet : 0
HIServer start at 2022-01-17 16:34:05.075876 | runtime 7.280e+02s
HIServer total number of jobs : 500
| processed : 500
| succeeded : 500
| failed : 0
| timing in sec: min 1.386e+01 | max 4.145e+01 | avr 2.478e+01
| not processed : 0
| queried : 0
| not queried yet : 0
:END:
And jack in with a remote client. In this case my box at home.
* Using the Data
** Jupyter Setup
#+begin_src jupyter-python
import matplotlib.pyplot as plt
import numpy as np
#+end_src
** Client
Starting a client is trivial.
#+RESULTS:
** Check the Freshness of the Data
This doesn't check for modifications in this file though!
#+begin_src jupyter-python
from deps import deps
deps.report()
#+end_src
#+RESULTS:
: Is fresh: True
: Overall Hash: bfe5a79a9c7e767f4b470f1096cbbf22d05e3977
~True~ means that no important code has changed. In this case it even
checks if we have all the samples.
** Load the Data
Stghelper seems to be what we want.
#+begin_src jupyter-python
import stg_helper
import stg
import hopsflow
from hopsflow import util
#+end_src
#+RESULTS:
Now let's load the system parameters.
#+begin_src jupyter-python
system_params = stg_helper.get_system_param(stg)
system_params
#+end_src
#+RESULTS:
#+begin_example
H_dynamic : []
H_sys : Operator with format 'coo' and shape(2, 2)
(0, 0) -0.5
(1, 1) 0.5
L : Operator with format 'coo' and shape(2, 2)
(0, 1) 0.5
(1, 0) 0.5
bcf_scale : 0.8
g : [-0.06469402-0.02291455j -0.51837826-0.63817493j -0.9180341 -0.03207301j
0.79032868-3.79162312j 0.92537272+5.45668527j 7.74372319-0.97260702j]
psi0 : [0 1]
w : [ 0.33112135 +0.0369207j 1.4655583 +0.35463741j
20.83418848+27.9612112j 3.94583654 +1.66419407j
13.81649632+13.01348981j 8.09528316 +5.28092745j]
--- extra info ---
T : 0.0
T_method : stoc_pot
gw_info : None
len_gw : None
#+end_example
Now we read the trajectory data.
#+begin_src jupyter-python
class result:
with stg_helper.get_hierarchy_data(stg, read_only=True) as hd:
N = hd.get_samples()
τ = hd.get_time()
ρ = hd.get_rho_t()
ψ_1 = np.array(hd.aux_states)[0:N]
ψ = np.array(hd.stoc_traj)[0:N]
#+end_src
#+RESULTS:
** Calculate System Energy
Simple sanity check.
#+begin_src jupyter-python
e_sys = util.operator_expectation(result.ρ, system_params.H_sys.todense())
plt.plot(result.τ, e_sys)
#+begin_src vterm :term-name local-client
client localhost
#+end_src
#+RESULTS:
:RESULTS:
| <matplotlib.lines.Line2D | at | 0x7f6a3bcd61c0> |
[[file:./.ob-jupyter/a7742fc7d6826fdc3a3005e8f06e017744c80631.svg]]
Linux ArLeenUX 5.15.11-zen1 x86_64
16:34:08 up 2 days 19:58, 1 user, load average: 1.07, 1.66, 2.51
impure  ~/D/P/U/m/m/p/e/01_zero_temperature  client localhost
/nix/store/zwwf4gkrcx2ly273ivhn7a0bwwl0r9ki-python3-3.9.9-env/lib/python3.9/site-packages/jobmanager/jobmanager.py:130: UserWa
rning: num_threads could not be set, MKL / openblas not found
warnings.warn("num_threads could not be set, MKL / openblas not found")
/nix/store/zwwf4gkrcx2ly273ivhn7a0bwwl0r9ki-python3-3.9.9-env/lib/python3.9/site-packages/jobmanager/jobmanager.py:130: UserWa
rning: num_threads could not be set, MKL / openblas not found
warnings.warn("num_threads could not be set, MKL / openblas not found")
/nix/store/zwwf4gkrcx2ly273ivhn7a0bwwl0r9ki-python3-3.9.9-env/lib/python3.9/site-packages/jobmanager/jobmanager.py:130: UserWa
rning: num_threads could not be set, MKL / openblas not found
warnings.warn("num_threads could not be set, MKL / openblas not found")
/nix/store/zwwf4gkrcx2ly273ivhn7a0bwwl0r9ki-python3-3.9.9-env/lib/python3.9/site-packages/jobmanager/jobmanager.py:130: UserWa
rning: num_threads could not be set, MKL / openblas not found
warnings.warn("num_threads could not be set, MKL / openblas not found")
w1:00:11:55 [2.0c/min] #23 - [TET 7.38s [0.0c/s] TTG -- 0.0% ETA -- ORT --]
w2:00:11:55 [2.0c/min] #23 - [TET 4.46s [0.0c/s] TTG -- 0.0% ETA -- ORT --]
w3:00:11:55 [2.1c/min] #23 - [TET 5.82s [0.0c/s] TTG -- 0.0% ETA -- ORT --]
w4:00:11:55 [2.1c/min] #23 - [TET 9.32s [0.0c/s] TTG -- 0.0% ETA -- ORT --]
local res_q 0 416.7GB/s
:END:
* Using the Data
** Jupyter Setup
#+begin_src jupyter-python :results none
import matplotlib.pyplot as plt
import numpy as np
import utilities as ut
#+end_src
** Load the Data
#+begin_src jupyter-python :results none
from hopsflow import hopsflow, util
from hops.core.hierarchyLib import HI
#+end_src
Now we read the trajectory data.
#+begin_src jupyter-python
class result:
with HI(params, 500).get_data(read_only=True) as hd:
N = hd.samples
τ = hd.get_time()
ρ = hd.get_rho_t()
ψ_1 = np.array(hd.aux_states)[0:N]
ψ = np.array(hd.stoc_traj)[0:N]
result.N
#+end_src
#+RESULTS:
: 1000
** Calculate System Energy
Simple sanity check.
#+begin_src jupyter-python
_, e_sys, σ_e_sys = util.operator_expectation_ensemble(
iter(result.ψ),
system.H_sys,
result.N,
params.HiP.nonlinear,
save="./results/energy.npy"
)
plt.errorbar(result.τ, e_sys.real, yerr=σ_e_sys.real, ecolor="yellow")
#+end_src
#+RESULTS:
:RESULTS:
: 100% 999/999 [00:00<00:00, 1645.43it/s]
: <ErrorbarContainer object of 3 artists>
[[file:./.ob-jupyter/bd7fe1b1f16f9711d71689389818fa54480dba99.svg]]
:END:
The energy bleeds out of the system. We don't reach the steady state
@ -233,7 +245,7 @@ yet. Also we don't loose all the energy.
The energy eigenvalues of the system are.
#+begin_src jupyter-python
np.linalg.eig(system_params.H_sys.todense())[0]
np.linalg.eig(system.H_sys)[0]
#+end_src
#+RESULTS:
@ -241,23 +253,23 @@ The energy eigenvalues of the system are.
The begin and and values of the system energy expectation are.
#+begin_src jupyter-python
e_sys[0], e_sys[-1]
e_sys[0].real, e_sys[-1].real
#+end_src
#+RESULTS:
| 0.5 | -0.44815376641059734 |
| 0.5 | -0.44770384926040235 |
And the total energy lost is:
#+begin_src jupyter-python
e_sys[0] - e_sys[-1]
e_sys[0].real - e_sys[-1].real
#+end_src
#+RESULTS:
: 0.9481537664105973
: 0.9477038492604024
We do start in the state.
#+begin_src jupyter-python
system_params.psi0
system.psi0
#+end_src
#+RESULTS:
@ -268,121 +280,83 @@ Now let's calculate the heatflow. In this simple case it is engouh to
know the first hierarchy states.
First we set up some parameter objects for the alogrithm.
#+begin_src jupyter-python
#+begin_src jupyter-python :results none
hf_system = hopsflow.SystemParams(
system_params.L.todense(), stg.__g, stg.__w, stg.__bcf_scale, stg.__HI_nonlinear
system.L, system.g, system.w, system.bcf_scale, params.HiP.nonlinear
)
#+end_src
#+RESULTS:
Now we can apply our tooling to one trajectory for testing.
#+begin_src jupyter-python
hf_sample_run = hopsflow.HOPSRun(result.ψ[0], result.ψ_1[0], hf_system)
first_flow = hopsflow.flow_trajectory_coupling(hf_sample_run, hf_system)
plt.plot(result.τ, first_flow)
with ut.hiro_style():
plt.plot(result.τ, first_flow)
#+end_src
#+RESULTS:
:RESULTS:
| <matplotlib.lines.Line2D | at | 0x7f6a3bcb9fa0> |
[[file:./.ob-jupyter/efdf662d48ebc0cfa16c163932cc45b205466fba.svg]]
:END:
[[file:./.ob-jupyter/c7984b39bab2dfd43f7a9f95bdf0badd202394a0.svg]]
And now for all trajectories.
#+begin_src jupyter-python
full_flow = hopsflow.heat_flow_ensemble(result.ψ, result.ψ_1, hf_system, result.N)
plt.plot(result.τ, full_flow)
full_flow = hopsflow.heat_flow_ensemble(
result.ψ, result.ψ_1, hf_system, result.N, every=result.N // 10, save="results/flow.npy"
)
with ut.hiro_style():
_, ax = ut.plot_convergence(result.τ, full_flow, transform=lambda y: -y)
ax.legend()
#+end_src
#+RESULTS:
:RESULTS:
| <matplotlib.lines.Line2D | at | 0x7f6a3bfee0d0> |
[[file:./.ob-jupyter/3850d1b72e60f2311045d24399e69ba792255439.svg]]
: 100% 999/999 [00:01<00:00, 503.21it/s]
[[file:./.ob-jupyter/c998467651c2660a92b64ec40f17672cbd6f16aa.svg]]
:END:
We can integrate the energy change in the bath:
#+begin_src jupyter-python
e_bath = util.integrate_array(-full_flow, result.τ)
e_bath = util.integrate_array(-full_flow[-1][1], result.τ)
plt.plot(result.τ, e_bath)
#+end_src
#+RESULTS:
:RESULTS:
| <matplotlib.lines.Line2D | at | 0x7f6a3c3119a0> |
[[file:./.ob-jupyter/db755c0365ed1377a36986466fa4e617fef9ebdd.svg]]
| <matplotlib.lines.Line2D | at | 0x7f700280b220> |
[[file:./.ob-jupyter/1ef90eca2ed89295be26af97745a08d32a9aa037.svg]]
:END:
** Calculate the Interaction Energy
First we calculate it from energy conservation.
#+begin_src jupyter-python
e_int = 1/2 - e_sys - e_bath
plt.plot(result.τ, e_int)
e_int = (1/2 - e_sys - e_bath).real
with ut.hiro_style():
plt.plot(result.τ, e_int)
#+end_src
#+RESULTS:
:RESULTS:
| <matplotlib.lines.Line2D | at | 0x7f6a3c376ee0> |
[[file:./.ob-jupyter/97d391819a65d8e5bf37e1c5b5eaba576667f120.svg]]
:END:
[[file:./.ob-jupyter/10f25f6b2f73d65ae8fb7775fef8dce0379fd08e.svg]]
And then from first principles:
#+begin_src jupyter-python
e_int_ex = hopsflow.interaction_energy_ensemble(result.ψ, result.ψ_1, hf_system, result.N)
plt.plot(result.τ, e_int_ex)
_, e_int_ex, σ_e_int_ex = hopsflow.interaction_energy_ensemble(result.ψ, result.ψ_1, hf_system, result.N)
with ut.hiro_style():
plt.errorbar(result.τ, e_int_ex, yerr=σ_e_int_ex, ecolor="yellow")
#+end_src
#+RESULTS:
:RESULTS:
| <matplotlib.lines.Line2D | at | 0x7f6a3c1cb880> |
[[file:./.ob-jupyter/86e89b1f1f342f53929294909d1b6834f81e9758.svg]]
: 100% 999/999 [00:02<00:00, 406.62it/s]
[[file:./.ob-jupyter/d14fe1b04f0527eec44c69990195936cdcbbd965.svg]]
:END:
And both together:
#+begin_src jupyter-python
plt.plot(result.τ, e_int)
plt.plot(result.τ, e_int_ex)
with ut.hiro_style():
plt.errorbar(result.τ, e_int_ex, yerr=σ_e_int_ex, ecolor="yellow")
plt.plot(result.τ, e_int)
#+end_src
#+RESULTS:
:RESULTS:
| <matplotlib.lines.Line2D | at | 0x7f6a3bf153a0> |
[[file:./.ob-jupyter/2f62c356fed1d7133aa3ef68bb29b3efca86b58e.svg]]
:END:
** Scratch
So the ~G~ and ~W~ do function as expected
#+begin_src jupyter-python
t = np.linspace(0, stg.t_max, 100)
#plt.plot(t, stg.__bcf(t).real)
plt.plot(t, stg.__bcf(t).imag)
plt.plot(t, hopsflow.util.α_apprx(t, stg.__g, stg.__w).imag)
#+end_src
#+RESULTS:
:RESULTS:
| <matplotlib.lines.Line2D | at | 0x7f6a3c04a5e0> |
[[file:./.ob-jupyter/99df85a9e29da5768f796ed82ac9827df688e8d9.svg]]
:END:
#+begin_src jupyter-python
import os
path = os.path.dirname(hopsflow.__file__)
path
#+end_src
#+RESULTS:
: /home/hiro/Documents/Projects/UNI/master/masterarb/python/energy_flow_proper/hopsflow
* Update Dependency Hash
When we're done we update the dependency hash. This helps us to check
if we have to recompute anything later on.
#+begin_src jupyter-python
deps.write_hash()
deps.get_hash()[0]
#+end_src
#+RESULTS:
: bfe5a79a9c7e767f4b470f1096cbbf22d05e3977
[[file:./.ob-jupyter/7cebf22e2e864368752a1919b342b685fcdd1303.svg]]

File diff suppressed because it is too large Load diff

View file

@ -13,6 +13,7 @@ stocproc = { git = "https://github.com/vale981/stocproc" }
hops = { git = "git@gitlab.hrz.tu-chemnitz.de:s8896854--tu-dresden.de/hops.git", branch="main" }
hopsflow = { git = "https://github.com/vale981/hopsflow", branch="main" }
matplotlib = "^3.5.0"
jupyter = "^1.0.0"
[tool.poetry.dev-dependencies]
black = "^21.12b0"

View file

@ -1,198 +0,0 @@
# native
import pathlib
import traceback
import pickle
# third party
import numpy as np
from scipy.special import gamma as gamma_func
# hops
import hops.core.hierarchyData as hid
import hops.util.bcf as bcf
import hops.util.matrixLib as ml
import hops.util.truncation_schemes as truncation_schemes
import stg_helper
from hops.data.path import get_path as get_hops_data_path
################################################
#
# OVERALL PARAMETERS
#
# may be overwritten in later definitions
#
################################################
OMEGA = 1
EPSILON = 0.5
wc = 5
s = 1
__BCF_FIT_n = 6
__T = 0.0
__HI_eta_type = "fft"
__HI_eta_temperature_type = "fft"
eta = 0.8
p_trunc = 1
q_trunc = 0.5
n_eq = None
kfac = 1.4
kmax_list_pre_sqrt = True
__HI_k_max = None
t_max = 30
sp_tol = 1e-3
__HI_seed = 0
__HI_accum_only = False
__HI_number_of_samples = 500
__BCF_FIT_good_data_path = get_hops_data_path() + "/good_fit_data_abs_brute_force"
with open(__BCF_FIT_good_data_path, "rb") as f:
good_fit_data_abs = pickle.load(f)
try:
_, g_tilde, w_tilde = good_fit_data_abs[(__BCF_FIT_n, s)]
__g = 1 / np.pi * gamma_func(s + 1) * wc ** (s + 1) * np.asarray(g_tilde)
__w = wc * np.asarray(w_tilde)
__HI_truncation_scheme = stg_helper.get_truncation_scheme(
kmax_list_pre_sqrt=kmax_list_pre_sqrt,
g=__g,
w=__w,
q=q_trunc,
p=p_trunc,
kfac=kfac,
)
except KeyError:
raise KeyError(
"no fit data in {} for n={} and s={}".format(
__BCF_FIT_good_data_path, __BCF_FIT_n, s
)
)
__BCF_FIT_gw_hash = None
__temp_method = "stoc_pot"
__bcf_scale = eta
# print("eta", __bcf_scale)
__bcf_zero_temp = bcf.OhmicBCF_zeroTemp(s=s, eta=1, w_c=wc)
__spd_zero_temp = bcf.OhmicSD_zeroTemp(s=s, eta=1, w_c=wc)
if __T == 0:
__bcf = __bcf_zero_temp
__spec_dens = __spd_zero_temp
__stoc_temp_corr = None
__stoc_temp_dens = None
beta = np.inf
else:
__bcf = bcf.OhmicBCF_nonZeroTemp(s=s, eta=1, w_c=wc, beta=1 / __T)
__spec_dens = bcf.PseudoSD(sd_at_t_zero=__spd_zero_temp, T=__T)
__stoc_temp_corr = bcf.Ohmic_StochasticPotentialCorrelations(
s=s, eta=1, w_c=wc, beta=1 / __T
)
__stoc_temp_dens = bcf.Ohmic_StochasticPotentialDensity(
s=s, eta=1, w_c=wc, beta=1 / __T
)
beta = 1 / __T
__L = 0.5 * ml.SIGMA_X
__H_sys = 0.5 * OMEGA * ml.SIGMA_Z
__L = ml.Operator(data=__L, fmt="coo")
__H_sys = ml.Operator(data=__H_sys, fmt="coo")
#################################################
#
# settings for stoc proc
#
#################################################
__SP_t_max = t_max
__SP_db_name = "SPCache"
__SP_db_path = "."
__SP_KLE_tol = sp_tol
__SP_KLE_ng_fac = 4
__SP_KLE_meth = "fourpoint"
# __SP_KLE_meth = 'trapz'
# __SP_KLE_diff_method = 'full'
# __SP_KLE_dm_random_samples = None
__SP_KLE_diff_method = "random"
__SP_KLE_dm_random_samples = 10000
if __temp_method == "stoc_pot":
__SP_FFT_neg_frequ = False
else:
if __T == 0:
__SP_FFT_neg_frequ = False
else:
__SP_FFT_neg_frequ = True
# __SP_FFT_intgr_tol = 5e-3
# __SP_FFT_intpl_tol = 5e-3
__SP_FFT_intgr_tol = sp_tol
__SP_FFT_intpl_tol = sp_tol
################################################
#
# System and Hierarchy parameters
#
################################################
# __g = None
# __w = None
__H_dyn = []
__psi0 = ml.PSI_UP
# for image: stoch_trj.png
# __INTGR_t_max = 6
# __INTGR_t_steps = 750
__INTGR_t_max = t_max
__INTGR_t_steps = 1000
__INTGR_name = "zvode"
__INTGR_atol = "1e-8"
__INTGR_rtol = "1e-8"
__INTGR_order = 5
__INTGR_nsteps = 5000
__INTGR_method = "bdf"
__HI_g_scale = None
__HI_sample_method = "random"
__HI_nonlinear = True
__HI_normalized = False
__HI_normalized_by_hand = False
__HI_with_terminator = False
# __HI_result_data = hid.RESULT_TYPE_ZEROTH_ORDER_ONLY
__HI_result_data = hid.ResultType.ZEROTH_AND_FIRST_ORDER
#################################################
#
# DB and Server/Client parameters
#
#################################################
__db_name = "SBM2"
__db_path = "."
__host = "localhost"
__verbose = 1
__authkey = __db_name
__desc = __db_name
__port = 35254
__nproc = 0
__nice = 19