@@ -1393,3 +1393,115 @@ def test_wave_port_to_absorber(tmp_path):
1393
1393
sim = list (modeler .sim_dict .values ())[0 ]
1394
1394
absorber = sim .internal_absorbers [0 ]
1395
1395
assert absorber .boundary_spec == custom_boundary_spec
1396
+
1397
+
1398
+ def test_low_freq_smoothing_spec_initialization_default_values ():
1399
+ """Test that LowFrequencySmoothingSpec initializes with correct default values."""
1400
+ from tidy3d .plugins .smatrix .component_modelers .terminal import ModelerLowFrequencySmoothingSpec
1401
+
1402
+ spec = ModelerLowFrequencySmoothingSpec ()
1403
+ assert spec .min_sampling_time == 1
1404
+ assert spec .max_sampling_time == 5
1405
+ assert spec .order == 1
1406
+ assert spec .max_deviation == 0.5
1407
+
1408
+
1409
+ def test_low_freq_smoothing_spec_initialization_custom_values ():
1410
+ """Test that LowFrequencySmoothingSpec initializes with custom values."""
1411
+ from tidy3d .plugins .smatrix .component_modelers .terminal import ModelerLowFrequencySmoothingSpec
1412
+
1413
+ spec = ModelerLowFrequencySmoothingSpec (
1414
+ min_sampling_time = 2 , max_sampling_time = 8 , order = 2 , max_deviation = 0.3
1415
+ )
1416
+ assert spec .min_sampling_time == 2
1417
+ assert spec .max_sampling_time == 8
1418
+ assert spec .order == 2
1419
+ assert spec .max_deviation == 0.3
1420
+
1421
+
1422
+ def test_low_freq_smoothing_spec_edge_cases ():
1423
+ """Test edge cases and boundary conditions."""
1424
+ from tidy3d .plugins .smatrix .component_modelers .terminal import ModelerLowFrequencySmoothingSpec
1425
+
1426
+ # Test with order 0 (constant fit)
1427
+ spec = ModelerLowFrequencySmoothingSpec (order = 0 )
1428
+ assert spec .order == 0
1429
+
1430
+ # Test with maximum order
1431
+ spec = ModelerLowFrequencySmoothingSpec (order = 3 )
1432
+ assert spec .order == 3
1433
+
1434
+ # Test with zero max_deviation
1435
+ spec = ModelerLowFrequencySmoothingSpec (max_deviation = 0.0 )
1436
+ assert spec .max_deviation == 0.0
1437
+
1438
+ # Test with maximum max_deviation
1439
+ spec = ModelerLowFrequencySmoothingSpec (max_deviation = 1.0 )
1440
+ assert spec .max_deviation == 1.0
1441
+
1442
+
1443
+ def test_low_freq_smoothing_spec_validation_sampling_times_invalid ():
1444
+ """Test validation of sampling time parameters."""
1445
+ from tidy3d .plugins .smatrix .component_modelers .terminal import ModelerLowFrequencySmoothingSpec
1446
+
1447
+ # Test invalid range where min_sampling_time >= max_sampling_time
1448
+ with pytest .raises (
1449
+ ValueError , match = "The minimum sampling time must be less than the maximum sampling time"
1450
+ ):
1451
+ ModelerLowFrequencySmoothingSpec (min_sampling_time = 5 , max_sampling_time = 3 )
1452
+
1453
+ with pytest .raises (
1454
+ ValueError , match = "The minimum sampling time must be less than the maximum sampling time"
1455
+ ):
1456
+ ModelerLowFrequencySmoothingSpec (min_sampling_time = 3 , max_sampling_time = 3 )
1457
+
1458
+
1459
+ def test_low_freq_smoothing_spec_validation_order_bounds ():
1460
+ """Test validation of order parameter bounds."""
1461
+ from tidy3d .plugins .smatrix .component_modelers .terminal import ModelerLowFrequencySmoothingSpec
1462
+
1463
+ # Test valid orders
1464
+ ModelerLowFrequencySmoothingSpec (order = 0 )
1465
+ ModelerLowFrequencySmoothingSpec (order = 3 )
1466
+
1467
+ # Test invalid orders
1468
+ with pytest .raises (pd .ValidationError ):
1469
+ ModelerLowFrequencySmoothingSpec (order = - 1 )
1470
+
1471
+ with pytest .raises (pd .ValidationError ):
1472
+ ModelerLowFrequencySmoothingSpec (order = 4 )
1473
+
1474
+
1475
+ def test_low_freq_smoothing_spec_validation_max_deviation_bounds ():
1476
+ """Test validation of max_deviation parameter bounds."""
1477
+ from tidy3d .plugins .smatrix .component_modelers .terminal import ModelerLowFrequencySmoothingSpec
1478
+
1479
+ # Test valid max_deviation
1480
+ ModelerLowFrequencySmoothingSpec (max_deviation = 0.0 )
1481
+ ModelerLowFrequencySmoothingSpec (max_deviation = 1.0 )
1482
+
1483
+ # Test invalid max_deviation
1484
+ with pytest .raises (pd .ValidationError ):
1485
+ ModelerLowFrequencySmoothingSpec (max_deviation = - 0.1 )
1486
+
1487
+
1488
+ def test_low_freq_smoothing_spec_sim_dict ():
1489
+ """Test that LowFrequencySmoothingSpec is correctly added to the sim_dict."""
1490
+ from tidy3d .plugins .smatrix .component_modelers .terminal import ModelerLowFrequencySmoothingSpec
1491
+
1492
+ spec = ModelerLowFrequencySmoothingSpec (
1493
+ min_sampling_time = 2 , max_sampling_time = 8 , order = 2 , max_deviation = 0.3
1494
+ )
1495
+
1496
+ modeler = make_coaxial_component_modeler (port_types = (WavePort , WavePort ))
1497
+ modeler = modeler .updated_copy (low_freq_smoothing = spec )
1498
+ for sim in modeler .sim_dict .values ():
1499
+ assert spec .min_sampling_time == sim .low_freq_smoothing .min_sampling_time
1500
+ assert spec .max_sampling_time == sim .low_freq_smoothing .max_sampling_time
1501
+ assert spec .order == sim .low_freq_smoothing .order
1502
+ assert spec .max_deviation == sim .low_freq_smoothing .max_deviation
1503
+ assert sim .low_freq_smoothing .monitors == tuple (mnt .name for mnt in sim .monitors [- 2 :])
1504
+
1505
+ modeler = modeler .updated_copy (low_freq_smoothing = None )
1506
+ for sim in modeler .sim_dict .values ():
1507
+ assert sim .low_freq_smoothing is None
0 commit comments