piel.flows.electro_optic#

Attributes#

Functions#

compose_phase_address_state(→ dict)

This function composes the phase shifter address state for each circuit. This means that we have a dictionary

compose_switch_function_parameter_state(→ dict)

This function composes the combinations of the phase shifter inputs into a form that can be inputted into sax for

calculate_switch_unitaries(...)

This function calculates the switch unitaries for a given circuit. This means that we iterate over each switch

calculate_all_transition_probability_amplitudes(...)

This tells us the transition probabilities between our photon states for a particular implemented unitary.

calculate_classical_transition_probability_amplitudes(→ dict)

This tells us the classical transition probabilities between our photon states for a particular implemented

construct_unitary_transition_probability_performance(...)

This function determines the Fock state probability performance for a given implemented unitary. This means we

compose_network_matrix_from_models(circuit_component, ...)

This function composes the network matrix from the measurement dictionary and the switch states. It does this by first

extract_phase_from_fock_state_transitions(...[, ...])

Extracts the phase corresponding to the specified transition type.

extract_phase_tuple_from_phase_address_state(...)

Extracts phase values from a dictionary where keys are tuples representing components and values are the phase values.

format_electro_optic_fock_transition(...)

Formats the electro-optic state into a standard FockStatePhaseTransition format. This is useful for the

generate_s_parameter_circuit_from_photonic_circuit(...)

Generates the S-parameters and related information for a given circuit using SAX and custom measurement.

get_state_phase_transitions(...)

The goal of this function is to extract the corresponding phase required to implement a state transition.

get_state_to_phase_map(→ tuple[piel.types.ArrayTypes])

The goal of this function is to extract the corresponding phase required to implement a state transition.

Module Contents#

logger#
compose_phase_address_state(switch_instance_map: dict, switch_phase_permutation_map: dict) dict[source]#

This function composes the phase shifter address state for each circuit. This means that we have a dictionary that maps the instance address to the phase shifter state. This is then used to compose the function parameter state.

Parameters:
  • switch_instance_map (dict) – The dictionary of the switch instances.

  • switch_phase_permutation_map (dict) – The dictionary of the switch phase permutations.

Returns:

The dictionary of the phase shifter address state.

Return type:

phase_shifter_address_state (dict)

compose_switch_function_parameter_state(switch_phase_address_state: dict) dict[source]#

This function composes the combinations of the phase shifter inputs into a form that can be inputted into sax for each particular address.

Parameters:

switch_phase_address_state (dict) – The dictionary of the switch phase address state.

Returns:

The dictionary of the phase shifter function parameter state.

Return type:

phase_shifter_function_parameter_state (dict)

calculate_switch_unitaries(circuit: piel.types.OpticalTransmissionCircuit, switch_function_parameter_state: dict) piel.types.SParameterCollection[source]#

This function calculates the switch unitaries for a given circuit. This means that we iterate over each switch function parameter state and we calculate the corresponding unitary matrix.

Parameters:
  • circuit (OpticalTransmissionCircuit) – The optical transmission circuit.

  • switch_function_parameter_state (dict) – The dictionary of the switch function parameter state.

Returns:

calculate_all_transition_probability_amplitudes(unitary_matrix: piel.types.ArrayTypes, input_fock_states: list[piel.types.ArrayTypes], output_fock_states: list[piel.types.ArrayTypes]) dict[int, piel.types.FockStatePhaseTransition][source]#

This tells us the transition probabilities between our photon states for a particular implemented unitary.

Parameters:
  • unitary_matrix (jnp.ndarray) – The unitary matrix.

  • input_fock_states (list) – The list of input Fock states.

  • output_fock_states (list) – The list of output Fock states.

Returns:

The dictionary of the Fock state phase transition type.

Return type:

dict[int, FockStatePhaseTransition]

calculate_classical_transition_probability_amplitudes(unitary_matrix: piel.types.ArrayTypes, input_fock_states: list[piel.types.ArrayTypes], target_mode_index: int | None = None, determine_ideal_mode_function: Callable | None = None) dict[source]#

This tells us the classical transition probabilities between our photon states for a particular implemented s-parameter transformation.

Note that if no target_mode_index is provided, then the determine_ideal_mode_function will analyse the provided files and return the target mode and append the relevant probability files to the files dictionary. It will raise an error if no method is implemented.

Parameters:
  • unitary_matrix (jnp.ndarray) – The unitary matrix.

  • input_fock_states (list) – The list of input Fock states.

  • target_mode_index (int) – The target mode index.

  • determine_ideal_mode_function (Callable) – The function that determines the ideal mode.

Returns:

The dictionary of the circuit transition probability files.

Return type:

dict

construct_unitary_transition_probability_performance(unitary_phase_implementations_dictionary: dict, input_fock_states: list, output_fock_states: list) dict[int, dict[int, piel.types.FockStatePhaseTransition]][source]#

This function determines the Fock state probability performance for a given implemented unitary. This means we iterate over each circuit, then each implemented unitary, and we determine the probability transformation accordingly.

Parameters:
  • unitary_phase_implementations_dictionary (dict) – The dictionary of the unitary phase implementations.

  • input_fock_states (list) – The list of input Fock states.

  • output_fock_states (list) – The list of output Fock states.

Returns:

The dictionary of the implemented unitary probability.

Return type:

implemented_unitary_probability_dictionary (dict)

compose_network_matrix_from_models(circuit_component: piel.types.PhotonicCircuitComponent, models: dict, switch_states: list, top_level_instance_prefix: str = 'component_lattice_generic', target_component_prefix: str = 'mzi', netlist_function: Callable | None = None, **kwargs)[source]#

