Skip to content

qiu_classical_simulation.wave_optics.result

The result of a lens experiment: snapshots of the transverse field along the way.

The snapshots are named, in the order the simulation takes them: step_0 for the entering beam, step_lens_{i} after each lens slice i, after_lens behind the lens, step_after_lens_{j} after each free propagation step j = 1, 2, ..., and final.

Classes:

  • ExperimentResult –

    The snapshots of an experiment and the success probabilities of its protocol.

Functions:

ExperimentResult dataclass

ExperimentResult(snapshots: dict[str, NDArray[complex128]], total_lenses_simulated: int, total_probability_of_success: float | None = None, success_probabilities: list[float] | None = None)

The snapshots of an experiment and the success probabilities of its protocol.

Methods:

  • success_probability –

    Return the cumulative success probability up to a named snapshot.

  • lens_states –

    Return the snapshots after each lens slice.

  • free_space_states –

    Return the snapshots after each free propagation step.

  • summary –

    Return the scalar results, stored with the parameters.

Attributes:

snapshots instance-attribute

snapshots: dict[str, NDArray[complex128]]

The normalized amplitudes of the named snapshots, in the order taken.

total_lenses_simulated instance-attribute

total_lenses_simulated: int

The number of lens slices with a phase, i.e. not skipped as constant.

total_probability_of_success class-attribute instance-attribute

total_probability_of_success: float | None = None

The probability that all cycles of the phase protocol succeeded.

success_probabilities class-attribute instance-attribute

success_probabilities: list[float] | None = field(default=None)

The cumulative success probability at each snapshot, in the same order.

success_probability

success_probability(snapshot: str) -> float

Return the cumulative success probability up to a named snapshot.

Source code in packages/qiu-classical-simulation/src/qiu_classical_simulation/wave_optics/result.py
44
45
46
47
48
def success_probability(self, snapshot: str) -> float:
    """Return the cumulative success probability up to a named snapshot."""
    if self.success_probabilities is None:
        raise ValueError("The result has no success probabilities.")
    return self.success_probabilities[list(self.snapshots).index(snapshot)]

lens_states

lens_states(lens_slices: int) -> list[NDArray[complex128]]

Return the snapshots after each lens slice.

Source code in packages/qiu-classical-simulation/src/qiu_classical_simulation/wave_optics/result.py
50
51
52
def lens_states(self, lens_slices: int) -> list[npt.NDArray[np.complex128]]:
    """Return the snapshots after each lens slice."""
    return [self.snapshots[lens_snapshot_name(i)] for i in range(lens_slices)]

free_space_states

free_space_states(steps: int) -> list[NDArray[complex128]]

Return the snapshots after each free propagation step.

Source code in packages/qiu-classical-simulation/src/qiu_classical_simulation/wave_optics/result.py
54
55
56
def free_space_states(self, steps: int) -> list[npt.NDArray[np.complex128]]:
    """Return the snapshots after each free propagation step."""
    return [self.snapshots[free_space_snapshot_name(j + 1)] for j in range(steps)]

summary

summary() -> dict

Return the scalar results, stored with the parameters.

Source code in packages/qiu-classical-simulation/src/qiu_classical_simulation/wave_optics/result.py
58
59
60
61
62
63
64
def summary(self) -> dict:
    """Return the scalar results, stored with the parameters."""
    return {
        "total_lenses_simulated": self.total_lenses_simulated,
        "total_probability_of_success": self.total_probability_of_success,
        "success_probabilities": self.success_probabilities,
    }

lens_snapshot_name

lens_snapshot_name(slice_index: int) -> str

Return the name of the snapshot after a lens slice, counted from 0.

Source code in packages/qiu-classical-simulation/src/qiu_classical_simulation/wave_optics/result.py
14
15
16
def lens_snapshot_name(slice_index: int) -> str:
    """Return the name of the snapshot after a lens slice, counted from 0."""
    return f"step_lens_{slice_index}"

free_space_snapshot_name

free_space_snapshot_name(step: int) -> str

Return the name of the snapshot after a free propagation step, from 1.

Source code in packages/qiu-classical-simulation/src/qiu_classical_simulation/wave_optics/result.py
19
20
21
def free_space_snapshot_name(step: int) -> str:
    """Return the name of the snapshot after a free propagation step, from 1."""
    return f"step_after_lens_{step}"