grape (GRadient Ascent Pulse Engineering)#

GRadient Ascent Pulse Engineering (GRAPE)

feedback_grape.grape.optimize_pulse(H_drift: Array, H_control: list[Array], U_0: Array, C_target: Array, num_t_slots: int, total_evo_time: float, evo_type: str, ctrl_amp_lower_bound: float = -0.3141592653589793, ctrl_amp_upper_bound: float = 0.3141592653589793, c_ops: list[Array] = [], max_iter: int = 1000, convergence_threshold: float = 1e-06, learning_rate: float = 0.01, optimizer: str = 'adam', propcomp: str = 'time-efficient', progress: bool = False) result#

Uses GRAPE to optimize a pulse.

Parameters:
  • H_drift – Drift Hamiltonian.

  • H_control – List of Control Hamiltonians.

  • U_0 – Initial state or unitary/density matrix.

  • C_target – Target state or unitary/density matrix.

  • num_t_slots – Number of time slots.

  • total_evo_time – Total evolution time.

  • evo_type

    Type of fidelity and evolution calculation (“unitary” or “state” or “density”).

    Options:
    • ”unitary”: For unitary evolution.

    • ”state”: For state evolution.

    • ”density”: For density matrix evolution.

  • ctrl_amp_lower_bound

    Lower bound for control amplitudes initialization

    • (default: -2 * jnp.pi * 0.05).

  • ctrl_amp_upper_bound

    Upper bound for control amplitudes initialization

    • (default: 2 * jnp.pi * 0.05).

  • c_ops

    List of collapse operators (optional, used for dissipative evolution)

    • (default: []).

  • max_iter

    Maximum number of iterations

    • (default: 1000).

  • convergence_threshold

    Convergence threshold provide None to enforce max iterations

    • (default: 1e-6).

  • learning_rate

    Learning rate for gradient ascent

    • (default: 0.01)

  • optimizer

    Optimizer to use (“adam” or “L-BFGS”)

    • (default: “adam”)

  • propcomp

    Propagator computation method (“time-efficient” or “memory-efficient”)

    • (default: “time-efficient”).

  • progress

    Whether to show progress (cost every 10 iterations) during optimization. (for debugging purposes) This may significantly slow down the optimization process

    • (default: False).

Returns:

NamedTuple containing optimized pulse and convergence data.

Return type:

result

feedback_grape.grape.plot_control_amplitudes(times, final_amps, labels)#

Plot control amplitudes with fixed y-axis scale highlighting each control amplitude with respect to the other in its respective plot.

Parameters:
  • times – Time points for the x-axis.

  • final_amps – Control amplitudes to plot.

  • labels – Labels for each control amplitude.

class feedback_grape.grape.result(control_amplitudes: Array, final_fidelity: float, iterations: int, final_operator: Array)#

Bases: NamedTuple

result class to store the results of the optimization process.

control_amplitudes: Array#

Optimized control amplitudes.

final_fidelity: float#

Final fidelity of the optimized control.

final_operator: Array#

Final operator after applying the optimized control amplitudes.

iterations: int#

Number of iterations taken for optimization.