27
27
28
28
# width of Chebyshev grid used for broadband sources (in units of pulse width)
29
29
CHEB_GRID_WIDTH = 1.5
30
- # Number of frequencies in a broadband source above which to issue a warning
31
- WARN_NUM_FREQS = 20
32
30
# For broadband plane waves with constan in-plane k, the Chebyshev grid is truncated at
33
31
# ``CRITICAL_FREQUENCY_FACTOR * f_crit``, where ``f_crit`` is the critical frequency
34
32
# (oblique propagation).
@@ -90,14 +88,14 @@ def _dir_vector(self) -> tuple[float, float, float]:
90
88
class BroadbandSource (Source , ABC ):
91
89
"""A source with frequency dependent field distributions."""
92
90
93
- # Default as for analytic beam sources; overwrriten for ModeSource below
94
91
num_freqs : int = pydantic .Field (
95
- 3 ,
92
+ 1 ,
96
93
title = "Number of Frequency Points" ,
97
94
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." ,
101
99
ge = 1 ,
102
100
le = 20 ,
103
101
)
@@ -116,23 +114,6 @@ def _chebyshev_freq_grid(self, freq_min, freq_max):
116
114
cheb_points = np .cos (np .pi * np .flip (uni_points ))
117
115
return freq_avg + freq_diff * cheb_points
118
116
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
-
136
117
137
118
""" Source current profiles determined by user-supplied data on a plane."""
138
119
@@ -422,16 +403,6 @@ class ModeSource(DirectionalSource, PlanarSource, BroadbandSource):
422
403
"``num_modes`` in the solver will be set to ``mode_index + 1``." ,
423
404
)
424
405
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
-
435
406
@cached_property
436
407
def angle_theta (self ):
437
408
"""Polar angle of propagation."""
@@ -515,6 +486,17 @@ class PlaneWave(AngledFieldSource, PlanarSource, BroadbandSource):
515
486
discriminator = TYPE_TAG_STR ,
516
487
)
517
488
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
+
518
500
@cached_property
519
501
def _is_fixed_angle (self ) -> bool :
520
502
"""Whether the plane wave is at a fixed non-zero angle."""
@@ -594,6 +576,18 @@ class GaussianBeam(AngledFieldSource, PlanarSource, BroadbandSource):
594
576
units = MICROMETER ,
595
577
)
596
578
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
+
597
591
598
592
class AstigmaticGaussianBeam (AngledFieldSource , PlanarSource , BroadbandSource ):
599
593
"""The simple astigmatic Gaussian distribution allows
@@ -642,6 +636,18 @@ class AstigmaticGaussianBeam(AngledFieldSource, PlanarSource, BroadbandSource):
642
636
units = MICROMETER ,
643
637
)
644
638
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
+
645
651
646
652
class TFSF (AngledFieldSource , VolumeSource , BroadbandSource ):
647
653
"""Total-field scattered-field (TFSF) source that can inject a plane wave in a finite region.
0 commit comments