Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow mmi imbalance #386

Merged
merged 5 commits into from
Apr 25, 2024
Merged

allow mmi imbalance #386

merged 5 commits into from
Apr 25, 2024

Conversation

joamatab
Copy link
Contributor

  • add mmi_nxn
  • add model for mmi imbalance

@joamatab joamatab requested a review from flaport April 23, 2024 17:45
Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @joamatab - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟡 General issues: 2 issues found
  • 🟢 Security: all looks good
  • 🟡 Testing: 2 issues found
  • 🟢 Complexity: all looks good
  • 🟢 Docstrings: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment to tell me if it was helpful.

Comment on lines +394 to +397
loss_dB_cross: Float | None = None,
loss_dB_thru: Float | None = None,
splitting_ratio_cross: Float = 0.5,
splitting_ratio_thru: Float = 0.5,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (testing): Tests needed for new parameters in mmi2x2 function.

The mmi2x2 function now includes additional parameters such as loss_dB_cross, loss_dB_thru, splitting_ratio_cross, and splitting_ratio_thru. It's important to verify that these parameters are handled correctly and interact as expected with the existing parameters. Please add tests to validate these interactions and their impact on the output.

Comment on lines +335 to +373
def _mmi_nxn(
n,
wl=1.55,
wl0=1.55,
fwhm=0.2,
loss_dB=None,
shift=None,
splitting_matrix=None,
) -> sax.SDict:
"""
General n x n MMI model.

Args:
n (int): Number of input and output ports.
wl (float): Operating wavelength.
wl0 (float): Center wavelength of the MMI.
fwhm (float): Full width at half maximum.
loss_dB (np.array): Array of loss values in dB for each port.
shift (np.array): Array of wavelength shifts for each port.
splitting_matrix (np.array): nxn matrix defining the power splitting ratios between ports.
"""
if loss_dB is None:
loss_dB = jnp.zeros(n)
if shift is None:
shift = jnp.zeros(n)
if splitting_matrix is None:
splitting_matrix = jnp.full((n, n), 1 / n) # Uniform splitting as default

S = {}
for i in range(n):
for j in range(n):
amplitude = _mmi_amp(wl, wl0 + shift[j], fwhm, loss_dB[j])
amplitude *= jnp.sqrt(
splitting_matrix[i][j]
) # Convert power ratio to amplitude
loss_factor = 10 ** (-loss_dB[j] / 20)
S[(f"o{i+1}", f"o{j+1}")] = amplitude * loss_factor

return sax.reciprocal(S)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (testing): Missing tests for the new _mmi_nxn function.

The addition of the _mmi_nxn function introduces significant new functionality. It's crucial to ensure this function behaves as expected under various conditions, including edge cases such as extreme values for n, wl, wl0, fwhm, loss_dB, shift, and splitting_matrix. Please add unit tests to cover these scenarios.

@joamatab joamatab added the enhancement New feature or request label Apr 23, 2024
@joamatab joamatab merged commit 5ad5bfb into main Apr 25, 2024
14 checks passed
@joamatab joamatab deleted the mmi_imbalance branch April 25, 2024 19:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant