# tgrape.m

A special case of Gradient Ascent Pulse Engineering (GRAPE) objective function and gradient with respect to the vector of waveform slice durations.

## Syntax

[fidelity,grad]=tgrape(spin_system,drift,controls,waveform,... dt_grid,time_unit,rho_init,rho_targ)

## Arguments

drift - the drift Liouvillian, a matrix controls - control operators, a cell array of matrices waveform - control coefficients for each control operator (columns) at each time slice (rows), rad/s dt_grid - time slice durations, a row vector in the units of time chosen so that the elements are of the order of 1 time_unit - unit of time, seconds; this is needed because optimisers get stuck when the variables are badly scaled rho_init - initial state of the system, a column vector rho_targ - target state of the system, a column vector

## Outputs

fidelity - fidelity of the control sequence grad - gradient of the fidelity with respect to the durations of the slices

## Notes

At the moment, the function is not integrated with the rest of the optimal control module - use Matlab's optimisers (fmincon, fminunc, etc.).

## See also

*Version 2.7, authors: Ilya Kuprov*