Skip to content

Commit

Permalink
Sounds like inminent upgrade is required
Browse files Browse the repository at this point in the history
  • Loading branch information
daquintero committed May 8, 2024
1 parent 9f26098 commit 69e81db
Show file tree
Hide file tree
Showing 5 changed files with 101 additions and 3 deletions.
26 changes: 26 additions & 0 deletions docs/autoapi/piel/visual/style/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
:py:mod:`piel.visual.style`
===========================

.. py:module:: piel.visual.style
Module Contents
---------------


Functions
~~~~~~~~~

.. autoapisummary::

piel.visual.style.activate_piel_styles



.. py:function:: activate_piel_styles()
Activates the piel fast rc params.

:returns: None


2 changes: 1 addition & 1 deletion docs/examples/03a_sax_cocotb_cosimulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@
#
# So this tells us all the models that are recursively composed, but not inherently provided by our defaults library. These are the models we can explore.

recursive_composed_required_models_0 = sax.get_required_circuit_models(
recursive_composed_required_models_0 = piel.tools.sax.get_required_circuit_models(
mixed_switch_lattice_circuit_netlist[recursive_composed_required_models[0]],
models=piel.models.frequency.get_default_models(),
)
Expand Down
33 changes: 31 additions & 2 deletions docs/examples/03b_optical_function_verification.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,18 @@
import functools
from itertools import product
import gdsfactory as gf
import jax
import jax.numpy as jnp
import numpy as np
import pandas as pd
from piel import straight_heater_metal_simple
import piel
import pprint as pp
import sax
import random

random.seed(0)
jax.random.key(0)
np.random.seed(0)
# -

# ## Circuit Construction
Expand Down Expand Up @@ -251,6 +254,32 @@
# True
# ```

# One thing I have noticed is that depending on the random configuration of the runner, sometimes the cross and bar states invert on which phase they map. I need to see how to fix that within the computation, if it is even possible.
# WARNING: One thing I have noticed is that depending on the random configuration of the runner, sometimes the cross and bar states invert on which phase they map. I need to see how to fix that within the computation, if it is even possible.

# ## Further Analytical Modelling
#
# Let's consider how a switching network behaves symbolically. Say we have two switches in a chain, illustrated by this format:

chain_mode_3 = np.array([['X', 0,],
[0, 'X']])
chain_mode_3_switch_position_list = piel.models.logic.photonic.compose_switch_position_list(
network=chain_mode_3
)
chain_mode_3, chain_mode_3_switch_position_list


# Let's consider the "X" state can only have two possible states, cross and bar which are represented by the angle applied, (0 -> 0, bar) and (1 -> $\pi$, cross).
#
# If we have a fock state `[[1], [0], [0]]` inputted onto the switch lattice, we want it to route out the photon accordingly at the bottom mode index 2, third waveguide. Accordingly, the top-most switch needs to cross and the bottom most needs to bar in order to achieve this function.
#
#
# We can try a little analytical simulator accordingly. Each "switch" state gets replaced by a 2x2 transmission matrix for each specific state, and concatenated to build the correponding state of the system.

def a(
switch_network: list[list]
states: tuple = (0,1)
):




1 change: 1 addition & 0 deletions piel/models/logic/photonic/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .switch_lattice import compose_switch_position_list
42 changes: 42 additions & 0 deletions piel/models/logic/photonic/switch_lattice.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import functools
from itertools import product
import numpy as np
import pathlib
from typing import Optional, Callable


def compose_switch_position_list(
network: np.array,
gap_elements: list = None,
cross_elements: list = None,
*args,
**kwargs
):
"""
This function returns a list of the switch positions in the network, the corresponding instance, and the 2D position in the network.
Args:
network (np.array): The network array.
gap_elements (list, optional): The gap elements in the network. Defaults to None.
cross_elements (list, optional): The cross elements in the network. Defaults to None.
Returns:
switch_position_list (list): A list of tuples of the form (switch_instance, (row, col)).
"""
if cross_elements is None:
cross_elements = ["-"]
if gap_elements is None:
gap_elements = ["0"]

# Temporary fix for the case where the gap_elements and cross_elements are lists
cross_elements = cross_elements[0]
gap_elements = gap_elements[0]

switch_position_list = [
(value, (row, col))
for row, row_values in enumerate(network)
for col, value in enumerate(row_values)
if (value != gap_elements)
if (value != cross_elements)
]
return switch_position_list

0 comments on commit 69e81db

Please sign in to comment.