diff --git a/docs/api/plugins/smatrix.rst b/docs/api/plugins/smatrix.rst index ef11814844..a43d3146d9 100644 --- a/docs/api/plugins/smatrix.rst +++ b/docs/api/plugins/smatrix.rst @@ -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:: @@ -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 @@ -66,4 +71,4 @@ Further Details tidy3d.plugins.smatrix.AbstractComponentModeler tidy3d.plugins.smatrix.AbstractComponentModelerData tidy3d.SimulationMap - tidy3d.SimulationDataMap \ No newline at end of file + tidy3d.SimulationDataMap diff --git a/tests/test_components/test_microwave.py b/tests/test_components/test_microwave.py index 779d1ade75..88d6e1e642 100644 --- a/tests/test_components/test_microwave.py +++ b/tests/test_components/test_microwave.py @@ -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 ( diff --git a/tidy3d/components/microwave/base.py b/tidy3d/components/microwave/base.py index 6d8ae5e8ec..417adeb4e0 100644 --- a/tidy3d/components/microwave/base.py +++ b/tidy3d/components/microwave/base.py @@ -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``.""" diff --git a/tidy3d/components/simulation.py b/tidy3d/components/simulation.py index 86c57d71a1..50cb3416fa 100644 --- a/tidy3d/components/simulation.py +++ b/tidy3d/components/simulation.py @@ -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) diff --git a/tidy3d/log.py b/tidy3d/log.py index b2e98b9fa7..20f08682f1 100644 --- a/tidy3d/log.py +++ b/tidy3d/log.py @@ -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: @@ -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: diff --git a/tidy3d/plugins/smatrix/__init__.py b/tidy3d/plugins/smatrix/__init__.py index b048e4c9f9..d271a75e19 100644 --- a/tidy3d/plugins/smatrix/__init__.py +++ b/tidy3d/plugins/smatrix/__init__.py @@ -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, ) diff --git a/tidy3d/plugins/smatrix/component_modelers/base.py b/tidy3d/plugins/smatrix/component_modelers/base.py index 74c5afe1c0..49f04ca377 100644 --- a/tidy3d/plugins/smatrix/component_modelers/base.py +++ b/tidy3d/plugins/smatrix/component_modelers/base.py @@ -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.""" diff --git a/tidy3d/plugins/smatrix/component_modelers/terminal.py b/tidy3d/plugins/smatrix/component_modelers/terminal.py index c656ce24b5..e9be3e1596 100644 --- a/tidy3d/plugins/smatrix/component_modelers/terminal.py +++ b/tidy3d/plugins/smatrix/component_modelers/terminal.py @@ -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.""" diff --git a/tidy3d/plugins/smatrix/data/terminal.py b/tidy3d/plugins/smatrix/data/terminal.py index ddab0f8f24..c00a889efa 100644 --- a/tidy3d/plugins/smatrix/data/terminal.py +++ b/tidy3d/plugins/smatrix/data/terminal.py @@ -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 ( @@ -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, diff --git a/tidy3d/rf.py b/tidy3d/rf.py index 0c2b6c453c..3369afd3c1 100644 --- a/tidy3d/rf.py +++ b/tidy3d/rf.py @@ -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, )