Difference between revisions of "Grape liouv.m"

From Spinach Documentation Wiki
Jump to: navigation, search
m (title letter case change)
 
(sync with Spinach main 3975f139: trajectory cost terms)
 
(22 intermediate revisions by 3 users not shown)
Line 1: Line 1:
−
{{DISPLAYTITLE:grape.m}}
+
{{DISPLAYTITLE:grape_liouv.m}} __NOTOC__
 +
Gradient Ascent Pulse Engineering (GRAPE) objective function, gradient, and Hessian. Propagates the system through a user-supplied shaped pulse from a given initial state and projects the result onto the given final state. The fidelity is returned, along with its gradient and Hessian with respect to amplitudes of all control operators at every time step of the shaped pulse. Uses Liouville-space formalism.
  
−
This is the GRadient Ascent Pulse Engineering function; utilising the piecewise constant approximation in state to state transfer. Syntax:
+
==Syntax==
  
−
    [diag_data,total_objective,total_grad,total_hess]=...
+
        [traj_data,fidelity,...
−
          grape(spin_system,drift,controls,waveform,time_step,nsteps,...
+
        grad,hess]=grape_liouv(spin_system,drifts,controls,...
−
          initial_state_array,target_state_array,power_level)
+
                                waveform,rho_init,rho_targ,...
 +
                                fidelity_type)
  
−
=Inputs=
+
==Parameters==
−
{| class="wikitable"
 
−
|'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=
+
  spin_system        - Spinach data object that has been through
−
{| class="wikitable"
+
                        the [[optimcon.m]] problem setup function.
−
|'total_objective'
+
−
|the value of the GRAPE objective function.
+
  drifts              - the drift Liouvillians: a cell array con-
−
|-
+
                        taining one matrix (for time-independent
−
|'total_grad'
+
                        drift) or multiple matrices (one per time
−
|the gradient of the objective function with respect to control amplitudes.
+
                        slice / point, for time-dependent drift).
−
|-
+
−
|'total_hess'
+
  controls            - control operators in Liouville space (cell
−
|the Hessian of the objective function with respect to control amplitudes when
+
                        array of matrices).
−
using the Newton‐Raphson method.
+
−
|-
+
  waveform            - control coefficients for each control ope-
−
|'diag_data'
+
                        rator (in vertical dimension) at each time
−
|diagnostics data structure, containing complete information about the calculation. It has the following self‐explanatory fields:
+
                        slice / point (horizonal dimension), rad/s
 +
 +
  rho_init            - initial state of the system as a vector in
 +
                        Liouville space, ignored in stroboscopic
 +
                        steady state optimisations.
 +
 +
  rho_targ            - target state of the system as a vector in
 +
                        Liouville space.
 +
 +
  fidelity_type      - 'real'   (real part of the overlap)
 +
                        'imag'  (imaginary part of the overlap)
 +
                        'square' (absolute square of the overlap)
  
−
diag_data.initial_state_array
+
==Returns==
  
−
diag_data.target_state_array
+
  fidelity            - fidelity of the control sequence
 +
 +
  grad                - gradient of the fidelity with respect to
 +
                        the control sequence
 +
 +
  hess                - Hessian of the fidelity with respect to
 +
                        the control sequence, not available for
 +
                        piecewise-linear and stroboscopic stea-
 +
                        dy state optimisations
 +
 +
  traj_data.forward  - forward trajectory from the initial con-
 +
                        dition or stroboscopic steady state (a
 +
                        stack of state vectors); this is returned
 +
                        only when requested by the control settings
  
−
diag_data.total_objective
+
==Notes==
 +
This is a low level function that is not designed to be called directly. Use [[grape_xy.m]], [[grape_phase.m]], or other wrapper functions instead.
  
−
diag_data.spin_system
+
Trajectory cost terms are read from spin_system.control: when fid_type is 'average', the fidelity is averaged over the pulse nodes 1..N instead of being taken at the last node; traj_pen operators are summed, their expectation value is averaged over the same nodes and subtracted from the fidelity. Both terms use costates that ride on the backward sweep, the trajectory never leaves the worker. Hessians are not available with these terms.
  
−
diag_data.power_level
+
==See also==
 +
[[dirdiff.m]], [[step.m]], [[optimcon.m]], [[grape_xy.m]], [[grape_phase.m]], [[penalty.m]], [[grape_coop.m]], [[grape_curv.m]], [[grape_hilb.m]], [[tgrape.m]], [[Optimal_control_module]]
  
−
diag_data.trajectory
+
''Version 2.2, authors: [[Ilya Kuprov]], [[David Goodwin]], [[Uluk Rasulov]], [[Maxi Keitel]]''
−
 
 
−
diag_data.total_grad
 
−
 
 
−
diag_data.total_hess
 
−
 
 
−
diag_data.time_step
 
−
 
 
−
diag_data.controls
 
−
 
 
−
diag_data.waveform
 
−
 
 
−
diag_data.nsteps
 
−
 
 
−
diag_data.drift
 
−
|}
 

Latest revision as of 09:59, 18 September 2026

Gradient Ascent Pulse Engineering (GRAPE) objective function, gradient, and Hessian. Propagates the system through a user-supplied shaped pulse from a given initial state and projects the result onto the given final state. The fidelity is returned, along with its gradient and Hessian with respect to amplitudes of all control operators at every time step of the shaped pulse. Uses Liouville-space formalism.

Syntax

       [traj_data,fidelity,...
        grad,hess]=grape_liouv(spin_system,drifts,controls,...
                               waveform,rho_init,rho_targ,...
                               fidelity_type)

Parameters

  spin_system         - Spinach data object that has been through 
                        the optimcon.m problem setup function.

  drifts              - the drift Liouvillians: a cell array con-
                        taining one matrix (for time-independent 
                        drift) or multiple matrices (one per time
                        slice / point, for time-dependent drift).

  controls            - control operators in Liouville space (cell 
                        array of matrices).

  waveform            - control coefficients for each control ope-
                        rator (in vertical dimension) at each time
                        slice / point (horizonal dimension), rad/s

  rho_init            - initial state of the system as a vector in
                        Liouville space, ignored in stroboscopic
                        steady state optimisations.

  rho_targ            - target state of the system as a vector in
                        Liouville space.

  fidelity_type       - 'real'   (real part of the overlap)
                        'imag'   (imaginary part of the overlap)
                        'square' (absolute square of the overlap)

Returns

  fidelity            - fidelity of the control sequence

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

  hess                - Hessian of the fidelity with respect to 
                        the control sequence, not available for
                        piecewise-linear and stroboscopic stea-
                        dy state optimisations

  traj_data.forward   - forward trajectory from the initial con-
                        dition or stroboscopic steady state (a 
                        stack of state vectors); this is returned
                        only when requested by the control settings

Notes

This is a low level function that is not designed to be called directly. Use grape_xy.m, grape_phase.m, or other wrapper functions instead.

Trajectory cost terms are read from spin_system.control: when fid_type is 'average', the fidelity is averaged over the pulse nodes 1..N instead of being taken at the last node; traj_pen operators are summed, their expectation value is averaged over the same nodes and subtracted from the fidelity. Both terms use costates that ride on the backward sweep, the trajectory never leaves the worker. Hessians are not available with these terms.

See also

dirdiff.m, step.m, optimcon.m, grape_xy.m, grape_phase.m, penalty.m, grape_coop.m, grape_curv.m, grape_hilb.m, tgrape.m, Optimal_control_module

Version 2.2, authors: Ilya Kuprov, David Goodwin, Uluk Rasulov, Maxi Keitel