2727
2828# width of Chebyshev grid used for broadband sources (in units of pulse width)
2929CHEB_GRID_WIDTH = 1.5
30- # Number of frequencies in a broadband source above which to issue a warning
31- WARN_NUM_FREQS = 20
3230# For broadband plane waves with constan in-plane k, the Chebyshev grid is truncated at
3331# ``CRITICAL_FREQUENCY_FACTOR * f_crit``, where ``f_crit`` is the critical frequency
3432# (oblique propagation).
@@ -90,14 +88,14 @@ def _dir_vector(self) -> tuple[float, float, float]:
9088class BroadbandSource (Source , ABC ):
9189 """A source with frequency dependent field distributions."""
9290
93- # Default as for analytic beam sources; overwrriten for ModeSource below
9491 num_freqs : int = pydantic .Field (
95- 3 ,
92+ 1 ,
9693 title = "Number of Frequency Points" ,
9794 description = "Number of points used to approximate the frequency dependence of the injected "
98- "field. Default is 3, which should cover even very broadband sources. For simulations "
99- "which are not very broadband and the source is very large (e.g. metalens simulations), "
100- "decreasing the value to 1 may lead to a speed up in the preprocessing." ,
95+ "field. A Chebyshev interpolation is used, thus, only a small number of points is "
96+ "typically sufficient to obtain converged results. Note that larger values of 'num_freqs' "
97+ "could spread out the source time signal and introduce numerical noise, or prevent timely "
98+ "field decay." ,
10199 ge = 1 ,
102100 le = 20 ,
103101 )
@@ -116,23 +114,6 @@ def _chebyshev_freq_grid(self, freq_min, freq_max):
116114 cheb_points = np .cos (np .pi * np .flip (uni_points ))
117115 return freq_avg + freq_diff * cheb_points
118116
119- @pydantic .validator ("num_freqs" , always = True , allow_reuse = True )
120- def _warn_if_large_number_of_freqs (cls , val ):
121- """Warn if a large number of frequency points is requested."""
122-
123- if val is None :
124- return val
125-
126- if val >= WARN_NUM_FREQS :
127- log .warning (
128- f"A large number ({ val } ) of frequency points is used in a broadband source. "
129- "This can lead to solver slow-down and increased cost, and even introduce "
130- "numerical noise. This may become a hard limit in future Tidy3D versions." ,
131- custom_loc = ["num_freqs" ],
132- )
133-
134- return val
135-
136117
137118""" Source current profiles determined by user-supplied data on a plane."""
138119
@@ -422,16 +403,6 @@ class ModeSource(DirectionalSource, PlanarSource, BroadbandSource):
422403 "``num_modes`` in the solver will be set to ``mode_index + 1``." ,
423404 )
424405
425- num_freqs : int = pydantic .Field (
426- 1 ,
427- title = "Number of Frequency Points" ,
428- description = "Number of points used to approximate the frequency dependence of injected "
429- "field. A Chebyshev interpolation is used, thus, only a small number of points, i.e., less "
430- "than 20, is typically sufficient to obtain converged results." ,
431- ge = 1 ,
432- le = 99 ,
433- )
434-
435406 @cached_property
436407 def angle_theta (self ):
437408 """Polar angle of propagation."""
@@ -515,6 +486,17 @@ class PlaneWave(AngledFieldSource, PlanarSource, BroadbandSource):
515486 discriminator = TYPE_TAG_STR ,
516487 )
517488
489+ num_freqs : int = pydantic .Field (
490+ 3 ,
491+ title = "Number of Frequency Points" ,
492+ description = "Number of points used to approximate the frequency dependence of the injected "
493+ "field. Default is 3, which should cover even very broadband plane waves. For simulations "
494+ "which are not very broadband and the source is very large (e.g. metalens simulations), "
495+ "decreasing the value to 1 may lead to a speed up in the preprocessing." ,
496+ ge = 1 ,
497+ le = 20 ,
498+ )
499+
518500 @cached_property
519501 def _is_fixed_angle (self ) -> bool :
520502 """Whether the plane wave is at a fixed non-zero angle."""
@@ -594,6 +576,18 @@ class GaussianBeam(AngledFieldSource, PlanarSource, BroadbandSource):
594576 units = MICROMETER ,
595577 )
596578
579+ num_freqs : int = pydantic .Field (
580+ 1 ,
581+ title = "Number of Frequency Points" ,
582+ description = "Number of points used to approximate the frequency dependence of the injected "
583+ "field. For broadband, angled Gaussian beams it is advisable to check the beam propagation "
584+ "in an empty simulation to ensure there are no injection artifacts when 'num_freqs' > 1. "
585+ "Note that larger values of 'num_freqs' could spread out the source time signal and "
586+ "introduce numerical noise, or prevent timely field decay." ,
587+ ge = 1 ,
588+ le = 20 ,
589+ )
590+
597591
598592class AstigmaticGaussianBeam (AngledFieldSource , PlanarSource , BroadbandSource ):
599593 """The simple astigmatic Gaussian distribution allows
@@ -642,6 +636,18 @@ class AstigmaticGaussianBeam(AngledFieldSource, PlanarSource, BroadbandSource):
642636 units = MICROMETER ,
643637 )
644638
639+ num_freqs : int = pydantic .Field (
640+ 1 ,
641+ title = "Number of Frequency Points" ,
642+ description = "Number of points used to approximate the frequency dependence of the injected "
643+ "field. For broadband, angled Gaussian beams it is advisable to check the beam propagation "
644+ "in an empty simulation to ensure there are no injection artifacts when 'num_freqs' > 1. "
645+ "Note that larger values of 'num_freqs' could spread out the source time signal and "
646+ "introduce numerical noise, or prevent timely field decay." ,
647+ ge = 1 ,
648+ le = 20 ,
649+ )
650+
645651
646652class TFSF (AngledFieldSource , VolumeSource , BroadbandSource ):
647653 """Total-field scattered-field (TFSF) source that can inject a plane wave in a finite region.
0 commit comments