master-thesis/python/energy_flow_proper/01_zero_temperature/notebook.org

12 KiB
Raw Blame History

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.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 '.'

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.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

And jack in with a remote client. In this case my box at home.

Using the Data

Jupyter Setup

  import matplotlib.pyplot as plt
  import numpy as np

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: 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.

  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 0x7f6a3bcd61c0>

/hiro/master-thesis/media/commit/9cdd6d81869ecffc3f0fe317711d749256bbb1c9/python/energy_flow_proper/01_zero_temperature/.ob-jupyter/a7742fc7d6826fdc3a3005e8f06e017744c80631.svg

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.44815376641059734

And the total energy lost is:

  e_sys[0] - e_sys[-1]
0.9481537664105973

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 0x7f6a3bcb9fa0>

/hiro/master-thesis/media/commit/9cdd6d81869ecffc3f0fe317711d749256bbb1c9/python/energy_flow_proper/01_zero_temperature/.ob-jupyter/efdf662d48ebc0cfa16c163932cc45b205466fba.svg

And now for all trajectories.

  full_flow = hopsflow.heat_flow_ensemble(result.ψ, result.ψ_1, hf_system, result.N)
  plt.plot(result.τ, full_flow)
<matplotlib.lines.Line2D at 0x7f6a3bfee0d0>

/hiro/master-thesis/media/commit/9cdd6d81869ecffc3f0fe317711d749256bbb1c9/python/energy_flow_proper/01_zero_temperature/.ob-jupyter/3850d1b72e60f2311045d24399e69ba792255439.svg

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 0x7f6a3c3119a0>

/hiro/master-thesis/media/commit/9cdd6d81869ecffc3f0fe317711d749256bbb1c9/python/energy_flow_proper/01_zero_temperature/.ob-jupyter/db755c0365ed1377a36986466fa4e617fef9ebdd.svg

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 0x7f6a3c376ee0>

/hiro/master-thesis/media/commit/9cdd6d81869ecffc3f0fe317711d749256bbb1c9/python/energy_flow_proper/01_zero_temperature/.ob-jupyter/97d391819a65d8e5bf37e1c5b5eaba576667f120.svg

And then from first principles:

  e_int_ex = hopsflow.interaction_energy_ensemble(result.ψ, result.ψ_1, hf_system, result.N)
  plt.plot(result.τ, e_int_ex)
<matplotlib.lines.Line2D at 0x7f6a3c1cb880>

/hiro/master-thesis/media/commit/9cdd6d81869ecffc3f0fe317711d749256bbb1c9/python/energy_flow_proper/01_zero_temperature/.ob-jupyter/86e89b1f1f342f53929294909d1b6834f81e9758.svg

And both together:

  plt.plot(result.τ, e_int)
  plt.plot(result.τ, e_int_ex)
<matplotlib.lines.Line2D at 0x7f6a3bf153a0>

/hiro/master-thesis/media/commit/9cdd6d81869ecffc3f0fe317711d749256bbb1c9/python/energy_flow_proper/01_zero_temperature/.ob-jupyter/2f62c356fed1d7133aa3ef68bb29b3efca86b58e.svg

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 0x7f6a3c04a5e0>

/hiro/master-thesis/media/commit/9cdd6d81869ecffc3f0fe317711d749256bbb1c9/python/energy_flow_proper/01_zero_temperature/.ob-jupyter/99df85a9e29da5768f796ed82ac9827df688e8d9.svg

  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]
bfe5a79a9c7e767f4b470f1096cbbf22d05e3977