paraqeet.signal.envelopes.DCRABEnvelope#

class paraqeet.signal.envelopes.DCRABEnvelope(amplitude=None, t_final=None, num_components=2, min_frequency=0.0, max_frequency=31.41592653589793, seed=None)[source]#

Bases: Envelope

Create a dCRAB pulse envelope.

The dCRAB pulse is given as a sum of sinusoidal components as [Müller2022]

\[f(t) = g(t)( 1 + \sum_{i=1}^{N_c / 2} c_{2i} \frac{\cos(\omega_{2i} t)}{\Lambda(t)} + \sum_{i = 1} ^ {N_c/2} c_{2i + 1} \frac{\sin(\omega_{2i + 1} t)}{\Lambda(t)} )\]

Here we consider \(g(t) = \Lambda(t) = 1\) for simplicity. Further, even components are for cosine and odd components are for sine. Note - The function is designed to work well for even total number of components. For odd total number it may not work as expected.

[Müller2022] Müller et al. “One decade of quantum optimal control in the chopped random basis”

_amplitude: Quantity

The amplitude of the envelope.

_t_final: Quantity

The length in time of the envelope.

_num_components: int

Number of components added each iteration to the dCRAB basis. Defaults to 2. Advised to be an even number.

_total_num_components: int

Total number of components in the current dCRAB basis. This is the number of coefficients or the number of frequencies present. NOT the sum of them.

_real_coefficients: list[Quantity]

Vector quantity as a list of amplitudes of individual sinusoidal components.

_real_frequencies: list[Quantity]

Vector quantity as a list of frequencies of individual sinusoidal components.

_real_phases: list[Quantity]

Vector quantity as a list of phases of individual sinusoidal components.

_gradient_function: Callable | None

The function to calculate the gradient with respect to a set of previously defined parameters.

_grad_arg_nums: tuple[int, …]

The identifying indices of which parameters to calculate the gradient with respect to.

Parameters:
  • amplitude (Quantity | None)

  • t_final (Quantity | None)

  • num_components (int)

  • min_frequency (float)

  • max_frequency (float)

  • seed (int | None)

__init__(amplitude=None, t_final=None, num_components=2, min_frequency=0.0, max_frequency=31.41592653589793, seed=None)[source]#
Parameters:
  • amplitude (Quantity | None)

  • t_final (Quantity | None)

  • num_components (int)

  • min_frequency (float)

  • max_frequency (float)

  • seed (int | None)

Methods

__init__([amplitude, t_final, ...])

add_new_components([seed])

Add self._num_components number of new randomized components to the optimization.

get_coefficients_frequencies_and_phases()

Return all the coefficients and frequencies used in the CRAB signal.

get_parameters()

Return the parameters of the CRAB signal.

get_time_and_parameter_gradient(times)

Compute the double derivative with respect to parameter and time.

get_time_gradient(times)

Compute a signal envelopes time derivative.

get_value(t)

Compute the CRAB signal.

get_value_and_gradient(times)

Compute the gradient of the _evaluate method.

remove_small_coefficients([tol])

Remove coefficients (and corresponding frequencies) that are smaller than a tolerance.

set_all_optimizable_parameters(all_params)

Set all optimizable parameters in the optimization.

set_optimizable_parameters(params)

Set optimizable parameters for optimization.

Attributes

all_optimizable_parameters

Get the optimizable parameters

amplitude

Get the amplitude of the system.

name

Get the name of the parameter.

optimizable_parameters

Get the optimizable parameters

t_final

Get the length of the tone.

add_new_components(seed=None)[source]#

Add self._num_components number of new randomized components to the optimization.

Parameters:

seed (int | None)

Return type:

None

property all_optimizable_parameters: list[Quantity]#

Get the optimizable parameters

Returns:

The list of all the optimizable parameters considered in the optimization

Return type:

list[Quantity]

property amplitude: Quantity#

Get the amplitude of the system.

Returns:

Amplitude of the system.

Return type:

Quantity

get_coefficients_frequencies_and_phases()[source]#

Return all the coefficients and frequencies used in the CRAB signal.

Return type:

list[Quantity]

get_parameters()[source]#

Return the parameters of the CRAB signal.

The parameters are arranged as follows, [amplitude, t_final, … total_num coefficients …, … total_num frequencies …]

get_time_and_parameter_gradient(times)[source]#

Compute the double derivative with respect to parameter and time.

This function computes $\frac{\partial^2 \Omega}{\partial t \partial alpha}$ for a pulse $\Omega(t)$ and parameter $\alpha$.

Parameters:

times (Array) – One-dimensional vector of timestamps.

Returns:

Returns a vector signals time derivative.

Return type:

Array

get_time_gradient(times)[source]#

Compute a signal envelopes time derivative.

Parameters:

times (Array) – One-dimensional vector of timestamps.

Returns:

Returns a vector signals time derivative.

Return type:

Array

get_value(t)[source]#

Compute the CRAB signal.

Parameters:

t (Array) – One-dimensional vector of timestamps.

Returns:

Returns a vector CRAB signal.

Return type:

Array

get_value_and_gradient(times)[source]#

Compute the gradient of the _evaluate method.

Uses Automatic differentiation as a fallback. The _evaluate method should be a pure function (should take the optimizable parameters as function arguments and doesn’t depend on global variables). Refer to https://jax.readthedocs.io/en/latest/notebooks/Common_Gotchas_in_JAX.html for functionally pure functions. To implement analytical gradients / other methods for gradient computation overwrite this method in the inherited class.

Parameters:

times (Array) – One-dimensional vector of timestamps.

Returns:

Returns the gradient array of the _evaluate method.

Return type:

Array

property name: str | None#

Get the name of the parameter.

Returns:

Name of the parameter.

Return type:

str | None

property optimizable_parameters: list[Quantity]#

Get the optimizable parameters

Returns:

The list of optimizable parameters associated with the object.

Return type:

list[Quantity]

remove_small_coefficients(tol=1e-07)[source]#

Remove coefficients (and corresponding frequencies) that are smaller than a tolerance.

Parameters:

tol (float)

Return type:

None

set_all_optimizable_parameters(all_params)[source]#

Set all optimizable parameters in the optimization.

Parameters:
  • params (List[Quantity]) – List of optimizable parameters to be set.

  • all_params (list[Quantity])

Return type:

None

set_optimizable_parameters(params)[source]#

Set optimizable parameters for optimization.

Parameters:

params (list[Quantity]) – Input list of parameters to be set.

Return type:

None

property t_final: Quantity#

Get the length of the tone.

Returns:

Length in time of the tone.

Return type:

Quantity