code updates

This commit is contained in:
valentin.boettcher@mailbox.tu-dresden.de 2022-12-02 17:46:42 -05:00
parent 42432aa045
commit 57ac62a919
No known key found for this signature in database
GPG key ID: E034E12B7AF56ACE
5 changed files with 220 additions and 49 deletions

View file

@ -0,0 +1,46 @@
import figsaver as fs
import plot_utils as pu
from hiro_models.one_qubit_model import StocProcTolerances
from hiro_models.otto_cycle import OttoEngine
import hiro_models.model_auxiliary as aux
import numpy as np
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()
from hops.util.logging_setup import logging_setup
import logging
logging_setup(logging.INFO)
plt.rcParams['figure.figsize'] = (12,4)
model = OttoEngine(
δ=[0.4, 0.4],
ω_c=[1, 1],
ψ_0=qt.basis([2], [1]),
description=f"A basic near-markovian, weakly coupled Otto Cycle that actually works.",
k_max=4,
bcf_terms=[6] * 2,
truncation_scheme="simplex",
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.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,
)
ot.plot_cycle(model)
ot.full_report(model)

View file

@ -0,0 +1,46 @@
import figsaver as fs
import plot_utils as pu
from hiro_models.one_qubit_model import StocProcTolerances
from hiro_models.otto_cycle import OttoEngine
import hiro_models.model_auxiliary as aux
import numpy as np
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()
from hops.util.logging_setup import logging_setup
import logging
logging_setup(logging.INFO)
plt.rcParams['figure.figsize'] = (12,4)
model = OttoEngine(
δ=[0.4, 0.4],
ω_c=[1, 1],
ψ_0=qt.basis([2], [1]),
description=f"A basic near-markovian, weakly coupled Otto Cycle that actually works.",
k_max=4,
bcf_terms=[6] * 2,
truncation_scheme="simplex",
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.5 / 0.05,
dt=0.001,
timings_H=(0, 0.1, 0.5, 0.6),
timings_L=(None, None),
streaming_mode=True,
)
ot.plot_cycle(model)
ot.integrate_online(model, 5000)

View file

@ -2,7 +2,7 @@
* Boilerplate
#+name: boilerplate
#+begin_src jupyter-python :results none :tangle otto_boilerplate.py
#+begin_src jupyter-python :results none
import figsaver as fs
import plot_utils as pu
from hiro_models.one_qubit_model import StocProcTolerances
@ -73,7 +73,7 @@ A basic otto cycle that has a finite power output.
: [INFO hops.core.integration 143440] Using 1820 hierarchy states.
: 0it [00:00, ?it/s]
#+begin_src jupyter-python :tangle nilorg basics
#+begin_src jupyter-python
ot.full_report(model)
#+end_src
:RESULTS:
@ -135,19 +135,19 @@ A basic otto cycle that has a finite power output without coupling modulation.
:END:
#+begin_src jupyter-python :tangle nil
#+begin_src jupyter-python
ot.integrate_online(model, 5000)
#+end_src
#+RESULTS:
: [INFO hops.core.integration 211210] Choosing the nonlinear integrator.
: [INFO root 211210] Starting analysis process.
: [INFO root 211210] Started analysis process with pid 621102.
: [INFO root 211210] Started analysis process with pid 630343.
: [INFO hops.core.hierarchy_data 211210] Creating the streaming fifo at: /home/hiro/Documents/Projects/UNI/master/eflow_paper/python/otto_motor/results_fea83562df42901b66a85396f98a6c69d504e3a6d3dcc59cb83c5f34ec4077ca.fifo
: [INFO hops.core.integration 211210] Using 32 integrators.
: [INFO hops.core.integration 211210] Some 343 trajectories have to be integrated.
: [INFO hops.core.integration 211210] Some 0 trajectories have to be integrated.
: [INFO hops.core.integration 211210] Using 1820 hierarchy states.
: 100% 343/343 [06:21<00:00, 1.11s/it]
: 0it [00:00, ?it/s]
** Results
:PROPERTIES:

