|
| 1 | +```@raw html |
| 2 | +<!--- |
| 3 | +Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. |
| 4 | +SPDX-License-Identifier: Apache-2.0 |
| 5 | +---> |
| 6 | +``` |
| 7 | + |
| 8 | +```@raw html |
| 9 | +<!--- |
| 10 | +MAINTAINER NOTE |
| 11 | +
|
| 12 | +The SVGs referenced from this page (docs/src/assets/examples/driven_ua_*.svg) |
| 13 | +are committed snapshots, not auto-generated artifacts. The underlying Palace |
| 14 | +runs take several hours and are not feasible to re-run in CI or at docs build |
| 15 | +time. The plots will drift relative to the current solver behaviour over time, |
| 16 | +which is acceptable for a feature guide; if you make a change that meaningfully |
| 17 | +alters the qualitative shape of these curves, please refresh |
| 18 | +them by hand. |
| 19 | +
|
| 20 | +To regenerate, from the repository root: |
| 21 | +
|
| 22 | + julia --project=examples -e 'include("examples/cpw/cpw_tutorial_lumped_driven.jl"); \ |
| 23 | + generate_cpw_lumped_driven_data(num_processors=4)' |
| 24 | + julia --project=examples -e 'include("examples/transmon/transmon_tutorial_driven.jl"); \ |
| 25 | + generate_transmon_driven_data(num_processors=4)' |
| 26 | + julia --project=examples examples/cpw/cpw_tutorial_lumped_driven_plots.jl |
| 27 | + julia --project=examples examples/transmon/transmon_tutorial_driven_plots.jl |
| 28 | +
|
| 29 | +then commit the updated docs/src/assets/examples/driven_ua_*.svg. |
| 30 | +---> |
| 31 | +``` |
| 32 | + |
| 33 | +# Adaptive Frequency Sweeps for Driven Simulations |
| 34 | + |
| 35 | +*Palace* has two modes for frequency-domain driven simulations: uniform and adaptive. The |
| 36 | +uniform solver runs one full finite-element solve per output frequency. The adaptive solver |
| 37 | +runs a much smaller number of full solves, constructs a projection-based reduced-order model |
| 38 | +(PROM), and evaluates that model over the requested output grid. |
| 39 | + |
| 40 | +The adaptive solver can be much faster than the uniform solver on fine frequency grids, but |
| 41 | +it introduces an approximation error that should be controlled and validated for the |
| 42 | +quantities of interest. The implementation details are described in the |
| 43 | +[adaptive driven solver reference](../reference.md#Adaptive-driven-solver-and-reduced-order-modeling). |
| 44 | +This page focuses on practical setup and validation. |
| 45 | + |
| 46 | +!!! warning "Advanced feature" |
| 47 | + |
| 48 | + Adaptive driven sweeps rely on algorithmic choices inside *Palace*. They are useful and |
| 49 | + efficient, but users should validate them against uniform sweeps when studying a new |
| 50 | + model or a new output quantity. |
| 51 | + |
| 52 | +## Quick start |
| 53 | + |
| 54 | +The only configuration difference between uniform and adaptive driven sweeps is the value of |
| 55 | +[`config["Solver"]["Driven"]["AdaptiveTol"]`](../config/solver.md#solver%5B%22Driven%22%5D). |
| 56 | +The default value is `0.0`, which uses the uniform solver. Any positive value enables the |
| 57 | +adaptive solver. |
| 58 | + |
| 59 | +```json |
| 60 | +"Solver": { |
| 61 | + "Driven": { |
| 62 | + "Samples": [ {"Type": "Linear", "MinFreq": 3.5, "MaxFreq": 7.0, "FreqStep": 0.1} ], |
| 63 | + "AdaptiveTol": 1e-3 |
| 64 | + } |
| 65 | +} |
| 66 | +``` |
| 67 | + |
| 68 | +The `"Samples"` specification defines the output frequency grid for both solvers. For the |
| 69 | +adaptive solver this grid can usually be fine, since adding output frequencies is much |
| 70 | +cheaper than adding full finite-element solves. The output files, such as `domain-E.csv` and |
| 71 | +`port-S.csv`, have the same format in both modes. |
| 72 | + |
| 73 | +When studying a new model, a good workflow is: |
| 74 | + |
| 75 | + 1. Run a uniform sweep on a coarse output grid or at key frequencies. |
| 76 | + 2. Run the adaptive solver on the same grid and compare the quantities you care about. |
| 77 | + 3. Tighten tolerances, add validation frequencies, or fall back to the uniform solver if the |
| 78 | + adaptive result is not accurate enough for the application. |
| 79 | + 4. Once validated, run the adaptive solver on the desired fine output grid. |
| 80 | + |
| 81 | +## Tuning parameters |
| 82 | + |
| 83 | +The most important configuration options are: |
| 84 | + |
| 85 | + - [`config["Solver"]["Driven"]["AdaptiveTol"]`](../config/solver.md#solver%5B%22Driven%22%5D): |
| 86 | + adaptive convergence tolerance. A value around `1e-3` is often a reasonable starting |
| 87 | + point for S-parameter sweeps, but the right value is model- and quantity-dependent. |
| 88 | + - [`config["Solver"]["Linear"]["Tol"]`](../config/solver.md#solver%5B%22Linear%22%5D): |
| 89 | + linear solver tolerance for the underlying full solves. This should usually be |
| 90 | + substantially smaller than `"AdaptiveTol"`. If *Palace* logs warnings about a |
| 91 | + rank-deficient minimal rational interpolation, try tightening this tolerance or using a |
| 92 | + looser `"AdaptiveTol"`. |
| 93 | + - [`config["Solver"]["Driven"]["AdaptiveMaxSamples"]`](../config/solver.md#solver%5B%22Driven%22%5D): |
| 94 | + maximum number of full samples per excitation. If this cap is reached before |
| 95 | + convergence, increase it or revisit the tolerances. |
| 96 | + - [`config["Solver"]["Driven"]["AdaptiveConvergenceMemory"]`](../config/solver.md#solver%5B%22Driven%22%5D): |
| 97 | + number of consecutive successful sample checks required before convergence. Increasing |
| 98 | + this can make early termination less likely, at the cost of more full solves. |
| 99 | + |
| 100 | +`"AdaptiveTol"` controls an error criterion on the finite-element electric-field solution, |
| 101 | +not a strict relative-error bound on every derived output. For example, a scattering |
| 102 | +parameter that is nearly zero can have a large pointwise relative error even when the |
| 103 | +absolute error is small. Validate the derived quantities that matter for your analysis. |
| 104 | + |
| 105 | +## Coplanar waveguide example |
| 106 | + |
| 107 | +The files for the CPW part of this guide are in |
| 108 | +[`examples/cpw/`](https://github.com/awslabs/palace/blob/main/examples/cpw): |
| 109 | + |
| 110 | + - `cpw_tutorial_lumped_uniform.json`: uniform reference sweep. |
| 111 | + - `cpw_tutorial_lumped_adaptive.json`: adaptive sweep template. |
| 112 | + - `cpw_tutorial_lumped_driven.jl`: runs the uniform and adaptive simulations. |
| 113 | + - `cpw_tutorial_lumped_driven_plots.jl`: regenerates the plots below from the simulation |
| 114 | + outputs. |
| 115 | + |
| 116 | +This example revisits the lumped-port version of the |
| 117 | +[CPW crosstalk example](../examples/cpw.md). The uniform reference performs a full solve at |
| 118 | +each output frequency, while the adaptive sweeps use the same output grid but construct a |
| 119 | +PROM from adaptively selected full solves. |
| 120 | + |
| 121 | +The uniform solver gives the following total electric energy and S-parameter magnitude: |
| 122 | + |
| 123 | +```@raw html |
| 124 | +<br/><p align="center"> |
| 125 | + <img src="../../assets/examples/driven_ua_cpw_domain_energy_uniform.svg" width="80%" /> |
| 126 | +</p><br/> |
| 127 | +``` |
| 128 | + |
| 129 | +```@raw html |
| 130 | +<br/><p align="center"> |
| 131 | + <img src="../../assets/examples/driven_ua_cpw_domain_sparam_uniform.svg" width="80%" /> |
| 132 | +</p><br/> |
| 133 | +``` |
| 134 | + |
| 135 | +For the adaptive solver, the diamond markers show the internal sample frequencies used to |
| 136 | +build the PROM. These samples need not coincide with the output grid, except for required |
| 137 | +boundary or user-forced samples. |
| 138 | + |
| 139 | +```@raw html |
| 140 | +<br/><p align="center"> |
| 141 | + <img src="../../assets/examples/driven_ua_cpw_domain_energy_adaptive_single.svg" width="80%" /> |
| 142 | +</p><br/> |
| 143 | +``` |
| 144 | + |
| 145 | +As `"AdaptiveTol"` is tightened, *Palace* adds more internal samples and the error against |
| 146 | +the uniform reference generally decreases. |
| 147 | + |
| 148 | +```@raw html |
| 149 | +<br/><p align="center"> |
| 150 | + <img src="../../assets/examples/driven_ua_cpw_domain_energy_adaptive_sweep.svg" width="80%" /> |
| 151 | +</p><br/> |
| 152 | +``` |
| 153 | + |
| 154 | +The pointwise relative error for S-parameters can look large when the reference value is |
| 155 | +small. In the CPW example, some scattering parameters are tiny over much of the band, so |
| 156 | +relative error alone can exaggerate visually small absolute differences. |
| 157 | + |
| 158 | +```@raw html |
| 159 | +<br/><p align="center"> |
| 160 | + <img src="../../assets/examples/driven_ua_cpw_domain_sparam_adaptive_pointwise.svg" width="80%" /> |
| 161 | +</p><br/> |
| 162 | +``` |
| 163 | + |
| 164 | +A complementary view is the absolute error normalized by an RMS scale for the reference |
| 165 | +S-parameter over the frequency range: |
| 166 | + |
| 167 | +```@raw html |
| 168 | +<br/><p align="center"> |
| 169 | + <img src="../../assets/examples/driven_ua_cpw_domain_sparam_adaptive_rms.svg" width="80%" /> |
| 170 | +</p><br/> |
| 171 | +``` |
| 172 | + |
| 173 | +The adaptive error indicator does not have to decrease monotonically. The convergence memory |
| 174 | +parameter exists because an estimator can occasionally look converged before the next samples |
| 175 | +would reveal a larger error. |
| 176 | + |
| 177 | +```@raw html |
| 178 | +<br/><p align="center"> |
| 179 | + <img src="../../assets/examples/driven_ua_cpw_adaptive_convergence_curve.svg" width="80%" /> |
| 180 | +</p><br/> |
| 181 | +``` |
| 182 | + |
| 183 | +## Transmon example |
| 184 | + |
| 185 | +The transmon part of this guide uses the same geometry as the |
| 186 | +[transmon eigenmode example](../examples/transmon.md), but runs driven simulations by |
| 187 | +exciting the two resistive feedline ports. The files are in |
| 188 | +[`examples/transmon/`](https://github.com/awslabs/palace/blob/main/examples/transmon): |
| 189 | + |
| 190 | + - `transmon_tutorial_driven.json`: driven simulation template. |
| 191 | + - `transmon_tutorial_driven.jl`: runs the uniform and adaptive simulations. |
| 192 | + - `transmon_tutorial_driven_plots.jl`: regenerates the plots below. |
| 193 | + |
| 194 | +The model contains resonant modes near the driven frequency band, so the response is more |
| 195 | +structured than in the CPW example. This is a useful case for adaptive sampling: the PROM can |
| 196 | +place full solves near the frequencies that most influence the response. |
| 197 | + |
| 198 | +The uniform driven sweep resolves the electric energy and the feedline S-parameters: |
| 199 | + |
| 200 | +```@raw html |
| 201 | +<br/><p align="center"> |
| 202 | + <img src="../../assets/examples/driven_ua_transmon_energy_uniform.svg" width="80%" /> |
| 203 | +</p><br/> |
| 204 | +``` |
| 205 | + |
| 206 | +```@raw html |
| 207 | +<br/><p align="center"> |
| 208 | + <img src="../../assets/examples/driven_ua_transmon_sparam_uniform.svg" width="80%" /> |
| 209 | +</p><br/> |
| 210 | +``` |
| 211 | + |
| 212 | +The adaptive error is largest near resonant features and decreases as the tolerance is |
| 213 | +tightened. The sample locations become more structured than in the CPW example because the |
| 214 | +response is influenced by nearby poles. |
| 215 | + |
| 216 | +```@raw html |
| 217 | +<br/><p align="center"> |
| 218 | + <img src="../../assets/examples/driven_ua_transmon_energy_adaptive_sweep.svg" width="80%" /> |
| 219 | +</p><br/> |
| 220 | +``` |
| 221 | + |
| 222 | +```@raw html |
| 223 | +<br/><p align="center"> |
| 224 | + <img src="../../assets/examples/driven_ua_transmon_sparam_adaptive_rms.svg" width="80%" /> |
| 225 | +</p><br/> |
| 226 | +``` |
| 227 | + |
| 228 | +The uniform reference can also lose accuracy near high-``Q`` poles because the full system is |
| 229 | +more poorly conditioned there. Tightening only the adaptive tolerance is not useful if the |
| 230 | +underlying full solves are themselves inaccurate. |
| 231 | + |
| 232 | +## Regenerating the plots |
| 233 | + |
| 234 | +The committed plots are snapshots. To regenerate them, first run the simulations, then run |
| 235 | +the plot scripts: |
| 236 | + |
| 237 | +```bash |
| 238 | +julia --project=examples -e 'include("examples/cpw/cpw_tutorial_lumped_driven.jl"); generate_cpw_lumped_driven_data(num_processors=4)' |
| 239 | +julia --project=examples -e 'include("examples/transmon/transmon_tutorial_driven.jl"); generate_transmon_driven_data(num_processors=4)' |
| 240 | +julia --project=examples examples/cpw/cpw_tutorial_lumped_driven_plots.jl |
| 241 | +julia --project=examples examples/transmon/transmon_tutorial_driven_plots.jl |
| 242 | +``` |
| 243 | + |
| 244 | +The scripts write SVGs to `docs/src/assets/examples/` by default. |
0 commit comments