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

fix grating couplers in tidy3d #522

Merged
merged 3 commits into from
Dec 26, 2024
Merged

fix grating couplers in tidy3d #522

merged 3 commits into from
Dec 26, 2024

Conversation

joamatab
Copy link
Contributor

@joamatab joamatab commented Dec 26, 2024

Fixes grating couplers simulations in tidy3d

Before, as seen in this picture, the derived layers were missing from the simulatoin

image

@yaugenst

Summary by Sourcery

Fix derived layers in tidy3d simulations for grating couplers.

Bug Fixes:

  • Fixed missing derived layers in tidy3d simulations, ensuring their inclusion in grating coupler simulations.

Enhancements:

  • Refactored layer handling to include derived layers, updated simulation boundaries calculation, and improved port handling.

@joamatab joamatab added the bug Something isn't working label Dec 26, 2024
Copy link
Contributor

sourcery-ai bot commented Dec 26, 2024

Reviewer's Guide by Sourcery

This pull request fixes an issue with grating coupler simulations in tidy3d where derived layers were missing from the simulation. This was achieved by refactoring the get_simulation_grating_coupler function to correctly handle derived layers. The updated function now takes a layer_stack argument and uses it to apply derived layers to the component before extracting polygons for simulation. Additionally, the function now supports excluding specific layers from the simulation using the exclude_layers argument.

Class diagram for grating coupler simulation components

classDiagram
    class Component {
        +get_polygons_points()
        +ports
        +layers
    }

    class LayerStack {
        +layers
        +get_component_with_derived_layers()
        +get_layer_to_thickness()
        +get_layer_to_material()
    }

    class Layer {
        +layer
        +zmin
        +thickness
    }

    class LogicalLayer {
        +layer
    }

    class DerivedLayer {
        +layer
    }

    Layer <|-- LogicalLayer
    Layer <|-- DerivedLayer
    LayerStack *-- Layer
    Component --> LayerStack: uses
Loading

File-Level Changes

Change Details Files
Refactored the get_simulation_grating_coupler function to handle derived layers correctly.
  • Added exclude_layers parameter to exclude specific layers from the simulation.
  • Modified the function to use the provided layer_stack to apply derived layers to the component.
  • Updated polygon extraction to use the component with derived layers applied.
gplugins/tidy3d/get_simulation_grating_coupler.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time. You can also use
    this command to specify where the summary should be inserted.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

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.

We've reviewed this pull request using the Sourcery rules engine. If you would also like our AI-powered code review then let us know.

get_index,
get_medium,
)
from gplugins.tidy3d.materials import get_medium


def get_simulation_grating_coupler(
Copy link
Contributor

Choose a reason for hiding this comment

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

issue (code-quality): We've found these issues:


Explanation
The quality score for this function is below the quality threshold of 25%.
This score is a combination of the method length, cognitive complexity and working memory.

How can you solve this?

It might be worth refactoring this function to make it shorter and more readable.

  • Reduce the function length by extracting pieces of functionality out into
    their own functions. This is the most important thing you can do - ideally a
    function should be less than 10 lines.
  • Reduce nesting, perhaps by introducing guard clauses to return early.
  • Ensure that variables are tightly scoped, so that code using related concepts
    sits together within the function rather than being scattered.

@joamatab joamatab merged commit 6bf14ab into main Dec 26, 2024
11 of 15 checks passed
@joamatab joamatab deleted the fix_tidy3d_gratings branch December 26, 2024 06:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant