Skip to content

Commit a27afd2

Browse files
committed
fix(rf): enforce far_field_approx=True for DirectivityMonitor
1 parent 86b4292 commit a27afd2

File tree

6 files changed

+49
-2
lines changed

6 files changed

+49
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3333
- `CustomVoltageIntegral2D``Custom2DVoltageIntegral`
3434
- `CustomCurrentIntegral2D``Custom2DCurrentIntegral`
3535
- Path integral and impedance calculator classes have been refactored and moved from `tidy3d.plugins.microwave` to `tidy3d.components.microwave`. They are now publicly exported via the top-level package `__init__.py`, so you can import them directly, e.g. `from tidy3d import ImpedanceCalculator, AxisAlignedVoltageIntegral, AxisAlignedCurrentIntegral, Custom2DVoltageIntegral, Custom2DCurrentIntegral, Custom2DPathIntegral`.
36+
- `DirectivityMonitor` now forces `far_field_approx` to `True`, which was previously configurable.
3637

3738
### Fixed
3839
- More robust `Sellmeier` and `Debye` material model, and prevent very large pole parameters in `PoleResidue` material model.

schemas/Simulation.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5379,6 +5379,9 @@
53795379
},
53805380
"far_field_approx": {
53815381
"default": true,
5382+
"enum": [
5383+
true
5384+
],
53825385
"type": "boolean"
53835386
},
53845387
"freqs": {

schemas/TerminalComponentModeler.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5860,6 +5860,9 @@
58605860
},
58615861
"far_field_approx": {
58625862
"default": true,
5863+
"enum": [
5864+
true
5865+
],
58635866
"type": "boolean"
58645867
},
58655868
"freqs": {

tests/test_components/test_monitor.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,3 +445,26 @@ def test_monitor_surfaces_from_volume():
445445
# z+ surface
446446
assert monitor_surfaces[5].center == (center[0], center[1], center[2] + size[2] / 2.0)
447447
assert monitor_surfaces[5].size == (size[0], size[1], 0.0)
448+
449+
450+
def test_directivity_monitor():
451+
"""Check validation of directivity monitor."""
452+
size = (1, 2, 3)
453+
center = (1, 2, 3)
454+
455+
pd = np.atleast_1d(40000)
456+
thetas = np.linspace(0, 2 * np.pi, 100)
457+
phis = np.linspace(0, np.pi, 100)
458+
459+
# far_field_approx cannot be set to False
460+
with pytest.raises(pydantic.ValidationError):
461+
_ = td.DirectivityMonitor(
462+
size=size,
463+
center=center,
464+
theta=thetas,
465+
phi=phis,
466+
proj_distance=pd,
467+
freqs=FREQS,
468+
name="directivity",
469+
far_field_approx=False,
470+
)

tests/test_plugins/test_array_factor.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,6 @@ def make_antenna_sim():
308308
name="directivity",
309309
phi=list(phi),
310310
theta=list(theta),
311-
far_field_approx=False,
312311
)
313312

314313
# Create the simulation object
@@ -628,7 +627,6 @@ def test_rectangular_array_calculator_monitor_data_from_array_factor():
628627
name="radiation",
629628
phi=list(np.linspace(0, 2 * np.pi, 10)),
630629
theta=list(np.linspace(0, np.pi, 10)),
631-
far_field_approx=False,
632630
)
633631
coords_under_sampled = {
634632
"r": [monitor_directivity_under_sampled.proj_distance],

tidy3d/components/monitor.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1237,8 +1237,27 @@ class DirectivityMonitor(MicrowaveBaseModel, FieldProjectionAngleMonitor, FluxMo
12371237
12381238
Balanis, Constantine A., "Antenna Theory: Analysis and Design,"
12391239
John Wiley & Sons, Chapter 2.12 (2016).
1240+
1241+
Example
1242+
-------
1243+
>>> import numpy as np
1244+
>>> monitor = DirectivityMonitor( # doctest: +SKIP
1245+
... center=(0, 0, 0),
1246+
... size=(2, 2, 2),
1247+
... freqs=[1e9, 2e9, 3e9],
1248+
... name='directivity_monitor',
1249+
... theta=np.linspace(0, np.pi, 10),
1250+
... phi=np.linspace(0, 2*np.pi, 20),
1251+
... )
12401252
"""
12411253

1254+
far_field_approx: Literal[True] = pydantic.Field(
1255+
True,
1256+
title="Far Field Approximation",
1257+
description="Directivity calculations require the far field approximation. "
1258+
"This field is hard-coded to be ``True`` and cannot be changed.",
1259+
)
1260+
12421261
def storage_size(self, num_cells: int, tmesh: ArrayFloat1D) -> int:
12431262
"""Size of monitor storage given the number of points after discretization."""
12441263
# stores 1 complex number per pair of angles, per frequency,

0 commit comments

Comments
 (0)