master-thesis/python/energy_flow_proper/02_finite_temperature/notebook.org

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

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

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

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

Local Client

  python ../hops/hi.py -s stg.py client

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

Churn in with our local machine :).

Using the Data

Jupyter Setup

  import numpy as np
  import matplotlib.pyplot as plt

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

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

Now we read the trajectory data.

  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

Calculate System Energy

Simple sanity check.

  e_sys = util.operator_expectation_ensemble(
      iter(result.ψ), system_params.H_sys.todense(), result.N, stg.__HI_nonlinear
  )
  plt.plot(result.τ, e_sys)
/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)
<matplotlib.lines.Line2D at 0x7fbe92a1f160>

/hiro/master-thesis/media/commit/99a8f2311409b66c16681a7076259dacb0ccfd6c/python/energy_flow_proper/02_finite_temperature/.ob-jupyter/c0dc239491ac0a8c63db7dd6d912a22523ebfcf5.svg

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
  )
  η = stg_helper.get_eta(stg)

  ξ = stg_helper.get_eta_therm(stg)
  ξ.calc_deriv = True
  hf_therm = hopsflow.ThermalParams(ξ=ξ, τ=result.τ, num_deriv=False)

Now we can apply our tooling to one trajectory for testing.

  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)
<matplotlib.lines.Line2D at 0x7fbe92932a60>

/hiro/master-thesis/media/commit/99a8f2311409b66c16681a7076259dacb0ccfd6c/python/energy_flow_proper/02_finite_temperature/.ob-jupyter/d3704acd8907cce8fff23234fd2e73729593caf3.svg

And now for all trajectories.

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

/hiro/master-thesis/media/commit/99a8f2311409b66c16681a7076259dacb0ccfd6c/python/energy_flow_proper/02_finite_temperature/.ob-jupyter/aa3d7f22017d994caa199611df2e5e2f27ee8bec.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 0x7fbe92484820>

/hiro/master-thesis/media/commit/99a8f2311409b66c16681a7076259dacb0ccfd6c/python/energy_flow_proper/02_finite_temperature/.ob-jupyter/8f7fb585f526f7676f76c37a5aef0244b4d3ca88.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)
/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)
<matplotlib.lines.Line2D at 0x7fbe921de190>

/hiro/master-thesis/media/commit/99a8f2311409b66c16681a7076259dacb0ccfd6c/python/energy_flow_proper/02_finite_temperature/.ob-jupyter/e53ffa1f94610fafd5f3ff2ab3f4d85d95619077.svg

And then from first principles:

  e_int_ex = hopsflow.interaction_energy_ensemble(
      result.ψ, result.ψ_1, hf_system, result.N, (result.therm_y, hf_therm)
  )

And both together:

  plt.plot(result.τ, e_int, label="integrated")
  plt.plot(result.τ, e_int_ex, label="exact")
  plt.legend()
/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)
<matplotlib.legend.Legend at 0x7fbe9214d100>

/hiro/master-thesis/media/commit/99a8f2311409b66c16681a7076259dacb0ccfd6c/python/energy_flow_proper/02_finite_temperature/.ob-jupyter/63a6155c1d7b836db3f678b89cadd9d0bf90d92b.svg

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.

  deps.write_hash()
  deps.get_hash()[0]
a94d2f6f1da1923ebad6d66b736e2cd3207b3b0b