diff --git a/.github/workflows/tidy3d-python-client-tests.yml b/.github/workflows/tidy3d-python-client-tests.yml index 010e0fb1b6..eb08db9930 100644 --- a/.github/workflows/tidy3d-python-client-tests.yml +++ b/.github/workflows/tidy3d-python-client-tests.yml @@ -262,7 +262,7 @@ jobs: BRANCH_NAME="${STEPS_EXTRACT_BRANCH_NAME_OUTPUTS_BRANCH_NAME}" echo $BRANCH_NAME # Allow only Jira keys from known projects, even if the branch has an author prefix - ALLOWED_JIRA_PROJECTS=("FXC" "SCEM") + ALLOWED_JIRA_PROJECTS=("FXC" "SCEM" "SCRF") JIRA_PROJECT_PATTERN=$(IFS='|'; echo "${ALLOWED_JIRA_PROJECTS[*]}") JIRA_PATTERN="(${JIRA_PROJECT_PATTERN})-[0-9]+" diff --git a/tests/test_plugins/test_array_factor.py b/tests/test_plugins/test_array_factor.py index 2ffe92afee..959e1dc7b0 100644 --- a/tests/test_plugins/test_array_factor.py +++ b/tests/test_plugins/test_array_factor.py @@ -363,16 +363,15 @@ def make_antenna_sim(): remove_dc_component=False, # Include DC component for more accuracy at low frequencies ) - sim_unit = list(modeler.sim_dict.values())[0] - - return sim_unit + return modeler def test_rectangular_array_calculator_array_make_antenna_array(): """Test automatic antenna array creation.""" freq0 = 10e9 wavelength0 = td.C_0 / 10e9 - sim_unit = make_antenna_sim() + modeler = make_antenna_sim() + sim_unit = list(modeler.sim_dict.values())[0] array_calculator = mw.RectangularAntennaArrayCalculator( array_size=(1, 2, 3), spacings=(0.5 * wavelength0, 0.6 * wavelength0, 0.4 * wavelength0), @@ -437,8 +436,9 @@ def test_rectangular_array_calculator_array_make_antenna_array(): assert len(sim_array.sources) == 6 # check that override_structures are duplicated - assert len(sim_unit.grid_spec.override_structures) == 2 - assert len(sim_array.grid_spec.override_structures) == 7 + # assert len(sim_unit.grid_spec.override_structures) == 2 + # assert len(sim_array.grid_spec.override_structures) == 7 + assert sim_unit.grid.boundaries == modeler.base_sim.grid.boundaries # check that phase shifts are applied correctly phases_expected = array_calculator._antenna_phases @@ -674,7 +674,8 @@ def test_rectangular_array_calculator_simulation_data_from_array_factor(): phase_shifts=(np.pi / 3, np.pi / 4, np.pi / 5), ) - sim_unit = make_antenna_sim() + modeler = make_antenna_sim() + sim_unit = list(modeler.sim_dict.values())[0] monitor = sim_unit.monitors[0] monitor_directivity = sim_unit.monitors[2] diff --git a/tidy3d/plugins/smatrix/component_modelers/terminal.py b/tidy3d/plugins/smatrix/component_modelers/terminal.py index f865286c4e..b06f0404c0 100644 --- a/tidy3d/plugins/smatrix/component_modelers/terminal.py +++ b/tidy3d/plugins/smatrix/component_modelers/terminal.py @@ -223,7 +223,7 @@ def _warn_refactor_2_10(cls, values): @property def _sim_with_sources(self) -> Simulation: - """Instance of :class:`.Simulation` with all sources and absorbers added for each port, for troubleshooting.""" + """Instance of :class:`.Simulation` with all sources and absorbers added for each port, for plotting.""" sources = [port.to_source(self._source_time) for port in self.ports] absorbers = [ @@ -231,7 +231,9 @@ def _sim_with_sources(self) -> Simulation: for port in self.ports if isinstance(port, WavePort) and port.absorber ] - return self.simulation.updated_copy(sources=sources, internal_absorbers=absorbers) + return self.simulation.updated_copy( + sources=sources, internal_absorbers=absorbers, validate=False + ) @equal_aspect @add_ax_if_none @@ -382,6 +384,10 @@ def matrix_indices_run_sim(self) -> tuple[NetworkIndex, ...]: def sim_dict(self) -> SimulationMap: """Generate all the :class:`.Simulation` objects for the port parameter calculation.""" + # Check base simulation for grid size at ports + TerminalComponentModeler._check_grid_size_at_ports(self.base_sim, self._lumped_ports) + TerminalComponentModeler._check_grid_size_at_wave_ports(self.base_sim, self._wave_ports) + sim_dict = {} # Now, create simulations with wave port sources and mode solver monitors for computing port modes for network_index in self.matrix_indices_run_sim: @@ -389,11 +395,6 @@ def sim_dict(self) -> SimulationMap: # update simulation sim_dict[task_name] = sim_with_src - # Check final simulations for grid size at ports - for _, sim in sim_dict.items(): - TerminalComponentModeler._check_grid_size_at_ports(sim, self._lumped_ports) - TerminalComponentModeler._check_grid_size_at_wave_ports(sim, self._wave_ports) - return SimulationMap(keys=tuple(sim_dict.keys()), values=tuple(sim_dict.values())) @cached_property @@ -414,7 +415,10 @@ def _base_sim_no_radiation_monitors(self) -> Simulation: # Make an initial simulation with new grid_spec to determine where LumpedPorts are snapped sim_wo_source = self.simulation.updated_copy( - grid_spec=grid_spec, lumped_elements=lumped_resistors + grid_spec=grid_spec, + lumped_elements=lumped_resistors, + validate=False, + deep=False, ) snap_centers = {} for port in self._lumped_ports: @@ -480,7 +484,11 @@ def _base_sim_no_radiation_monitors(self) -> Simulation: ) # update base simulation with updated set of shared components - sim_wo_source = sim_wo_source.copy(update=update_dict) + sim_wo_source = sim_wo_source.updated_copy( + **update_dict, + validate=False, + deep=False, + ) # extrude port structures sim_wo_source = self._extrude_port_structures(sim=sim_wo_source) @@ -527,7 +535,10 @@ def base_sim(self) -> Simulation: """The base simulation with all components added, including radiation monitors.""" base_sim_tmp = self._base_sim_no_radiation_monitors mnts_with_radiation = list(base_sim_tmp.monitors) + list(self._finalized_radiation_monitors) - return base_sim_tmp.updated_copy(monitors=mnts_with_radiation) + grid_spec = GridSpec.from_grid(base_sim_tmp.grid) + grid_spec.attrs["from_grid_spec"] = base_sim_tmp.grid_spec + # We skipped validations up to now, here we finally validate the base sim + return base_sim_tmp.updated_copy(monitors=mnts_with_radiation, grid_spec=grid_spec) def _generate_radiation_monitor( self, simulation: Simulation, auto_spec: DirectivityMonitorSpec @@ -712,7 +723,10 @@ def _add_source_to_sim(self, source_index: NetworkIndex) -> tuple[str, Simulatio ) task_name = self.get_task_name(port=port, mode_index=mode_index) - return (task_name, self.base_sim.updated_copy(sources=[port_source])) + return ( + task_name, + self.base_sim.updated_copy(sources=[port_source], validate=False, deep=False), + ) @cached_property def _source_time(self): @@ -983,6 +997,8 @@ def _extrude_port_structures(self, sim: Simulation) -> Simulation: sim = sim.updated_copy( grid_spec=GridSpec.from_grid(sim.grid), structures=[*sim.structures, *all_new_structures], + validate=False, + deep=False, ) return sim