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

Empirical loss model for tidy3d mode solver #831

Merged
merged 5 commits into from Nov 10, 2022

Conversation

simbilod
Copy link
Collaborator

@simbilod simbilod commented Nov 10, 2022

Users can now empirically model the impact of surface scattering on waveguide propagation loss

This is done by adding a small parametrizable layer of imaginary index at the waveguide boundary as per this reference that can be calibrated to data. Top and side interfaces are treated independently.

While it is less robust than a full scattering treatment as per other references, the latter still requires external knowledge of RMS roughness and correlation length, in practice also calibrated from data. Both approaches also agree somewhat in the sense that ultimately, both only consider the overlap of the mode with the waveguide interface.

Example use:

wg = Waveguide(nmodes=2, 
                    wg_width=500*nm, 
                    wavelength=1.55, 
                    wg_thickness=220 * nm, 
                    slab_thickness=90 * nm, 
                    ncore=si, 
                    nclad=sio2,
                    loss_model=True, # boolean flag to trigger loss evaluation, default to False
                    sidewall_k = 1E-4, # imaginary index of scattering layer (sides)
                    top_k = 1E-4, # imaginary index of scattering layer (top)
                    sidewall_sigma = 20*nm, # thickness of scattering layer (sides)
                    top_sigma = 20*nm, # thickness of scattering layer (top)
                    resolution = 400,
                    cache=None,
                    precision='double'
                    )
wg.plot_index(func=np.imag) # new argument to pass callable to plotting function

image

This results in

print(wg.neffs)
print(wg.get_loss()) # new function to get loss in dB/cm
[2.58589854+6.95743124e-06j 2.16344   +9.52938134e-06j]
[2.44969153 3.35526776]

Note that fine resolution is required, which makes this method better suited to FEM, see the new package femwell if interested

@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Nov 10, 2022

Sourcery Code Quality Report

❌  Merging this PR will decrease code quality in the affected files by 0.80%.

Quality metrics Before After Change
Complexity 6.31 ⭐ 6.57 ⭐ 0.26 👎
Method Length 116.55 🙂 122.47 😞 5.92 👎
Working memory 14.71 😞 14.70 😞 -0.01 👍
Quality 52.09% 🙂 51.29% 🙂 -0.80% 👎
Other metrics Before After Change
Lines 907 954 47
Changed files Quality Before Quality After Quality Change
gdsfactory/simulation/gtidy3d/modes.py 52.09% 🙂 51.29% 🙂 -0.80% 👎

Here are some functions in these files that still need a tune-up:

File Function Complexity Length Working Memory Quality Recommendation
gdsfactory/simulation/gtidy3d/modes.py Waveguide.compute_modes 19 😞 822 ⛔ 28 ⛔ 17.37% ⛔ Refactor to reduce nesting. Try splitting into smaller methods. Extract out complex expressions
gdsfactory/simulation/gtidy3d/modes.py Waveguide.get_n 11 🙂 497 ⛔ 19 ⛔ 28.01% 😞 Try splitting into smaller methods. Extract out complex expressions
gdsfactory/simulation/gtidy3d/modes.py plot 6 ⭐ 183 😞 15 😞 45.96% 😞 Try splitting into smaller methods. Extract out complex expressions
gdsfactory/simulation/gtidy3d/modes.py plot_sweep_width 5 ⭐ 206 ⛔ 13 😞 47.80% 😞 Try splitting into smaller methods. Extract out complex expressions
gdsfactory/simulation/gtidy3d/modes.py Waveguide.compute_mode_properties 2 ⭐ 207 ⛔ 11 😞 54.00% 🙂 Try splitting into smaller methods. Extract out complex expressions

Legend and Explanation

The emojis denote the absolute quality of the code:

  • ⭐ excellent
  • 🙂 good
  • 😞 poor
  • ⛔ very poor

The 👍 and 👎 indicate whether the quality has improved or gotten worse with this pull request.


Please see our documentation here for details on how these metrics are calculated.

We are actively working on this report - lots more documentation and extra metrics to come!

Help us improve this quality report!

@codecov
Copy link

codecov bot commented Nov 10, 2022

Codecov Report

Merging #831 (69705fc) into master (d759947) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##           master     #831   +/-   ##
=======================================
  Coverage   74.66%   74.66%           
=======================================
  Files         425      425           
  Lines       20979    20979           
  Branches     2840     2840           
=======================================
  Hits        15664    15664           
  Misses       4444     4444           
  Partials      871      871           

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@simbilod
Copy link
Collaborator Author

fixing pre-commit now

@sonarcloud
Copy link

sonarcloud bot commented Nov 10, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@joamatab
Copy link
Contributor

Thank you Simon!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants