Skip to content

Commit 41cf6cc

Browse files
committed
reverted changes to corner_finder.py and added more changes to geometry/base.py, geometry/primitives.py
1 parent b25b7a6 commit 41cf6cc

File tree

3 files changed

+18
-16
lines changed

3 files changed

+18
-16
lines changed

tidy3d/components/geometry/base.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1739,7 +1739,7 @@ def _intersections_normal(self, z: float, transpose: bool = False) -> list:
17391739
z : float
17401740
Position along the axis normal to slab
17411741
transpose : bool
1742-
Optional: Swap the order of the x and y axis in the geometry data
1742+
Optional: Swap the order of the x and y axis in the geometry data.
17431743
17441744
Returns
17451745
-------
@@ -1760,7 +1760,7 @@ def _intersections_side(self, position: float, axis: Axis, transpose: bool = Fal
17601760
axis : int
17611761
Integer index into 'xyz' (0,1,2).
17621762
transpose : bool
1763-
Optional: Swap the order of the remaining two axes (the ones not equal to axis)
1763+
Optional: Swap the order of the remaining two axes (the axes not equal to axis).
17641764
17651765
Returns
17661766
-------
@@ -2098,6 +2098,8 @@ def intersections_plane(
20982098
Position of plane in y direction, only one of x,y,z can be specified to define plane.
20992099
z : float = None
21002100
Position of plane in z direction, only one of x,y,z can be specified to define plane.
2101+
transpose: bool = False
2102+
Optional: Swap the order of the coordinates in the two remaining (unspecified) axis?
21012103
21022104
Returns
21032105
-------
@@ -2483,13 +2485,12 @@ def _derivative_face(
24832485
min_max_index: int,
24842486
axis_normal: Axis,
24852487
derivative_info: DerivativeInfo,
2486-
transpose: bool = False,
24872488
) -> float:
24882489
"""Compute the derivative w.r.t. shifting a face in the normal direction."""
24892490

24902491
# normal and tangential dims
2491-
dim_normal, dims_perp = self.pop_axis("xyz", axis=axis_normal, transpose=transpose)
2492-
fld_normal, flds_perp = self.pop_axis(("Ex", "Ey", "Ez"), axis=axis_normal, transpose=transpose)
2492+
dim_normal, dims_perp = self.pop_axis("xyz", axis=axis_normal)
2493+
fld_normal, flds_perp = self.pop_axis(("Ex", "Ey", "Ez"), axis=axis_normal)
24932494

24942495
# normal and tangential fields
24952496
D_normal = derivative_info.D_der_map[fld_normal].sel(f=derivative_info.frequency)
@@ -2499,7 +2500,7 @@ def _derivative_face(
24992500

25002501
# normal and tangential bounds
25012502
bounds_T = np.array(derivative_info.bounds).T # put (xyz) first dimension
2502-
bounds_normal, bounds_perp = self.pop_axis(bounds_T, axis=axis_normal, transpose=transpose)
2503+
bounds_normal, bounds_perp = self.pop_axis(bounds_T, axis=axis_normal)
25032504

25042505
# define the integration plane
25052506
coord_normal_face = bounds_normal[min_max_index]
@@ -2546,8 +2547,8 @@ def _derivative_face(
25462547
eps_xyz_outside = [eps.isel(**{dim_normal: index_out}) for eps in eps_xyz]
25472548

25482549
# put in normal / tangential basis
2549-
eps_in_normal, eps_in_perps = self.pop_axis(eps_xyz_inside, axis=axis_normal, transpose=transpose)
2550-
eps_out_normal, eps_out_perps = self.pop_axis(eps_xyz_outside, axis=axis_normal, transpose=transpose)
2550+
eps_in_normal, eps_in_perps = self.pop_axis(eps_xyz_inside, axis=axis_normal)
2551+
eps_out_normal, eps_out_perps = self.pop_axis(eps_xyz_outside, axis=axis_normal)
25512552

25522553
# compute integration pre-factors
25532554
delta_eps_perps = [eps_in - eps_out for eps_in, eps_out in zip(eps_in_perps, eps_out_perps)]

tidy3d/components/geometry/primitives.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,11 @@ def intersections_tilted_plane(
112112
return [shapely.Polygon(vertices[:, :2])]
113113

114114
def intersections_plane(
115-
self, x: Optional[float] = None, y: Optional[float] = None, z: Optional[float] = None
115+
self,
116+
x: Optional[float] = None,
117+
y: Optional[float] = None,
118+
z: Optional[float] = None,
119+
transpose: bool = False,
116120
):
117121
"""Returns shapely geometry at plane specified by one non None value of x,y,z.
118122
@@ -135,7 +139,7 @@ def intersections_plane(
135139
axis, position = self.parse_xyz_kwargs(x=x, y=y, z=z)
136140
if not self.intersects_axis_position(axis, position):
137141
return []
138-
z0, (x0, y0) = self.pop_axis(self.center, axis=axis)
142+
z0, (x0, y0) = self.pop_axis(self.center, axis=axis, transpose=transpose)
139143
intersect_dist = self._intersect_dist(position, z0)
140144
if not intersect_dist:
141145
return []

tidy3d/components/grid/corner_finder.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ def _merged_pec_on_plane(
8585
structure_list: list[Structure],
8686
center: tuple[float, float] = [0, 0, 0],
8787
size: tuple[float, float, float] = [inf, inf, inf],
88-
transpose: bool = False,
8988
) -> list[tuple[Any, Shapely]]:
9089
"""On a 2D plane specified by axis = `normal_axis` and coordinate `coord`, merge geometries made of PEC.
9190
@@ -124,7 +123,7 @@ def _merged_pec_on_plane(
124123
PEC if (mat.is_pec or isinstance(mat, LossyMetalMedium)) else mat for mat in medium_list
125124
]
126125
# merge geometries
127-
merged_geos = merging_geometries_on_plane(geometry_list, plane, medium_list, transpose=transpose)
126+
merged_geos = merging_geometries_on_plane(geometry_list, plane, medium_list)
128127

129128
return merged_geos
130129

@@ -134,7 +133,6 @@ def _corners_and_convexity(
134133
coord: float,
135134
structure_list: list[Structure],
136135
ravel: bool,
137-
transpose: bool = False,
138136
) -> tuple[ArrayFloat2D, ArrayFloat1D]:
139137
"""On a 2D plane specified by axis = `normal_axis` and coordinate `coord`, find out corners of merged
140138
geometries made of PEC.
@@ -159,7 +157,7 @@ def _corners_and_convexity(
159157

160158
# merge geometries
161159
merged_geos = self._merged_pec_on_plane(
162-
normal_axis=normal_axis, coord=coord, structure_list=structure_list, transpose=transpose
160+
normal_axis=normal_axis, coord=coord, structure_list=structure_list
163161
)
164162

165163
# corner finder
@@ -197,7 +195,6 @@ def corners(
197195
normal_axis: Axis,
198196
coord: float,
199197
structure_list: list[Structure],
200-
transpose: bool = False,
201198
) -> ArrayFloat2D:
202199
"""On a 2D plane specified by axis = `normal_axis` and coordinate `coord`, find out corners of merged
203200
geometries made of `medium`.
@@ -219,7 +216,7 @@ def corners(
219216
"""
220217

221218
corner_list, _ = self._corners_and_convexity(
222-
normal_axis=normal_axis, coord=coord, structure_list=structure_list, ravel=True, transpose=transpose
219+
normal_axis=normal_axis, coord=coord, structure_list=structure_list, ravel=True
223220
)
224221
return corner_list
225222

0 commit comments

Comments
 (0)