grape.m

From Spinach Documentation Wiki
Revision as of 19:01, 25 August 2016 by Goodwin (talk | contribs) (basics of grape.m (outdated))

Jump to: navigation, search


Gradient Ascent Pulse Engineering (GRAPE) objective function and gradient. Propagates the system through a user‐supplied shaped pulse from a given initial state and projects the result onto the given final state. The real part of the projection is returned, along with its gradient with respect to amplitudes of all operators in every step of the shaped pulse.

    [diag_data,total_objective,total_grad,total_hess]=...
         grape(spin_system,drift,controls,waveform,time_step,nsteps,...
         initial_state_array,target_state_array,power_level)

Four derivative calculation methods are available: Hausdorff series, second order central finite difference, fourth order central finite difference and Sophie Schirmer's expm algorithm. The default (Sophie's algorithm) is fast and accurate to machine precision. Sophie Schirmer’s expm algorithm is the only option for the Newton‐Raphson method.

Inputs

'spin_system' A spin system created with Spinach should always be passed to the grape optimal control module.
'drift' the "drift" Liouvillian: couplings, relaxation and other things that continue operating while the pulse is being executed.
'controls' a cell array of commutation superoperators whose coefficients are getting modulated by the pulse, e.g. {Lx,Ly}.
'waveform' matrix of doubles with n_controls rows and n_steps columns, where n_controls is the number of control operators and n_steps is the number of steps in the waveform. The waveform should be specified as fractions of the total power level, which is specified separately.
'time_step' waveform time step, in seconds.
'nsteps' number of time steps in the waveform.
'initial_state_array' cell array of initial state vectors (if multiple sources and targets are supplied, the resulting objective function and the gradient are sums over these source‐target pairs).
'target_state_array' a cell array of target state vectors (if multiple sources and targets are supplied, the resulting objective function and the gradient are sums over these source‐target pairs).
'power_level' nominal power level, in units of angular frequency. The waveform values should be specified as fractions of this power level.

Four derivative calculation methods are available: Hausdorff series, second order central finite difference, fourth order central finite difference and Sophie Schirmer's expm algorithm. The default (Sophie's algorithm) is fast and accurate to machine precision. Sophie Schirmer’s expm algorithm is the only option for the Newton‐Raphson method.

Outputs

'total_objective' the value of the GRAPE objective function.
'total_grad' the gradient of the objective function with respect to control amplitudes.
'total_hess' the Hessian of the objective function with respect to control amplitudes when

using the Newton‐Raphson method.

'diag_data' diagnostics data structure, containing complete information about the calculation. It has the following self‐explanatory fields:

diag_data.initial_state_array

diag_data.target_state_array

diag_data.total_objective

diag_data.spin_system

diag_data.power_level

diag_data.trajectory

diag_data.total_grad

diag_data.total_hess

diag_data.time_step

diag_data.controls

diag_data.waveform

diag_data.nsteps

diag_data.drift