#+PROPERTY: header-args :session zero_temp_new :kernel python :pandoc t * Configuration and Setup The main process configuration is to be found [[file:stg.py][here]]. ** Stochastic Processes We then proceed to initialize the stochastic processes. #+begin_src vterm python ../hops/sp.py -s stg.py #+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 #+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% /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! ############## 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: And there we go. It is better to run the above command in a 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 #+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 ############## 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 :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 #+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) #+end_src #+RESULTS: :RESULTS: | | [[file:./.ob-jupyter/a7742fc7d6826fdc3a3005e8f06e017744c80631.svg]] :END: The energy bleeds out of the system. We don't reach the steady state 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] #+end_src #+RESULTS: : array([-0.5, 0.5]) The begin and and values of the system energy expectation are. #+begin_src jupyter-python e_sys[0], e_sys[-1] #+end_src #+RESULTS: | 0.5 | -0.44815376641059734 | And the total energy lost is: #+begin_src jupyter-python e_sys[0] - e_sys[-1] #+end_src #+RESULTS: : 0.9481537664105973 We do start in the state. #+begin_src jupyter-python system_params.psi0 #+end_src #+RESULTS: : array([0, 1]) ** Calculate the Heat Flow 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 hf_system = hopsflow.SystemParams( system_params.L.todense(), stg.__g, stg.__w, stg.__bcf_scale, stg.__HI_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) #+end_src #+RESULTS: :RESULTS: | | [[file:./.ob-jupyter/efdf662d48ebc0cfa16c163932cc45b205466fba.svg]] :END: 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) #+end_src #+RESULTS: :RESULTS: | | [[file:./.ob-jupyter/3850d1b72e60f2311045d24399e69ba792255439.svg]] :END: We can integrate the energy change in the bath: #+begin_src jupyter-python e_bath = util.integrate_array(-full_flow, result.τ) plt.plot(result.τ, e_bath) #+end_src #+RESULTS: :RESULTS: | | [[file:./.ob-jupyter/db755c0365ed1377a36986466fa4e617fef9ebdd.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) #+end_src #+RESULTS: :RESULTS: | | [[file:./.ob-jupyter/97d391819a65d8e5bf37e1c5b5eaba576667f120.svg]] :END: 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) #+end_src #+RESULTS: :RESULTS: | | [[file:./.ob-jupyter/86e89b1f1f342f53929294909d1b6834f81e9758.svg]] :END: And both together: #+begin_src jupyter-python plt.plot(result.τ, e_int) plt.plot(result.τ, e_int_ex) #+end_src #+RESULTS: :RESULTS: | | [[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: | | [[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