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

automatic mode rotation for bent waveguide #2028

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from

Conversation

QimingFlex
Copy link
Contributor

@QimingFlex QimingFlex commented Oct 22, 2024

@momchil-flex This is a very initial draft and not ready for review yet, but could you take a quick look at the code structure to see if there are any major mistakes so I can address them early on? I added a field bend_correction in mode_spec, and the process for mode rotation is mostly in data_raw in ModeSolver.

Copy link
Collaborator

@momchil-flex momchil-flex left a comment

Choose a reason for hiding this comment

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

Adding some initial comments, overall the structure makes sense. So is this working currently? We'll obviously need to add a bunch of tests too.

tidy3d/plugins/mode/mode_solver.py Outdated Show resolved Hide resolved
tidy3d/plugins/mode/mode_solver.py Outdated Show resolved Hide resolved
@QimingFlex QimingFlex changed the title Qiming/mode rotation automatic mode rotation for bent waveguide Oct 22, 2024
@QimingFlex
Copy link
Contributor Author

Adding some initial comments, overall the structure makes sense. So is this working currently? We'll obviously need to add a bunch of tests too.

Thanks! I’ve validated the process locally with several cases involving differently oriented bends, and I’ll add those to the tests. This PR isn’t fully working yet, but it’s close. I’ll wrap up the code based on your feedback.

@QimingFlex QimingFlex force-pushed the qiming/mode_rotation branch 5 times, most recently from 1353ea5 to c1fd5c1 Compare October 28, 2024 17:48
@QimingFlex QimingFlex marked this pull request as ready for review November 1, 2024 21:15
@QimingFlex QimingFlex force-pushed the qiming/mode_rotation branch 2 times, most recently from 6e51b86 to 4e6dbc7 Compare November 1, 2024 22:41
@momchil-flex momchil-flex added the 2.8 will go into version 2.8.* label Nov 5, 2024
tidy3d/components/mode.py Outdated Show resolved Hide resolved
tidy3d/components/mode.py Outdated Show resolved Hide resolved
tidy3d/components/mode.py Outdated Show resolved Hide resolved
tidy3d/plugins/mode/mode_solver.py Outdated Show resolved Hide resolved
tidy3d/plugins/mode/mode_solver.py Show resolved Hide resolved
tidy3d/plugins/mode/mode_solver.py Show resolved Hide resolved
tidy3d/plugins/mode/mode_solver.py Outdated Show resolved Hide resolved
tidy3d/plugins/mode/mode_solver.py Outdated Show resolved Hide resolved
cmp_1, cmp_2 = source_names

for mode_idx in range(mode_index.size):
for f_idx, f_val in enumerate(f.values):
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would think it should be possible to vectorize if not along both of these dims, then at least over the frequency one. This could be left as an optimization for later though.

}

# Transform fields from Cartesian to cylindrical coordinates
for i, _rho in enumerate(rho):
Copy link
Collaborator

Choose a reason for hiding this comment

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

I suspect this could be slow in some cases, but we may have no choice, or do you have any ideas about vectorizing?

@QimingFlex QimingFlex force-pushed the qiming/mode_rotation branch 5 times, most recently from b1c38bc to c5f79fc Compare November 13, 2024 16:25
cmp_1, cmp_2 = source_names

for mode_idx in range(mode_index.size):
for f_idx, f_val in enumerate(f):
Copy link
Collaborator

Choose a reason for hiding this comment

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

These two loops seem easy to vectorize out.

if sym == 0:
colocate_coords[dim] = coords[1:-1]
else:
colocate_coords[dim] = coords[:-1]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's separate this out in a separate private method that we can call both here and in _colocate_fields to avoid code duplication.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2.8 will go into version 2.8.*
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants