-
Notifications
You must be signed in to change notification settings - Fork 49
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
Nonuniform Mesh API #296
Comments
My opinion is actually do 1 and then transition to 3. Like you say, I believe that we should be writing What I'm thinking right now is:
The Mesher can also be available as a plugin. The point however is that we don't need to use that plugin in order to initialize a simulation. We just need to provide the correct grid_size (which can be a MeshSpec) that we want. This is similar to how you don't need to use the mode solver plugin to define the mode sources and monitors in the simulation. You provide the ModeSpec, not the solved fields. The plugin is just a convenience to examine the modes and their fields before settling on a ModeSpec. Similarly, you provide a MeshSpec for the nonuniform mesh, not the grid or grid boundaries that are computed by the Mesher for a given MeshSpec. But, you can use the Mesher in advance to examine how things look before settling on a MeshSpec. |
I dont think the Mesher can be a plugin since Simulation depends on it. There's also a circular import issue that sets off some red flags for me: mesher.py from .simulation import Simulation
from .types import GridSize
class Mesher:
sim : Simulation
grid_size : GridSize simulation.py from .mesher import Mesher
class Simulation
@property
def grid(self):
mesher = Mesher(self, grid_size)
return mesher.grid It's kind of inherently circular. One workaround is similar to something shashwat suggested, which is to pass the relevant simulation parameters. In fact a while ago when we considered grid spec, I had something like this, but it was very clunky. I'm not sure if there's another approach if we go with 1 or 3. We'll need something that takes a |
I guess the way we're currently doing it is essentially #1 (without mesher) but I was never 100% happy with it. |
Yeah you're right. As long as we want to give MeshSpec-s to the simulation (which I do), it seems to me that the mesher is an integral part of the simulation rather than a plugin, because the simulation needs it to make its grid, which is needed in many places. Maybe I've got it - it just requires a small API change. Instead of
Internally, the It's a separate question if we want to combine the grid plotting in |
Ok so here the I think this is getting better. I think that since the Mesher is ultimately getting turned into specs, it might make more sense for it to just be called I'm still leaning towards an interim plugin for generating the |
Yeah.
Agree on calling it
It is a major change so painful yeah, but as usual better earlier than later? Like, the question is if that's what we want to have eventually, and if yes - then we should do it now. I kinda feel like we'll have to change the I don't anticipate any other risks apart from just the need to change like every simulation init in all our docs and tests. |
I'd say we just have a few options for MeshSpec1D subclasses, like
Yea.. just throwing this idea out there (similar to what you said): we add |
|
In the branch
Some issues and TODOs:
|
|
I've created I think we can postpone 3. and 4. from the list above for next patch. What still needs to be done is:
|
Here's another update.
Also, I introduced
After giving it some thought, I am not that enthusiastic about adding a For next patch:
|
Here's a list of all docs notebooks. We need to incorporate the new auto nonuniform grid in all of them. You can do something like
To have a look at the grid. In most cases the grid will be too dense to show, so if everything looks good, remove the grid plotting. But if you find some cases where it's useful to keep it on, do so!
|
I have gone through and updated all the notebooks whose check boxes are ticked above. Here are some observations:
|
Let's use this to iterate on the nonuniform mesh architecture and API?
General picture
Introducing the notion of a
MeshSpec
that contains specifications about how the user wants the space to be discretized (minimum grids per wavelength, etc.).a
MeshSpec
+Simulation
+ other parameters ultimately determines a set of coordinates in 1D that define the yee cell boundaries.If these mesh specs will be contained directly in the
Simulation
, whenSimulation.grid
property is called, the coordinates from the mesh specs should be evaluated loaded into aGrid()
.If these mesh specs are defined externally to set
grid_size
, then the code functions as it does now.Main API Options
MeshSpec()
as another accepted value in one ofSimulation.grid_size
. When computing grid boundaries, add a special case to handle aMeshSpec()
.Simulation.grid_size
asfloat
orarray
and make an external plugin to generate agrid_size
givenMeshSpec()
,simulation
and other parameters.3.MeshSpec()
the only way to define discretization, but supply otherMeshSpec()
types to handle uniform or user specified grid sizes.4.Considerations
MeshSpec
directly, or add an optionalfreq
Field
to theSimulation
, or have it be a kwarg in the plugin init.MeshSpec
would be easier to read than raw coords.Thoughts
if meshSpec1: do this elif meshSpec2 do this
. Ideally, theMeshSpec
should contain it's own way to generate a 1D grid from a set of parameters, whether that be size & center, structures, simulation, etc.The text was updated successfully, but these errors were encountered: