Skip to content

Commit 0a9f0f5

Browse files
authored
Merge branch 'develop' into rahul-flex/rotated-box-derivatives
2 parents 856f237 + 35469b0 commit 0a9f0f5

File tree

90 files changed

+4562
-502
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

90 files changed

+4562
-502
lines changed

.github/workflows/run_tests.yml

Lines changed: 161 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,12 @@ name: "tidy3d-frontend-tests"
33
on:
44
workflow_dispatch:
55
inputs:
6-
run_tests:
7-
description: 'Run test suite'
6+
remote_tests:
7+
description: 'remote-tests'
8+
type: boolean
9+
default: true
10+
local_tests:
11+
description: 'local-tests'
812
type: boolean
913
default: false
1014
push:
@@ -14,12 +18,85 @@ on:
1418
- latest
1519
- develop
1620
- 'pre/*'
21+
types: ['opened', 'reopened', 'synchronize', 'ready_for_review']
22+
pull_request_review:
23+
types: [submitted]
1724

1825
jobs:
26+
determine-test-scope:
27+
runs-on: [ inhouse ]
28+
if: |
29+
github.event.pull_request.draft == false ||
30+
github.ref == 'refs/heads/develop' ||
31+
github.event_name == 'workflow_dispatch'
32+
outputs:
33+
local_tests: ${{ steps.determine-test-type.outputs.local_tests }}
34+
remote_tests: ${{ steps.determine-test-type.outputs.remote_tests }}
35+
steps:
36+
- name: determine-test-type
37+
id: determine-test-type
38+
env:
39+
DRAFT_STATE: ${{ github.event.pull_request.draft }}
40+
EVENT_NAME: ${{ github.event_name }}
41+
REVIEW_STATE: ${{ github.event.review.state }}
42+
REF: ${{ github.ref }}
43+
INPUT_LOCAL: ${{ github.event.inputs.local_tests }}
44+
INPUT_REMOTE: ${{ github.event.inputs.remote_tests }}
45+
run: |
46+
echo "Event: $EVENT_NAME"
47+
echo "Draft: $DRAFT_STATE"
48+
echo "Review State: $REVIEW_STATE"
49+
echo "Git REF: $REF"
50+
echo "Input local: $INPUT_FAST"
51+
echo "Input remote: $INPUT_FULL"
52+
53+
remote_tests=false
54+
local_tests=false
55+
# Workflow_dispatch input override
56+
if [[ "$EVENT_NAME" == "workflow_dispatch" ]]; then
57+
58+
# Each option is self contained
59+
if [[ "$INPUT_REMOTE" == "true" ]]; then
60+
remote_tests=true
61+
fi
62+
63+
if [[ "$INPUT_LOCAL" == "true" ]]; then
64+
local_tests=true
65+
fi
66+
fi
67+
68+
# If triggered by PR review and approved
69+
if [[ "$EVENT_NAME" == "pull_request_review" ]]; then
70+
if [[ "$REVIEW_STATE" == "approved" ]]; then
71+
local_tests=true
72+
remote_tests=true
73+
else
74+
local_tests=false
75+
remote_tests=false
76+
fi
77+
fi
78+
79+
# All PRs that have been triggered need local tests
80+
if [[ "$EVENT_NAME" == "pull_request" ]]; then
81+
local_tests=true
82+
fi
83+
84+
# If it's a push to develop
85+
if [[ "$EVENT_NAME" == "push" && "$REF" == "refs/heads/develop" ]]; then
86+
local_tests=true
87+
remote_tests=true
88+
fi
1989
90+
echo "local_tests=$local_tests" >> $GITHUB_OUTPUT
91+
echo "remote_tests=$remote_tests" >> $GITHUB_OUTPUT
92+
echo "local_tests=$local_tests"
93+
echo "remote_tests=$remote_tests"
94+
2095
lint:
96+
needs: determine-test-scope
97+
if: ( needs.determine-test-scope.outputs.local_tests == 'true' ) || ( needs.determine-test-scope.outputs.remote_tests == 'true' )
2198
name: Run linting
22-
runs-on: ubuntu-latest
99+
runs-on: [ inhouse ]
23100
steps:
24101
- uses: actions/checkout@v4
25102
with:
@@ -32,15 +109,66 @@ jobs:
32109
- name: Run ruff check
33110
run: ruff check tidy3d
34111

