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
Introduce SubpixelSpec to allow for selecting subpixel averaging methods on different materials #1689
base: pre/2.7
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.
I think the API looks pretty good. Nothing stands out to me as an issue.
One thing is that we should choose the class names carefully. Specifically,
BenklerSubpixel
HeuristicSubpixel
are both not clear from the title what exactly they are and when to use them. I'm not sure about the specific details, eg maybe these are commonly used names in the field, but if there are any more intuitive names for these, we should consider using them? Or even making up our own.
Good point. I have concerns about the names as well, but forgot to bring it up. E.g. Benkler is too specific. How about a general name Regarding Heuristic, how about HeuristicStaircasingSubpixel? @momchil-flex |
Yeah, I agree with both of those suggestions. |
One more question on names: is it necessary for each of them ending in |
Yeah, I think dropping Subpixel makes sense.
I think it's probably better in the long run yeah. You don't have to allow volumetric to be an actual option if it requires more effort on the backend. What should we call the dielectric subpixel? |
ddc016e
to
d9f4bf2
Compare
Still haven't figured out a good name for dielectric subpixel averaging, so it remains as boolean for now. Docstrings have been updated. Now the new API looks like this
@tylerflex how do I fix the failing test_IO.py that loads an incompatible |
hm, try running this script? |
Thanks, that fixes it. |
Sorry another question @tylerflex: it seems that allowing a simulation field to be the union of a basic type (e.g. bool in |
Hm, not sure about this, sorry. Maybe @dbochkov-flexcompute has some idea? |
It seems to be related to the fact that pydantic tries to initialize a field with all possible options, if no guidance for it is given. That is, adding |
That is working! thanks |
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 to me! just one thing: would it make sense to rename MetalConformal
to PECConformal
since it goes into pec:
but not metal:
field?
We plan to add good conductor handling in the near quarter (a new field |
Now as I read more about good conductor subpixel, it's likely to have quite different fields compared to PEC-type conformal. In that regard, there is no need to share this class between PEC and metal, so it's a good idea to rename it to |
5f8fb18
to
df349c3
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.
Few minor comments about the current code. Otherwise, two more questions to discuss further:
- for
dielectric
, should we avoid using boolean but define an explicitly named spec instead (also in view of defining different ones in the future) - are we eventually going to have a
good_conductor
kind of field inSubpixelSpec
too, and how is that going to interact withmetal
?
tidy3d/components/eme/simulation.py
Outdated
title="Subpixel Averaging", | ||
description="If ``True``, uses subpixel averaging of the permittivity " | ||
"based on structure definition, resulting in much higher accuracy for a given grid size.", | ||
"based on structure definition, resulting in much higher accuracy for a given grid size. " |
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 think we need to flip this message around and say what SubpixelSpec does; then say what setting subpixel=True
corresponds to in terms of a SubpixelSpec (dielectric subpixel, everything else staircased).
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.
when subpixel=True
, now conformal is also applied to PEC, as it is in general much more accurate than staircasing.
In the 1st release, we might just limit |
…s on different materials Validate dielectric subpixel in adjoint plugin Enable VolumetricAveraging to automatically switch to Staircasing if the field is substantially normal to the interface
1d494af
to
864945b
Compare
864945b
to
f448f2c
Compare
New API
Metal is defined as
Re[eps]<1
at the central frequency.You can still set
subpixel=True/False
:True
using the defaultSubpixelSpec()
: dielectric subpixel averaging on dielectric interface, staircasing on metal interface, and conformal (previously called Benkler) scheme on PEC;False
: staircasing on any material interface.TODO
Note
scene.mediums
.staircase_normal_component
. WhenTrue
, apply staircasing if the field component is mostly normal to the interface, since volumetric averaging won't help there.Open question: