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_constructorhas to return a list of states
f_ocreturning a list of floats doesn't make sense)
f_octhat returns a the value of the functional as a number (but that doesn't get passed to
chis_octhat returns a list of of states obtained from
print_table(https://krotov.readthedocs.io/en/stable/API/krotov.info_hooks.html) have an
chaintogether two calls of e.g.
print_table, one with the default
stdoutand one pointing to a file handle.
argskeyword 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]]
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
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
guess_control. That means that currently,
argsin any control function is a no-op (which is exactly why I wish QuTiP didn't require it).
ampl0is the kind of parameter you would normally put in
args. As you can see, here the value is set by a closure instead (
guess_controlkeeps a hidden reference to
ampl0from its surrounding scope
hamiltonian, even after
hamiltonianreturns). This is the current "official" solution for static parameters in a control. I would not recommend using global variables
optimize_pulsesthat gets passed to the control function. I'll consider this for the next version.
argsin 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_pulsesto add the
argsdict 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.