35-
test:
36-
# Run on internal PRs/pushes OR when manually triggered with run_tests=true
37-
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository || (github.event_name == 'workflow_dispatch' && inputs.run_tests)
112+
local-tests:
113+
# Run on open PRs OR when manually triggered with local_tests=true
114+
needs: determine-test-scope
115+
if: needs.determine-test-scope.outputs.local_tests == 'true'
116+
name: Python ${{ matrix.python-version }} - self-hosted-runner
117+
runs-on: [ inhouse ]
118+
strategy:
119+
matrix:
120+
python-version: ['3.9', '3.13']
121+
defaults:
122+
run:
123+
shell: bash
124+
env: # Set environment variables for the whole job
125+
PIP_ONLY_BINARY: gdstk
126+
MPLBACKEND: agg
127+
128+
steps:
129+
- uses: actions/checkout@v4
130+
with:
131+
fetch-depth: 1
132+
133+
- name: Set up Python ${{ matrix.python-version }}
134+
uses: actions/setup-python@v4
135+
with:
136+
python-version: ${{ matrix.python-version }}
137+
138+
- name: Install project
139+
run: |
140+
python -m venv ${GITHUB_WORKSPACE}/.venv
141+
source ${GITHUB_WORKSPACE}/.venv/bin/activate
142+
python --version
143+
which python
144+
which pip
145+
pip list
146+
pip install --upgrade pip wheel setuptools
147+
pip install gdstk --only-binary gdstk
148+
pip install -e ".[dev]"
149+
150+
- name: Run tests with coverage
151+
env:
152+
PYTHONUNBUFFERED: "1"
153+
run: |
154+
source ${GITHUB_WORKSPACE}/.venv/bin/activate
155+
pytest --cov=tidy3d -rF --tb=short tests/_test_data/_test_datasets_no_vtk.py
156+
pytest --cov=tidy3d -rF --tb=short tests
157+
coverage report -m
158+
TOTAL_COVERAGE=$(coverage report --format=total)
159+
echo "total=$TOTAL_COVERAGE" >> "$GITHUB_ENV"
160+
echo "### Total coverage: ${TOTAL_COVERAGE}%"
161+
162+
remote-tests:
163+
# Run tests on a push event OR a workflow dispatch with remote_tests
164+
needs: determine-test-scope
165+
if: needs.determine-test-scope.outputs.remote_tests == 'true'
38166
name: Python ${{ matrix.python-version }} - ${{ matrix.platform }}
39167
runs-on: ${{ matrix.platform }}
40168
strategy:
41169
matrix:
42170
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']
43-
platform: [ubuntu-latest, windows-latest, macos-latest]
171+
platform: [windows-latest, ubuntu-latest, macos-latest]
44172
defaults:
45173
run:
46174
shell: bash
@@ -103,3 +231,29 @@ jobs:
103231
maxColorRange: 95
104232
valColorRange: ${{ env.total }}
105233
style: "for-the-badge"
234+
235+
pr-requirements-pass:
236+
name: pr-requirements-pass
237+
if: ( needs.determine-test-scope.outputs.local_tests == 'true' ) || ( needs.determine-test-scope.outputs.remote_tests == 'true' )
238+
needs: [local-tests, remote-tests, lint]
239+
runs-on: [ inhouse ]
240+
steps:
241+
- name: check-passing-remote-tests
242+
run: |
243+
echo "Remote tests result: ${{ needs.remote-tests.result }}"
244+
245+
if [[ "${{ needs.lint.result }}" != "success" ]]; then
246+
echo "❌ Linting failed or was skipped."
247+
exit 1
248+
fi
249+
250+
if [[ "${{ needs.remote-tests.result }}" != "success" ]]; then
251+
echo "❌ remote-tests failed or were skipped."
252+
fi
253+
254+
if [[ "${{ needs.local-tests.result }}" != "success" ]]; then
255+
echo "❌ local-tests failed or were skipped."
256+
exit 1
257+
fi
258+
259+
echo "✅ All required test jobs passed!"