View file

@ -1,45 +1,21 @@
model = OttoEngine(
δ=[0.4, 0.4],
ω_c=[1, 1],
ψ_0=qt.basis([2], [1]),
description=f"A basic near-markovian, weakly coupled Otto Cycle that actually works.",
k_max=4,
bcf_terms=[6] * 2,
truncation_scheme="simplex",
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.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,
)
import figsaver as fs
import plot_utils as pu
from hiro_models.one_qubit_model import StocProcTolerances
from hiro_models.otto_cycle import OttoEngine
import hiro_models.model_auxiliary as aux
import numpy as np
import qutip as qt
import utilities as ut
import stocproc
import matplotlib.pyplot as plt
import otto_utilities as ot
# model = OttoEngine(
# δ=[0.4, 0.4],
# ω_c=[1, 1],
# ψ_0=qt.basis([2], [1]),
# description=f"An otto cycle with longer cooling.",
# 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,
# )
import ray
ray.shutdown()
ot.plot_cycle(model)
ot.plot_sd_overview(model)
ray.init(address='auto')
#ray.init()
from hops.util.logging_setup import logging_setup
import logging
logging_setup(logging.INFO)
plt.rcParams['figure.figsize'] = (12,4)

View file

@ -0,0 +1,103 @@
import matplotlib.pyplot as plt
import plot_utils as pu
from hiro_models.otto_cycle import OttoEngine
import numpy as np
import figsaver as fs
import hiro_models.model_auxiliary as aux
@pu.wrap_plot
def plot_cycle(model: OttoEngine, ax=None):
assert ax is not None
ax.plot(
model.t, model.coupling_operators[0].operator_norm(model.t) * 2, label=r"$L_c$"
)
ax.plot(
model.t, model.coupling_operators[1].operator_norm(model.t) * 2, label=r"$L_h$"
)
ax.plot(
model.t,
(model.H.operator_norm(model.t)) / model.H.operator_norm(model.τ_compressed),
label="H",
)
ax.set_xlim((0, model.Θ))
ax.set_xlabel(r"$\tau$")
ax.set_ylabel(r"Operator Norm")
ax.legend()
@pu.wrap_plot
def plot_sd_overview(model: OttoEngine, ax=None):
assert ax is not None
gaps = model.energy_gaps
ω = np.linspace(0.001, gaps[-1] + gaps[0], 1000)
for ω_i, label, i in zip(gaps, ["Cold", "Hot"], range(len(gaps))):
lines = ax.plot(
ω,
model.full_thermal_spectral_density(i)(ω) * model.bcf_scales[i],
label=f"{label} $T={model.T[i]}$",
)
ax.plot(
ω,
model.spectral_density(i)(ω) * model.bcf_scales[i],
label=f"{label} $T=0$",
color=pu.lighten_color(lines[0].get_color()),
linestyle="--",
)
ax.plot(
ω_i,
model.full_thermal_spectral_density(i)(ω_i) * model.bcf_scales[i],
marker="o",
color=lines[0].get_color(),
)
# 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"
# )
ax.set_xlabel(r"$\omega$")
ax.set_ylabel(r"Spectral Density")
ax.legend()
def full_report(model):
cyc = plot_cycle(model)
sd = plot_sd_overview(model)
f, a = plot_energy(model)
pu.plot_with_σ(model.t, model.total_energy(), ax=a)
power = model.power()
η = model.efficiency() * 100
print(
fs.tex_value(power.value, err=power.σ, prefix="P="),
)
print(
fs.tex_value(η.value, err=η.σ, prefix=r"\eta="),
)
def plot_energy(model):
f, a = pu.plot_energy_overview(
model,
strobe_frequency=model.Ω,
hybrid=True,
bath_names=["Cold", "Hot"],
online=True,
)
a.legend()
return f, a
def integrate_online(model, n):
aux.integrate(model, n, stream_file=f"results_{model.hexhash}.fifo", analyze=True)