Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/tidy3d-python-client-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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]+"

Expand Down
15 changes: 8 additions & 7 deletions tests/test_plugins/test_array_factor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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]
Expand Down
38 changes: 27 additions & 11 deletions tidy3d/plugins/smatrix/component_modelers/terminal.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,15 +223,17 @@ 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 = [
port.to_absorber()
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
Expand Down Expand Up @@ -382,18 +384,17 @@ 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:
task_name, sim_with_src = self._add_source_to_sim(network_index)
# 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
Expand All @@ -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:
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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
Expand Down
Loading