optimcon.m

From Spinach Documentation Wiki
Jump to: navigation, search

Validates optimal control options and updates the spin_system object.

Syntax

    spin_system=optimcon(spin_system,control)

Parameters

    spin_system  - primary Spinach data structure,
                   created by create.m and updated
                   by basis.m functions

    control      - control data structure described 
                   in detail in the online manual

Outputs

    spin_system  - updated Spinach data structure

Examples

See the examples given in examples/optimal_control directory. A fairly typical control parameter structure appears below.

    % Define control parameters
    control.drifts={{H}};                           % Drift
    control.operators={LxH,LyH,LxC,LyC,LxF,LyF};    % Controls
    control.rho_init={rho_init};                    % Starting state
    control.rho_targ={rho_targ};                    % Destination state
    control.pwr_levels=2*pi*1e3;                    % Pulse power
    control.pulse_dur=10e-3;                        % Pulse duration
    control.pulse_nsteps=50;                        % Time points
    control.penalties={'SNS'};                      % Penalty
    control.p_weights=100;                          % Penalty weight
    control.method='newton';                        % Optimisation method
    control.tol_g=1e-5;                             % Termination tolerance
    control.freeze=zeros(6,50);                     % Freeze mask

    % Plots during optimisation
    control.plotting={'correlation_order','local_each_spin','xy_controls'};

Notes

This function freezes the optimisation problem. The ensemble case catalog is built here, its cases are assigned to the parallel pool workers in contiguous blocks recorded in spin_system.control.worker_cases, and the frozen problem is published to the workers exactly once: the common part as a parallel.pool.Constant in spin_system.control.invariants, the drift generators as a parallel.pool.Constant built from a per-worker Composite in spin_system.control.drift_slices, so that each worker receives the drifts of its own case block and nothing else; the pool must therefore have SpmdEnabled set to true. Heavy invariants - the drift generators, the control operators, the offset operators, the control commutators, and the Bloch-Siegert response operators - are then removed from the returned structure, and their names are recorded in spin_system.control.frozen_fields. All other control fields stay live: ensemble() re-sends them to the workers at every evaluation, and they may be overwritten between optimisations. Changes to the ensemble composition, the operators, or the generators require a fresh optimcon() call.

The plotting should be switched off for large production calculations - optimal control diagnostic plots are computationally expensive.

See also

create.m, basis.m, alpha_conds.m, aux_mat.m, bfgs.m, cubic_interp.m, dirdiff.m, drifts.m, ens_block.m, ensemble.m, hess_reorder.m, mas_drifts.m, objeval.m, trapdiff.m, Optimal control module

Version 2.4, authors: Ilya Kuprov, David Goodwin