Skip to content

Commit b151969

Browse files
yaugenst-flexmomchil-flex
authored andcommitted
feat: flux and poynting properties for FieldProjectionCartesianData
1 parent 003b37a commit b151969

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1414
- `autograd` gradient calculations can be performed on the server by passing `local_gradient = False` into `web.run()` or `web.run_async()`.
1515
- Automatic differentiation with `autograd` supports multiple frequencies through single, broadband adjoint simulation when the objective function can be formulated as depending on a single dataset in the output `SimulationData` with frequency dependence only.
1616
- Convenience method `EMESimulation.subsection` to create a new EME simulation based on a subregion of an existing one.
17+
- Added `flux` and `poynting` properties to `FieldProjectionCartesianData`.
1718

1819
### Changed
1920
- Error if field projection monitors found in 2D simulations, except `FieldProjectionAngleMonitor` with `far_field_approx = True`. Support for other monitors and for exact field projection will be coming in a subsequent Tidy3D version.

tests/test_components/test_field_projection.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,8 @@ def test_proj_clientside():
344344
far_fields_cartesian.fields_cartesian
345345
far_fields_cartesian.radar_cross_section
346346
far_fields_cartesian.power
347+
far_fields_cartesian.poynting
348+
far_fields_cartesian.flux
347349
for val in far_fields_cartesian.field_components.values():
348350
val.sel(f=f0)
349351
far_fields_cartesian.renormalize_fields(proj_distance=5e6)
@@ -366,6 +368,8 @@ def test_proj_clientside():
366368
exact_fields_cartesian.fields_cartesian
367369
exact_fields_cartesian.radar_cross_section
368370
exact_fields_cartesian.power
371+
exact_fields_cartesian.poynting
372+
exact_fields_cartesian.flux
369373
for val in exact_fields_cartesian.field_components.values():
370374
val.sel(f=f0)
371375
with pytest.raises(DataError):

tidy3d/components/data/monitor_data.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2465,6 +2465,35 @@ def z(self) -> np.ndarray:
24652465
"""Z positions."""
24662466
return self.Etheta.z.values
24672467

2468+
@property
2469+
def tangential_dims(self):
2470+
tangential_dims = ["x", "y", "z"]
2471+
tangential_dims.pop(self.monitor.proj_axis)
2472+
return tangential_dims
2473+
2474+
@property
2475+
def poynting(self) -> xr.DataArray:
2476+
"""Time-averaged Poynting vector for field data associated to a Cartesian field projection monitor."""
2477+
fc = self.fields_cartesian
2478+
dim1, dim2 = self.tangential_dims
2479+
2480+
e1 = fc["E" + dim1]
2481+
e2 = fc["E" + dim2]
2482+
h1 = fc["H" + dim1]
2483+
h2 = fc["H" + dim2]
2484+
2485+
e1_h2 = e1 * h2.conj()
2486+
e2_h1 = e2 * h1.conj()
2487+
2488+
e_x_h_star = e1_h2 - e2_h1
2489+
return 0.5 * np.real(e_x_h_star)
2490+
2491+
@cached_property
2492+
def flux(self) -> FluxDataArray:
2493+
"""Flux for projecteded field data corresponding to a Cartesian field projection monitor."""
2494+
flux = self.poynting.integrate(self.tangential_dims)
2495+
return FluxDataArray(flux)
2496+
24682497
def renormalize_fields(self, proj_distance: float) -> FieldProjectionCartesianData:
24692498
"""Return a :class:`.FieldProjectionCartesianData` with fields re-normalized to a new
24702499
projection distance, by applying a phase factor based on ``proj_distance``.

0 commit comments

Comments
 (0)