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 field projections through a manually-specified medium #1291

Merged
merged 1 commit into from
Dec 8, 2023

Conversation

shashwat-sh
Copy link
Contributor

@shashwat-sh shashwat-sh commented Dec 6, 2023

@shashwat-sh shashwat-sh self-assigned this Dec 6, 2023
@shashwat-sh shashwat-sh linked an issue Dec 6, 2023 that may be closed by this pull request
@@ -11,6 +11,7 @@
from .base import cached_property, Tidy3dBaseModel
from .mode import ModeSpec
from .apodization import ApodizationSpec
from .medium import MediumType
Copy link
Collaborator

Choose a reason for hiding this comment

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

@tylerflex do you think importing from medium here could be problematic in the future? I'm not sure anymore if we ever defined the heirarchy of what's allowed to import from what.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Shoot, i don't remember now but this is giving me Deja vu remembering some annoying refactorings. So I'm not sure. My feeling is we probably shouldn't import it here if possible. is there a way around it? Im on mobile and can't look now in detail

Copy link
Collaborator

Choose a reason for hiding this comment

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

Bump

Copy link
Contributor Author

Choose a reason for hiding this comment

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

One idea, to allow for frequency dependence, is a projection_index field that accepts either a scalar, or an array whose size is validated to match the size of monitor.freqs, so that the user can provide a constant or one value per frequency?

Copy link
Collaborator

Choose a reason for hiding this comment

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

For medium, my preference is to set it in the FieldProjector. For example, can we add an optional field projection_medium : MediumType = None, if it is set, we return it in the property FieldProjector.medium otherwise, we use the default FieldProjector.medium. This way we dont introduce any coupling between monitors and mediums that can trip us up down the line. @shashwat-sh @momchil-flex how does this sound?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Well, it's definitely clunkier this way... But it sounds like we have to either live with it, or switch back to importing from Medium and hope this will not be an issue in the future?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@tylerflex do you have a strong preference either way? Regarding importing MediumType, one consideration is how the structure might change in 3.0 or other future refactors? Conceptually, it does make sense to me that a Medium is more "fundamental" than a monitor, so medium.py should never depend on anything in monitor.py, but you never know...

Copy link
Collaborator

Choose a reason for hiding this comment

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

I suppose it's probably ok. I guess in 3.0 we might have a division between "physics / scene" (including mediums) and "simulation / experiment" (including monitors). So now that I think about it, it could be ok to import scene objects into simulation modules.

My knee jerk reaction was just to not couple things if possible and I specifically remember some coupling between medium and monitor before that was an issue, but now that I think about it, it probably makes sense to allow it assuming things all work and there aren't any other closed loops formed by this import.

Copy link
Contributor Author

@shashwat-sh shashwat-sh Dec 7, 2023

Choose a reason for hiding this comment

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

At one point we had discussed getting rid of client-side projections altogether, especially if the plan is to provide a standalone server-side projector. Is this still the goal? If so, maybe the clunkiness is tolerable since it's mostly field_projection.py that's clunky now?

Copy link
Collaborator

Choose a reason for hiding this comment

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

It also seems more annoying for the user if it's not taking medium directly. Let's go with medium.

Copy link
Contributor

@tomflexcompute tomflexcompute left a comment

Choose a reason for hiding this comment

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

Thanks for the quick implementation!

@momchil-flex
Copy link
Collaborator

Squash and ship as far as I'm concerned. Could you also git checkout pre/2.5 -- tests/sims before your final commit? I already updated the version to 2.5.0 there so the new files you're commiting as 2_5_0rc3 actually aren't right.

@shashwat-sh shashwat-sh force-pushed the shash/projection_medium branch from bc54660 to 8684c7c Compare December 8, 2023 03:44
@shashwat-sh shashwat-sh merged commit e9fc81b into pre/2.5 Dec 8, 2023
@shashwat-sh shashwat-sh deleted the shash/projection_medium branch December 8, 2023 03:59
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.

Enabling medium index option for field projection monitors
4 participants