piel.models.physical.photonic.component_lattice_generic
=======================================================

.. py:module:: piel.models.physical.photonic.component_lattice_generic

.. autoapi-nested-parse::

   In a multiple-topology Clements Scheme we can implement any universal photonic function.



Attributes
----------

.. autoapisummary::

   piel.models.physical.photonic.component_lattice_generic.c


Functions
---------

.. autoapisummary::

   piel.models.physical.photonic.component_lattice_generic.find_largest_component
   piel.models.physical.photonic.component_lattice_generic.component_lattice_generic


Module Contents
---------------

.. py:function:: find_largest_component(component_list: list) -> gdsfactory.component.Component

.. py:function:: component_lattice_generic(network: list[list] | None = None, **kwargs) -> gdsfactory.component.Component

   The shape of the `network` matrix determines the physical interconnection.
   Note that there should be at least S+1=N modes
   based on this formalism of interconnection,
   and the position of the component implements a connectivity in between the modes,
   and assumes a 2x2 network encoding.
   One nice functionality by this component is that it can generate a
   component lattice for generic variable components with different x and y pitches.
   Initially this will maximise the surface area required
   but different placement algorithms can compact the size.

   :param network: A list of lists of components that are to be placed in the lattice.

   :returns: A component lattice that implements the physical network.
   :rtype: Component

   The placement matrix is in this form:
   .. math::

       M = X & 0 & X
           0 & P & 0
           X & 0 & X


   :include-source:
       import gdsfactory as gf
       from gdsfactory.components.mzi import mzi2x2_2x2

       example_component_lattice = [
           [mzi2x2_2x2(), 0, mzi2x2_2x2()],
           [0, mzi2x2_2x2(delta_length=30.0), 0],
           [mzi2x2_2x2(), 0, mzi2x2_2x2()],
       ]
       c = gf.components.component_lattice_generic(example_component_lattice)


   Another example that demonstrates the generic-nature of this component lattice
   algorithm can be with an mixed set of actively driven and passiver interferometers.
   The placement matrix is in this form:

   .. math::

       M = Y & 0 & A
           0 & B & 0
           C & 0 & Y

   :include-source:
       import gdsfactory as gf
       from gdsfactory.components import mzi2x2_2x2_phase_shifter, mzi2x2_2x2

       example_mixed_component_lattice = [
           [mzi2x2_2x2_phase_shifter(), 0, mzi2x2_2x2(delta_length=20.0)],
           [0, mzi2x2_2x2(delta_length=30.0), 0],
           [mzi2x2_2x2(delta_length=15.0), 0, mzi2x2_2x2_phase_shifter()],
       ]
       c = gf.components.component_lattice_generic(
           network=example_mixed_component_lattice
       )

   # TODO implement balanced waveguide paths function per stage
   # TODO automatic electrical fanout?
   # TODO multiple placement optimization algorithms.


.. py:data:: c

