Skip to content
Merged
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
19 changes: 12 additions & 7 deletions docs/api/plugins/smatrix.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ S-Matrix Component Modelers Plugin
This plugin provides component modelers for computing S-parameters (scattering parameters) for both **photonics** and **RF/microwave** applications. The plugin supports:

* **Photonics**: Modal component modelers for photonic devices (waveguides, splitters, filters, etc.)
* **RF/Microwave**: Terminal component modelers for microwave circuits and antennas (available in :class:`tidy3d.rf` subpackage)
* **RF/Microwave**: Terminal component modelers for microwave circuits and antennas (available in :class:`tidy3d.rf` subpackage as well)

.. warning::

Expand All @@ -28,21 +28,26 @@ For photonics applications, use the **ModalComponentModeler** which computes mod

RF/Microwave Component Modelers
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. seealso::

For classes related to microwave/RF modeling, please refer to the main `Microwave and RF <../microwave/index.html>`_ page and `tidy3d.rf` sub-package.


For RF and microwave applications, use the **TerminalComponentModeler** (available in ``tidy3d.rf``) which computes terminal-based S-parameters.
For RF and microwave applications, use the **TerminalComponentModeler** (available in ``tidy3d.rf`` as well) which computes terminal-based S-parameters.

.. warning::

RF simulations will require new license requirements in an upcoming release. All RF-specific classes are available in the ``tidy3d.rf`` subpackage.


.. autosummary::
:toctree: ../_autosummary/
:template: module.rst

tidy3d.rf.TerminalComponentModeler
tidy3d.rf.TerminalComponentModelerData
tidy3d.rf.LumpedPort
tidy3d.rf.CoaxialLumpedPort
tidy3d.plugins.smatrix.TerminalComponentModeler
tidy3d.plugins.smatrix.TerminalComponentModelerData
tidy3d.plugins.smatrix.LumpedPort
tidy3d.plugins.smatrix.CoaxialLumpedPort
tidy3d.rf.WavePort
tidy3d.rf.MicrowaveSMatrixData
tidy3d.rf.TerminalPortDataArray
Expand All @@ -66,4 +71,4 @@ Further Details
tidy3d.plugins.smatrix.AbstractComponentModeler
tidy3d.plugins.smatrix.AbstractComponentModelerData
tidy3d.SimulationMap
tidy3d.SimulationDataMap
tidy3d.SimulationDataMap
11 changes: 0 additions & 11 deletions tests/test_components/test_microwave.py
Original file line number Diff line number Diff line change
Expand Up @@ -1912,17 +1912,6 @@ def test_impedance_calculator_mode_direction_handling():
assert hasattr(impedance_mode, "values")


def test_RF_license_suppression():
"""Ensure license warnings are being emitted properly and default instantiations avoid the warning."""
original_setting = td.config.microwave.suppress_rf_license_warning
td.config.microwave.suppress_rf_license_warning = False
with AssertLogLevel("WARNING", contains_str="new license requirements"):
mode_spec = td.MicrowaveModeSpec()
with AssertLogLevel(None):
mode_spec = td.MicrowaveModeSpec._default_without_license_warning()
td.config.microwave.suppress_rf_license_warning = original_setting


