-
Notifications
You must be signed in to change notification settings - Fork 65
feat(source_time): broadband pulse #2969
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
base: develop
Are you sure you want to change the base?
Conversation
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.
5 files reviewed, 1 comment
6c05805 to
026198a
Compare
026198a to
b00febc
Compare
Diff CoverageDiff: origin/develop...HEAD, staged and unstaged changes
Summary
tidy3d/components/source/time.pytidy3d/packaging.py |
tidy3d/packaging.py
Outdated
| tidy3d_extras["mod"] = tidy3d_extras_mod | ||
| tidy3d_extras["use_local_subpixel"] = "local_subpixel" in features | ||
| try: | ||
| _check_tidy3d_extras_available() |
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.
in this case, you need to set tidy3d_extras["use_local_subpixel"] = True, right? The backend tidy3d-extras tests should catch this?
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.
also, can you just make this use your check_tidy3d_extras_licensed_feature function too?
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.
In your current code, it doesn't raise an error if the subpixel is not licensed: it just silently disables local subpixel. Do you think we should instead raise an error here?
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.
(the error is raised in the revised version)
tidy3d/components/source/time.py
Outdated
| 5.0, | ||
| title="Offset", | ||
| description="Time delay of the maximum value of the " | ||
| "pulse in units of 1 / (``2pi * fwidth``).", |
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.
Looks like this was copy-pasted from Pulse, but BroadbandPulse doesn't have an fwidth?
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.
Actually, that's the part I have been working on since yesterday: offset is not well defined in this pulse. I need to find a better definition.
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.
Updated
| def frequency_range(self, num_fwidth: float = DEFAULT_SIGMA) -> FreqBound: | ||
| """Frequency range where the source amplitude is within ``exp(-sigma**2/2)`` of the peak amplitude.""" | ||
| return self.frequency_range_sigma(num_fwidth) |
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.
This just delegates to frequency_range_sigma but it keeps the sigma-based docstring, which is misleading. This should provide the correct description for the function.
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.
Now it's "Delegated to frequency_range_sigma(sigma=num_fwidth) for computing the frequency range where the source amplitude is within exp(-num_fwidth**2/2) of the peak amplitude"
72a3ed2 to
dc16fac
Compare
Greptile Overview
Updated On: 2025-11-05 20:52:36 UTC
Greptile Summary
This PR introduces
BroadbandPulse, a new source time dependence class that enables exciting simulations across a wide frequency spectrum. The feature is implemented as a wrapper around the tidy3d-extras licensed implementation.Key changes:
BroadbandPulseclass intidy3d/components/source/time.pywith configurable frequency range and minimum amplitude_check_tidy3d_extras_availableandcheck_tidy3d_extras_licensed_feature)Issues found:
tidy3d/packaging.py:244- missing 'f' prefix on f-string causes literal{exc!s}to appear in error message instead of being interpolatedConfidence Score: 4/5
tidy3d/packaging.pywhich contains a syntax error on line 244Important Files Changed
File Analysis
BroadbandPulseclass that wraps tidy3d-extras implementation for wide frequency spectrum excitationSequence Diagram
sequenceDiagram participant User participant BroadbandPulse participant Validator participant PackagingModule participant TidyExtras User->>BroadbandPulse: Instantiate with freq_range, minimum_amplitude BroadbandPulse->>Validator: _check_broadband_pulse_available() Validator->>PackagingModule: check_tidy3d_extras_licensed_feature("BroadbandPulse") PackagingModule->>PackagingModule: _check_tidy3d_extras_available() alt tidy3d-extras not loaded PackagingModule->>TidyExtras: import tidy3d_extras alt Import fails TidyExtras-->>PackagingModule: ImportError PackagingModule-->>Validator: Tidy3dImportError Validator-->>User: Error: Install tidy3d-extras else Import succeeds TidyExtras-->>PackagingModule: tidy3d_extras_mod PackagingModule->>PackagingModule: Check version and features alt BroadbandPulse not in features PackagingModule-->>Validator: Tidy3dImportError Validator-->>User: Error: Feature not licensed else Feature available PackagingModule->>PackagingModule: Cache tidy3d_extras["mod"] Validator-->>BroadbandPulse: Validation passed end end else tidy3d-extras already loaded PackagingModule->>PackagingModule: Check features list alt BroadbandPulse not in features PackagingModule-->>Validator: Tidy3dImportError Validator-->>User: Error: Feature not licensed else Feature available Validator-->>BroadbandPulse: Validation passed end end BroadbandPulse->>User: Instance created User->>BroadbandPulse: Call amp_time(time) or amp_freq(freq) BroadbandPulse->>BroadbandPulse: Access _source property BroadbandPulse->>TidyExtras: extension.BroadbandPulse(...) TidyExtras-->>BroadbandPulse: BroadbandPulse instance BroadbandPulse->>TidyExtras: _source.amp_time(time) TidyExtras-->>BroadbandPulse: Complex amplitude BroadbandPulse-->>User: Return amplitude