-
Notifications
You must be signed in to change notification settings - Fork 50
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
Add subsection for EMESimulation #1863
Conversation
@weiliangjin2021 @momchil-flex I am tempted to make |
935bffb
to
1fa96d3
Compare
If frontend and backend tests all pass I think it should be good? |
Cool, I made the change. I'll run the backend tests some time today to confirm |
1fa96d3
to
9509e66
Compare
Curious about the reason behind this? I have a high-level code architecture question regarding this change: in some places we update ModeSolver object directly by swapping its simulation field to be the reduced simulation; now here with this change, some class methods themselves will reduce the simulation. So overall, the simulation can be reduced twice. Another major concern is that class methods are employing different simulations, which can be confusing in future development. I wonder if it's possible to either 1) before running any mode solver, update its simulation field, or 2) all class methods in mode solver take reduced simulation. |
I don't want to update the simulation field -- I think it is reasonable for the user to expect that the simulation field of the mode solver will remain the simulation that they put in. I just want to internally use You also mention worries about reducing the simulation twice. I thought that the reduction operation should be idempotent -- doing it twice is the same as doing it once. Is that incorrect? If so, that might raise a concern about the semantics of reduction. Overall, I don't want to change the simulation field of the |
Good point. The backend change happens to be all internal. I guess in the future we can revert the backend change, and just update those methods to use reduced simulation?
Correct. Just feel unnecessary of doing it twice. |
Ah, good point -- with this change in the frontend, the backend PR is no longer needed? I think I'll leave it in |
Yeah, the backend PR is indeed not needed now, as you are using the reduced simulation in computing the modes. Verified in the slow custom medium example. |
9509e66
to
0f04817
Compare
@momchil-flex can we merge this? I made some comments on the backend PR about memory estimation, but ultimately I don't think any backend updates are needed here, and the current memory estimation should remain valid? |
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.
Yeah, looks good. Just remove the modification to the notebooks submodule.
(Note I recently had a message about this on slack too, you can refer to it if unsure about the reasoning / workflow going forward.)
Let's also add a changelog item to |
6e25dfb
to
4454a83
Compare
ok, both fixed |
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.
looks good, but I'm confused about a validator _validate_size
tidy3d/components/eme/simulation.py
Outdated
def _validate_size(cls, val): | ||
"""An EME simulation must be fully 3D.""" | ||
if any(val == 0): | ||
raise SetupError("'EMESimulation' cannot have any component of 'size' equal to zero.") |
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.
hm, shouldn't this return val
if it works? I'm a bit confused
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.
good catch. The validator was overwritten by another validator with the same name below, so it was not being run. I added a few more tests to catch this
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.
often, other errors were being raised, say when the mode solver monitors were not 2D. but now I test zero size in transverse direction too
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.
ah ok 👍 approving
4454a83
to
0867154
Compare
This PR:
subsection
fromSimulation
toAbstractYeeGridSimulation
.subsection
inEMESimulation
to also allow inheriting the EME grid spec. The behavior wheneme_grid_spec == "identical"
is to extend the region to snap to EME cell boundaries.ModeSolver.reduced_simulation_copy
useModeSolver.to_fdtd_mode_solver()
when thesimulation
is anEMESimulation
. This is needed for now because anEMESimulation
must be fully 3D, while we need a 2D subsection in the mode solver. Eventually, instead of usingsubsection
ofFDTDSimulation
, it might be nicer to convert to aModeSimulation
and usesubsection
ofModeSimulation
. But that would be after theModeSimulation
PR is merged.data_on_yee_grid
always use thereduced_simulation_copy
.