Skip to navigation

stanza.routines.builtins.dqd_search.utils

Module Contents

Classes

NameDescription
SweepGeometryRandom sweep configuration in 2D voltage space.
GateIndicesIndices for different gate types in the voltage array.

Functions

NameDescription
build_gate_indicesExtract indices for each gate type from the gate list.
generate_linear_sweepGenerate evenly-spaced points along a line segment.
generate_random_sweepGenerate random sweep that stays within bounds.
build_full_voltagesConstruct full voltage array from plunger sweep voltages.
compute_peak_spacingsCalculate inter-peak spacings in voltage space.
get_global_turn_on_voltageGet global turn-on voltage from results.
_get_gate_characterizationGet combined gate characterization results.
get_voltagesGet voltages for all gates.
get_plunger_gate_boundsGet plunger bounds for all plunger gates.
get_gate_safe_boundsGet safe voltage bounds.
measure_and_classifyMeasure current and classify result.
log_measurementLog measurement data to session.
log_classificationLog classification result to session.

API

class stanza.routines.builtins.dqd_search.utils.SweepGeometry

Random sweep configuration in 2D voltage space.

start: numpy.typing.NDArray[numpy.float64]

Value: None

end: numpy.typing.NDArray[numpy.float64]

Value: None

direction: numpy.typing.NDArray[numpy.float64]

Value: None

angle: float

Value: None

total_distance: float

Value: None

class stanza.routines.builtins.dqd_search.utils.GateIndices

Indices for different gate types in the voltage array.

plunger: list[int]

Value: None

reservoir: list[int]

Value: None

barrier: list[int]

Value: None

stanza.routines.builtins.dqd_search.utils.build_gate_indices(
gates: list[str], device: stanza.device.Device
) -> stanza.routines.builtins.dqd_search.utils.GateIndices

Extract indices for each gate type from the gate list.

Parameters:

gates
list[str]

List of gate electrode names.

device
stanza.device.Device

Device instance with get_gate_by_type method.

Returns:

GateIndices with plunger, reservoir, and barrier indices.

stanza.routines.builtins.dqd_search.utils.generate_linear_sweep(
start_point: numpy.typing.NDArray[numpy.float64],
direction: numpy.typing.NDArray[numpy.float64],
total_sweep_dist: float,
n_points: int
) -> numpy.typing.NDArray[numpy.float64]

Generate evenly-spaced points along a line segment.

Parameters:

start_point
numpy.typing.NDArray[numpy.float64]

(d,) array with starting coordinates.

direction
numpy.typing.NDArray[numpy.float64]

(d,) array with normalized direction vector.

total_sweep_dist
float

Total sweep distance.

n_points
int

Number of points in the trace.

Returns:

(n_points, d) array of coordinates along the line.

stanza.routines.builtins.dqd_search.utils.generate_random_sweep(
x_bounds: tuple[float, float],
y_bounds: tuple[float, float],
scale: float,
num_points: int
) -> stanza.routines.builtins.dqd_search.utils.SweepGeometry | None

Generate random sweep that stays within bounds.

Parameters:

x_bounds
tuple[float, float]

(min, max) voltage bounds for X axis.

y_bounds
tuple[float, float]

(min, max) voltage bounds for Y axis.

scale
float

Voltage spacing per step.

num_points
int

Number of points in sweep.

Returns:

SweepGeometry if sweep stays in bounds, None otherwise.

stanza.routines.builtins.dqd_search.utils.build_full_voltages(
sweep_voltages: numpy.typing.NDArray[numpy.float64],
gates: list[str],
gate_idx: stanza.routines.builtins.dqd_search.utils.GateIndices,
transition_voltages: dict[str, float],
saturation_voltages: dict[str, float],
barrier_voltages: dict[str, float] | None = None
) -> numpy.typing.NDArray[numpy.float64]

Construct full voltage array from plunger sweep voltages.

Works with arbitrary-dimensional sweep arrays (1D, 2D, 3D, etc). Applies fixed voltages to reservoir and barrier gates based on characterization data.

Parameters:

sweep_voltages
numpy.typing.NDArray[numpy.float64]

(…, 2) array of plunger voltages.

gates
list[str]

List of all gate names.

gate_idx
stanza.routines.builtins.dqd_search.utils.GateIndices

Indices for each gate type.

transition_voltages
dict[str, float]

Transition voltages for all gates.

saturation_voltages
dict[str, float]

Saturation voltages for all gates.

barrier_voltages
dict[str, float] | None

Optional explicit barrier voltages (overrides defaults).

Returns:

(…, num_gates) array of voltages.

stanza.routines.builtins.dqd_search.utils.compute_peak_spacings(
peak_indices: numpy.typing.NDArray[numpy.int64],
sweep_voltages: numpy.typing.NDArray[numpy.float64]
) -> numpy.typing.NDArray[numpy.float64] | None

