Skip to content

qiu_classical_simulation.wave_optics.cli

The command line of the lens experiment simulations, shared by their backends.

The defaults are the experiment of the paper: a beam of 25 um FWHM at 1 um wavelength through a plano-convex lens of 200 um focal length and refractive index 1.25, in a transverse window of 100 um, sliced into 10000 slices, followed by 300 um of free space in 300 steps.

Functions:

Attributes:

  • LENGTH_SCALE –

    The scale of the lengths of the experiment, except for the wavelength.

LENGTH_SCALE module-attribute

LENGTH_SCALE = 0.001

The scale of the lengths of the experiment, except for the wavelength.

argument_parser

argument_parser(description: str, default_results_dir: Path) -> ArgumentParser

Return the parser of the simulation's command line.

Source code in packages/qiu-classical-simulation/src/qiu_classical_simulation/wave_optics/cli.py
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
def argument_parser(
    description: str, default_results_dir: Path
) -> argparse.ArgumentParser:
    """Return the parser of the simulation's command line."""
    parser = argparse.ArgumentParser(description=description)
    parser.add_argument(
        "--max-delta",
        type=float,
        required=True,
        help="Maximum phase per cycle of the sample-based phase protocol.",
    )
    parser.add_argument(
        "--direct-propagator",
        action="store_true",
        help="Apply free propagation directly instead of with the phase protocol.",
    )
    parser.add_argument(
        "--reverse-order",
        action="store_true",
        help="Let the beam enter the lens through its plane side.",
    )
    parser.add_argument(
        "--fresnel-approximation",
        action="store_true",
        help="Approximate the spherical lens surface by a paraboloid.",
    )
    parser.add_argument("--num-qubits", type=int, default=7)
    parser.add_argument("--lens-slices", type=int, default=10000)
    parser.add_argument("--steps-after-lens", type=int, default=300)
    parser.add_argument(
        "--results-dir",
        type=Path,
        default=default_results_dir,
        help=f"Directory of the run folders (default: {default_results_dir}).",
    )
    return parser

parameters_from_arguments

parameters_from_arguments(arguments: Namespace) -> ExperimentParameters

Return the parameters of the experiment of the paper, as the arguments vary it.

Source code in packages/qiu-classical-simulation/src/qiu_classical_simulation/wave_optics/cli.py
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
def parameters_from_arguments(arguments: argparse.Namespace) -> ExperimentParameters:
    """Return the parameters of the experiment of the paper, as the arguments vary it."""
    return ExperimentParameters(
        vacuum_wavelength=1e-6,
        beam_FWHM=25e-3 * LENGTH_SCALE,
        focal_length=200e-3 * LENGTH_SCALE,
        refractive_index=1.25,
        propagation_after_lens=1.5 * 200e-3 * LENGTH_SCALE,
        transverse_length=100e-3 * LENGTH_SCALE,
        num_of_steps_after_lens=arguments.steps_after_lens,
        lens_slices=arguments.lens_slices,
        num_qubits=arguments.num_qubits,
        max_delta=arguments.max_delta,
        lens_reverse_order=arguments.reverse_order,
        fresnel_approximation=arguments.fresnel_approximation,
        scale_down_phases=True,
        direct_propagator=arguments.direct_propagator,
    )

parse_parameters

parse_parameters(description: str, default_results_dir: Path, argv: Sequence[str] | None = None) -> tuple[ExperimentParameters, Path]

Parse the command line into the parameters and the results directory.

Source code in packages/qiu-classical-simulation/src/qiu_classical_simulation/wave_optics/cli.py
77
78
79
80
81
82
def parse_parameters(
    description: str, default_results_dir: Path, argv: Sequence[str] | None = None
) -> tuple[ExperimentParameters, Path]:
    """Parse the command line into the parameters and the results directory."""
    arguments = argument_parser(description, default_results_dir).parse_args(argv)
    return parameters_from_arguments(arguments), arguments.results_dir