diff --git a/python/richard_hops/energy_flow.org b/python/richard_hops/energy_flow.org index c64f60a..a1c6fd5 100644 --- a/python/richard_hops/energy_flow.org +++ b/python/richard_hops/energy_flow.org @@ -9,10 +9,6 @@ #+end_src #+RESULTS: -: The autoreload extension is already loaded. To reload it, use: -: %reload_ext autoreload -: The jupyter_spaces extension is already loaded. To reload it, use: -: %reload_ext jupyter_spaces ** Matplotlib #+begin_src jupyter-python @@ -105,9 +101,9 @@ Basic parameters. #+RESULTS: :RESULTS: -| | -| | -| | +| | +| | +| | [[file:./.ob-jupyter/252b4713c37e957d1909f4354fd107d3803ecda2.png]] :END: @@ -273,19 +269,89 @@ Initialize Hierarchy. Run the integration. #+begin_src jupyter-python - myHierarchy.integrate_simple(data_name="energy_flow.data") + myHierarchy.integrate_simple(data_name="energy_flow_new.data", overwrite=True) #+end_src #+RESULTS: -: samples :0.0% -: integration :0.0% -: samples : 100% -: integration :0.0% -:  +#+begin_example + samples :0.0% + integration :0.0% + samples :2.0% + integration :40.4% + samples :5.0% + integration :19.0% + samples :8.0% + integration :4.6% + samples :11.0% + integration :1.8% + samples :14.0% + integration :1.0% + samples :16.0% + integration :99.8% + samples :19.0% + integration :99.8% + samples :23.0% + integration :0.8% + samples :25.0% + integration :87.8% + samples :28.0% + integration :69.0% + samples :31.0% + integration :62.0% + samples :34.0% + integration :55.6% + samples :37.0% + integration :49.8% + samples :40.0% + integration :39.6% + samples :43.0% + integration :39.4% + samples :46.0% + integration :28.2% + samples :49.0% + integration :28.0% + samples :52.0% + integration :20.4% + samples :55.0% + integration :17.2% + samples :58.0% + integration :12.6% + samples :61.0% + integration :18.6% + samples :64.0% + integration :10.2% + samples :66.0% + integration :82.8% + samples :69.0% + integration :55.6% + samples :72.0% + integration :44.8% + samples :75.0% + integration :41.2% + samples :78.0% + integration :33.2% + samples :81.0% + integration :27.8% + samples :84.0% + integration :30.0% + samples :87.0% + integration :20.0% + samples :90.0% + integration :11.2% + samples :93.0% + integration :10.2% + samples :96.0% + integration :7.8% + samples :99.0% + integration :0.8% + samples : 100% + integration :0.0% +  +#+end_example Get the samples. #+begin_src jupyter-python # to access the data the 'hi_key' is used to find the data in the hdf5 file - with hierarchyData.HIMetaData(hid_name="energy_flow.data", hid_path=".") as metaData: + with hierarchyData.HIMetaData(hid_name="energy_flow_new.data", hid_path=".") as metaData: with metaData.get_HIData(hi_key, read_only=True) as data: smp = data.get_samples() print("{} samples found in database".format(smp)) @@ -299,7 +365,7 @@ Get the samples. #+end_src #+RESULTS: -: 122 samples found in database +: 200 samples found in database Calculate energy. #+begin_src jupyter-python @@ -309,8 +375,8 @@ Calculate energy. #+RESULTS: :RESULTS: -| | -[[file:./.ob-jupyter/009521d0047fb3d6927063413a3290f039a1cbe3.png]] +| | +[[file:./.ob-jupyter/be6c2de12726698c7cc02ae53a819ba08e14f319.png]] :END: #+begin_src jupyter-python @@ -320,8 +386,8 @@ Calculate energy. #+RESULTS: :RESULTS: -| | -[[file:./.ob-jupyter/6b4898a15426ff4e99c43e8db1649e9fe9f1ec28.png]] +| | +[[file:./.ob-jupyter/3f92fa53823636bc644ef2400693567d7f641b4e.png]] :END: * Energy Flow @@ -342,25 +408,24 @@ Let's look at the norm. #+RESULTS: :RESULTS: -| | -[[file:./.ob-jupyter/542a9e20ddb61f23548be094780da540cd1d60b2.png]] +| | +[[file:./.ob-jupyter/05059610be839a612c11be140a5ad0e2d6bd2ab4.png]] :END: And try to calculate the energy flow. #+begin_src jupyter-python def flow_for_traj(ψ_0, ψ_1): a = np.array((L @ ψ_0.T).T) - return np.array(2 * (1j * -W * np.sum(a.conj() * ψ_1, axis=1)).real).flatten() def flow_for_traj_alt(ψ_0, y): Eta.new_process(y) - eta_dot = scipy.misc.derivative(Eta, τ, dx=1e-6) - a = L @ ψ_0.T + eta_dot = scipy.misc.derivative(Eta, τ, dx=1e-8) + a = np.array((L @ ψ_0.T).T) - return ( - eta_dot * np.array(2 * (1j * np.sum(ψ_0.conj() * a, axis=1))).flatten() + return -( + 2j * eta_dot.conj() * np.array((np.sum(ψ_0.conj() * a, axis=1))).flatten() ).real #+end_src @@ -428,11 +493,58 @@ With this we can retrieve the energy of the interaction Hamiltonian. #+RESULTS: :RESULTS: -| | -| | -| | +| | +| | +| | : Text(0.5, 0, 'τ') -: -[[file:./.ob-jupyter/54dcf3f70f069181a1bba0ac9b3037900cb69e2f.png]] +: +[[file:./.ob-jupyter/45f86f6728fd17bb4bfc0b6d9e8f5ad1fc14898b.png]] :END: #+RESULTS: + +* System + Interaction Energy +:PROPERTIES: +:ID: cbc95df0-609d-4b1f-a51d-ebca7b680ec7 +:END: +#+begin_src jupyter-python + def h_si_for_traj(ψ_0, ψ_1): + a = np.array((L @ ψ_0.T).T) + b = np.array((H_s @ ψ_0.T).T) + E_i = np.array(2 * (-1j * np.sum(a.conj() * ψ_1, axis=1)).real).flatten() + E_s = np.array(np.sum(b.conj() * ψ_0, axis=1)).flatten().real + + return E_i + E_s + + def h_si_for_traj_alt(ψ_0, y): + Eta.new_process(y) + + a = np.array((L.conj().T @ ψ_0.T).T) + b = np.array((H_s @ ψ_0.T).T) + E_i = np.array(2 * (Eta(τ) * 1j * np.sum(a.conj() * ψ_0, axis=1)).real).flatten() + E_s = np.array(np.sum(b.conj() * ψ_0, axis=1)).flatten().real + + return E_i + E_s +#+end_src + +#+RESULTS: + +#+begin_src jupyter-python + e_si = np.zeros_like(τ) + for i in range(0, N): + e_si += h_si_for_traj(ψ_0[i], ψ_1[i]) + e_si /= N +#+end_src + +#+RESULTS: + +Checks out. +#+begin_src jupyter-python + plt.plot(τ, e_si) + plt.plot(τ, E_I + energy) +#+end_src + +#+RESULTS: +:RESULTS: +| | +[[file:./.ob-jupyter/db7e2b07936c085337617799cbca51600a0ad57e.png]] +:END: