From 2f9b728c62fcd18fd919cb787984491d79b6f012 Mon Sep 17 00:00:00 2001 From: daquinteroflex Date: Fri, 5 Dec 2025 14:01:45 +0100 Subject: [PATCH 1/2] fix: rf license warnings and docs --- docs/api/microwave/index.rst | 2 +- docs/api/plugins/microwave.rst | 2 +- docs/api/plugins/smatrix.rst | 2 +- tidy3d/components/microwave/base.py | 21 ------------------- tidy3d/components/simulation.py | 2 +- tidy3d/log.py | 14 ++++++------- tidy3d/plugins/smatrix/__init__.py | 2 +- .../smatrix/component_modelers/base.py | 8 +++++++ .../smatrix/component_modelers/terminal.py | 8 ------- tidy3d/plugins/smatrix/data/terminal.py | 9 -------- tidy3d/rf.py | 2 +- 11 files changed, 21 insertions(+), 51 deletions(-) diff --git a/docs/api/microwave/index.rst b/docs/api/microwave/index.rst index 19f7240191..caf42500d8 100644 --- a/docs/api/microwave/index.rst +++ b/docs/api/microwave/index.rst @@ -6,7 +6,7 @@ Overview .. warning:: - RF simulations will be subject to new license requirements in the future. + 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'. .. warning:: diff --git a/docs/api/plugins/microwave.rst b/docs/api/plugins/microwave.rst index a6d8a89ac7..ac75add01b 100644 --- a/docs/api/plugins/microwave.rst +++ b/docs/api/plugins/microwave.rst @@ -5,7 +5,7 @@ Microwave .. warning:: - RF simulations are subject to new license requirements in the future. These components are within the RF scope. + 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'. These classes are included. .. autosummary:: diff --git a/docs/api/plugins/smatrix.rst b/docs/api/plugins/smatrix.rst index ae14f5245e..1f19e12edc 100644 --- a/docs/api/plugins/smatrix.rst +++ b/docs/api/plugins/smatrix.rst @@ -14,7 +14,7 @@ S-Matrix Component Modelers Plugin .. seealso:: - For classes related to microwave/RF modeling, please refer to the main `Microwave and RF <../microwave/index.html>`_ page. + For classes related to microwave/RF modeling, please refer to the main `Microwave and RF <../microwave/index.html>`_ page and `tidy3d.rf` sub-package. .. warning:: diff --git a/tidy3d/components/microwave/base.py b/tidy3d/components/microwave/base.py index 6d8ae5e8ec..9dc5692694 100644 --- a/tidy3d/components/microwave/base.py +++ b/tidy3d/components/microwave/base.py @@ -2,36 +2,15 @@ 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``.""" if config.microwave.suppress_rf_license_warning is True: return cls() - else: - config.microwave.suppress_rf_license_warning = True - default_constructed = cls() - config.microwave.suppress_rf_license_warning = False - return default_constructed 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, ) From 49b316f33b80cafc63ae35754df74875b8fbc77b Mon Sep 17 00:00:00 2001 From: daquinteroflex Date: Fri, 5 Dec 2025 14:11:08 +0100 Subject: [PATCH 2/2] update to .rf on api references --- docs/api/microwave/component_modeler.rst | 10 +++++----- docs/api/microwave/material.rst | 6 +++--- docs/api/microwave/ports/lumped.rst | 14 +++++++------- docs/api/microwave/ports/wave.rst | 18 +++++++++--------- docs/api/microwave/radiation_scattering.rst | 10 +++++----- 5 files changed, 29 insertions(+), 29 deletions(-) diff --git a/docs/api/microwave/component_modeler.rst b/docs/api/microwave/component_modeler.rst index d0e82e2851..3a71d6ad7c 100644 --- a/docs/api/microwave/component_modeler.rst +++ b/docs/api/microwave/component_modeler.rst @@ -7,11 +7,11 @@ TerminalComponentModeler :toctree: ../_autosummary/ :template: module.rst - tidy3d.plugins.smatrix.TerminalComponentModeler - tidy3d.plugins.smatrix.TerminalComponentModelerData - tidy3d.plugins.smatrix.MicrowaveSMatrixData - tidy3d.plugins.smatrix.TerminalPortDataArray - tidy3d.plugins.smatrix.PortDataArray + tidy3d.rf.TerminalComponentModeler + tidy3d.rf.TerminalComponentModelerData + tidy3d.rf.MicrowaveSMatrixData + tidy3d.rf.TerminalPortDataArray + tidy3d.rf.PortDataArray The :class:`.TerminalComponentModeler` is the core simulation object for 3D RF/microwave simulations in Tidy3D. Its primary function is to simulate the system over ``N`` number of ports and ``M`` number of frequency points, with the end result being a ``MxNxN`` S-parameter matrix. diff --git a/docs/api/microwave/material.rst b/docs/api/microwave/material.rst index 30be7e1da3..d88fd6ad25 100644 --- a/docs/api/microwave/material.rst +++ b/docs/api/microwave/material.rst @@ -10,9 +10,9 @@ RF Materials Models tidy3d.PECMedium tidy3d.PMCMedium tidy3d.LossyMetalMedium - tidy3d.SurfaceImpedanceFitterParam - tidy3d.HammerstadSurfaceRoughness - tidy3d.HuraySurfaceRoughness + tidy3d.rf.SurfaceImpedanceFitterParam + tidy3d.rf.HammerstadSurfaceRoughness + tidy3d.rf.HuraySurfaceRoughness The :class:`.PECMedium` and :class:`.LossyMetalMedium` classes can be used to model metallic materials. diff --git a/docs/api/microwave/ports/lumped.rst b/docs/api/microwave/ports/lumped.rst index b583cb8bf2..a0ff874912 100644 --- a/docs/api/microwave/ports/lumped.rst +++ b/docs/api/microwave/ports/lumped.rst @@ -7,8 +7,8 @@ Lumped Port & Elements :toctree: ../_autosummary/ :template: module.rst - tidy3d.plugins.smatrix.LumpedPort - tidy3d.plugins.smatrix.CoaxialLumpedPort + tidy3d.rf.LumpedPort + tidy3d.rf.CoaxialLumpedPort The :class:`LumpedPort` feature represents a planar, uniform current excitation with a fixed impedance termination. @@ -52,11 +52,11 @@ The ``CoaxialLumpedPort`` represents an analytical coaxial field source. :toctree: ../_autosummary/ :template: module.rst - tidy3d.LumpedResistor - tidy3d.CoaxialLumpedResistor - tidy3d.LinearLumpedElement - tidy3d.RLCNetwork - tidy3d.AdmittanceNetwork + tidy3d.rf.LumpedResistor + tidy3d.rf.CoaxialLumpedResistor + tidy3d.rf.LinearLumpedElement + tidy3d.rf.RLCNetwork + tidy3d.rf.AdmittanceNetwork For a simple resistive lumped element, use ``LumpedResistor``. diff --git a/docs/api/microwave/ports/wave.rst b/docs/api/microwave/ports/wave.rst index 5aa95ae9fd..cf4c7868b2 100644 --- a/docs/api/microwave/ports/wave.rst +++ b/docs/api/microwave/ports/wave.rst @@ -7,8 +7,8 @@ Wave Port :toctree: ../_autosummary/ :template: module.rst - tidy3d.plugins.smatrix.WavePort - tidy3d.ModeSpec + tidy3d.rf.WavePort + tidy3d.rf.MicrowaveModeSpec The :class:`.WavePort` represents a modal source port. The port mode is first calculated in the 2D mode solver, then injected into the 3D simulation. The :class:`.WavePort` is also automatically terminated with a modal absorbing boundary :class:`.ModeABCBoundary` that perfectly absorbs the outgoing mode. Any non-matching modes are subject to PEC reflection. @@ -46,13 +46,13 @@ If it is desired to only solve for the 2D port mode, one can use the ``to_mode_s :toctree: ../_autosummary/ :template: module.rst - tidy3d.plugins.microwave.AxisAlignedVoltageIntegral - tidy3d.plugins.microwave.AxisAlignedCurrentIntegral - tidy3d.plugins.microwave.Custom2DVoltageIntegral - tidy3d.plugins.microwave.Custom2DCurrentIntegral - tidy3d.plugins.microwave.AxisAlignedPathIntegral - tidy3d.plugins.microwave.Custom2DPathIntegral - tidy3d.plugins.microwave.ImpedanceCalculator + tidy3d.rf.AxisAlignedVoltageIntegral + tidy3d.rf.AxisAlignedCurrentIntegral + tidy3d.rf.Custom2DVoltageIntegral + tidy3d.rf.Custom2DCurrentIntegral + tidy3d.rf.AxisAlignedPathIntegral + tidy3d.rf.Custom2DPathIntegral + tidy3d.rf.ImpedanceCalculator The classes above are used to define the voltage/current integration paths for impedance calculation. diff --git a/docs/api/microwave/radiation_scattering.rst b/docs/api/microwave/radiation_scattering.rst index db22fb3f3f..466185b85e 100644 --- a/docs/api/microwave/radiation_scattering.rst +++ b/docs/api/microwave/radiation_scattering.rst @@ -7,11 +7,11 @@ Radiation & Scattering :toctree: ../_autosummary/ :template: module.rst - tidy3d.DirectivityMonitor - tidy3d.plugins.smatrix.DirectivityMonitorSpec - tidy3d.plugins.microwave.RectangularAntennaArrayCalculator - tidy3d.plugins.microwave.LobeMeasurer - tidy3d.AntennaMetricsData + tidy3d.rf.DirectivityMonitor + tidy3d.rf.DirectivityMonitorSpec + tidy3d.rf.RectangularAntennaArrayCalculator + tidy3d.rf.LobeMeasurer + tidy3d.rf.AntennaMetricsData When modeling antennas or scattering problems, it is vital to analyze the radiated far-field. For such applications, the :class:`.DirectivityMonitor` should be used.