Calculate inter-peak spacings in voltage space.

Parameters:

peak_indices
numpy.typing.NDArray[numpy.int64]

Indices of detected peaks.

sweep_voltages
numpy.typing.NDArray[numpy.float64]

(num_points, 2) array of voltage coordinates.

Returns:

Array of inter-peak spacings, or None if fewer than 3 peaks.

stanza.routines.builtins.dqd_search.utils.get_global_turn_on_voltage(results: stanza.registry.ResultsRegistry) -> float

Get global turn-on voltage from results.

Parameters:

results
stanza.registry.ResultsRegistry

ResultsRegistry instance.

Returns:

Global turn-on voltage.

Raises:

ValueError: If global accumulation results not found.

stanza.routines.builtins.dqd_search.utils._get_gate_characterization(results: stanza.registry.ResultsRegistry) -> dict[str, dict[str, float]]

Get combined gate characterization results.

Parameters:

results
stanza.registry.ResultsRegistry

ResultsRegistry instance.

Returns:

Combined dict of reservoir and finger gate characterization.

Raises:

ValueError: If characterization results not found.

stanza.routines.builtins.dqd_search.utils.get_voltages(
gates: list[str],
key: str,
results: stanza.registry.ResultsRegistry
) -> dict[str, float]

Get voltages for all gates.

Parameters:

gates
list[str]

List of gate names.

key
str

Key to extract (“saturation_voltage”, “cutoff_voltage”, or “transition_voltage”).

results
stanza.registry.ResultsRegistry

ResultsRegistry instance.

Returns:

Dict mapping gate names to voltages.

stanza.routines.builtins.dqd_search.utils.get_plunger_gate_bounds(
plunger_gates: list[str], results: stanza.registry.ResultsRegistry
) -> dict[str, tuple[float, float]]

Get plunger bounds for all plunger gates.

Parameters:

plunger_gates
list[str]

List of plunger gate names.

results
stanza.registry.ResultsRegistry

ResultsRegistry instance.

Returns:

Dict mapping plunger gate names to (min, max) voltage bounds.

stanza.routines.builtins.dqd_search.utils.get_gate_safe_bounds(results: stanza.registry.ResultsRegistry) -> tuple[float, float]

Get safe voltage bounds.

Parameters:

results
stanza.registry.ResultsRegistry

ResultsRegistry instance.

Returns:

(min, max) safe voltage bounds.

Raises:

ValueError: If leakage test results not found.

stanza.routines.builtins.dqd_search.utils.measure_and_classify(
device: stanza.device.Device,
client: conductorquantum.base_client.BaseConductorQuantum,
gates: list[str],
voltages: numpy.typing.NDArray[numpy.float64],
measure_electrode: str,
model: str,
reshape: tuple[int, ...] | None = None
) -> tuple[numpy.typing.NDArray[numpy.float64], bool, float]

Measure current and classify result.

Performs device measurement sweep and classifies the resulting current data using a specified ML model.

Parameters:

device
stanza.device.Device

Device instance.

client
conductorquantum.base_client.BaseConductorQuantum

Models client.

gates
list[str]

Gate electrode names.

voltages
numpy.typing.NDArray[numpy.float64]

Voltage array.

measure_electrode
str

Current measurement electrode.

model
str

Classification model name.

reshape
tuple[int, ...] | None

Optional reshape dimensions for output.

Returns:

Tuple of (currents, classification, score).

stanza.routines.builtins.dqd_search.utils.log_measurement(
session: stanza.logger.session.LoggerSession | None,
name: str,
measurement_id: str,
data: dict[str, typing.Any],
metadata: dict[str, typing.Any],
routine_name: str
) -> None

Log measurement data to session.

Parameters:

session
stanza.logger.session.LoggerSession | None

Logger session instance (optional).

name
str

Measurement name.

measurement_id
str

Unique measurement identifier.

data
dict[str, typing.Any]

Measurement data dict.

metadata
dict[str, typing.Any]

Measurement metadata dict.

routine_name
str

Name of the routine performing the measurement.

stanza.routines.builtins.dqd_search.utils.log_classification(
session: stanza.logger.session.LoggerSession | None,
measurement_id: str,
measurement_type: str,
classification: bool,
score: float,
metadata: dict[str, typing.Any],
routine_name: str
) -> None

Log classification result to session.

Parameters:

session
stanza.logger.session.LoggerSession | None

Logger session instance (optional).

measurement_id
str

Unique measurement identifier.

measurement_type
str

Type of measurement being classified.

classification
bool

Classification result (True/False).

score
float

Classification confidence score.

metadata
dict[str, typing.Any]

Classification metadata dict.

routine_name
str

Name of the routine performing the classification.