|
38 | 38 | FIELD_MONITOR_2D, |
39 | 39 | FIELD_TIME_MONITOR, |
40 | 40 | FIELD_TIME_MONITOR_2D, |
| 41 | + FIELDS, |
41 | 42 | FLUX_MONITOR, |
42 | 43 | FLUX_TIME_MONITOR, |
| 44 | + FREQS, |
43 | 45 | MEDIUM_MONITOR, |
44 | 46 | MODE_MONITOR, |
45 | 47 | MODE_MONITOR_WITH_FIELDS, |
@@ -1133,3 +1135,39 @@ def test_from_zbf_dimsfail(self, tmp_path, field_data, dim1, dim2): |
1133 | 1135 | # this should fail |
1134 | 1136 | with pytest.raises(ValueError) as e: |
1135 | 1137 | _ = td.FieldDataset.from_zbf(filename=zbf_filename, dim1=dim1, dim2=dim2) |
| 1138 | + |
| 1139 | + |
| 1140 | +def test_symmetry_expansion_no_interpolation_warning(): |
| 1141 | + """Regression test: symmetry_expanded_copy should not warn when monitor is on |
| 1142 | + the negative side of the symmetry center. Bug was using coords[-1] (negative) |
| 1143 | + instead of coords_interp[-1] (positive) for coordinate matching.""" |
| 1144 | + # Monitor entirely on negative y side (need size > 0 for multiple coords) |
| 1145 | + monitor = td.FieldMonitor( |
| 1146 | + size=(2, 0.5, 5), center=(0, -1.0, 0), fields=FIELDS, name="field", freqs=FREQS |
| 1147 | + ) |
| 1148 | + sim = SIM_SYM.updated_copy(monitors=[monitor], symmetry=(0, -1, 0)) |
| 1149 | + grid = sim.discretize_monitor(monitor) |
| 1150 | + |
| 1151 | + # Grid y coords are negative; data stored at mirrored positive coords |
| 1152 | + y_grid = grid["Ex"].y |
| 1153 | + assert len(y_grid) > 1 and all(y < 0 for y in y_grid) |
| 1154 | + y_data = [-y for y in y_grid] |
| 1155 | + |
| 1156 | + data = td.ScalarFieldDataArray( |
| 1157 | + np.ones((len(grid["Ex"].x), len(y_data), len(grid["Ex"].z), len(FREQS))) + 0j, |
| 1158 | + coords={"x": grid["Ex"].x, "y": y_data, "z": grid["Ex"].z, "f": FREQS}, |
| 1159 | + ) |
| 1160 | + field_data = FieldData( |
| 1161 | + monitor=monitor, |
| 1162 | + Ex=data, |
| 1163 | + Ey=data, |
| 1164 | + Ez=data, |
| 1165 | + Hx=data, |
| 1166 | + Hz=data, |
| 1167 | + symmetry=sim.symmetry, |
| 1168 | + symmetry_center=sim.center, |
| 1169 | + grid_expanded=grid, |
| 1170 | + ) |
| 1171 | + |
| 1172 | + with AssertLogLevel(None): |
| 1173 | + _ = field_data.symmetry_expanded_copy |
0 commit comments