goerz on v0.5.0
goerz on master
Bump version to 0.5.0 (update H… (compare)
~/miniconda3/envs/qutip-env/lib/python3.7/site-packages/krotov/optimize.py in <listcomp>(.0)
343 fw_states_T=fw_states_T, objectives=objectives, tau_vals=tau_vals
344 )
--> 345 chi_norms = [chi.norm() for chi in chi_states]
346 # normalizing χ improves numerical stability; the norm then has to be
347 # taken into account when calculating Δϵ
AttributeError: 'numpy.float64' object has no attribute 'norm'
chi_constructor
has to return a list of states
f_oc
returning a list of floats doesn't make sense)
f_oc
that returns a the value of the functional as a number (but that doesn't get passed to optimize_pulses
)
chis_oc
that returns a list of of states obtained from ∂JT/∂⟨ϕ∣
info_hooks
in krotov
, print_debug_information
and print_table
(https://krotov.readthedocs.io/en/stable/API/krotov.info_hooks.html) have an out
parameter
out
chain
together two calls of e.g. print_table
, one with the default out
pointing to stdout
and one pointing to a file handle.args
keyword to mesolve, to change parameters of the time-dependent functions easily. Is krotov currently missing this feature and all parameters in time-depent functions must be defined globally?
def hamiltonian(omega=1.0, ampl0=0.2):
"""Two-level-system Hamiltonian
Args:
omega (float): energy separation of the qubit levels
ampl0 (float): constant amplitude of the driving field
"""
H0 = -0.5 * omega * qutip.operators.sigmaz()
H1 = qutip.operators.sigmax()
def guess_control(t, args):
return ampl0 * krotov.shapes.flattop(
t, t_start=0, t_stop=5, t_rise=0.3, func="blackman"
)
return [H0, [H1, guess_control]]
t
and args
, simply because that is what QuTiP requires. As an aside, I actually think this is a design flaw in QuTiP: it would be much better if controls had the form func(t, **args)
making args
optional.
krotov
, time-dependent controls are converted from the callable to a numpy array of control values on the intervals of the time grid very early on, before the actual optimization starts. In this conversion, currently there are no args
passed to guess_control
. That means that currently, args
in any control function is a no-op (which is exactly why I wish QuTiP didn't require it).
ampl0
is the kind of parameter you would normally put in args
. As you can see, here the value is set by a closure instead (guess_control
keeps a hidden reference to ampl0
from its surrounding scope hamiltonian
, even after hamiltonian
returns). This is the current "official" solution for static parameters in a control. I would not recommend using global variables
args
dict to optimize_pulses
that gets passed to the control function. I'll consider this for the next version.
args
in standard qutip, I am now used to it and have integrated it into my workflow and programming style. I might take a look at optimize_pulses
to add the args
dict manually. Should I do so, I will report back to you.
args
. I've opened a ticket for this at qucontrol/krotov#56 and implemented a potential solution. Let's continue the discussion there.