thunder4d.inputfile
Standard THUNDER4D input file (JSON): one file describes one simulation completely (laser, gas, cell, mirrors, grid, solver, run), so that a design exported by the design helper, a GUI session or a script can be re-run from the file alone.
import thunder4d as th
cfg = th.load_input("cell.json") # defaults filled in, checked
b = th.run_input(cfg) # build + run; b.sim holds the results
th.save_input(cfg, "copy.json")
Units are in the key names (_J, _fs, _nm, _m, _bar, _K). Tables (measured
spectrum, mirror reflectivity and GDD curves) are stored inline as
{"wavelength_nm": [...], "value": [...]}. Unknown keys are rejected (a typo would otherwise be
ignored silently), except in the free-form design and notes blocks. Every missing required
field is listed in one error message.
Block |
Keys (required in bold) |
|---|---|
|
energy_J, duration_fs (transform-limited FWHM), wavelength_nm, shape
( |
|
injection ( |
|
gas, pressure_bar, temperature_K, n2_1bar (None: thunder4d.materials) |
|
roc_m, separation_m, n_passes, herriott (information: round_trips, k, branch) |
|
reflectivity and gdd_fs2 (scalar or table, per bounce), tod_fs3, diameter_m, coating (information) |
|
preset ( |
|
phi_max, gouy_step, self_steepening, kernels ( |
|
record_every, near_field, record_mirror |
|
free form: provenance written by the design helper (predictions, margins) |
- thunder4d.inputfile.default_input(**blocks)[source]
A complete input with the defaults; keyword blocks are merged in, e.g.
default_input(laser={"energy_J": 1e-3, "duration_fs": 200}, medium={"gas": "Ar", ...}).
- thunder4d.inputfile.load_input(path_or_dict)[source]
Read a file (or take a dict), fill in the defaults and check it (
ValueErrorlisting every problem,KeyErrorfor an unknown key).
- thunder4d.inputfile.save_input(cfg, path)[source]
Write an input, defaults filled in, as indented JSON.
- thunder4d.inputfile.build_simulation(cfg, verbose=False)[source]
Input -> object with
cell,grid,pulseandsim(aLensFrameSimulationready to run), plusw0_injected_m.
- thunder4d.inputfile.run_input(cfg, verbose=True, max_seconds=None)[source]
build_simulation()thensim.run(); returns the built object.
- thunder4d.inputfile.input_problems(cfg)[source]
Every problem of a merged input, as a list of
(path, message), wherepathis the key at fault ("cell.separation_m"); empty when the input is valid.load_input()raises with these messages.
- thunder4d.inputfile.describe_input(cfg)[source]
Quick checks of an input before launching it, in milliseconds (neither the pulse nor the solver is built): linear eigenmode (
w0_m,w_mirror_m,zR_m,gouy_per_pass_rad), grid size (grid_shape,field_MB), Gaussian estimates of the peak power, ofp_over_pcrand of the peak fluence on the mirrors (mirror_fluence_J_cm2).
- thunder4d.inputfile.FIELDS
How each key is shown and edited (label, displayed unit, kind of editor, help, conditions), as
{"block.key": Field}. The GUI builder is generated from it, and a test checks that every key of the input file has an entry: a new key gets itsFieldin the same change.