-
Notifications
You must be signed in to change notification settings - Fork 44
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
base: develop
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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.
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. |
1353ea5
to
c1fd5c1
Compare
e9eb835
to
00976a1
Compare
6e51b86
to
4e6dbc7
Compare
tidy3d/plugins/mode/mode_solver.py
Outdated
cmp_1, cmp_2 = source_names | ||
|
||
for mode_idx in range(mode_index.size): | ||
for f_idx, f_val in enumerate(f.values): |
There was a problem hiding this comment.
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): |
There was a problem hiding this comment.
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?
b1c38bc
to
c5f79fc
Compare
c5f79fc
to
2517468
Compare
cmp_1, cmp_2 = source_names | ||
|
||
for mode_idx in range(mode_index.size): | ||
for f_idx, f_val in enumerate(f): |
There was a problem hiding this comment.
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] |
There was a problem hiding this comment.
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.
@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 indata_raw
inModeSolver
.