@@ -88,6 +88,10 @@ def _solver_grid(self) -> Grid:
8888 will be reset to the exact plane position after the solve."""
8989 plane_sym = self .simulation .min_sym_box (self .plane )
9090 boundaries = self .simulation .discretize (plane_sym , extend = True ).boundaries .to_list
91+ # Do not extend if simulation has a single pixel along a dimension
92+ for dim , num_cells in enumerate (self .simulation .grid .num_cells ):
93+ if num_cells <= 1 :
94+ boundaries [dim ] = self .simulation .grid .boundaries .to_list [dim ]
9195 # Remove extension on the min side if symmetry present
9296 bounds_norm , bounds_plane = plane_sym .pop_axis (boundaries , self .normal_axis )
9397 bounds_plane = list (bounds_plane )
@@ -140,7 +144,14 @@ def data_raw(self) -> ModeSolverData:
140144 for field_name in ("Ex" , "Ey" , "Ez" , "Hx" , "Hy" , "Hz" ):
141145
142146 xyz_coords = self ._solver_grid [field_name ].to_list
147+ # Snap to plane center along normal direction
143148 xyz_coords [self .normal_axis ] = [self .plane .center [self .normal_axis ]]
149+ # Snap to simulation center if simulation is 0D along a tangential dimension
150+ _ , plane_axes = self .plane .pop_axis ([0 , 1 , 2 ], axis = self .normal_axis )
151+ for plane_axis in plane_axes :
152+ if len (xyz_coords [plane_axis ]) == 1 :
153+ xyz_coords [plane_axis ] = [self .simulation .center [plane_axis ]]
154+
144155 scalar_field_data = ScalarModeFieldDataArray (
145156 np .stack ([field_freq [field_name ] for field_freq in fields ], axis = - 2 ),
146157 coords = dict (
0 commit comments