Skip to content

Commit eeaa764

Browse files
committed
Convenience class to generate charge perturbations following model by Nedeljkovic Soref Mashanovich
1 parent a021423 commit eeaa764

File tree

3 files changed

+434
-1
lines changed

3 files changed

+434
-1
lines changed

tests/test_components/test_parameter_perturbation.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -653,3 +653,24 @@ def test_index_perturbation():
653653
),
654654
freq=freq0,
655655
)
656+
657+
658+
def test_delta_model():
659+
"""Test delta models."""
660+
661+
# let's first define a frequency
662+
wvl = (3.5 + 4) / 2
663+
freq = td.C_0 / wvl
664+
delta_model = td.NedeljkovicSorefMashanovich(ref_freq=freq)
665+
666+
# make sure it's interpolating correctly
667+
coeffs_3_5 = np.array([3.10e-21, 1.210, 6.05e-20, 1.145, 6.95e-21, 0.986, 9.28e-18, 0.834])
668+
coeffs_4 = np.array([7.4e-22, 1.245, 5.43e-20, 1.153, 7.25e-21, 0.991, 9.99e-18, 0.839])
669+
670+
averaged_vals = (coeffs_3_5 + coeffs_4) / 2
671+
interpolated_results = [
672+
value.item() for _, value in delta_model._coeffs_at_ref_freq.data_vars.items()
673+
]
674+
error = np.abs(np.mean(averaged_vals - np.array(interpolated_results)))
675+
676+
assert error < 1e-16

tidy3d/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,7 @@
290290
IndexPerturbation,
291291
LinearChargePerturbation,
292292
LinearHeatPerturbation,
293+
NedeljkovicSorefMashanovich,
293294
ParameterPerturbation,
294295
PermittivityPerturbation,
295296
)
@@ -432,6 +433,7 @@ def set_logging_level(level: str) -> None:
432433
"RotationAroundAxis",
433434
"PerturbationMedium",
434435
"PerturbationPoleResidue",
436+
"NedeljkovicSorefMashanovich",
435437
"ParameterPerturbation",
436438
"LinearHeatPerturbation",
437439
"CustomHeatPerturbation",

0 commit comments

Comments
 (0)