Protocols

The protocols described here specify which methods a class must implement such that it can be used for a specific purpose.

The hierarchy of the protocols for quantum systems is shown in the following diagram.

../_images/Protocols.png
class Evolvable(*args, **kwargs)[source]

Minimal interface for a system that can be time evolved.

Used by rydopt.simulation.evolve().

initial_basis_states()[source]

The initial basis states \((1, 0, ...)\) of appropriate dimension.

Returns:

Tuple of initial basis states.

Return type:

tuple[Array, …]

hamiltonian_functions_for_basis_states()[source]

The Hamiltonian under which the initial basis states evolve.

A separate Hamiltonian function is returned for each initial basis state. In the case of a block-diagonal Hamiltonian, this allows for returning only the block that is of relevance for a particular basis state.

Returns:

Tuple of Hamiltonian functions.

Return type:

tuple[TypeAliasForwardRef(‘HamiltonianFunction’), …]

class Optimizable(*args, **kwargs)[source]

Minimal interface for a system that can be optimized.

Used by rydopt.optimization.optimize().

cost(pulse, params, tol)[source]

Evaluate the cost function for a pulse ansatz and parameters.

Parameters:
  • pulse (PulseAnsatzT) – Pulse description, typically a SinglePhotonPulseAnsatz or PulseFamilyAnsatz.

  • params (ParamsFloatLike) – Pulse or pulse-family parameters.

  • tol (float) – Numerical tolerance used when evaluating the cost.

Returns:

Cost function value.

Return type:

Array

class GateSystem(*args, **kwargs)[source]

Interface for gates that can be optimized for process fidelity. The interface is derived from Evolvable and Optimizable. Additionally, methods are present for calculating fidelities from time-evolved basis states.

Used by rydopt.simulation.process_fidelity(), rydopt.simulation.average_gate_fidelity(), rydopt.optimization.optimize(), rydopt.characterization.analyze_gate(), and rydopt.characterization.analyze_gate_qutip().

process_fidelity_helper(final_basis_states)[source]

Given the basis states evolved under the pulse, this function calculates the fidelity with respect to the gate’s target state, specified by the gate angles \(\phi, \, \theta, \, \ldots\)

Parameters:

final_basis_states (tuple[Array, ...]) – Time-evolved basis states.

Returns:

Fidelity with respect to the target state.

Return type:

Array

dim()[source]

Hilbert space dimension.

Returns:

Dimensionality \(2^n\), where \(n\) is the number of atoms.

Return type:

int

class RydbergSystem(*args, **kwargs)[source]

Interface for Evolvables that utilize Rydberg states. The interface is derived from Evolvable. Additionally, methods are present for calculating the time spent in Rydberg states during time evolution.

Used by rydopt.simulation.rydberg_time(), rydopt.characterization.analyze_gate(), and rydopt.characterization.analyze_gate_qutip().

rydberg_population_operators_for_basis_states()[source]

For each basis state, the Rydberg population operators count the number of Rydberg excitations on the diagonal.

Returns:

Tuple of operators.

Return type:

tuple[Array, …]

rydberg_time(expectation_values_of_basis_states)[source]

Given the expectation values of Rydberg populations for each basis state, integrated over the full pulse, this function calculates the average time spent in Rydberg states during the gate.

Parameters:

expectation_values_of_basis_states (tuple[Array, ...]) – Expected Rydberg times for each basis state.

Returns:

Averaged Rydberg time \(T_R\).

Return type:

Array

with_decay(decay)[source]

Creates a copy of the gate with a new decay strength.

Parameters:

decay (float) – New decay strength \(\gamma/\Omega_0\).

Returns:

A copy of the gate object with the new decay strength.

Return type:

Self

class PulseAnsatz(*args, **kwargs)[source]

Interface for pulse ansatz classes, except for rydopt.pulses.PulseFamilyAnsatz, which has no evaluate_pulse_functions method.

evaluate_pulse_functions(t, params)[source]

Evaluate the pulse functions at the specified times.

Parameters:
  • t (float | Array) – Time samples at which the pulse functions are evaluated.

  • params (ParamsFloatLike) – Pulse or pulse-family parameters.

Returns:

Tuple (detuning_1, detuning_r, phase, rabi).

Return type:

tuple[Array, Array, Array, Array]

unpack_params(trainable_params)[source]

Convert trainable parameters to a structured parameter container.

Parameters:

trainable_params (ParamsFloatLike) – Packed or unpacked pulse parameters.

Returns:

A PulseParams instance with parameters restored to their original shapes.

Return type:

PulseParamsT