@@ -204,35 +204,35 @@ def test_abc_boundary():
204
204
with pytest .raises (pydantic .ValidationError ):
205
205
_ = td .ABCBoundary (permittivity = None , conductivity = - 0.1 )
206
206
207
- # test abc mode spec
207
+ # test mode abc
208
208
wvl_um = 1
209
209
freq0 = td .C_0 / wvl_um
210
- abc_mode_spec = td .ABCModeSpec (
211
- size = (1 , 1 , 0 ),
210
+ mode_abc = td .ModeABCBoundary (
211
+ plane = td . Box ( size = (1 , 1 , 0 ) ),
212
212
mode_spec = td .ModeSpec (num_modes = 2 ),
213
213
mode_index = 1 ,
214
214
frequency = freq0 ,
215
215
)
216
216
217
217
with pytest .raises (pydantic .ValidationError ):
218
- _ = td .ABCModeSpec (
219
- size = (1 , 1 , 0 ),
218
+ _ = td .ModeABCBoundary (
219
+ plane = td . Box ( size = (1 , 1 , 0 ) ),
220
220
mode_spec = td .ModeSpec (num_modes = 2 ),
221
221
mode_index = 1 ,
222
222
frequency = - 1 ,
223
223
)
224
224
225
225
with pytest .raises (pydantic .ValidationError ):
226
- _ = td .ABCModeSpec (
227
- size = (1 , 1 , 0 ),
226
+ _ = td .ModeABCBoundary (
227
+ plane = td . Box ( size = (1 , 1 , 0 ) ),
228
228
mode_spec = td .ModeSpec (num_modes = 2 ),
229
229
mode_index = - 1 ,
230
230
frequency = freq0 ,
231
231
)
232
232
233
233
with pytest .raises (pydantic .ValidationError ):
234
- _ = td .ABCModeSpec (
235
- size = (1 , 1 , 1 ),
234
+ _ = td .ModeABCBoundary (
235
+ plane = td . Box ( size = (1 , 1 , 1 ) ),
236
236
mode_spec = td .ModeSpec (num_modes = 2 ),
237
237
mode_index = 0 ,
238
238
frequency = freq0 ,
@@ -246,24 +246,41 @@ def test_abc_boundary():
246
246
mode_index = 1 ,
247
247
direction = "+" ,
248
248
)
249
+ mode_abc_from_source = td .ModeABCBoundary .from_source (mode_source )
250
+ assert mode_abc == mode_abc_from_source
249
251
250
- abc_mode_spec_from_source = td . ABCModeSpec . from_source ( mode_source )
251
-
252
- assert abc_mode_spec == abc_mode_spec_from_source
253
-
254
- _ = td .ABCBoundary ( permittivity = abc_mode_spec )
255
-
256
- with pytest . raises ( pydantic . ValidationError ):
257
- _ = td . ABCBoundary ( permittivity = abc_mode_spec , conductivity = 0.1 )
252
+ # from mode monitor
253
+ mode_monitor = td . ModeMonitor (
254
+ size = ( 1 , 1 , 0 ), mode_spec = td . ModeSpec ( num_modes = 2 ), freqs = [ freq0 ], name = "mnt"
255
+ )
256
+ mode_abc_from_monitor = td .ModeABCBoundary . from_monitor (
257
+ mode_monitor , mode_index = 1 , frequency = freq0
258
+ )
259
+ assert mode_abc == mode_abc_from_monitor
258
260
259
261
# in Boundary
260
262
_ = td .Boundary (
261
- minus = td .ABCBoundary (permittivity = 3 ), plus = td .ABCBoundary ( permittivity = abc_mode_spec )
263
+ minus = td .ABCBoundary (permittivity = 3 ), plus = td .ModeABCBoundary ( plane = td . Box ( size = ( 1 , 1 , 0 )) )
262
264
)
263
265
_ = td .Boundary .abc (permittivity = 3 , conductivity = 1e-5 )
266
+ abc_boundary = td .Boundary .mode_abc (
267
+ plane = td .Box (size = (1 , 1 , 0 )),
268
+ mode_spec = td .ModeSpec (num_modes = 2 ),
269
+ mode_index = 1 ,
270
+ frequency = freq0 ,
271
+ )
272
+ abc_boundary_from_source = td .Boundary .mode_abc_from_source (mode_source )
273
+ abc_boundary_from_monitor = td .Boundary .mode_abc_from_monitor (
274
+ mode_monitor , mode_index = 1 , frequency = freq0
275
+ )
276
+ assert abc_boundary == abc_boundary_from_source
277
+ assert abc_boundary == abc_boundary_from_monitor
264
278
265
279
with pytest .raises (pydantic .ValidationError ):
266
- _ = td .Boundary (minus = td .Periodic (), plus = td .ABCBoundary (permittivity = abc_mode_spec ))
280
+ _ = td .Boundary (minus = td .Periodic (), plus = td .ABCBoundary ())
281
+
282
+ with pytest .raises (pydantic .ValidationError ):
283
+ _ = td .Boundary (minus = td .Periodic (), plus = td .ModeABCBoundary (plane = td .Box (size = (1 , 1 , 0 ))))
267
284
268
285
# in Simulation
269
286
_ = td .Simulation (
@@ -390,7 +407,7 @@ def test_abc_boundary():
390
407
boundary_spec = td .BoundarySpec .all_sides (td .ABCBoundary ()),
391
408
)
392
409
393
- # need to define frequence for ABCModeSpec
410
+ # need to define frequence for ModeABCBoundary
394
411
# manually
395
412
_ = td .Simulation (
396
413
center = [0 , 0 , 0 ],
@@ -402,7 +419,7 @@ def test_abc_boundary():
402
419
sources = [],
403
420
run_time = 1e-20 ,
404
421
boundary_spec = td .BoundarySpec .all_sides (
405
- td .ABCBoundary ( permittivity = td .ABCModeSpec (size = (1 , 1 , 0 ), frequency = freq0 ) )
422
+ td .ModeABCBoundary ( plane = td .Box (size = (1 , 1 , 0 )) , frequency = freq0 )
406
423
),
407
424
)
408
425
# or at least one source
@@ -415,9 +432,7 @@ def test_abc_boundary():
415
432
),
416
433
sources = [mode_source ],
417
434
run_time = 1e-20 ,
418
- boundary_spec = td .BoundarySpec .all_sides (
419
- td .ABCBoundary (permittivity = td .ABCModeSpec (size = (1 , 1 , 0 )))
420
- ),
435
+ boundary_spec = td .BoundarySpec .all_sides (td .ModeABCBoundary (plane = td .Box (size = (1 , 1 , 0 )))),
421
436
)
422
437
# multiple sources with different central freqs is still ok, but show warning
423
438
with AssertLogLevel (
@@ -438,6 +453,6 @@ def test_abc_boundary():
438
453
],
439
454
run_time = 1e-20 ,
440
455
boundary_spec = td .BoundarySpec .all_sides (
441
- td .ABCBoundary ( permittivity = td .ABCModeSpec (size = (1 , 1 , 0 )))
456
+ td .ModeABCBoundary ( plane = td .Box (size = (1 , 1 , 0 )))
442
457
),
443
458
)
0 commit comments