-
Notifications
You must be signed in to change notification settings - Fork 66
fix(source_time): more accurate frequency_range and central frequency #2873
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
Merged
weiliangjin2021
merged 1 commit into
develop
from
weiliang/FXC-3541-more-accurate-frequency-range
Oct 9, 2025
Merged
fix(source_time): more accurate frequency_range and central frequency #2873
weiliangjin2021
merged 1 commit into
develop
from
weiliang/FXC-3541-more-accurate-frequency-range
Oct 9, 2025
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Additional Comments (1)
13 files reviewed, 5 comments
Diff CoverageDiff: origin/develop...HEAD, staged and unstaged changes
Summary
tidy3d/components/source/field.py
tidy3d/components/source/time.py
|
ad9d0fb
to
2886bf1
Compare
momchil-flex
approved these changes
Oct 8, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great!
2886bf1
to
0e26a65
Compare
weiliangjin2021
commented
Oct 8, 2025
0e26a65
to
25f2f30
Compare
dbochkov-flexcompute
approved these changes
Oct 8, 2025
25f2f30
to
fd34d8d
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Aside from the issue described in https://flow360.atlassian.net/browse/FXC-3541, this is also a preparation for https://flow360.atlassian.net/browse/FXC-2556
Greptile Overview
Updated On: 2025-10-07 23:42:48 UTC
Summary
This PR implements significant improvements to frequency range calculations and central frequency determination for source time dependencies, particularly for GaussianPulse sources when DC component removal is enabled. The core change introduces a new `frequency_range_sigma()` method that uses transcendental equation solving to find precise frequency bounds where amplitude drops to exp(-σ²/2) of the peak, replacing the less accurate standard deviation-based `frequency_range()` method.The PR systematically refactors the codebase to use a private
_freq0
property instead of the publicfreq0
property throughout the simulation framework. This new property provides more accurate central frequency calculations by intelligently choosing between user-specifiedfreq0
(for Pulse sources) and computed_freq0_sigma_centroid
(for other source types). This ensures consistent frequency handling across different source time types.Additionally, the PR enhances the testing infrastructure with new log assertion utilities (
AssertLogStr
andassert_str_in_log
) that enable more granular validation of log message content beyond just checking log levels. The changes also add a new pyroots dependency for numerical root-finding operations required by the improved frequency calculations.These modifications address accuracy issues described in FXC-3541 and prepare the codebase for future enhancements mentioned in FXC-2556, ensuring that electromagnetic simulations have more precise frequency domain representations, especially for asymmetric spectral content like DC-removed Gaussian pulses.
Important Files Changed
Changed Files
tidy3d/components/source/time.py
frequency_range_sigma()
method and enhanced central frequency determinationtidy3d/components/simulation.py
freq0
with_freq0
across 14 locations for more accurate frequency calculationstidy3d/components/data/sim_data.py
_freq0
property for consistent frequency handlingtests/utils.py
AssertLogStr
andassert_str_in_log
for enhanced test validationtests/test_components/test_source.py
frequency_range_sigma()
method and validates improved frequency calculationstests/test_components/test_simulation.py
tidy3d/components/source/base.py
_freq0_sigma_centroid
for more accurate minimum frequency checkstidy3d/components/source/field.py
frequency_range_sigma()
and_freq0
for improved accuracytidy3d/components/boundary.py
freq0
to_freq0
in boundary condition frequency calculationstidy3d/components/grid/grid_spec.py
_freq0
for more accurate wavelength calculationstidy3d/plugins/smatrix/ports/coaxial_lumped.py
tests/test_components/autograd/test_autograd.py
CHANGELOG.md
Confidence score: 4/5
tidy3d/components/source/time.py
andtests/utils.py
for the core frequency calculation logic and debug statements that should be removedContext used:
Rule from
dashboard
- Remove temporary debugging code (print() calls), commented-out code, and other workarounds before fi... (source)Rule from
dashboard
- Update the CHANGELOG.md file when making changes that affect user-facing functionality or fix bugs. (source)