Skip to content

Can't change frequency list in Microring example #14

@danielj-n

Description

@danielj-n
  • OPICS version: 0.3.3
  • Python version: Python 3.10.5
  • Operating System: Arch Linux

Description

I was trying to change the frequency range used in the microring example by changing the line in the Network initialization:

freq = np.linspace(C * 1e6 / 1.5, C * 1e6 / 1.6, 2000)

I changed "2000" to "20000" hoping to get 20000 points in the output plot instead of 2000 for more resolution.

When I did this I got an error:

daniel@acer-swift maybe_trash]$ python microring.py

   ____  ____  _______________
  / __ \/ __ \/  _/ ____/ ___/
 / / / / /_/ // // /    \__ \
/ /_/ / ____// // /___ ___/ /
\____/_/   /___/\____//____/

OPICS version 0.3.3
20000
Traceback (most recent call last):
  File "/home/daniel/documents/school/masc/research/maybe_trash/microring.py", line 35, in <module>
    circuit.sim_result.plot_sparameters(
  File "/home/daniel/.local/lib/python3.10/site-packages/opics/components.py", line 262, in plot_sparameters
    plt.plot(x_data, np.square(np.abs(self.s[:, int(i), int(j)])))
  File "/usr/lib/python3.10/site-packages/matplotlib/pyplot.py", line 2769, in plot
    return gca().plot(
  File "/usr/lib/python3.10/site-packages/matplotlib/axes/_axes.py", line 1632, in plot
    lines = [*self._get_lines(*args, data=data, **kwargs)]
  File "/usr/lib/python3.10/site-packages/matplotlib/axes/_base.py", line 312, in __call__
    yield from self._plot_args(this, kwargs)
  File "/usr/lib/python3.10/site-packages/matplotlib/axes/_base.py", line 498, in _plot_args
    raise ValueError(f"x and y must have same first dimension, but "
ValueError: x and y must have same first dimension, but have shapes (2000,) and (20000,)

What I Did

I was thinking this probably came from using the global frequency list instead of the supplied frequency list somewhere in the code. I traced my issue back in the Opics code to this line:

combination_f = F

This line seems to set the frequency list of the combined component to the global frequency list rather than using the frequency list of the supplied components. I believe this line should reuse the frequency list from the components that are being combined.

One quick fix for this is to change the line to:

combination_f = components[0].f

This fixes the problem for me. However, I'm not sure if this is an actual issue or if there's a proper way to do this I missed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions