12 KiB
Configuration and Setup
The main process configuration is to be found here.
Stochastic Processes
We then proceed to initialize the stochastic processes.
python ../hops/sp.py -s stg.py
Linux ArLeenUX 5.14.14-zen1 x86_64 16:06:06 up 3 days 23:48, 1 user, load average: 0.81, 1.19, 1.21 impure ~/D/P/U/m/m/p/e/01_zero_temperature python ../hops/sp.py -s stg.py StocProc found in database 'SPCache' at '.'
The stochastic process is initialized and cached in ./SPCache
.
Hops Integration
We can use multiple avenues.
Local Integration
python ../hops/hi.py -s stg.py
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)
And there we go. It is better to run the above command in a vterm-session.
Remote/Distributed Integration
We start the server locally.
python ../hops/hi.py -s stg.py server
Linux ArLeenUX 5.14.14-zen1 x86_64 18:00:32 up 4 days 1:42, 1 user, load average: 2.45, 2.86, 2.99 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:06:01—–[2.5c/s]-TTG-0.00ms———100%———ETA-20211110_18:06:38-ORT-00:06:01] res_q #0 17.85GB/s 3.506TB|rem.:0, done:500, failed:0, prog.:0
############## in JM SERVER EXIT
HI_Server start at 2021-11-10 18:00:36.345825 | runtime 3.640e+02s HI_Server total number of jobs : 500
processed : 500 | ||
succeeded : 500 | ||
failed : 0 | ||
timing in sec: min 3.446e+00 | max 6.235e+00 | avr 5.008e+00 |
not processed : 0 | ||
queried : 0 | ||
not queried yet : 0 |
And jack in with a remote client. In this case my box at home.
Using the Data
Jupyter Setup
%load_ext autoreload
%autoreload 2
import matplotlib.pyplot as plt
import numpy as np
plt.style.use('ggplot')
import qutip
Check the Freshness of the Data
This doesn't check for modifications in this file though!
from deps import deps
deps.report()
Is fresh: True Overall Hash: b69f09d7a1ad29b11fe2af2e1574161333632d46
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.
import stg_helper
import stg
import hopsflow
from hopsflow import util
Now let's load the system parameters.
system_params = stg_helper.get_system_param(stg)
system_params
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
Now we read the trajectory data.
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]
Calculate System Energy
Simple sanity check.
e_sys = util.operator_expectation(result.ρ, system_params.H_sys.todense())
plt.plot(result.τ, e_sys)
<matplotlib.lines.Line2D | at | 0x7f2850534ac0> |
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.
np.linalg.eig(system_params.H_sys.todense())[0]
array([-0.5, 0.5])
The begin and and values of the system energy expectation are.
e_sys[0], e_sys[-1]
0.5 | -0.44786036208449925 |
And the total energy lost is:
e_sys[0] - e_sys[-1]
0.9478603620844992
We do start in the state.
system_params.psi0
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.
hf_system = hopsflow.SystemParams(
system_params.L.todense(), stg.__g, stg.__w, stg.__bcf_scale, stg.__HI_nonlinear
)
Now we can apply our tooling to one trajectory for testing.
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)
<matplotlib.lines.Line2D | at | 0x7f284e433ca0> |
And now for all trajectories.
full_flow = hopsflow.heat_flow_ensemble(result.ψ, result.ψ_1, hf_system)
plt.plot(result.τ, full_flow)
<matplotlib.lines.Line2D | at | 0x7f284e3a0fd0> |
We can integrate the energy change in the bath:
e_bath = util.integrate_array(-full_flow, result.τ)
plt.plot(result.τ, e_bath)
<matplotlib.lines.Line2D | at | 0x7f284e30b850> |
Calculate the Interaction Energy
First we calculate it from energy conservation.
e_int = 1/2 - e_sys - e_bath
plt.plot(result.τ, e_int)
<matplotlib.lines.Line2D | at | 0x7f284e2fd910> |
And then from first principles:
e_int_ex = hopsflow.interaction_energy_ensemble(result.ψ, result.ψ_1, hf_system)
plt.plot(result.τ, e_int_ex)
<matplotlib.lines.Line2D | at | 0x7f284e2790d0> |
And both together:
plt.plot(result.τ, e_int)
plt.plot(result.τ, e_int_ex)
<matplotlib.lines.Line2D | at | 0x7f284e1e1b50> |
Scratch
So the G
and W
do function as expected
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)
<matplotlib.lines.Line2D | at | 0x7f284e15a880> |
import os
path = os.path.dirname(hopsflow.__file__)
path
/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.
deps.write_hash()
deps.get_hash()[0]
b69f09d7a1ad29b11fe2af2e1574161333632d46