kqcircuits.simulations.epr.utils
- kqcircuits.simulations.epr.utils.in_gui(element: Simulation | Element) bool [source]
partition_regions
andcorrection_cuts
can be called for elements when KLayout is in GUI mode, in which case element is not of type Simulation. This check can be used ifpartition_regions
andcorrection_cuts
implementations useSimulation
specific attributes and methods likebox
orface_stack
. If True is returned, some alternative attributes need to be used.
- kqcircuits.simulations.epr.utils.extract_child_simulation(simulation: Simulation | Element, refpoint_prefix: str | None = None, parameter_remap_function: Callable[[Simulation | Element, str], any] | None = None, needed_parameters: list[str] | None = None) Simulation [source]
Given a simulation object that builds multiple elements within it, extracts a “child simulation” which is a stub object that only contains minimal set of refpoints and parameters from which element specific parition regions and correction cuts can be derived.
When defining parition regions and correction cuts for an element under
kqcircuits.simulations.epr
, it is recommended to create a function that takes arguments(simulation, refpoint_prefix, parameter_remap_function)
that passes the arguments toextract_child_simulation
and explicitly listsneeded_parameters
. Seekqcircuits.simulations.epr.example
.- Parameters:
simulation – Simulation object that contains needed child simulation
refpoint_prefix – Child simulation refpoints usually have a common prefix in refpoint names, which identify that the refpoint belongs to that child.
parameter_remap_function – If
simulation
defines parameters that overrides parameters of the needed child simulation, these parameters should be mapped for the partition region and correction cut extraction functions to work. For example, suppose the correction cut location of some qubit is defined relative to itsa
parameter. But when thesimulation
inserts the qubit, it overrides qubit’sa
parameter withsimulation``s ``qubit_a
parameter.parameter_remap_function
should be such thatparameter_remap_function(simulation, "a") = simulation.qubit_a
.needed_parameters – List of all parameters that are needed to derive parition regions and correction cuts for needed child simulation.
- Returns:
A “simulation object” that only contains minimal set of refpoints and parameters from which element specific parition regions and correction cuts can be derived. The result is a stub simulation object, so it doesn’t have well defined build function or any features that would be useful to export a simulation by itself.