-
Notifications
You must be signed in to change notification settings - Fork 40
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
Reduced sim mode solver #1316
Reduced sim mode solver #1316
Conversation
0fcf757
to
60422cc
Compare
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.
Thanks @dbochkov-flexcompute I think the implementation makes a lot of sense. I just had a few minor comments about some of the conversions. This will be a nice feature to have in ways we haven't anticipated yet, I'm sure!
@@ -64,6 +65,9 @@ def run( | |||
Optional callback function called when uploading file with ``bytes_in_chunk`` as argument. | |||
progress_callback_download : Callable[[float], None] = None | |||
Optional callback function called when downloading file with ``bytes_in_chunk`` as argument. | |||
reduce_simulation : bool = True |
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.
probably a good idea to do it this way.
for pole, residue in self.poles: | ||
|
||
if not pole.does_cover(bounds=bounds): | ||
log.warning("Pole spatial data array does not fully cover the requested region.") |
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 wonder if it is necessary to warn at all. It is expected that some structure will be outside the requested region. It might raise tons of warning from a dispersive custom medium.
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.
actually, here bounds
would represent intersection of region from .subsection(region=region, ...)
and the bounding box of underlying structure or simulation itself (if background medium). So, if the original structure was put together correctly (that is, custom medium either covers it entirely or only one point is provided along a given dimension for constant extrapolation), then it won't produce any warnings
@@ -3843,6 +4167,9 @@ def eps_dataarray_freq( | |||
for ind, mat_component in enumerate(self.components.values()) | |||
) | |||
|
|||
def _sel_custom_data_inside(self, bounds: Bound): | |||
return self | |||
|
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.
The reduction doesn't seem to apply to anistoropic custom medium?
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.
It does apply. It's just a proper sel_inside()
is already inherited from AnisotropicMedium
and we just need to neutralize abstract _sel_custom_data_inside
inherited from AbstractCustomMedium
d271522
to
2d6bd78
Compare
addressed all comments, plus:
|
This is a good question. I think there are two issues, both of which probably lie outside the scope of this PR.
|
5496208
to
76559d3
Compare
76559d3
to
ef5d6c6
Compare
Implements #1191. That is, there is a new simulation method
.subsection(region: Box, ...)
that can be used to create a smaller simulation based on original one.grid_spec="identical"
). In this case it's converted into a custom grid and the requested region is expanded to match parent grid lines. One small issue here is that if the parent grid already matches the requested region, than due to numerical precision one additional cell might be included. But that doesn't seem cause any real issues.ModeSolver._solver_eps()
of local mode solver. That is, effective boundaries of structures might differ by one pixel between parent and child simulations..subsection(region: Box, ...)
is used internally in mode solver web api call and whether it is used or not is controlled by flagreduce_simulation
. I set it by default toTrue
, that is, all mode solver calls will use a reduced simulation. We can change it either toFalse
, or make it so that only simulation containing custom mediums are reduced and also display a warning/info notifying that this is done. What do you think?.subsection()
to cut out individual components for optic simulations).sel_inside()
fromSpatialDataArray
to other spatial data arrays (ScalarFieldDataArray
,ScalarFieldTimeDataArray
), custom medium classes and space time modulation classes. I realize that the name I used.sel_inside(bounds: Bound)
might be a bit misleading, because we extract data not just inside but that coversbounds
. An alternative could be.reduce_to_cover(bounds: Bound)
,.sel_to_cover(bounds: Bound)
. Any other suggestions?I put three of you as reviewers, but I don't think all of you need to review the entire thing. Maybe @weiliangjin2021 can looks through changes to custom medium classes and modulation classes, while @tylerflex and/or @momchil-flex can comment on overall implementation?