Difference between revisions of "Grape xy.m"

From Spinach Documentation Wiki
Jump to: navigation, search
(Sync syntax/arguments/outputs with current Spinach source)
(Restore pre-bulk-edit wiki content)
Line 1: Line 1:
 
{{DISPLAYTITLE:grape_xy.m}} __NOTOC__
 
{{DISPLAYTITLE:grape_xy.m}} __NOTOC__
−
 
 
Cost function for optimal control using the GRAPE algorithm. Returns fidelity, gradient and hessian for a given waveform, specified as a list of coefficients in front of the corresponding control operators. All relevant types of control operators are supported: spin, gradients, diffusion, relaxation, ''etc.''
 
Cost function for optimal control using the GRAPE algorithm. Returns fidelity, gradient and hessian for a given waveform, specified as a list of coefficients in front of the corresponding control operators. All relevant types of control operators are supported: spin, gradients, diffusion, relaxation, ''etc.''
  
 
==Syntax==
 
==Syntax==
  
−
[traj_data,fidelity,grad,hess]=grape_xy(waveform,spin_system)
+
    [fidelity,gradient,hessian]=grape_xy(waveform,spin_system)
  
 
==Arguments==
 
==Arguments==
  
−
waveform      - normalised set of control amplitudes.
+
  waveform      - normalised set of control amplitudes.
  
−
==Outputs==
+
==Returns==
−
 
 
−
traj_data    - trajectory data
 
  
 
   fidelity      - figure of merit for the overlap of the current state
 
   fidelity      - figure of merit for the overlap of the current state
Line 20: Line 17:
 
                   ray separating the penalties from the simulation
 
                   ray separating the penalties from the simulation
 
                   fidelity.
 
                   fidelity.
−
 
+
−
   gradient      - gradient of the fidelity with respect to the control
+
   gradient      - gradient of the fidelity with respect to the control  
 
                   sequence. When penalty methods are specified, gradi-
 
                   sequence. When penalty methods are specified, gradi-
 
                   ent is returned as an array separating penalty gra-
 
                   ent is returned as an array separating penalty gra-
 
                   dients from the fidelity gradient.
 
                   dients from the fidelity gradient.
−
 
+
−
   hessian      - Hessian of the fidelity with respect to the control
+
   hessian      - Hessian of the fidelity with respect to the control  
 
                   sequence. When penalty methods are specified, gradi-
 
                   sequence. When penalty methods are specified, gradi-
 
                   ent is returned as an array separating penalty Hes-
 
                   ent is returned as an array separating penalty Hes-
 
                   sians from the fidelity Hessian.
 
                   sians from the fidelity Hessian.
−
 
−
david.goodwin@inano.au.dk
 
−
ilya.kuprov@weizmann.ac.il
 
  
 
==Examples==
 
==Examples==
−
 
 
A typical call would be from an optimisation function (see examples/optimal_control):  
 
A typical call would be from an optimisation function (see examples/optimal_control):  
  
Line 42: Line 35:
  
 
==Notes==
 
==Notes==
−
 
+
The fidelity, the gradient and the Hessian may be supplied to any optimisation routine, including those in the Optimisation Toolbox of Matlab.  
−
The fidelity, the gradient and the Hessian may be supplied to any optimisation routine, including those in the Optimisation Toolbox of Matlab.
 
  
 
==See also==
 
==See also==
−
 
 
[[Optimal control module]]
 
[[Optimal control module]]
  
  
 
''Version 2.2, authors: [[Ilya Kuprov]], [[David Goodwin]]''
 
''Version 2.2, authors: [[Ilya Kuprov]], [[David Goodwin]]''
−
 
−
==Returns==
 
−
 
−
fidelity      - figure of merit for the overlap of the current state
 
−
                  of the system and the desired state(s). When penalty
 
−
                  methods are specified, fidelity is returned as an ar-
 
−
                  ray separating the penalties from the simulation
 
−
                  fidelity.
 
−
 
−
  gradient      - gradient of the fidelity with respect to the control
 
−
                  sequence. When penalty methods are specified, gradi-
 
−
                  ent is returned as an array separating penalty gra-
 
−
                  dients from the fidelity gradient.
 
−
 
−
  hessian      - Hessian of the fidelity with respect to the control
 
−
                  sequence. When penalty methods are specified, gradi-
 
−
                  ent is returned as an array separating penalty Hes-
 
−
                  sians from the fidelity Hessian.
 

Revision as of 14:48, 5 April 2026

Cost function for optimal control using the GRAPE algorithm. Returns fidelity, gradient and hessian for a given waveform, specified as a list of coefficients in front of the corresponding control operators. All relevant types of control operators are supported: spin, gradients, diffusion, relaxation, etc.

Syntax

    [fidelity,gradient,hessian]=grape_xy(waveform,spin_system)

Arguments

  waveform      - normalised set of control amplitudes.

Returns

  fidelity      - figure of merit for the overlap of the current state
                  of the system and the desired state(s). When penalty
                  methods are specified, fidelity is returned as an ar-
                  ray separating the penalties from the simulation
                  fidelity.

  gradient      - gradient of the fidelity with respect to the control 
                  sequence. When penalty methods are specified, gradi-
                  ent is returned as an array separating penalty gra-
                  dients from the fidelity gradient.

  hessian       - Hessian of the fidelity with respect to the control 
                  sequence. When penalty methods are specified, gradi-
                  ent is returned as an array separating penalty Hes-
                  sians from the fidelity Hessian.

Examples

A typical call would be from an optimisation function (see examples/optimal_control):

    % Run the optimization
    fminnewton(spin_system,@grape_xy,guess);

Notes

The fidelity, the gradient and the Hessian may be supplied to any optimisation routine, including those in the Optimisation Toolbox of Matlab.

See also

Optimal control module


Version 2.2, authors: Ilya Kuprov, David Goodwin