From a46289dbfeb1a7678af95e1981e45f265a5e0028 Mon Sep 17 00:00:00 2001 From: "valentin.boettcher@mailbox.tu-dresden.de" Date: Thu, 1 Dec 2022 18:56:26 -0500 Subject: [PATCH] add basic simulation --- python/otto_motor/flake.lock | 6 +- python/otto_motor/flake.nix | 2 +- python/otto_motor/otto_baseline.org | 99 +++++++++++++++++------------ python/otto_motor/otto_baseline.py | 59 ++++++++++------- python/otto_motor/poetry.lock | 6 +- 5 files changed, 101 insertions(+), 71 deletions(-) diff --git a/python/otto_motor/flake.lock b/python/otto_motor/flake.lock index cbf8d11..8658176 100644 --- a/python/otto_motor/flake.lock +++ b/python/otto_motor/flake.lock @@ -32,11 +32,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1669542132, - "narHash": "sha256-DRlg++NJAwPh8io3ExBJdNW7Djs3plVI5jgYQ+iXAZQ=", + "lastModified": 1669791787, + "narHash": "sha256-KBfoA2fOI5+wCrm7PR+j7jHqXeTkVRPQ0m5fcKchyuU=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "a115bb9bd56831941be3776c8a94005867f316a7", + "rev": "e76c78d20685a043d23f5f9e0ccd2203997f1fb1", "type": "github" }, "original": { diff --git a/python/otto_motor/flake.nix b/python/otto_motor/flake.nix index 8cd28be..8231a46 100644 --- a/python/otto_motor/flake.nix +++ b/python/otto_motor/flake.nix @@ -21,7 +21,7 @@ shellOverride = (pkgs: oldAttrs: { shellHook = '' export PYTHONPATH=/home/hiro/src/two_qubit_model/:$PYTHONPATH - #export PYTHONPATH=/home/hiro/src/hops/:$PYTHONPATH + export PYTHONPATH=/home/hiro/src/hops/:$PYTHONPATH export PYTHONPATH=/home/hiro/src/hopsflow/:$PYTHONPATH export LD_LIBRARY_PATH="${(pkgs.lib.makeLibraryPath [pkgs.arb])}" # ''; diff --git a/python/otto_motor/otto_baseline.org b/python/otto_motor/otto_baseline.org index 4662a76..7d036ff 100644 --- a/python/otto_motor/otto_baseline.org +++ b/python/otto_motor/otto_baseline.org @@ -12,96 +12,111 @@ import utilities as ut import stocproc import matplotlib.pyplot as plt + import otto_utilities as ot #+end_src Init ray and silence stocproc. #+begin_src jupyter-python import ray ray.shutdown() - #ray.init(address='auto') - ray.init() + ray.init(address='auto') + #ray.init() #+end_src #+RESULTS: -: RayContext(dashboard_url='', python_version='3.9.15', ray_version='1.13.0', ray_commit='e4ce38d001dbbe09cd21c497fedd03d692b2be3e', address_info={'node_ip_address': '10.0.0.102', 'raylet_ip_address': '10.0.0.102', 'redis_address': None, 'object_store_address': '/tmp/ray/session_2022-11-30_18-22-21_330665_940019/sockets/plasma_store', 'raylet_socket_name': '/tmp/ray/session_2022-11-30_18-22-21_330665_940019/sockets/raylet', 'webui_url': '', 'session_dir': '/tmp/ray/session_2022-11-30_18-22-21_330665_940019', 'metrics_export_port': 56187, 'gcs_address': '10.0.0.102:49774', 'address': '10.0.0.102:49774', 'node_id': '657606fac86410cf9d4a663984fdd108bb4ed71b2bad5450c38f8c7e'}) +: RayContext(dashboard_url='', python_version='3.9.15', ray_version='1.13.0', ray_commit='e4ce38d001dbbe09cd21c497fedd03d692b2be3e', address_info={'node_ip_address': '10.0.0.102', 'raylet_ip_address': '10.0.0.102', 'redis_address': None, 'object_store_address': '/tmp/ray/session_2022-12-01_12-49-01_211839_372329/sockets/plasma_store', 'raylet_socket_name': '/tmp/ray/session_2022-12-01_12-49-01_211839_372329/sockets/raylet', 'webui_url': '', 'session_dir': '/tmp/ray/session_2022-12-01_12-49-01_211839_372329', 'metrics_export_port': 51539, 'gcs_address': '10.0.0.102:6379', 'address': '10.0.0.102:6379', 'node_id': 'a0e22c6e0493add2b51aa52eeaf1e90766c796c1f430527c008a3242'}) #+begin_src jupyter-python :results none from hops.util.logging_setup import logging_setup import logging logging_setup(logging.INFO) - plt.rcParams['figure.figsize'] = (16,8) + plt.rcParams['figure.figsize'] = (12,4) #+end_src -* Model +* Model: Baseline #+begin_src jupyter-python model = OttoEngine( - δ=[.4, .4], + δ=[0.4, 0.4], ω_c=[1, 1], ψ_0=qt.basis([2], [1]), - description=f"An otto cycle on the way to finding the baseline.", + description=f"A basic near-markovian, weakly coupled Otto Cycle that actually works.", k_max=4, - bcf_terms=[6]*2, + bcf_terms=[6] * 2, truncation_scheme="simplex", - driving_process_tolerances=[StocProcTolerances(1e-3, 1e-3)] * 2, - thermal_process_tolerances=[StocProcTolerances(1e-3, 1e-3)] * 2, - T = [1, 10], + driving_process_tolerances=[StocProcTolerances(1e-4, 1e-4)] * 2, + thermal_process_tolerances=[StocProcTolerances(1e-4, 1e-4)] * 2, + T=[1, 10], therm_methods=["tanhsinh", "fft"], Δ=1, num_cycles=5, - Θ=1/.05, - dt=.001, - timings_H=(0, .1, .5, .6), - timings_L=((.6, .7, .9, 1), (.1, .2, .4, .5)), + Θ=1.5 / 0.05, + dt=0.001, + timings_H=(0, 0.1, 0.5, 0.6), + timings_L=((0.6, 0.7, 0.9, 1), (0.1, 0.2, 0.4, 0.5)), streaming_mode=True, ) -#+end_src -#+RESULTS: + # model = OttoEngine( + # δ=[0.4, 0.4], + # ω_c=[1, 1], + # ψ_0=qt.basis([2], [1]), + # description=f"An otto cycle on the way to finding the baseline.", + # k_max=3, + # bcf_terms=[4] * 2, + # truncation_scheme="simplex", + # driving_process_tolerances=[StocProcTolerances(1e-3, 1e-3)] * 2, + # thermal_process_tolerances=[StocProcTolerances(1e-3, 1e-3)] * 2, + # T=[1, 10], + # therm_methods=["tanhsinh", "fft"], + # Δ=1, + # num_cycles=4, + # Θ=1.5 / 0.05, + # dt=0.001, + # timings_H=(0, 0.1, 0.3, 0.4), + # timings_L=((0.4, 0.5, 0.9, 1), (0.1, 0.11, 0.29, 0.3)), + # streaming_mode=True, + # ) - -#+begin_src jupyter-python - plt.plot(model.t, model.H.operator_norm(model.t) - 1, label="H") - plt.plot(model.t, model.coupling_operators[0].operator_norm(model.t) * 2, label="cold") - plt.plot(model.t, model.coupling_operators[1].operator_norm(model.t) * 2, label="hot") - plt.legend() + ot.plot_cycle(model) #+end_src #+RESULTS: :RESULTS: -: -[[file:./.ob-jupyter/eebb82a5e335f4dddadad7a2863b41de48f0faf2.svg]] +|
| | +[[file:./.ob-jupyter/16e356aa8afc7a911b3edcfccea6559fe028821c.svg]] :END: + #+begin_src jupyter-python - ω = np.linspace(.01, 3, 1000) - plt.plot(ω, model.full_thermal_spectral_density(0)(ω) * model.bcf_scales[0]) - plt.plot(1, model.full_thermal_spectral_density(0)(1) * model.bcf_scales[0], marker="o") - plt.plot(ω, model.full_thermal_spectral_density(1)(ω) * model.bcf_scales[1]) - plt.plot(2, model.full_thermal_spectral_density(1)(2) * model.bcf_scales[1], marker="o") + ot.plot_sd_overview(model) #+end_src #+RESULTS: :RESULTS: -| | -[[file:./.ob-jupyter/ee3ba754fa0f582037a99ec2f42d470f971fe91d.svg]] +|
| | +[[file:./.ob-jupyter/dc9e4dff3bc359892e01587cbcba157708c27487.svg]] :END: * Integration -:LOGBOOK: -CLOCK: [2022-11-30 Wed 16:27] -:END: #+begin_src jupyter-python :tangle nil - aux.integrate(model, 10_000, stream_file="results.fifo", analyze=True) + aux.integrate(model, 100, stream_file="results.fifo", analyze=True) #+end_src +#+RESULTS: +: [INFO hops.core.integration 403378] Choosing the nonlinear integrator. +: [INFO root 403378] Starting analysis process. +: [INFO root 403378] Started analysis process with pid 447894. +: [INFO hops.core.hierarchy_data 403378] Creating the streaming fifo at: /home/hiro/Documents/Projects/UNI/master/eflow_paper/python/otto_motor/results.fifo +: [INFO hops.core.integration 403378] Using 16 integrators. +: [INFO hops.core.integration 403378] Some 0 trajectories have to be integrated. +: [INFO hops.core.integration 403378] Using 1820 hierarchy states. +: 0it [00:00, ?it/s] + + #+begin_src jupyter-python :tangle nil f, a = pu.plot_energy_overview(model, strobe_frequency=model.Ω, hybrid=True, bath_names=["C","H"], online=True) - - a.plot(model.t, model.coupling_operators[0].operator_norm(model.t), linestyle="dashed", label="Mod Cold") - a.plot(model.t, model.coupling_operators[1].operator_norm(model.t), linestyle="dashed", label="Mod Hot") - a.plot(model.t, model.H.operator_norm(model.t) - 1, linestyle="dashed", label="Mod H") # a.set_xlabel(r"$\tau$") # a.plot(model.t, model.coupling_operators[0].operator_norm(model.t), label="cold") a.legend() @@ -109,6 +124,6 @@ CLOCK: [2022-11-30 Wed 16:27] #+RESULTS: :RESULTS: -: -[[file:./.ob-jupyter/24a2a15398d054ad800997d31485ea871537e98c.svg]] +: +[[file:./.ob-jupyter/c7e0e16b981d66a30d3686f1d753d1319794b083.svg]] :END: diff --git a/python/otto_motor/otto_baseline.py b/python/otto_motor/otto_baseline.py index d0c4d61..b7fd19d 100644 --- a/python/otto_motor/otto_baseline.py +++ b/python/otto_motor/otto_baseline.py @@ -8,45 +8,60 @@ import qutip as qt import utilities as ut import stocproc import matplotlib.pyplot as plt +import otto_utilities as ot import ray ray.shutdown() -#ray.init(address='auto') -ray.init() +ray.init(address='auto') +#ray.init() from hops.util.logging_setup import logging_setup import logging logging_setup(logging.INFO) -plt.rcParams['figure.figsize'] = (16,8) +plt.rcParams['figure.figsize'] = (12,4) model = OttoEngine( - δ=[.4, .4], + δ=[0.4, 0.4], ω_c=[1, 1], ψ_0=qt.basis([2], [1]), - description=f"An otto cycle on the way to finding the baseline.", + description=f"A basic near-markovian, weakly coupled Otto Cycle that actually works.", k_max=4, - bcf_terms=[6]*2, + bcf_terms=[6] * 2, truncation_scheme="simplex", - driving_process_tolerances=[StocProcTolerances(1e-3, 1e-3)] * 2, - thermal_process_tolerances=[StocProcTolerances(1e-3, 1e-3)] * 2, - T = [1, 10], + driving_process_tolerances=[StocProcTolerances(1e-4, 1e-4)] * 2, + thermal_process_tolerances=[StocProcTolerances(1e-4, 1e-4)] * 2, + T=[1, 10], therm_methods=["tanhsinh", "fft"], Δ=1, num_cycles=5, - Θ=1/.05, - dt=.001, - timings_H=(0, .1, .5, .6), - timings_L=((.6, .7, .9, 1), (.1, .2, .4, .5)), + Θ=1.5 / 0.05, + dt=0.001, + timings_H=(0, 0.1, 0.5, 0.6), + timings_L=((0.6, 0.7, 0.9, 1), (0.1, 0.2, 0.4, 0.5)), streaming_mode=True, ) -plt.plot(model.t, model.H.operator_norm(model.t) - 1, label="H") -plt.plot(model.t, model.coupling_operators[0].operator_norm(model.t) * 2, label="cold") -plt.plot(model.t, model.coupling_operators[1].operator_norm(model.t) * 2, label="hot") -plt.legend() +# model = OttoEngine( +# δ=[0.4, 0.4], +# ω_c=[1, 1], +# ψ_0=qt.basis([2], [1]), +# description=f"An otto cycle on the way to finding the baseline.", +# k_max=3, +# bcf_terms=[4] * 2, +# truncation_scheme="simplex", +# driving_process_tolerances=[StocProcTolerances(1e-3, 1e-3)] * 2, +# thermal_process_tolerances=[StocProcTolerances(1e-3, 1e-3)] * 2, +# T=[1, 10], +# therm_methods=["tanhsinh", "fft"], +# Δ=1, +# num_cycles=4, +# Θ=1.5 / 0.05, +# dt=0.001, +# timings_H=(0, 0.1, 0.3, 0.4), +# timings_L=((0.4, 0.5, 0.9, 1), (0.1, 0.11, 0.29, 0.3)), +# streaming_mode=True, +# ) -ω = np.linspace(.01, 3, 1000) -plt.plot(ω, model.full_thermal_spectral_density(0)(ω) * model.bcf_scales[0]) -plt.plot(1, model.full_thermal_spectral_density(0)(1) * model.bcf_scales[0], marker="o") -plt.plot(ω, model.full_thermal_spectral_density(1)(ω) * model.bcf_scales[1]) -plt.plot(2, model.full_thermal_spectral_density(1)(2) * model.bcf_scales[1], marker="o") +ot.plot_cycle(model) + +ot.plot_sd_overview(model) diff --git a/python/otto_motor/poetry.lock b/python/otto_motor/poetry.lock index 0a73a6a..72f26b6 100644 --- a/python/otto_motor/poetry.lock +++ b/python/otto_motor/poetry.lock @@ -135,7 +135,7 @@ test-tox-coverage = ["coverage (>=5.5)"] type = "git" url = "https://github.com/beartype/beartype" reference = "main" -resolved_reference = "8f33d55d7673dc7f2e57216ed03e27d9b971f443" +resolved_reference = "91d1d89c8015ba75a3c990e2ab6b93e9c61f8651" [[package]] name = "beautifulsoup4" @@ -508,7 +508,7 @@ qutip = "^4.6.3" type = "git" url = "git@github.com:vale981/two_qubit_model.git" reference = "main" -resolved_reference = "256ada3d767b93bec1bb340d89c947f966c8cab1" +resolved_reference = "5d901b0878e738cb03ce17ceee910db240f1607a" [[package]] name = "hops" @@ -569,7 +569,7 @@ tqdm = "^4.62.3" type = "git" url = "https://github.com/vale981/hopsflow" reference = "main" -resolved_reference = "5afd2b6e081591350739b4c483dc0bf356a80b2a" +resolved_reference = "51a55945cc1953442c8d10852a3793fb0414c853" [[package]] name = "humanfriendly"