solprop-gui 0.2.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- solprop_gui/__init__.py +24 -0
- solprop_gui/__main__.py +11 -0
- solprop_gui/app.py +67 -0
- solprop_gui/classes/__init__.py +9 -0
- solprop_gui/classes/catalog.py +854 -0
- solprop_gui/classes/problem.py +868 -0
- solprop_gui/classes/workflow.py +139 -0
- solprop_gui/help/__init__.py +7 -0
- solprop_gui/help/figures/antiresonant.svg +70 -0
- solprop_gui/help/figures/capillary-averaged.svg +63 -0
- solprop_gui/help/figures/capillary-modal.svg +65 -0
- solprop_gui/help/figures/cartesian.svg +164 -0
- solprop_gui/help/figures/gnlse.svg +64 -0
- solprop_gui/help/figures/grin.svg +63 -0
- solprop_gui/help/figures/line.svg +84 -0
- solprop_gui/help/figures/radial.svg +68 -0
- solprop_gui/help/figures/rectangular.svg +63 -0
- solprop_gui/help/figures/slab.svg +68 -0
- solprop_gui/help/figures/step-index.svg +63 -0
- solprop_gui/help/figures.py +106 -0
- solprop_gui/help/guide/analysis.md +96 -0
- solprop_gui/help/guide/classes.md +94 -0
- solprop_gui/help/guide/design.md +59 -0
- solprop_gui/help/guide/first-run.md +101 -0
- solprop_gui/help/guide/images/capillary-along.png +0 -0
- solprop_gui/help/guide/images/capillary-overview.png +0 -0
- solprop_gui/help/guide/images/capillary-plane.png +0 -0
- solprop_gui/help/guide/images/capillary-run.png +0 -0
- solprop_gui/help/guide/images/capillary-sheet.png +0 -0
- solprop_gui/help/guide/images/capillary-target.png +0 -0
- solprop_gui/help/guide/images/design.png +0 -0
- solprop_gui/help/guide/images/filament-overview.png +0 -0
- solprop_gui/help/guide/images/filament-sheet.png +0 -0
- solprop_gui/help/guide/images/home.png +0 -0
- solprop_gui/help/guide/images/plot-menu.png +0 -0
- solprop_gui/help/guide/images/scan.png +0 -0
- solprop_gui/help/guide/index.md +104 -0
- solprop_gui/help/guide/scans.md +55 -0
- solprop_gui/help/guide.py +48 -0
- solprop_gui/help/manual.py +199 -0
- solprop_gui/model/__init__.py +12 -0
- solprop_gui/model/compressor.py +407 -0
- solprop_gui/model/display.py +501 -0
- solprop_gui/model/plot_options.py +343 -0
- solprop_gui/model/quantities.py +179 -0
- solprop_gui/model/recipe.py +473 -0
- solprop_gui/model/scans.py +288 -0
- solprop_gui/model/snippets.py +118 -0
- solprop_gui/model/stats_layout.py +115 -0
- solprop_gui/model/values.py +195 -0
- solprop_gui/model/workspace.py +151 -0
- solprop_gui/py.typed +0 -0
- solprop_gui/registry/__init__.py +12 -0
- solprop_gui/registry/explore.py +481 -0
- solprop_gui/registry/pages.py +273 -0
- solprop_gui/registry/routes.py +450 -0
- solprop_gui/registry/units.py +135 -0
- solprop_gui/service/__init__.py +12 -0
- solprop_gui/service/beam.py +226 -0
- solprop_gui/service/beams.py +257 -0
- solprop_gui/service/client.py +398 -0
- solprop_gui/service/design.py +362 -0
- solprop_gui/service/figures.py +106 -0
- solprop_gui/service/handlers.py +709 -0
- solprop_gui/service/kernel.py +187 -0
- solprop_gui/service/messages.py +210 -0
- solprop_gui/service/outbox.py +139 -0
- solprop_gui/service/postprocess.py +513 -0
- solprop_gui/service/reduce.py +368 -0
- solprop_gui/service/remote.py +513 -0
- solprop_gui/service/results.py +951 -0
- solprop_gui/service/run.py +648 -0
- solprop_gui/service/scan_reductions.py +261 -0
- solprop_gui/service/server.py +501 -0
- solprop_gui/service/sheet.py +1023 -0
- solprop_gui/service/states.py +146 -0
- solprop_gui/service/waveguide.py +320 -0
- solprop_gui/service/worker.py +97 -0
- solprop_gui/ui/__init__.py +11 -0
- solprop_gui/ui/analyse.py +808 -0
- solprop_gui/ui/analysis.py +338 -0
- solprop_gui/ui/analysis_pages.py +2954 -0
- solprop_gui/ui/assets/chevron.svg +6 -0
- solprop_gui/ui/assets/fonts/IBMPlexSans-Medium.ttf +0 -0
- solprop_gui/ui/assets/fonts/IBMPlexSans-Regular.ttf +0 -0
- solprop_gui/ui/assets/fonts/IBMPlexSans-SemiBold.ttf +0 -0
- solprop_gui/ui/assets/fonts/LICENSE.txt +93 -0
- solprop_gui/ui/assets/icon/solprop-1024.png +0 -0
- solprop_gui/ui/assets/icon/solprop-128.png +0 -0
- solprop_gui/ui/assets/icon/solprop-16.png +0 -0
- solprop_gui/ui/assets/icon/solprop-24.png +0 -0
- solprop_gui/ui/assets/icon/solprop-256.png +0 -0
- solprop_gui/ui/assets/icon/solprop-32.png +0 -0
- solprop_gui/ui/assets/icon/solprop-48.png +0 -0
- solprop_gui/ui/assets/icon/solprop-512.png +0 -0
- solprop_gui/ui/assets/icon/solprop-64.png +0 -0
- solprop_gui/ui/assets/icon/solprop-compact.svg +19 -0
- solprop_gui/ui/assets/icon/solprop.svg +20 -0
- solprop_gui/ui/betas.py +245 -0
- solprop_gui/ui/bridge.py +258 -0
- solprop_gui/ui/design_stage.py +956 -0
- solprop_gui/ui/document.py +693 -0
- solprop_gui/ui/fields.py +812 -0
- solprop_gui/ui/help_window.py +214 -0
- solprop_gui/ui/home.py +291 -0
- solprop_gui/ui/icons.py +191 -0
- solprop_gui/ui/identity.py +230 -0
- solprop_gui/ui/launch.py +261 -0
- solprop_gui/ui/objects.py +530 -0
- solprop_gui/ui/pages.py +436 -0
- solprop_gui/ui/pin.py +286 -0
- solprop_gui/ui/plot_options.py +439 -0
- solprop_gui/ui/postprocess.py +532 -0
- solprop_gui/ui/quantity.py +532 -0
- solprop_gui/ui/results.py +482 -0
- solprop_gui/ui/run_options.py +179 -0
- solprop_gui/ui/run_panel.py +767 -0
- solprop_gui/ui/scan_editor.py +421 -0
- solprop_gui/ui/scan_stage.py +724 -0
- solprop_gui/ui/sheet.py +1371 -0
- solprop_gui/ui/theme.py +247 -0
- solprop_gui/ui/tile_art.py +146 -0
- solprop_gui/ui/workflow_window.py +1332 -0
- solprop_gui/views/__init__.py +11 -0
- solprop_gui/views/compare.py +114 -0
- solprop_gui/views/compression.py +146 -0
- solprop_gui/views/controls.py +211 -0
- solprop_gui/views/cross_section.py +124 -0
- solprop_gui/views/live.py +704 -0
- solprop_gui/views/page_plots.py +1073 -0
- solprop_gui/views/plane.py +650 -0
- solprop_gui/views/plotting.py +381 -0
- solprop_gui/views/scan_browser.py +149 -0
- solprop_gui/views/sparkline.py +131 -0
- solprop_gui/views/splitter.py +141 -0
- solprop_gui/views/statistics.py +501 -0
- solprop_gui-0.2.0.dist-info/METADATA +92 -0
- solprop_gui-0.2.0.dist-info/RECORD +143 -0
- solprop_gui-0.2.0.dist-info/WHEEL +4 -0
- solprop_gui-0.2.0.dist-info/entry_points.txt +2 -0
- solprop_gui-0.2.0.dist-info/licenses/LICENSE +674 -0
- solprop_gui-0.2.0.dist-info/licenses/LICENSE-CC-BY-4.0.txt +156 -0
- solprop_gui-0.2.0.dist-info/licenses/src/solprop_gui/ui/assets/fonts/LICENSE.txt +93 -0
|
@@ -0,0 +1,854 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: 2026 John C. Travers and contributors
|
|
2
|
+
#
|
|
3
|
+
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
4
|
+
|
|
5
|
+
"""The first four problem classes (design 6.1), and how a recipe finds its class.
|
|
6
|
+
|
|
7
|
+
Every other route stays under Other geometry on the generic form. A test holds each
|
|
8
|
+
sheet's paths to its class's example recipe, each statistic to solprop's catalogue and
|
|
9
|
+
each derived number to the kernel's summary.
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
from collections.abc import Mapping, Sequence
|
|
13
|
+
from typing import Final
|
|
14
|
+
|
|
15
|
+
from solprop_gui.classes.problem import (
|
|
16
|
+
AnalysisPage,
|
|
17
|
+
Derived,
|
|
18
|
+
Field,
|
|
19
|
+
ProblemClass,
|
|
20
|
+
Section,
|
|
21
|
+
Target,
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
__all__ = [
|
|
25
|
+
"ANTIRESONANT",
|
|
26
|
+
"CAPILLARY",
|
|
27
|
+
"CARTESIAN",
|
|
28
|
+
"CARTESIAN_BEAM",
|
|
29
|
+
"CLASSES",
|
|
30
|
+
"FILAMENT",
|
|
31
|
+
"GENERIC_PAGES",
|
|
32
|
+
"GNLSE",
|
|
33
|
+
"GRIN",
|
|
34
|
+
"LINE",
|
|
35
|
+
"OTHER_KEY",
|
|
36
|
+
"STEP_INDEX",
|
|
37
|
+
"class_named",
|
|
38
|
+
"class_of",
|
|
39
|
+
"other_class",
|
|
40
|
+
]
|
|
41
|
+
|
|
42
|
+
_OVERVIEW = AnalysisPage("overview", "Overview", ("fields",))
|
|
43
|
+
_PLANE = AnalysisPage("plane", "At this plane", ("fields",))
|
|
44
|
+
_SPECTROGRAM = AnalysisPage("spectrogram", "Spectrogram", ("fields",))
|
|
45
|
+
_ALONG = AnalysisPage("along", "Along z", ("statistics",))
|
|
46
|
+
_MODES = AnalysisPage("modes", "Modes", ("fields", "modes"))
|
|
47
|
+
_COMPRESS = AnalysisPage("compress", "Compress", ("fields",), "compression")
|
|
48
|
+
_NOISE = AnalysisPage("noise", "Noise and coherence", ("fields", "ensemble"))
|
|
49
|
+
_HEALTH = AnalysisPage("health", "Run health")
|
|
50
|
+
|
|
51
|
+
_PULSE = Section(
|
|
52
|
+
"Pulse",
|
|
53
|
+
(
|
|
54
|
+
Field("wavelength", "Wavelength"),
|
|
55
|
+
Field("fwhm", "Duration"),
|
|
56
|
+
Field("energy"),
|
|
57
|
+
),
|
|
58
|
+
)
|
|
59
|
+
_GAS = Section("Gas", (Field("gas", choices="gases"), Field("pressure")))
|
|
60
|
+
_PHYSICS = Section(
|
|
61
|
+
"Physics",
|
|
62
|
+
(Field("kerr", "Kerr"), Field("plasma", "Plasma"), Field("raman", "Raman")),
|
|
63
|
+
)
|
|
64
|
+
_WINDOW = Section(
|
|
65
|
+
"Simulation window",
|
|
66
|
+
(
|
|
67
|
+
Field("wavelength_limits", "Wavelengths"),
|
|
68
|
+
Field("trange", "Time window"),
|
|
69
|
+
Field("n_save", "Saved planes"),
|
|
70
|
+
),
|
|
71
|
+
folded=True,
|
|
72
|
+
)
|
|
73
|
+
_GUIDE_NUMBERS = (
|
|
74
|
+
Derived(
|
|
75
|
+
"soliton_order",
|
|
76
|
+
"Soliton order",
|
|
77
|
+
prefixed=False,
|
|
78
|
+
target=Target("soliton_order", "order", None, ("energy", "peak_power")),
|
|
79
|
+
),
|
|
80
|
+
Derived(
|
|
81
|
+
"zdw",
|
|
82
|
+
"Zero-dispersion wavelength",
|
|
83
|
+
"m",
|
|
84
|
+
target=Target("zdw", "wavelength", "nm", ("pressure", "radius")),
|
|
85
|
+
),
|
|
86
|
+
Derived(
|
|
87
|
+
"rdw",
|
|
88
|
+
"Dispersive wave",
|
|
89
|
+
"m",
|
|
90
|
+
target=Target("rdw", "rdw", "nm", ("pressure", "radius")),
|
|
91
|
+
),
|
|
92
|
+
Derived("peak_power", "Peak power", "W"),
|
|
93
|
+
Derived("peak_intensity", "Peak intensity", "W/cm²", 1e-4, prefixed=False),
|
|
94
|
+
Derived("fission_length", "Fission length", "m"),
|
|
95
|
+
Derived("loss", "Loss at the pump", "dB/m", prefixed=False),
|
|
96
|
+
)
|
|
97
|
+
|
|
98
|
+
CAPILLARY: Final = ProblemClass(
|
|
99
|
+
key="capillary",
|
|
100
|
+
title="Capillary",
|
|
101
|
+
summary="A gas-filled hollow capillary, mode-averaged or with several modes.",
|
|
102
|
+
route="capillary",
|
|
103
|
+
example="rdw",
|
|
104
|
+
examples=(
|
|
105
|
+
"rdw",
|
|
106
|
+
"soliton_self_compression",
|
|
107
|
+
"ionisation_blue_shift",
|
|
108
|
+
"raman_self_frequency_shift",
|
|
109
|
+
"four_wave_mixing",
|
|
110
|
+
"supercontinuum_raman_comb",
|
|
111
|
+
"spm_compressor",
|
|
112
|
+
),
|
|
113
|
+
sections=(
|
|
114
|
+
Section(
|
|
115
|
+
"Capillary",
|
|
116
|
+
(Field("radius", "Core radius"), Field("length"), Field("modes")),
|
|
117
|
+
),
|
|
118
|
+
_GAS,
|
|
119
|
+
_PULSE,
|
|
120
|
+
_PHYSICS,
|
|
121
|
+
_WINDOW,
|
|
122
|
+
),
|
|
123
|
+
derived=_GUIDE_NUMBERS,
|
|
124
|
+
numbers="capillary_sheet",
|
|
125
|
+
curve="capillary_curve",
|
|
126
|
+
preview="Group-velocity dispersion at the entrance",
|
|
127
|
+
pages=(_OVERVIEW, _PLANE, _SPECTROGRAM, _ALONG, _MODES, _COMPRESS, _HEALTH),
|
|
128
|
+
statistics=("energy", "peak_intensity", "electron_density"),
|
|
129
|
+
)
|
|
130
|
+
|
|
131
|
+
ANTIRESONANT: Final = ProblemClass(
|
|
132
|
+
key="antiresonant",
|
|
133
|
+
title="Antiresonant fibre",
|
|
134
|
+
summary="A gas-filled hollow fibre with a tube lattice, and its wall loss.",
|
|
135
|
+
route="capillary",
|
|
136
|
+
example="antiresonant_fibre",
|
|
137
|
+
marker=("lattice",),
|
|
138
|
+
sections=(
|
|
139
|
+
Section(
|
|
140
|
+
"Fibre",
|
|
141
|
+
(
|
|
142
|
+
Field("radius", "Core radius"),
|
|
143
|
+
Field("length"),
|
|
144
|
+
Field("modes"),
|
|
145
|
+
Field("lattice.n_tubes", "Tubes"),
|
|
146
|
+
Field("lattice.tube_radius", "Tube radius"),
|
|
147
|
+
Field("lattice.wall_thickness", "Wall thickness"),
|
|
148
|
+
),
|
|
149
|
+
),
|
|
150
|
+
_GAS,
|
|
151
|
+
_PULSE,
|
|
152
|
+
_PHYSICS,
|
|
153
|
+
_WINDOW,
|
|
154
|
+
),
|
|
155
|
+
# A fibre has many zeros and resonances, so only the order is offered as a target.
|
|
156
|
+
derived=(
|
|
157
|
+
_GUIDE_NUMBERS[0],
|
|
158
|
+
Derived("zdw", "Zero-dispersion wavelength", "m"),
|
|
159
|
+
Derived("rdw", "Dispersive wave", "m"),
|
|
160
|
+
*_GUIDE_NUMBERS[3:],
|
|
161
|
+
),
|
|
162
|
+
numbers="capillary_sheet",
|
|
163
|
+
curve="capillary_curve",
|
|
164
|
+
preview="Group-velocity dispersion at the entrance",
|
|
165
|
+
pages=(_OVERVIEW, _PLANE, _SPECTROGRAM, _ALONG, _MODES, _COMPRESS, _HEALTH),
|
|
166
|
+
statistics=("energy", "peak_intensity"),
|
|
167
|
+
)
|
|
168
|
+
|
|
169
|
+
FILAMENT: Final = ProblemClass(
|
|
170
|
+
key="filament",
|
|
171
|
+
title="Radial filament",
|
|
172
|
+
summary="A beam in free space on a radial grid: self-focusing and plasma.",
|
|
173
|
+
route="radial",
|
|
174
|
+
example="filament",
|
|
175
|
+
sections=(
|
|
176
|
+
Section(
|
|
177
|
+
"Medium",
|
|
178
|
+
(
|
|
179
|
+
Field(
|
|
180
|
+
"medium.material",
|
|
181
|
+
"Gas",
|
|
182
|
+
choices="gases",
|
|
183
|
+
also=(
|
|
184
|
+
"responses[*].chi3.gas",
|
|
185
|
+
"responses[*].gas",
|
|
186
|
+
"responses[*].rate.source",
|
|
187
|
+
),
|
|
188
|
+
),
|
|
189
|
+
Field("medium.pressure", "Pressure"),
|
|
190
|
+
Field("grid.length", "Propagate", moves_planes="settings.save_planes"),
|
|
191
|
+
),
|
|
192
|
+
),
|
|
193
|
+
Section(
|
|
194
|
+
"Beam",
|
|
195
|
+
(
|
|
196
|
+
Field("initial.waist", "Waist"),
|
|
197
|
+
Field("initial.propz", "To focus", negated=True),
|
|
198
|
+
),
|
|
199
|
+
),
|
|
200
|
+
Section(
|
|
201
|
+
"Pulse",
|
|
202
|
+
(
|
|
203
|
+
Field(
|
|
204
|
+
"initial.temporal.wavelength",
|
|
205
|
+
"Wavelength",
|
|
206
|
+
also=(
|
|
207
|
+
"grid.reference_wavelength",
|
|
208
|
+
"responses[*].chi3.wavelength",
|
|
209
|
+
"responses[*].rate.wavelength",
|
|
210
|
+
),
|
|
211
|
+
),
|
|
212
|
+
Field("initial.temporal.fwhm", "Duration"),
|
|
213
|
+
Field("initial.temporal.energy", "Energy"),
|
|
214
|
+
),
|
|
215
|
+
),
|
|
216
|
+
Section(
|
|
217
|
+
"Physics",
|
|
218
|
+
(
|
|
219
|
+
Field("responses", "Kerr", member="KerrResponse"),
|
|
220
|
+
Field(
|
|
221
|
+
"responses",
|
|
222
|
+
"Plasma",
|
|
223
|
+
member="EnvelopePlasmaResponse",
|
|
224
|
+
goes_with=("settings.ionisation_field_range",),
|
|
225
|
+
),
|
|
226
|
+
),
|
|
227
|
+
),
|
|
228
|
+
Section(
|
|
229
|
+
"Resolution",
|
|
230
|
+
(
|
|
231
|
+
Field("space.radius", "Grid radius"),
|
|
232
|
+
Field("space.n_r", "Radial nodes"),
|
|
233
|
+
Field("grid.wavelength_limits", "Wavelengths"),
|
|
234
|
+
Field("grid.trange", "Time window"),
|
|
235
|
+
Field(
|
|
236
|
+
"settings.save_planes", "Saved planes", planes_over="grid.length"
|
|
237
|
+
),
|
|
238
|
+
),
|
|
239
|
+
folded=True,
|
|
240
|
+
),
|
|
241
|
+
),
|
|
242
|
+
derived=(
|
|
243
|
+
Derived("power_ratio", "P / P_cr", prefixed=False),
|
|
244
|
+
Derived("critical_power", "Critical power", "W"),
|
|
245
|
+
Derived("peak_power", "Peak power", "W"),
|
|
246
|
+
Derived("rayleigh_range", "Rayleigh range", "m"),
|
|
247
|
+
Derived("collapse_distance", "Collapse (Marburger)", "m"),
|
|
248
|
+
),
|
|
249
|
+
numbers="beam_sheet",
|
|
250
|
+
curve="beam_curve",
|
|
251
|
+
lens=("initial.waist", "initial.propz", "initial.temporal.wavelength"),
|
|
252
|
+
preview="Linear beam radius along z",
|
|
253
|
+
pages=(
|
|
254
|
+
AnalysisPage("overview", "Overview", ("fields",), view="beam_overview"),
|
|
255
|
+
AnalysisPage("plane", "At this plane", ("fields",), view="beam_plane"),
|
|
256
|
+
_ALONG,
|
|
257
|
+
AnalysisPage("axis", "On axis", ("fields",), view="on_axis"),
|
|
258
|
+
AnalysisPage("farfield", "Far field", ("fields",), view="far_field"),
|
|
259
|
+
_HEALTH,
|
|
260
|
+
),
|
|
261
|
+
statistics=(
|
|
262
|
+
"peak_intensity",
|
|
263
|
+
"electron_density",
|
|
264
|
+
"beam_radius",
|
|
265
|
+
"energy",
|
|
266
|
+
),
|
|
267
|
+
)
|
|
268
|
+
|
|
269
|
+
GNLSE: Final = ProblemClass(
|
|
270
|
+
key="gnlse",
|
|
271
|
+
title="GNLSE fibre",
|
|
272
|
+
summary="A fibre given by its γ and Taylor coefficients alone, in the GNLSE.", # noqa: RUF001 - gamma
|
|
273
|
+
route="gnlse",
|
|
274
|
+
example="soliton",
|
|
275
|
+
examples=("soliton", "fibre_supercontinuum"),
|
|
276
|
+
sections=(
|
|
277
|
+
Section(
|
|
278
|
+
"Fibre",
|
|
279
|
+
(
|
|
280
|
+
Field("gamma", "Nonlinear coefficient"),
|
|
281
|
+
Field("betas", "Dispersion"),
|
|
282
|
+
Field("length", also=("grid.length",)),
|
|
283
|
+
),
|
|
284
|
+
),
|
|
285
|
+
Section(
|
|
286
|
+
"Pulse",
|
|
287
|
+
(
|
|
288
|
+
Field("wavelength", "Wavelength", also=("grid.reference_wavelength",)),
|
|
289
|
+
Field("width", "Width"),
|
|
290
|
+
Field("peak_power"),
|
|
291
|
+
Field("shape"),
|
|
292
|
+
),
|
|
293
|
+
),
|
|
294
|
+
Section(
|
|
295
|
+
"Physics",
|
|
296
|
+
(Field("raman", "Raman (silica)"), Field("shock", "Self-steepening")),
|
|
297
|
+
),
|
|
298
|
+
Section(
|
|
299
|
+
"Simulation window",
|
|
300
|
+
(
|
|
301
|
+
Field("grid.wavelength_limits", "Wavelengths"),
|
|
302
|
+
Field("grid.trange", "Time window"),
|
|
303
|
+
Field("n_save", "Saved planes"),
|
|
304
|
+
),
|
|
305
|
+
folded=True,
|
|
306
|
+
),
|
|
307
|
+
),
|
|
308
|
+
derived=(
|
|
309
|
+
Derived("soliton_order", "Soliton order", prefixed=False),
|
|
310
|
+
Derived("zdw", "Zero-dispersion wavelength", "m"),
|
|
311
|
+
Derived("energy", "Energy", "J"),
|
|
312
|
+
Derived("dispersion_length", "Dispersion length", "m"),
|
|
313
|
+
Derived("nonlinear_length", "Nonlinear length", "m"),
|
|
314
|
+
Derived("fission_length", "Fission length", "m"),
|
|
315
|
+
),
|
|
316
|
+
numbers="fibre_sheet",
|
|
317
|
+
curve="fibre_curve",
|
|
318
|
+
preview="Group-velocity dispersion against wavelength",
|
|
319
|
+
pages=(_OVERVIEW, _PLANE, _SPECTROGRAM, _ALONG, _COMPRESS, _NOISE, _HEALTH),
|
|
320
|
+
statistics=("energy",),
|
|
321
|
+
)
|
|
322
|
+
|
|
323
|
+
STEP_INDEX: Final = ProblemClass(
|
|
324
|
+
key="step-index",
|
|
325
|
+
title="Step-index fibre",
|
|
326
|
+
summary="A solid core in a cladding of lower index, its mode solved for the GNLSE.",
|
|
327
|
+
route="gnlse",
|
|
328
|
+
example="step_index_fibre",
|
|
329
|
+
marker=("fibre.type=StepIndexMode",),
|
|
330
|
+
sections=(
|
|
331
|
+
Section(
|
|
332
|
+
"Fibre",
|
|
333
|
+
(
|
|
334
|
+
Field("fibre.radius", "Core radius"),
|
|
335
|
+
Field("fibre.core", "Core", blank="fused silica"),
|
|
336
|
+
Field("fibre.cladding", "Cladding", blank="air, index 1"),
|
|
337
|
+
Field("length"),
|
|
338
|
+
),
|
|
339
|
+
),
|
|
340
|
+
Section(
|
|
341
|
+
"Pulse",
|
|
342
|
+
(
|
|
343
|
+
Field("wavelength", "Wavelength", also=("fibre.profile_wavelength",)),
|
|
344
|
+
Field("fwhm", "Duration"),
|
|
345
|
+
Field("energy"),
|
|
346
|
+
Field("shape"),
|
|
347
|
+
),
|
|
348
|
+
),
|
|
349
|
+
Section(
|
|
350
|
+
"Physics",
|
|
351
|
+
(
|
|
352
|
+
Field("raman", "Raman (silica)"),
|
|
353
|
+
Field("shock", "Self-steepening"),
|
|
354
|
+
Field("n2", "Nonlinear index n₂"),
|
|
355
|
+
),
|
|
356
|
+
),
|
|
357
|
+
Section(
|
|
358
|
+
"Simulation window",
|
|
359
|
+
(
|
|
360
|
+
Field("wavelength_limits", "Wavelengths"),
|
|
361
|
+
Field("trange", "Time window"),
|
|
362
|
+
Field("n_save", "Saved planes"),
|
|
363
|
+
),
|
|
364
|
+
folded=True,
|
|
365
|
+
),
|
|
366
|
+
),
|
|
367
|
+
derived=(
|
|
368
|
+
Derived("soliton_order", "Soliton order", prefixed=False),
|
|
369
|
+
Derived("zdw", "Zero-dispersion wavelength", "m"),
|
|
370
|
+
Derived("peak_power", "Peak power", "W"),
|
|
371
|
+
Derived("gamma", "γ", "1/(W m)", prefixed=False), # noqa: RUF001 - gamma
|
|
372
|
+
Derived("dispersion_length", "Dispersion length", "m"),
|
|
373
|
+
Derived("fission_length", "Fission length", "m"),
|
|
374
|
+
),
|
|
375
|
+
numbers="fibre_sheet",
|
|
376
|
+
curve="fibre_curve",
|
|
377
|
+
preview="Group-velocity dispersion of its mode",
|
|
378
|
+
pages=(_OVERVIEW, _PLANE, _SPECTROGRAM, _ALONG, _COMPRESS, _HEALTH),
|
|
379
|
+
statistics=("energy",),
|
|
380
|
+
)
|
|
381
|
+
|
|
382
|
+
GRIN: Final = ProblemClass(
|
|
383
|
+
key="grin",
|
|
384
|
+
title="Graded-index fibre",
|
|
385
|
+
summary="A core whose index falls from its axis, several of its modes coupled.",
|
|
386
|
+
route="waveguide",
|
|
387
|
+
example="graded_index_fibre",
|
|
388
|
+
marker=("provider.provider.type=GradedIndexProvider",),
|
|
389
|
+
sections=(
|
|
390
|
+
Section(
|
|
391
|
+
"Fibre",
|
|
392
|
+
(
|
|
393
|
+
Field("provider.provider.radius", "Core radius"),
|
|
394
|
+
Field("provider.provider.permittivity.centre.index", "Index on axis"),
|
|
395
|
+
Field("provider.provider.permittivity.contrast", "Contrast Δ"),
|
|
396
|
+
Field("provider.provider.permittivity.exponent", "Profile exponent"),
|
|
397
|
+
Field("length", also=("grid.length",)),
|
|
398
|
+
),
|
|
399
|
+
),
|
|
400
|
+
Section(
|
|
401
|
+
"Pulse",
|
|
402
|
+
(
|
|
403
|
+
Field("wavelength", "Wavelength", also=("grid.reference_wavelength",)),
|
|
404
|
+
Field("fwhm", "Duration"),
|
|
405
|
+
Field("energy"),
|
|
406
|
+
Field("shape"),
|
|
407
|
+
),
|
|
408
|
+
),
|
|
409
|
+
Section(
|
|
410
|
+
"Simulation window",
|
|
411
|
+
(
|
|
412
|
+
Field("grid.wavelength_limits", "Wavelengths"),
|
|
413
|
+
Field("grid.trange", "Time window"),
|
|
414
|
+
Field("n_save", "Saved planes"),
|
|
415
|
+
),
|
|
416
|
+
folded=True,
|
|
417
|
+
),
|
|
418
|
+
),
|
|
419
|
+
derived=(
|
|
420
|
+
Derived("na", "Numerical aperture", prefixed=False),
|
|
421
|
+
Derived("v_number", "V number", prefixed=False),
|
|
422
|
+
Derived("mode_count", "Guided modes (about)", prefixed=False),
|
|
423
|
+
Derived("peak_power", "Peak power", "W"),
|
|
424
|
+
),
|
|
425
|
+
numbers="grin_sheet",
|
|
426
|
+
curve="grin_curve",
|
|
427
|
+
preview="Refractive index across the core",
|
|
428
|
+
pages=(_OVERVIEW, _PLANE, _SPECTROGRAM, _ALONG, _MODES, _HEALTH),
|
|
429
|
+
statistics=("energy",),
|
|
430
|
+
)
|
|
431
|
+
|
|
432
|
+
CARTESIAN: Final = ProblemClass(
|
|
433
|
+
key="cartesian",
|
|
434
|
+
title="Cartesian beams",
|
|
435
|
+
summary="Beams in free space on an x-y grid: two crossing at an angle.",
|
|
436
|
+
route="free",
|
|
437
|
+
example="crossing_beams",
|
|
438
|
+
marker=("space.type=FreeGrid", "initial.type=SpatialPulseSum"),
|
|
439
|
+
sections=(
|
|
440
|
+
Section(
|
|
441
|
+
"Medium",
|
|
442
|
+
(
|
|
443
|
+
Field(
|
|
444
|
+
"medium.material",
|
|
445
|
+
"Gas",
|
|
446
|
+
choices="gases",
|
|
447
|
+
also=("responses[*].chi3.gas",),
|
|
448
|
+
),
|
|
449
|
+
Field("medium.pressure", "Pressure"),
|
|
450
|
+
Field("grid.length", "Propagate", moves_planes="settings.save_planes"),
|
|
451
|
+
),
|
|
452
|
+
),
|
|
453
|
+
Section(
|
|
454
|
+
"Beam 1",
|
|
455
|
+
(
|
|
456
|
+
Field("initial.beams[0].temporal.energy", "Energy"),
|
|
457
|
+
Field("initial.beams[0].waist", "Waist"),
|
|
458
|
+
Field("initial.beams[0].displacement[0]", "Offset in x"),
|
|
459
|
+
Field("initial.beams[0].tilt[0]", "Angle in x"),
|
|
460
|
+
),
|
|
461
|
+
),
|
|
462
|
+
Section(
|
|
463
|
+
"Beam 2",
|
|
464
|
+
(
|
|
465
|
+
Field("initial.beams[1].temporal.energy", "Energy"),
|
|
466
|
+
Field("initial.beams[1].waist", "Waist"),
|
|
467
|
+
Field("initial.beams[1].displacement[0]", "Offset in x"),
|
|
468
|
+
Field("initial.beams[1].tilt[0]", "Angle in x"),
|
|
469
|
+
),
|
|
470
|
+
),
|
|
471
|
+
Section(
|
|
472
|
+
"Pulse",
|
|
473
|
+
(
|
|
474
|
+
Field(
|
|
475
|
+
"initial.beams[0].temporal.wavelength",
|
|
476
|
+
"Wavelength",
|
|
477
|
+
also=(
|
|
478
|
+
"initial.beams[1].temporal.wavelength",
|
|
479
|
+
"grid.reference_wavelength",
|
|
480
|
+
"responses[*].chi3.wavelength",
|
|
481
|
+
),
|
|
482
|
+
),
|
|
483
|
+
Field(
|
|
484
|
+
"initial.beams[0].temporal.fwhm",
|
|
485
|
+
"Duration",
|
|
486
|
+
also=("initial.beams[1].temporal.fwhm",),
|
|
487
|
+
),
|
|
488
|
+
),
|
|
489
|
+
),
|
|
490
|
+
Section(
|
|
491
|
+
"Physics",
|
|
492
|
+
(Field("responses", "Kerr", member="KerrResponse"),),
|
|
493
|
+
),
|
|
494
|
+
Section(
|
|
495
|
+
"Grid",
|
|
496
|
+
(
|
|
497
|
+
Field("space.radius_x", "Half-width in x"),
|
|
498
|
+
Field("space.n_x", "Nodes in x"),
|
|
499
|
+
Field("space.radius_y", "Half-width in y"),
|
|
500
|
+
Field("space.n_y", "Nodes in y"),
|
|
501
|
+
Field("grid.wavelength_limits", "Wavelengths"),
|
|
502
|
+
Field("grid.trange", "Time window"),
|
|
503
|
+
Field(
|
|
504
|
+
"settings.save_planes", "Saved planes", planes_over="grid.length"
|
|
505
|
+
),
|
|
506
|
+
),
|
|
507
|
+
folded=True,
|
|
508
|
+
),
|
|
509
|
+
),
|
|
510
|
+
derived=(
|
|
511
|
+
Derived("power_ratio", "P / P_cr, each beam", prefixed=False),
|
|
512
|
+
Derived("critical_power", "Critical power", "W"),
|
|
513
|
+
Derived("peak_power", "Peak power, each beam", "W"),
|
|
514
|
+
Derived("rayleigh_range", "Rayleigh range", "m"),
|
|
515
|
+
),
|
|
516
|
+
numbers="beam_sheet",
|
|
517
|
+
curve="beam_curve",
|
|
518
|
+
preview="Linear radius of each beam along z",
|
|
519
|
+
pages=(
|
|
520
|
+
_OVERVIEW,
|
|
521
|
+
AnalysisPage("across", "Across the beam", ("fields",), view="fluence_xy"),
|
|
522
|
+
_PLANE,
|
|
523
|
+
_ALONG,
|
|
524
|
+
_HEALTH,
|
|
525
|
+
),
|
|
526
|
+
statistics=("energy",),
|
|
527
|
+
examples=("crossing_beams",),
|
|
528
|
+
)
|
|
529
|
+
|
|
530
|
+
CARTESIAN_BEAM: Final = ProblemClass(
|
|
531
|
+
key="cartesian-beam",
|
|
532
|
+
title="Cartesian beam",
|
|
533
|
+
summary="One beam in free space on an x-y grid.",
|
|
534
|
+
route="free",
|
|
535
|
+
example="cartesian_beam",
|
|
536
|
+
marker=("space.type=FreeGrid",),
|
|
537
|
+
sections=(
|
|
538
|
+
Section(
|
|
539
|
+
"Medium",
|
|
540
|
+
(
|
|
541
|
+
Field(
|
|
542
|
+
"medium.material",
|
|
543
|
+
"Gas",
|
|
544
|
+
choices="gases",
|
|
545
|
+
also=("responses[*].chi3.gas",),
|
|
546
|
+
),
|
|
547
|
+
Field("medium.pressure", "Pressure"),
|
|
548
|
+
Field("grid.length", "Propagate", moves_planes="settings.save_planes"),
|
|
549
|
+
),
|
|
550
|
+
),
|
|
551
|
+
Section(
|
|
552
|
+
"Beam",
|
|
553
|
+
(
|
|
554
|
+
Field("initial.waist", "Waist"),
|
|
555
|
+
Field("initial.propz", "To focus", negated=True),
|
|
556
|
+
),
|
|
557
|
+
),
|
|
558
|
+
Section(
|
|
559
|
+
"Pulse",
|
|
560
|
+
(
|
|
561
|
+
Field(
|
|
562
|
+
"initial.temporal.wavelength",
|
|
563
|
+
"Wavelength",
|
|
564
|
+
also=("grid.reference_wavelength", "responses[*].chi3.wavelength"),
|
|
565
|
+
),
|
|
566
|
+
Field("initial.temporal.fwhm", "Duration"),
|
|
567
|
+
Field("initial.temporal.energy", "Energy"),
|
|
568
|
+
),
|
|
569
|
+
),
|
|
570
|
+
Section(
|
|
571
|
+
"Physics",
|
|
572
|
+
(Field("responses", "Kerr", member="KerrResponse"),),
|
|
573
|
+
),
|
|
574
|
+
Section(
|
|
575
|
+
"Grid",
|
|
576
|
+
(
|
|
577
|
+
Field("space.radius_x", "Half-width in x"),
|
|
578
|
+
Field("space.n_x", "Nodes in x"),
|
|
579
|
+
Field("space.radius_y", "Half-width in y"),
|
|
580
|
+
Field("space.n_y", "Nodes in y"),
|
|
581
|
+
Field("grid.wavelength_limits", "Wavelengths"),
|
|
582
|
+
Field("grid.trange", "Time window"),
|
|
583
|
+
Field(
|
|
584
|
+
"settings.save_planes", "Saved planes", planes_over="grid.length"
|
|
585
|
+
),
|
|
586
|
+
),
|
|
587
|
+
folded=True,
|
|
588
|
+
),
|
|
589
|
+
),
|
|
590
|
+
derived=(
|
|
591
|
+
Derived("power_ratio", "P / P_cr", prefixed=False),
|
|
592
|
+
Derived("critical_power", "Critical power", "W"),
|
|
593
|
+
Derived("peak_power", "Peak power", "W"),
|
|
594
|
+
Derived("rayleigh_range", "Rayleigh range", "m"),
|
|
595
|
+
Derived("collapse_distance", "Collapse (Marburger)", "m"),
|
|
596
|
+
),
|
|
597
|
+
numbers="beam_sheet",
|
|
598
|
+
curve="beam_curve",
|
|
599
|
+
lens=("initial.waist", "initial.propz", "initial.temporal.wavelength"),
|
|
600
|
+
preview="Linear beam radius along z",
|
|
601
|
+
pages=(
|
|
602
|
+
_OVERVIEW,
|
|
603
|
+
AnalysisPage("across", "Across the beam", ("fields",), view="fluence_xy"),
|
|
604
|
+
_PLANE,
|
|
605
|
+
_ALONG,
|
|
606
|
+
_HEALTH,
|
|
607
|
+
),
|
|
608
|
+
statistics=("energy",),
|
|
609
|
+
home=False,
|
|
610
|
+
)
|
|
611
|
+
|
|
612
|
+
LINE: Final = ProblemClass(
|
|
613
|
+
key="line",
|
|
614
|
+
title="Line beam",
|
|
615
|
+
summary="A beam in free space resolved in x alone, per metre of y.",
|
|
616
|
+
route="free",
|
|
617
|
+
example="line_beam",
|
|
618
|
+
marker=("space.type=LineGrid",),
|
|
619
|
+
sections=(
|
|
620
|
+
CARTESIAN_BEAM.sections[0],
|
|
621
|
+
Section(
|
|
622
|
+
"Beam",
|
|
623
|
+
(
|
|
624
|
+
Field("initial.waist", "Waist"),
|
|
625
|
+
Field("initial.propz", "To focus", negated=True),
|
|
626
|
+
),
|
|
627
|
+
),
|
|
628
|
+
CARTESIAN_BEAM.sections[2],
|
|
629
|
+
CARTESIAN_BEAM.sections[3],
|
|
630
|
+
Section(
|
|
631
|
+
"Grid",
|
|
632
|
+
(
|
|
633
|
+
Field("space.radius_x", "Half-width in x"),
|
|
634
|
+
Field("space.n_x", "Nodes in x"),
|
|
635
|
+
Field("grid.wavelength_limits", "Wavelengths"),
|
|
636
|
+
Field("grid.trange", "Time window"),
|
|
637
|
+
Field(
|
|
638
|
+
"settings.save_planes", "Saved planes", planes_over="grid.length"
|
|
639
|
+
),
|
|
640
|
+
),
|
|
641
|
+
folded=True,
|
|
642
|
+
),
|
|
643
|
+
),
|
|
644
|
+
derived=(
|
|
645
|
+
Derived("energy", "Energy per metre of y", "J/m"),
|
|
646
|
+
Derived("peak_power", "Peak power per metre of y", "W/m"),
|
|
647
|
+
),
|
|
648
|
+
preview="",
|
|
649
|
+
pages=(
|
|
650
|
+
_OVERVIEW,
|
|
651
|
+
AnalysisPage("across", "Across the beam", ("fields",), view="fluence_xz"),
|
|
652
|
+
_PLANE,
|
|
653
|
+
_ALONG,
|
|
654
|
+
_HEALTH,
|
|
655
|
+
),
|
|
656
|
+
statistics=("energy", "beam_radius"),
|
|
657
|
+
)
|
|
658
|
+
|
|
659
|
+
CLASSES: Final = (
|
|
660
|
+
CAPILLARY,
|
|
661
|
+
ANTIRESONANT,
|
|
662
|
+
FILAMENT,
|
|
663
|
+
CARTESIAN,
|
|
664
|
+
CARTESIAN_BEAM,
|
|
665
|
+
GNLSE,
|
|
666
|
+
STEP_INDEX,
|
|
667
|
+
GRIN,
|
|
668
|
+
LINE,
|
|
669
|
+
)
|
|
670
|
+
"""The classes, in Home's order; those off Home (``home`` false) still open their
|
|
671
|
+
recipes. Of two that fit a recipe, the first wins: the two beams before the one."""
|
|
672
|
+
|
|
673
|
+
GENERIC_PAGES: Final = (_OVERVIEW, _PLANE, _ALONG, _HEALTH)
|
|
674
|
+
"""The rail of a file whose route is no class's."""
|
|
675
|
+
|
|
676
|
+
OTHER_KEY: Final = "other"
|
|
677
|
+
"""The key of Other geometry's class, made for each route it holds."""
|
|
678
|
+
|
|
679
|
+
_OTHER_SECTIONS: Final = (
|
|
680
|
+
("Geometry", ("geometry",), False),
|
|
681
|
+
("Medium", ("medium",), False),
|
|
682
|
+
("Nonlinearity", ("nonlinear",), False),
|
|
683
|
+
("Input", ("input",), False),
|
|
684
|
+
("Grid", ("grid",), True),
|
|
685
|
+
("Output", ("output",), True),
|
|
686
|
+
)
|
|
687
|
+
"""The generic form's sections: title, metadata groups and whether folded."""
|
|
688
|
+
|
|
689
|
+
|
|
690
|
+
def other_class(
|
|
691
|
+
route: str,
|
|
692
|
+
title: str,
|
|
693
|
+
build: Mapping[str, object],
|
|
694
|
+
parameters: Sequence[Mapping[str, object]] = (),
|
|
695
|
+
) -> ProblemClass:
|
|
696
|
+
"""Return a route's class under Other geometry, its form from solprop's metadata.
|
|
697
|
+
|
|
698
|
+
A section holds the keywords of its groups that the recipe sets; the rest are under
|
|
699
|
+
Advanced, as on every sheet. With no metadata yet the form is empty.
|
|
700
|
+
|
|
701
|
+
Parameters
|
|
702
|
+
----------
|
|
703
|
+
route : str
|
|
704
|
+
The route.
|
|
705
|
+
title : str
|
|
706
|
+
What to call it: the recipe's title, or the route's.
|
|
707
|
+
build : Mapping
|
|
708
|
+
The recipe's ``[build]`` table.
|
|
709
|
+
parameters : Sequence of Mapping, optional
|
|
710
|
+
The route's keywords, as the kernel describes them, each with its ``group``.
|
|
711
|
+
|
|
712
|
+
Returns
|
|
713
|
+
-------
|
|
714
|
+
ProblemClass
|
|
715
|
+
The class, with the generic pages and solprop's summary for its numbers.
|
|
716
|
+
|
|
717
|
+
Examples
|
|
718
|
+
--------
|
|
719
|
+
>>> keywords = [{"name": "width", "group": "geometry"},
|
|
720
|
+
... {"name": "rtol", "group": "numerics"},
|
|
721
|
+
... {"name": "length", "group": "geometry"}]
|
|
722
|
+
>>> made = other_class("free", "A beam", {"width": 1, "rtol": 1e-6}, keywords)
|
|
723
|
+
>>> [(s.title, [f.path for f in s.fields]) for s in made.sections]
|
|
724
|
+
[('Geometry', ['width'])]
|
|
725
|
+
>>> made.key, made.title
|
|
726
|
+
('other', 'A beam')
|
|
727
|
+
>>> [page.key for page in other_class("planar", "P", {}).pages]
|
|
728
|
+
['plane', 'along', 'health']
|
|
729
|
+
"""
|
|
730
|
+
sections = []
|
|
731
|
+
for name, groups, folded in _OTHER_SECTIONS:
|
|
732
|
+
fields = tuple(
|
|
733
|
+
Field(str(entry["name"]))
|
|
734
|
+
for entry in parameters
|
|
735
|
+
if entry.get("group") in groups and entry.get("name") in build
|
|
736
|
+
)
|
|
737
|
+
if fields:
|
|
738
|
+
sections.append(Section(name, fields, folded=folded))
|
|
739
|
+
return ProblemClass(
|
|
740
|
+
key=OTHER_KEY,
|
|
741
|
+
title=title,
|
|
742
|
+
summary="Every other route, on the form solprop's metadata gives.",
|
|
743
|
+
route=route,
|
|
744
|
+
example="",
|
|
745
|
+
sections=tuple(sections),
|
|
746
|
+
derived=(
|
|
747
|
+
Derived("energy", "Energy", "J"),
|
|
748
|
+
Derived("peak_power", "Peak power", "W"),
|
|
749
|
+
),
|
|
750
|
+
preview="",
|
|
751
|
+
# A hybrid planar run's planes are slab amplitudes, which no map reads yet.
|
|
752
|
+
pages=GENERIC_PAGES[1:] if route == "planar" else GENERIC_PAGES,
|
|
753
|
+
)
|
|
754
|
+
|
|
755
|
+
|
|
756
|
+
def class_named(key: str) -> ProblemClass:
|
|
757
|
+
"""Return a class by its key.
|
|
758
|
+
|
|
759
|
+
Parameters
|
|
760
|
+
----------
|
|
761
|
+
key : str
|
|
762
|
+
The key.
|
|
763
|
+
|
|
764
|
+
Returns
|
|
765
|
+
-------
|
|
766
|
+
ProblemClass
|
|
767
|
+
The class.
|
|
768
|
+
|
|
769
|
+
Raises
|
|
770
|
+
------
|
|
771
|
+
KeyError
|
|
772
|
+
If no class has that key.
|
|
773
|
+
|
|
774
|
+
Examples
|
|
775
|
+
--------
|
|
776
|
+
>>> class_named("filament").route
|
|
777
|
+
'radial'
|
|
778
|
+
"""
|
|
779
|
+
for problem in CLASSES:
|
|
780
|
+
if problem.key == key:
|
|
781
|
+
return problem
|
|
782
|
+
raise KeyError(key)
|
|
783
|
+
|
|
784
|
+
|
|
785
|
+
def _has(build: Mapping[str, object], mark: str) -> bool:
|
|
786
|
+
"""Return whether a recipe's ``[build]`` table carries a class's mark.
|
|
787
|
+
|
|
788
|
+
Parameters
|
|
789
|
+
----------
|
|
790
|
+
build : Mapping
|
|
791
|
+
The table.
|
|
792
|
+
mark : str
|
|
793
|
+
A keyword it sets, or ``"keyword.type=Name"``: an object of that type.
|
|
794
|
+
|
|
795
|
+
Returns
|
|
796
|
+
-------
|
|
797
|
+
bool
|
|
798
|
+
Whether it does.
|
|
799
|
+
|
|
800
|
+
Examples
|
|
801
|
+
--------
|
|
802
|
+
>>> _has({"lattice": {}}, "lattice"), _has({}, "lattice")
|
|
803
|
+
(True, False)
|
|
804
|
+
>>> space = {"space": {"type": "FreeGrid"}}
|
|
805
|
+
>>> _has(space, "space.type=FreeGrid"), _has(space, "space.type=LineGrid")
|
|
806
|
+
(True, False)
|
|
807
|
+
>>> _has({"space": "x"}, "space.type=FreeGrid")
|
|
808
|
+
False
|
|
809
|
+
>>> deep = {"provider": {"provider": {"type": "GradedIndexProvider"}}}
|
|
810
|
+
>>> _has(deep, "provider.provider.type=GradedIndexProvider")
|
|
811
|
+
True
|
|
812
|
+
"""
|
|
813
|
+
path, _, wanted = mark.partition("=")
|
|
814
|
+
if not wanted:
|
|
815
|
+
return path in build
|
|
816
|
+
*steps, field = path.split(".")
|
|
817
|
+
held: object = build
|
|
818
|
+
for step in steps:
|
|
819
|
+
held = held.get(step) if isinstance(held, Mapping) else None
|
|
820
|
+
return isinstance(held, Mapping) and held.get(field) == wanted
|
|
821
|
+
|
|
822
|
+
|
|
823
|
+
def class_of(route: str, build: Mapping[str, object]) -> ProblemClass | None:
|
|
824
|
+
"""Return the class a recipe belongs to.
|
|
825
|
+
|
|
826
|
+
A class with a marker wins over one of the same route without, so a capillary with
|
|
827
|
+
a lattice is an antiresonant fibre.
|
|
828
|
+
|
|
829
|
+
Parameters
|
|
830
|
+
----------
|
|
831
|
+
route : str
|
|
832
|
+
The recipe's route.
|
|
833
|
+
build : Mapping
|
|
834
|
+
Its ``[build]`` table.
|
|
835
|
+
|
|
836
|
+
Returns
|
|
837
|
+
-------
|
|
838
|
+
ProblemClass or None
|
|
839
|
+
The class, or ``None`` for a route under Other geometry.
|
|
840
|
+
|
|
841
|
+
Examples
|
|
842
|
+
--------
|
|
843
|
+
>>> class_of("capillary", {"radius": "125 um"}).key
|
|
844
|
+
'capillary'
|
|
845
|
+
>>> class_of("capillary", {"lattice": {"type": "TubeLattice"}}).key
|
|
846
|
+
'antiresonant'
|
|
847
|
+
>>> class_of("free", {}) is None
|
|
848
|
+
True
|
|
849
|
+
"""
|
|
850
|
+
fits = [problem for problem in CLASSES if problem.route == route]
|
|
851
|
+
marked = [p for p in fits if p.marker and all(_has(build, k) for k in p.marker)]
|
|
852
|
+
if marked:
|
|
853
|
+
return marked[0]
|
|
854
|
+
return next((problem for problem in fits if not problem.marker), None)
|