Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expand ModeMonitor docstring and add changelog explanation for backward mode sign change #997

Merged
merged 1 commit into from
Jul 13, 2023
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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Source validation happens before simulation upload and raises an error if no source is present.
- Warning instead of error if structure out of simulation bounds.
- Internal refactor of `ComponentModeler` to simplify logic.
- (Changed effective 2.3.0) Backward-direction mode amplitudes from `ModeMonitors` have a flipped sign compared to previous versions.
Previously, the amplitudes were computed directly through the dot product ``amp = (mode, field)``, while, since 2.3.0, we use ``amp = (mode, field) / (mode, mode)`` instead.
The modes are already normalized to unit directed flux, such that ``(mode, mode) = 1`` for forward modes, and ``(mode, mode) = -1`` for backward modes
(the dot product of a mode with itself is equal to the flux through the mode plane). Therefore, the change in the ``amp`` formula is equivalent to a sign change for
backward modes. This makes their interpretation more intuitive, since the amplitude is now ``1`` if the recorded field and a mode match exactly. A ``-1`` amplitude means
that the fields match exactly except for a ``pi`` phase shift. This interpretation is also now independent of forward/backward direction.

### Fixed
- Point-like objects correctly appear as single points using `plt.scatter`.
Expand Down
6 changes: 3 additions & 3 deletions tidy3d/components/data/monitor_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,9 +427,9 @@ def dot(
modes in lossless waveguides but differs for modes in lossy materials. In that case,
the conjugated dot product can be interpreted as the fraction of the power of the first
mode carried by the second, but modes are not orthogonal with respect to that product
and the sum of carried power fractions exceed 1. In the non-conjugated definition,
orthogonal modes can be defined, but the interpretation of modal overlap as power
carried by a given mode is no longer valid.
and the sum of carried power fractions may be different from the total flux.
In the non-conjugated definition, modes are orthogonal, but the interpretation of the
dot product power carried by a given mode is no longer valid.
"""

# Tangential fields for current and other field data
Expand Down
5 changes: 5 additions & 0 deletions tidy3d/components/monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,11 @@ def storage_size(self, num_cells: int, tmesh: ArrayFloat1D) -> int:

class ModeMonitor(AbstractModeMonitor):
""":class:`Monitor` that records amplitudes from modal decomposition of fields on plane.
The amplitudes are defined as
``mode_solver_data.dot(recorded_field) / mode_solver_data.dot(mode_solver_data)``, where
``recorded_field`` is the field data recorded in the FDTD simulation at the monitor frequencies,
and ``mode_solver_data`` is the mode data from the mode solver at the monitor plane.
This gives the power amplitude of ``recorded_field`` carried by each mode.

Example
-------
Expand Down