.github/workflows/test_develop_cli.yaml

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,15 @@ name: "test-develop-cli"
22

33
on:
44
workflow_dispatch:
5-
workflow_run:
6-
workflows: [ "tidy3d-frontend-tests" ]
7-
types: [ completed ]
5+
schedule:
6+
- cron: '0 2 * * *' # Runs every day at 2:00 AM UTC
7+
push:
8+
branches:
9+
- develop
10+
- latest
811

912
jobs:
10-
on-success:
11-
runs-on: ubuntu-latest
12-
if: ${{ github.event.workflow_run.conclusion == 'success' }}
13-
steps:
14-
- run: echo 'The triggering workflow passed'
15-
on-failure:
16-
runs-on: ubuntu-latest
17-
if: ${{ github.event.workflow_run.conclusion == 'failure' }}
18-
steps:
19-
- run: echo 'The triggering workflow failed'
20-
2113
test-dev-commands:
22-
needs: [on-success]
2314
strategy:
2415
matrix:
2516
os: [ubuntu-latest, windows-latest, macos-latest]
@@ -29,7 +20,7 @@ jobs:
2920
- name: Checkout code
3021
uses: actions/checkout@v4
3122
with:
32-
ref: ${{ github.event.workflow_run.head_commit.id }}
23+
ref: develop
3324

3425

3526
- name: Set up Python

CHANGELOG.md

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,59 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Added
11+
- Gradient computation for rotated boxes in Transformed.
12+
13+
### Changed
14+
- Supplying autograd-traced values to geometric fields (`center`, `size`) of simulations, monitors, and sources now logs a warning and falls back to the static value instead of erroring.
15+
- Attempting to differentiate server-side field projections now raises a clear error instead of silently failing.
16+
17+
## [2.8.3] - 2025-04-24
18+
19+
### Added
20+
- Ability to select payment option when submitting jobs from the Python client.
21+
- Periodic repetition of EME subgrids via `num_reps` or `EMEPeriodicitySweep`.
22+
- Methods `EMEExplicitGrid.from_structures` and `EMECompositeGrid.from_structure_groups` to place EME cell boundaries at structure bounds.
23+
- 'ModeSimulation' now supports 'PermittivityMonitor'.
24+
- Classmethod `from_frequency_range` in `GaussianPulse` for generating a pulse whose amplitude in the frequency_range [fmin, fmax] is maximized, which is particularly useful for running broadband simulations.
25+
- Differentiable function `td.plugins.autograd.interpolate_spline` for 1D linear, quadratic, and cubic spline interpolation, supporting differentiation with respect to the interpolated values (`y_points`) and optional endpoint derivative constraints.
26+
- `SteadyEnergyBandMonitor` in the Charge solver.
27+
- Pretty printing enabled with `rich.print` for the material library, materials, and their variants. In notebooks, this can be accessed using `rich.print` or `display`, or by evaluating the material library, a material, or a variant in a cell.
28+
29+
### Changed
30+
- Performance enhancement for adjoint gradient calculations by optimizing field interpolation.
31+
- Auto grid in EME simulations with multiple `freqs` provided uses the largest instead of raising an error.
32+
- Named mediums now display by name for brevity; materials/variants print concise summaries including references.
33+
34+
### Fixed
35+
- Fixed `reverse` property of `td.Scene.plot_structures_property()` to also reverse the colorbar.
36+
37+
### Fixed
38+
- Fixed bug in surface gradient computation where fields, instead of gradients, were being summed in frequency.
39+
40+
## [2.8.2] - 2025-04-09
41+
1042
### Added
1143
- `fill` and `fill_structures` argument in `td.Simulation.plot_structures()` and `td.Simulation.plot()` respectively to disable fill and plot outlines of structures only.
1244
- New subpixel averaging option `ContourPathAveraging` applied to dielectric material boundaries.
1345
- A property `interior_angle` in `PolySlab` that stores angles formed inside polygon by two adjacent edges.
1446
- `eps_component` argument in `td.Simulation.plot_eps()` to optionally select a specific permittivity component to plot (eg. `"xx"`).
1547
- Monitor `AuxFieldTimeMonitor` for aux fields like the free carrier density in `TwoPhotonAbsorption`.
16-
- Gradient computation for rotated boxes in Transformed.
48+
- Broadband handling (`num_freqs` argument) to the TFSF source.
49+
- Ability to define a `WavePort` using only a voltage or current path integral, with the missing quantity inferred via power conservation.
1750

1851
### Fixed
1952
- Compatibility with `xarray>=2025.03`.
2053
- Inaccurate gradient when auto-grabbing permittivities for structures using `td.PolySlab` when using dispersive material models.
2154
- Fixed scaling for adjoint sources when differentiating with respect to `FieldData` to account for the mesh size of the monitor and thus the created source. This aligns adjoint gradient magnitudes with numerical finite difference gradients for field data.
2255
- Warn when mode solver pml covers a significant portion of the mode plane.
56+
- TFSF server errors related to the auxiliary plane wave source that would previously happen on the server are now caught upon simulation creation.
57+
- Opposite arrow curvature for mode sources and monitors with non-zero bendind radius when plotted in the figure's Y axis.
58+
59+
### Changed
60+
- `num_freqs` in Gaussian beam type sources limited to 20, which should besufficient for all cases.
61+
- The `angle_phi` parameter of `ModeSpec` is only limited to multiples of `np.pi / 2` if `angle_rotation` is set to `True`, as other values would currently not work correctly.
62+
- The `ramp_up_iters` parameter of the `ChargeSolver` was changed back to 1 for efficiency. It can be increased in cases with e.g. high doping when convergence is more difficult.
2363

2464
## [2.8.1] - 2025-03-20
2565

@@ -1561,7 +1601,9 @@ which fields are to be projected is now determined automatically based on the me
15611601
- Job and Batch classes for better simulation handling (eventually to fully replace webapi functions).
15621602
- A large number of small improvements and bug fixes.
15631603

1564-
[Unreleased]: https://github.com/flexcompute/tidy3d/compare/v2.8.1...develop
1604+
[Unreleased]: https://github.com/flexcompute/tidy3d/compare/v2.8.3...develop
1605+
[2.8.3]: https://github.com/flexcompute/tidy3d/compare/v2.8.2...v2.8.3
1606+
[2.8.2]: https://github.com/flexcompute/tidy3d/compare/v2.8.1...v2.8.2
15651607
[2.8.1]: https://github.com/flexcompute/tidy3d/compare/v2.8.0...v2.8.1
15661608
[2.8.0]: https://github.com/flexcompute/tidy3d/compare/v2.7.9...v2.8.0
15671609
[2.7.9]: https://github.com/flexcompute/tidy3d/compare/v2.7.8...v2.7.9

docs/_static/img/gui_overview.png

419 KB
Loading
179 KB
Loading
34.5 KB
Loading

docs/conf.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@
106106
"sphinx.ext.todo",
107107
"sphinx.ext.viewcode", # Add a link to the Python source code for classes, functions etc.
108108
"sphinx_copybutton",
109+
"sphinx_design",
109110
"sphinx_favicon",
110111
"sphinx_sitemap",
111112
"sphinx_tabs.tabs",
@@ -188,6 +189,7 @@
188189
}
189190
myst_enable_extensions = [
190191
"amsmath",
192+
"colon_fence",
191193
"dollarmath",
192194
]
193195
nbsphinx_allow_errors = True # Continue through Jupyter errors

0 commit comments

Comments
 (0)