@@ -159,6 +159,12 @@ def _validate_medium_freqs(self, medium: AbstractMedium, freqs: List[pd.Positive
159
159
"""Any additional validation that depends on the central frequencies of the sources."""
160
160
pass
161
161
162
+ def _hardcode_medium_freqs (
163
+ self , medium : AbstractMedium , freqs : List [pd .PositiveFloat ]
164
+ ) -> NonlinearSpec :
165
+ """Update the nonlinear model to hardcode information on medium and freqs."""
166
+ return self
167
+
162
168
def _get_freq0 (self , freq0 , freqs : List [pd .PositiveFloat ]) -> float :
163
169
"""Get a single value for freq0."""
164
170
@@ -426,6 +432,14 @@ def _validate_medium_freqs(self, medium: AbstractMedium, freqs: List[pd.Positive
426
432
"gain medium are unstable, and are likely to diverge."
427
433
)
428
434
435
+ def _hardcode_medium_freqs (
436
+ self , medium : AbstractMedium , freqs : List [pd .PositiveFloat ]
437
+ ) -> TwoPhotonAbsorption :
438
+ """Update the nonlinear model to hardcode information on medium and freqs."""
439
+ n0 = self ._get_n0 (n0 = self .n0 , medium = medium , freqs = freqs )
440
+ freq0 = self ._get_freq0 (freq0 = self .freq0 , freqs = freqs )
441
+ return self .updated_copy (n0 = n0 , freq0 = freq0 )
442
+
429
443
def _validate_medium (self , medium : AbstractMedium ):
430
444
"""Check that the model is compatible with the medium."""
431
445
# if n0 is specified, we can go ahead and validate passivity
@@ -515,6 +529,13 @@ def _validate_medium_freqs(self, medium: AbstractMedium, freqs: List[pd.Positive
515
529
"gain medium are unstable, and are likely to diverge."
516
530
)
517
531
532
+ def _hardcode_medium_freqs (
533
+ self , medium : AbstractMedium , freqs : List [pd .PositiveFloat ]
534
+ ) -> KerrNonlinearity :
535
+ """Update the nonlinear model to hardcode information on medium and freqs."""
536
+ n0 = self ._get_n0 (n0 = self .n0 , medium = medium , freqs = freqs )
537
+ return self .updated_copy (n0 = n0 )
538
+
518
539
def _validate_medium (self , medium : AbstractMedium ):
519
540
"""Check that the model is compatible with the medium."""
520
541
# if n0 is specified, we can go ahead and validate passivity
@@ -584,6 +605,16 @@ def _validate_num_iters(cls, val, values):
584
605
)
585
606
return val
586
607
608
+ def _hardcode_medium_freqs (
609
+ self , medium : AbstractMedium , freqs : List [pd .PositiveFloat ]
610
+ ) -> NonlinearSpec :
611
+ """Update the nonlinear spec to hardcode information on medium and freqs."""
612
+ new_models = []
613
+ for model in self .models :
614
+ new_model = model ._hardcode_medium_freqs (medium = medium , freqs = freqs )
615
+ new_models .append (new_model )
616
+ return self .updated_copy (models = new_models )
617
+
587
618
588
619
class AbstractMedium (ABC , Tidy3dBaseModel ):
589
620
"""A medium within which electromagnetic waves propagate."""
0 commit comments