def test_microwave_mode_data_reordering_with_transmission_line_data():
"""Test that transmission_line_data is correctly reordered when modes are reordered."""
from tidy3d.components.data.data_array import (
Expand Down
16 changes: 0 additions & 16 deletions tidy3d/components/microwave/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,13 @@

from __future__ import annotations

import pydantic.v1 as pd

from tidy3d.components.base import Tidy3dBaseModel
from tidy3d.config import config
from tidy3d.log import log


class MicrowaveBaseModel(Tidy3dBaseModel):
"""Base model that all RF and microwave specific components inherit from."""

@pd.root_validator(pre=False)
def _warn_rf_license(cls, values):
from tidy3d.config import config

# Skip warning when globally suppressed via config
if not config.microwave.suppress_rf_license_warning:
log.warning(
"ℹ️ ⚠️ RF simulations are subject to new license requirements in the future. "
"You have instantiated at least one RF-specific component.",
log_once=True,
)
return values

@classmethod
def _default_without_license_warning(cls) -> MicrowaveBaseModel:
"""Internal helper factory function for classes inheriting from ``MicrowaveBaseModel``."""
Expand Down
2 changes: 1 addition & 1 deletion tidy3d/components/simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -4282,7 +4282,7 @@ def _warn_rf_license(self) -> None:

# issue warning
if rf_component_breakdown_msg != "":
msg = " ℹ️ ⚠️ RF simulations are subject to new license requirements in the future. You are using RF-specific components in this simulation."
msg = "RF simulations and functionality will require new license requirements in an upcoming release. All RF-specific classes are now available within the sub-package 'tidy3d.rf'."
msg += rf_component_breakdown_msg
log.warning(msg, log_once=True)

Expand Down
14 changes: 7 additions & 7 deletions tidy3d/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,13 @@ def _log(
) -> None:
"""Distribute log messages to all handlers"""

# Check global cache if requested (before composing/capturing to avoid duplicates)
if log_once:
# Use the message body before composition as key
if message in self._static_cache:
return
self._static_cache.add(message)

# Compose message
if len(args) > 0:
try:
Expand All @@ -267,13 +274,6 @@ def _log(
custom_loc = []
self._stack[-1]["messages"].append((level_name, composed_message, custom_loc))

# Check global cache if requested
if log_once:
# Use the message body before composition as key
if message in self._static_cache:
return
self._static_cache.add(message)

# Context-local logger emits a single message and consolidates the rest
if self._counts is not None:
if len(self._counts) > 0:
Expand Down
2 changes: 1 addition & 1 deletion tidy3d/plugins/smatrix/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
# Instantiate on plugin import till we unite with toplevel
warnings.filterwarnings(
"once",
message="ℹ️ ⚠️ RF simulations are subject to new license requirements in the future. You have instantiated at least one RF-specific component.",
message="RF simulations and functionality will require new license requirements in an upcoming release. All RF-specific classes are now available within the sub-package 'tidy3d.rf'.",
category=FutureWarning,
)

Expand Down
8 changes: 8 additions & 0 deletions tidy3d/plugins/smatrix/component_modelers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,14 @@ class AbstractComponentModeler(ABC, Tidy3dBaseModel):
"Otherwise, a default source time will be constructed.",
)

@pd.root_validator(pre=False)
def _warn_refactor_2_10(cls, values):
log.warning(
f"'{cls.__name__}' was refactored (tidy3d 'v2.10.0'). Existing functionality is available differently. Please consult the migration documentation: https://docs.flexcompute.com/projects/tidy3d/en/latest/api/microwave/microwave_migration.html",
log_once=True,
)
return values

@pd.validator("simulation", always=True)
def _sim_has_no_sources(cls, val):
"""Make sure simulation has no sources as they interfere with tool."""
Expand Down
8 changes: 0 additions & 8 deletions tidy3d/plugins/smatrix/component_modelers/terminal.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,14 +210,6 @@ class TerminalComponentModeler(AbstractComponentModeler, MicrowaveBaseModel):
description="The low frequency smoothing parameters for the terminal component simulation.",
)

@pd.root_validator(pre=False)
def _warn_refactor_2_10(cls, values):
log.warning(
f"ℹ️ ⚠️ The {cls.__name__} class was refactored in tidy3d version 2.10. Migration documentation will be provided, and existing functionality can be accessed in a different way.",
log_once=True,
)
return values

@property
def _sim_with_sources(self) -> Simulation:
"""Instance of :class:`.Simulation` with all sources and absorbers added for each port, for plotting."""
Expand Down
9 changes: 0 additions & 9 deletions tidy3d/plugins/smatrix/data/terminal.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
from tidy3d.components.microwave.base import MicrowaveBaseModel
from tidy3d.components.microwave.data.monitor_data import AntennaMetricsData
from tidy3d.constants import C_0
from tidy3d.log import log
from tidy3d.plugins.smatrix.component_modelers.terminal import TerminalComponentModeler
from tidy3d.plugins.smatrix.data.base import AbstractComponentModelerData
from tidy3d.plugins.smatrix.data.data_array import (
Expand Down Expand Up @@ -227,14 +226,6 @@ def smatrix_deembedded(self, port_shifts: np.ndarray = None) -> MicrowaveSMatrix
"""Interface function returns de-embedded S-parameter matrix."""
return self.change_port_reference_planes(self.smatrix(), port_shifts=port_shifts)

@pd.root_validator(pre=False)
def _warn_rf_license(cls, values):
log.warning(
"ℹ️ ⚠️ RF simulations are subject to new license requirements in the future. You have instantiated at least one RF-specific component.",
log_once=True,
)
return values

def _monitor_data_at_port_amplitude(
self,
port_index: NetworkIndex,
Expand Down
2 changes: 1 addition & 1 deletion tidy3d/rf.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@
# Instantiate on plugin import till we unite with toplevel
warnings.filterwarnings(
"once",
message="ℹ️ ⚠️ RF simulations are subject to new license requirements in the future. You have instantiated at least one RF-specific component.",
message="RF simulations and functionality will require new license requirements in an upcoming release. All RF-specific classes are now available within the sub-package 'tidy3d.rf'.",
category=FutureWarning,
)

Expand Down