This function composes the network matrix from the measurement dictionary and the switch states. It does this by first composing the switch functions, then composing the switch matrix, then composing the network matrix. It returns the network matrix and the switch matrix.

Parameters:
  • circuit_component (gf.Component) – The circuit.

  • models (dict) – The measurement dictionary.

  • switch_states (list) – The list of switch states.

  • top_level_instance_prefix (str) – The top level instance prefix.

  • target_component_prefix (str) – The target component prefix.

  • netlist_function (Optional[Callable]) – The netlist function.

Returns:

The network matrix.

Return type:

network_matrix (np.ndarray)

extract_phase_from_fock_state_transitions(optical_state_transitions: piel.types.OpticalStateTransitionCollection, transition_type: piel.types.PhaseTransitionTypes = 'cross')[source]#

Extracts the phase corresponding to the specified transition type.

Parameters: optical_state_transitions (OpticalStateTransitionCollection): Optical state transitions.

transition_type (str): Type of transition to extract phase for (‘cross’ or ‘bar’).

Returns:

Phase corresponding to the specified transition type.

Return type:

float

extract_phase_tuple_from_phase_address_state(phase_address_state: dict)[source]#

Extracts phase values from a dictionary where keys are tuples representing components and values are the phase values.

Parameters:

phase_address_state (dict) – The dictionary with tuple keys representing components and their phase values.

Returns:

A list containing tuples of the phase values.

Return type:

list of tuples

format_electro_optic_fock_transition(switch_state_array: piel.types.ArrayTypes, input_fock_state_array: piel.types.ArrayTypes, raw_output_state: piel.types.ArrayTypes, **kwargs) piel.types.FockStatePhaseTransition[source]#

Formats the electro-optic state into a standard FockStatePhaseTransition format. This is useful for the electro-optic model to ensure that the output state is in the correct format. The output state is a dictionary that contains the phase, input fock state, and output fock state. The idea is that this will allow us to standardise and compare the output states of the electro-optic model across multiple formats.

Parameters:
  • switch_state_array (array_types) – Array of switch states.

  • input_fock_state_array (array_types) – Array of valid input fock states.

  • raw_output_state (array_types) – Array of raw output state.

  • **kwargs – Additional keyword arguments.

Returns:

Electro-optic state.

Return type:

electro_optic_state(FockStatePhaseTransition)

generate_s_parameter_circuit_from_photonic_circuit(circuit: piel.types.PhotonicCircuitComponent, models: Any = None, netlist_function: Callable | None = None) tuple[any, any][source]#

Generates the S-parameters and related information for a given circuit using SAX and custom measurement.

Parameters:
  • circuit (gf.Component) – The circuit for which the S-parameters are to be generated.

  • models (sax.ModelFactory, optional) – The measurement to be used for the S-parameter generation. Defaults to None.

  • netlist_function (Callable, optional) – The function to generate the netlist. Defaults to None.

Returns:

The S-parameters circuit and related information.

Return type:

tuple[any, any]

get_state_phase_transitions(circuit_component: piel.types.PhotonicCircuitComponent, models: dict = None, mode_amount: int = None, input_fock_states: list[piel.types.ArrayTypes] | None = None, switch_states: list[piel.types.NumericalTypes] | None = None, determine_ideal_mode_function: Callable | None = None, netlist_function: Callable | None = None, target_mode_index: int | None = None, **kwargs) piel.types.OpticalStateTransitionCollection[source]#

The goal of this function is to extract the corresponding phase required to implement a state transition.

Let’s consider a simple MZI 2x2 logic with two transmission states. We want to verify that the electronic function switch, effectively switches the optical output between the cross and bar states of the optical transmission function.

For the corresponding switch model:

Let’s assume a switch model unitary. For a given 2x2 input optical switch “X”. In bar state, in dual rail, transforms an optical input: ``` .. raw:

[[1] ----> [[1]
[0]]        [0]]

In cross state, in dual rail, transforms an optical input:

However, sometimes it is easier to describe a photonic logic transformation based on these states, rather than inherently the numerical phase that is applied. This may be the case, for example, in asymmetric Mach-Zehnder modulators measurement, etc.

As such, this function will help us extract the corresponding phase for a particular switch transition.

When the switch function is larger than a single switch, it is necessary to extract the location of the corresponding switches as function parameters.

get_state_to_phase_map(switch_function: piel.types.OpticalTransmissionCircuit, switch_states: list[piel.types.NumericalTypes] | None = None, input_fock_states: list[piel.types.ArrayTypes] | None = None, target_transition_list: list[dict] | None = None, mode_amount: int | None = None, **kwargs) tuple[piel.types.ArrayTypes][source]#

The goal of this function is to extract the corresponding phase required to implement a state transition.

Let’s consider a simple MZI 2x2 logic with two transmission states. We want to verify that the electronic function switch, effectively switches the optical output between the cross and bar states of the optical transmission function.

For the corresponding switch model:

Let’s assume a switch model unitary. For a given 2x2 input optical switch “X”. In bar state, in dual rail, transforms an optical input: ``` .. raw:

[[1] ----> [[1]
[0]]        [0]]

In cross state, in dual rail, transforms an optical input:

However, sometimes it is easier to describe a photonic logic transformation based on these states, rather than inherently the numerical phase that is applied. This may be the case, for example, in asymmetric Mach-Zehnder modulators measurement, etc.

As such, this function will help us extract the corresponding phase for a particular switch transition.