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

Momchil/nonuniform #314

Merged
merged 21 commits into from
Apr 23, 2022
Merged

Momchil/nonuniform #314

merged 21 commits into from
Apr 23, 2022

Conversation

momchil-flex
Copy link
Collaborator

No description provided.

Copy link
Collaborator

@tylerflex tylerflex left a comment

Choose a reason for hiding this comment

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

I really like the API, really no comments there.
There are a bunch of minor things related to the docstrings / type annotations etc. that can be cleaned up.
I think the auto meshing stuff needs to be refactored a bit to make it more readable and we should avoid free floating functions in favor of static methods. The idea is to make these functions more accessible ie AutoGrid.parse_structure instead of remembering where to import them from in the future.

Overall looks great, really excited for this feature!

CHANGELOG.md Outdated Show resolved Hide resolved
test_local.sh Show resolved Hide resolved
tidy3d/components/grid/grid_spec.py Show resolved Hide resolved
tidy3d/components/grid/grid_spec.py Outdated Show resolved Hide resolved
tidy3d/components/grid/grid_spec.py Outdated Show resolved Hide resolved
tidy3d/components/simulation.py Outdated Show resolved Hide resolved
tidy3d/components/simulation.py Outdated Show resolved Hide resolved
return Grid(boundaries=boundaries)

# Add a simulation Box as the first structure
structures = [Structure(geometry=self.geometry, medium=self.medium)]
Copy link
Collaborator

Choose a reason for hiding this comment

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

there's a @Property self.background_structure that does this now

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Actually, this doesn't work, because the box in that property has infinite size. Here we actually make a structure with the Simulation.geometry, which is used in make_grid. I think there's a need for both definitions of the backgroudn.

Copy link
Collaborator

Choose a reason for hiding this comment

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

k, yea let's make it a property then?

Copy link
Collaborator

Choose a reason for hiding this comment

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

maybe self.structure (singular?)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm a bit worried about future confusion with background_structure.

Copy link
Collaborator

Choose a reason for hiding this comment

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

ok feel free to rename these or leave one of them out.

tidy3d/components/simulation.py Show resolved Hide resolved
@@ -0,0 +1,770 @@
""" Collection of functions for automatically generating a nonuniform grid. """
Copy link
Collaborator

Choose a reason for hiding this comment

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

this file is pretty intense.. A couple general comments, I can't follow everything:

  1. We typically dont like to have free-floating functions when we can help it. I think these should be @staticmethods of the AutoGrid.
  2. The logic should be broken up into more bite sized chunks. Is there a way to refactor things a bit so the functions are not so enormous? it's definitely annoying and more work, but I think this would probably make it a lot easier to digest.

@tylerflex tylerflex linked an issue Apr 19, 2022 that may be closed by this pull request
@tylerflex tylerflex self-requested a review April 21, 2022 22:33
ax.add_collection(line_segments_x)
ax.add_collection(line_segments_y)

# Plto bounding boxes of override structures
Copy link
Collaborator

Choose a reason for hiding this comment

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

typo

ax.add_collection(line_segments_x)
ax.add_collection(line_segments_y)

# Plto bounding boxes of override structures
patch_kwargs = {
Copy link
Collaborator

Choose a reason for hiding this comment

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

the way the plotting is set up now it might be good to define these here
https://github.com/flexcompute/tidy3d/blob/develop/tidy3d/components/viz.py#L108
import them in this file, and then call
plot_params_override_structures.to_kwargs()
and pass zorder in Rectangle

Copy link
Collaborator

Choose a reason for hiding this comment

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

viz.py

# add `fill : bool = True` to `PlotParams`
plot_params_override_structures = PlotParams(linewidth=.4, edgecolor='black', fill=False)

simulation.py

from .viz import plot_params_override_structures
# ...
plot_params = plot_params_override_structure.copy(deep=True)
plot_params.include_kwargs(lw=2 * kwargs["linewidth"], ec=kwargs["colors"])
patch_kwargs = plot_params.to_kwargs()

@momchil-flex momchil-flex force-pushed the momchil/nonuniform branch 2 times, most recently from e35fcc4 to 502c7a4 Compare April 22, 2022 00:10
momchil-flex and others added 19 commits April 22, 2022 16:26
…array dl to not necessarily have a boundary at the simulation center
…lambda0 definition to just use sources' freq0 in validators
@momchil-flex momchil-flex force-pushed the momchil/nonuniform branch 2 times, most recently from 89b9f88 to f545b67 Compare April 22, 2022 23:54
@momchil-flex momchil-flex merged commit 72f2f84 into develop Apr 23, 2022
@momchil-flex momchil-flex deleted the momchil/nonuniform branch June 18, 2022 23:35
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.

Nonuniform Mesh API
3 participants