#+PROPERTY: header-args :session finite_temp_new :kernel python :pandoc yes :async yes * 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 19:19:41 up 7:45, 2 users, load average: 0.63, 1.00, 1.18 impure  ~/D/P/U/m/m/p/e/02_finite_temperature  python ../hops/sp.py -s stg.py /home/hiro/Documents/Projects/UNI/master/masterarb/python/energy_flow_proper/hops/hops/util/bc f.py:185: UserWarning: this implementation uses mpmath to evaluate the zeta_function! for a be tter performance consider the 'OhmEnv' package warnings.warn( /home/hiro/Documents/Projects/UNI/master/masterarb/python/energy_flow_proper/hops/hops/util/bc f.py:228: UserWarning: this implementation uses mpmath to evaluate the zeta_function! for a be tter performance consider the 'OhmEnv' package warnings.warn( StocProc found in database 'SPCache' at '.' 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.15-zen1 x86_64 16:47:19 up 5:13, 2 users, load average: 0.82, 0.96, 0.92 impure  ~/D/P/U/m/m/p/e/02_finite_temperature  python ../hops/hi.py -s stg.py run integrate /home/hiro/Documents/Projects/UNI/master/masterarb/python/energy_flow_proper/hops/hops/util/bc f.py:185: UserWarning: this implementation uses mpmath to evaluate the zeta_function! for a be tter performance consider the 'OhmEnv' package warnings.warn( /home/hiro/Documents/Projects/UNI/master/masterarb/python/energy_flow_proper/hops/hops/util/bc f.py:228: UserWarning: this implementation uses mpmath to evaluate the zeta_function! for a be tter performance consider the 'OhmEnv' package warnings.warn( 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:26524 (bytearray(b'HOPS26524')) hi server is up [in server process] set is_up is up event is now True [TET 9.61ms [0.0c/s] TTG -- 0.0% ETA -- ORT --] /nix/store/00v56a021xv35zkdhr91dd4rbccpp2x0-python3-3.9.4-env/lib/python3.9/site-packages/jobm anager/jobmanager.py:130: UserWarning: num_threads could not be set, MKL / openblas not found warnings.warn("num_threads could not be set, MKL / openblas not found") /nix/store/00v56a021xv35zkdhr91dd4rbccpp2x0-python3-3.9.4-env/lib/python3.9/site-packages/jobm anager/jobmanager.py:130: UserWarning: num_threads could not be set, MKL / openblas not found warnings.warn("num_threads could not be set, MKL / openblas not found") /nix/store/00v56a021xv35zkdhr91dd4rbccpp2x0-python3-3.9.4-env/lib/python3.9/site-packages/jobm anager/jobmanager.py:130: UserWarning: num_threads could not be set, MKL / openblas not found warnings.warn("num_threads could not be set, MKL / openblas not found") /nix/store/00v56a021xv35zkdhr91dd4rbccpp2x0-python3-3.9.4-env/lib/python3.9/site-packages/jobm [TET 1.01s [0.0c/s] TTG -- 0.0% ETA -- ORT --] res_q #0 0/s 0kB|rem.:1, done:0, failed:0, prog.:0 w1:3.02s [27.7c/min] #1 - [TET 848.21ms [0.0c/s] TTG -- 0.0% ETA -- ORT --] w2:3.02s [0.0c/s] #0 - 3.03s [0.0c/s] #0 w3:3.02s [0.0c/s] #0 - 3.03s [0.0c/s] #0 w4:3.02s [0.0c/s] #0 - 3.03s [0.0c/s] #0 local res_q 0 365.1GB/s ,********************************ms------------100%------------ETA-20211111_16:47:25-ORT-3.01s] ,********************************ne:1, failed:0, prog.:0 ,** the client has finished early! stop the server ,******************************** ,******************************** [TET-4.02s--[19.9c/min]-TTG-0.00ms------------100%------------ETA-20211111_16:47:26-ORT-4.02s] res_q #0 0kB/s 7.18GB|rem.:0, done:1, failed:0, prog.:0 [in server process] server has joined! ############## in JM SERVER EXIT HI_Server start at 2021-11-11 16:47:22.000943 | runtime 6.000e+00s HI_Server total number of jobs : 1 | processed : 1 | succeeded : 1 | failed : 0 | timing in sec: min 2.028e+00 | max 2.028e+00 | avr 2.028e+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 19:28:43 up 7:54, 2 users, load average: 0.43, 0.70, 0.96 impure  ~/D/P/U/m/m/p/e/02_finite_temperature  python ../hops/hi.py -s stg.py server run server /home/hiro/Documents/Projects/UNI/master/masterarb/python/energy_flow_proper/hops/hops/util/bc f.py:185: UserWarning: this implementation uses mpmath to evaluate the zeta_function! for a be tter performance consider the 'OhmEnv' package warnings.warn( /home/hiro/Documents/Projects/UNI/master/masterarb/python/energy_flow_proper/hops/hops/util/bc f.py:228: UserWarning: this implementation uses mpmath to evaluate the zeta_function! for a be tter performance consider the 'OhmEnv' package warnings.warn( init Hi class, use 464 equation JobManager started on ArLeenUX:35254 (bytearray(b'SBM')) hi server is running [TET-00:03:39-----[2.2c/s]-TTG-0.00ms---------100%---------ETA-20211111_19:32:25-ORT-00:03:39] res_q #0 15.09GB/s 3.183TB|rem.:0, done:452, failed:0, prog.:0 ############## in JM SERVER EXIT HI_Server start at 2021-11-11 19:28:46.024888 | runtime 2.210e+02s HI_Server total number of jobs : 452 | processed : 452 | succeeded : 452 | failed : 0 | timing in sec: min 4.039e+00 | max 9.583e+00 | avr 5.470e+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. ** Local Client #+begin_src vterm :term-name local-client python ../hops/hi.py -s stg.py client #+end_src #+RESULTS: :RESULTS: Linux ArLeenUX 5.14.15-zen1 x86_64 19:29:04 up 7:54, 2 users, load average: 0.46, 0.69, 0.95 impure  ~/D/P/U/m/m/p/e/02_finite_temperature  python ../hops/hi.py -s stg.py client run client /home/hiro/Documents/Projects/UNI/master/masterarb/python/energy_flow_proper/hops/hops/util/bc f.py:185: UserWarning: this implementation uses mpmath to evaluate the zeta_function! for a be tter performance consider the 'OhmEnv' package warnings.warn( /home/hiro/Documents/Projects/UNI/master/masterarb/python/energy_flow_proper/hops/hops/util/bc f.py:228: UserWarning: this implementation uses mpmath to evaluate the zeta_function! for a be tter performance consider the 'OhmEnv' package warnings.warn( timeout from args None start client on host ArLeenUX /nix/store/00v56a021xv35zkdhr91dd4rbccpp2x0-python3-3.9.4-env/lib/python3.9/site-packages/jobm anager/jobmanager.py:130: UserWarning: num_threads could not be set, MKL / openblas not found warnings.warn("num_threads could not be set, MKL / openblas not found") /nix/store/00v56a021xv35zkdhr91dd4rbccpp2x0-python3-3.9.4-env/lib/python3.9/site-packages/jobm anager/jobmanager.py:130: UserWarning: num_threads could not be set, MKL / openblas not found warnings.warn("num_threads could not be set, MKL / openblas not found") /nix/store/00v56a021xv35zkdhr91dd4rbccpp2x0-python3-3.9.4-env/lib/python3.9/site-packages/jobm anager/jobmanager.py:130: UserWarning: num_threads could not be set, MKL / openblas not found warnings.warn("num_threads could not be set, MKL / openblas not found") /nix/store/00v56a021xv35zkdhr91dd4rbccpp2x0-python3-3.9.4-env/lib/python3.9/site-packages/jobm anager/jobmanager.py:130: UserWarning: num_threads could not be set, MKL / openblas not found warnings.warn("num_threads could not be set, MKL / openblas not found") w1:00:03:30 [9.9c/min] #39 - [TET 00:00:12 [0.0c/s] TTG -- 0.0% ETA -- ORT --] w2:00:03:30 [9.7c/min] #38 - [TET 00:00:15 [0.0c/s] TTG -- 0.0% ETA -- ORT --] w3:00:03:30 [9.9c/min] #39 - [TET 00:00:13 [0.0c/s] TTG -- 0.0% ETA -- ORT --] w4:00:03:30 [9.9c/min] #38 - [TET 00:00:16 [0.0c/s] TTG -- 0.0% ETA -- ORT --] local res_q 0 319.4GB/s :END: Churn in with our local machine :). * Using the Data ** Jupyter Setup #+begin_src jupyter-python import numpy as np import matplotlib.pyplot as plt #+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: a94d2f6f1da1923ebad6d66b736e2cd3207b3b0b ~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.02721057-0.00954633j -0.2649888 -0.24446953j -0.42474792-0.17263986j -0.34393704-1.88365973j -1.05844961+3.42100634j 3.63543978-3.87070472j 6.44166867+2.75995815j] psi0 : [0 1] w : [ 0.2139392 +2.65203434e-02j 0.9575499 +2.23185841e-01j 22.20034528+3.21863905e+01j 2.63533411+9.82383126e-01j 15.64050609+1.63103642e+01j 5.60430249+3.07507006e+00j 9.99803518+7.65897515e+00j] --- extra info --- T : 0.1 T_method : stoc_pot gw_info : None len_gw : None #+end_example Now we read the trajectory data. #+begin_src jupyter-python class result: hd = stg_helper.get_hierarchy_data(stg, read_only=True) N = 5000 τ = hd.get_time() # ρ = hd.get_rho_t() ψ_1 = hd.aux_states ψ = hd.stoc_traj therm_y = hd.therm_y #+end_src #+RESULTS: ** Calculate System Energy Simple sanity check. #+begin_src jupyter-python e_sys = util.operator_expectation_ensemble( iter(result.ψ), system_params.H_sys.todense(), result.N, stg.__HI_nonlinear ) plt.plot(result.τ, e_sys) #+end_src #+RESULTS: :RESULTS: : /nix/store/k62y7zypgg51r34lyk8r0jzyrvnhkcc9-python3-3.9.4-env/lib/python3.9/site-packages/numpy/core/_asarray.py:102: ComplexWarning: Casting complex values to real discards the imaginary part : return array(a, dtype, copy=False, order=order) | | [[file:./.ob-jupyter/c0dc239491ac0a8c63db7dd6d912a22523ebfcf5.svg]] :END: ** 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 ) η = stg_helper.get_eta(stg) ξ = stg_helper.get_eta_therm(stg) ξ.calc_deriv = True hf_therm = hopsflow.ThermalParams(ξ=ξ, τ=result.τ, num_deriv=False) #+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) hf_sample_run_therm = hopsflow.ThermalRunParams(hf_therm, result.therm_y[0]) first_flow = hopsflow.flow_trajectory_coupling(hf_sample_run, hf_system) first_flow_therm = hopsflow.flow_trajectory_therm(hf_sample_run, hf_sample_run_therm) plt.plot(result.τ, first_flow) plt.plot(result.τ, first_flow_therm) #+end_src #+RESULTS: :RESULTS: | | [[file:./.ob-jupyter/d3704acd8907cce8fff23234fd2e73729593caf3.svg]] :END: And now for all trajectories. #+begin_src jupyter-python full_flow = hopsflow.heat_flow_ensemble( iter(result.ψ), iter(result.ψ_1), hf_system, result.N, (iter(result.therm_y), hf_therm) ) #+end_src #+RESULTS: #+begin_src jupyter-python plt.plot(result.τ, full_flow) #+end_src #+RESULTS: :RESULTS: | | [[file:./.ob-jupyter/aa3d7f22017d994caa199611df2e5e2f27ee8bec.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/8f7fb585f526f7676f76c37a5aef0244b4d3ca88.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: : /nix/store/k62y7zypgg51r34lyk8r0jzyrvnhkcc9-python3-3.9.4-env/lib/python3.9/site-packages/numpy/core/_asarray.py:102: ComplexWarning: Casting complex values to real discards the imaginary part : return array(a, dtype, copy=False, order=order) | | [[file:./.ob-jupyter/e53ffa1f94610fafd5f3ff2ab3f4d85d95619077.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, (result.therm_y, hf_therm) ) #+end_src #+RESULTS: And both together: #+begin_src jupyter-python plt.plot(result.τ, e_int, label="integrated") plt.plot(result.τ, e_int_ex, label="exact") plt.legend() #+end_src #+RESULTS: :RESULTS: : /nix/store/k62y7zypgg51r34lyk8r0jzyrvnhkcc9-python3-3.9.4-env/lib/python3.9/site-packages/numpy/core/_asarray.py:102: ComplexWarning: Casting complex values to real discards the imaginary part : return array(a, dtype, copy=False, order=order) : [[file:./.ob-jupyter/63a6155c1d7b836db3f678b89cadd9d0bf90d92b.svg]] :END: Seems to work :P. * 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: : a94d2f6f1da1923ebad6d66b736e2cd3207b3b0b