From 163804ecfbb2274f5ddde4ba501ab076b8ea9d5b Mon Sep 17 00:00:00 2001 From: dbochkov-flexcompute Date: Tue, 3 Dec 2024 10:31:35 -0600 Subject: [PATCH] pr comments --- tests/test_components/test_simulation.py | 2 +- tidy3d/components/simulation.py | 19 ++++++++++--------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/tests/test_components/test_simulation.py b/tests/test_components/test_simulation.py index beab580acd..4c974d8117 100644 --- a/tests/test_components/test_simulation.py +++ b/tests/test_components/test_simulation.py @@ -3067,7 +3067,7 @@ def test_fixed_angle_sim(): run_time=10 / fwidth, ) - # assert sim.i + assert sim._is_fixed_angle with pytest.raises(pydantic.ValidationError): _ = sim.updated_copy( diff --git a/tidy3d/components/simulation.py b/tidy3d/components/simulation.py index cc420c7a23..dbe1b59dd0 100644 --- a/tidy3d/components/simulation.py +++ b/tidy3d/components/simulation.py @@ -2428,12 +2428,12 @@ def plane_wave_boundaries(cls, val, values): num_bloch = sum(isinstance(bnd, BlochBoundary) for bnd in boundary) if num_bloch > 0: raise SetupError( - "Fixed angle plane wave sources ('FixedAngleSpec' and `angle_theta != 0`) do " + "Fixed angle plane wave sources ('FixedAngleSpec' and 'angle_theta' != 0) do " f"not require the Bloch boundary along dimension {tan_dir}. " "Either set the boundary conditions to 'Periodic' to proceed to simulate a plane " "wave with frequency-independent propagation direction, or switch to " - "'FixedInPlaneKSpec' specification to simulate a plane wave with " - "frequency-dependent propagation direction." + "'FixedInPlaneKSpec' specification to simulate a plane wave with a fixed " + "in-plane Bloch vector (frequency-dependent propagation direction)." ) else: num_bloch = sum(isinstance(bnd, (Periodic, BlochBoundary)) for bnd in boundary) @@ -2573,14 +2573,15 @@ def tfsf_with_symmetry(cls, val, values): return val @staticmethod - def _get_fixed_angle_sources(sources: Tuple[SourceType, ...]): + def _get_fixed_angle_sources(sources: Tuple[SourceType, ...]) -> Tuple[SourceType, ...]: """Get list of plane wave sources with ``FixedAngleSpec``.""" return [ source for source in sources if isinstance(source, PlaneWave) and source._is_fixed_angle ] - @pydantic.root_validator(skip_on_failure=True) + @pydantic.root_validator() + @skip_if_fields_missing(["sources", "structures", "medium", "monitors"], root=True) def check_fixed_angle_components(cls, values): """Error if a fixed-angle plane wave is combined with other sources or fully anisotropic mediums or gain mediums.""" @@ -3939,13 +3940,13 @@ def background_structure(self) -> Structure: return self.scene.background_structure @cached_property - def _fixed_angle_sources(self): + def _fixed_angle_sources(self) -> Tuple[SourceType, ...]: """List of plane wave sources with ``FixedAngleSpec``.""" return self._get_fixed_angle_sources(self.sources) @cached_property - def _is_fixed_angle(self): - """List of plane wave sources with ``FixedAngleSpec``.""" + def _is_fixed_angle(self) -> bool: + """Whether the simulation contains fixed angle sources.""" return len(self._fixed_angle_sources) > 0 # candidate for removal in 3.0 @@ -4373,7 +4374,7 @@ def plot_3d(self, width=800, height=800) -> None: """ Discretization """ @cached_property - def _dt_fixed_angle_reduction_factor(self): + def _dt_fixed_angle_reduction_factor(self) -> float: """Reduction in time step due to plane wave source with ``FixedAngleSpec``.""" if self._is_fixed_angle: theta = self._fixed_angle_sources[0].angle_theta