ens_block.m
Fidelity, gradient, and Hessian contributions of one block of ensemble cases, evaluated on the parallel pool worker that holds the drift generators of that block. This function is called by ensemble.m inside its spmd block; the per-case physics (phase cycle, offsets, power level, waveform distortions, GRAPE) is applied here. The live client-side control structure is grafted over the frozen worker copy of the problem, keeping the fields that only the worker holds; the GRAPE function is chosen by the formalism (grape_liouv.m for sphten-liouv, zeeman-liouv, and zeeman-wavef, grape_hilb.m for zeeman-hilb). For each case of the block, the phase cycle line rotates the control channels and multiplies the initial and target states by its phases, the offset terms are added to the drift with the first channel index running fastest, the waveform is moved into physical units by the power level, and the distortion functions are applied with their Jacobians when derivatives are needed; the gradient of each case is pulled back through the Jacobian, the phase cycle rotation, and the power level, and the Hessian through the phase cycle rotation and the power level squared. The gradients and the Hessians are summed over the block. When control.traj_opts contains 'average', the forward trajectories of the block are summed into one structure.
Syntax
[traj,fid,grad,hess]=ens_block(spin_system,drifts,control,...
block,waveform,n_outputs)
Parameters
spin_system - frozen problem published by optimcon.m, with
the drift generators removed
drifts - cell array of drift generators, populated at
the indices that the cases of this block use
control - live client-side control structure
block - index of the case block, into the cell array
spin_system.control.worker_cases
waveform - control coefficients for each control opera-
tor, [ncontrols x nsteps], rad/s
n_outputs - number of outputs requested from ensemble.m,
2 for the fidelity, 3 for the gradient, 4 for
the Hessian
Outputs
traj - cell array of trajectory structures, one per
case of the block in block order; when the
control.traj_opts contains 'average', one
structure holding the sum over the block, or
an empty cell for an empty block
fid - [1 x n_block] array of case fidelities
grad - sum of the case gradients over the block, a
[ncontrols*nsteps x 1] column, empty unless
n_outputs>2
hess - sum of the case Hessians over the block, a
[(ncontrols*nsteps)^2 x 1] column, empty un-
less n_outputs>3
Notes
This is a low level function that is not designed to be called directly; ensemble.m calls it on the workers. Hessians are only available with the rectangle integrator and without waveform distortions; the waveform must have nsteps+1 columns for the trapezium integrator.
See also
ensemble.m, optimcon.m, ens_catalog.m, grape_liouv.m, grape_hilb.m, Optimal control module
Version 2.13, authors: David Goodwin, Ilya Kuprov, Maxi Keitel