Control law plug-ins: specification¶
Status: draft for comment. Interface version 0.1. Both Random worlds, single-output (section 6) and MIMO (section 7), classical shock (section 8), SRS shock (section 9) and single-output Sine (section 10) are implemented: the host loads them and the built-in laws run through them. While the interface is 0.x it may still change (R15). Comments are wanted on every part, and on the questions still open (section 14).
1. Purpose¶
Hertzforge lets the math that closes a vibration control loop be changed without rebuilding the program. Each test type ships a default control law and may ship others; an operator chooses one per test, and can import a law of their own as a single file. This document states what a law file must be, what the controller guarantees around it, and the interface for each test type.
Single-output Random was the pilot. MIMO Random is the second test type with a law interface, and its world is frozen in this version (section 7).
2. Terms¶
| Term | Meaning |
|---|---|
| Law | The code that, once per control loop, turns the latest measurements into the next drive request. |
| Core | Everything else in the controller: acquisition, spectral estimation, system identification, drive synthesis, the level schedule, protection and records. |
| Law file | A WebAssembly component (.wasm) that implements one law for one test type. |
| Line | One frequency line of the control grid, spacing df. |
| Band | The half-open range of lines [lo, hi) the test controls. |
| SDM | Spectral density matrix: one-sided, per line, Hermitian. Its diagonal holds the power spectral densities, its off-diagonal terms the cross spectral densities. |
3. Who does what¶
A law only computes the next drive request. The core keeps every protection, and applies it to every law, built-in or imported.
| The law | The core |
|---|---|
| Computes the next drive spectrum (single output) or drive SDM (MIMO) from the inputs it is given | Acquires data, windows, averages, and estimates spectra and FRFs |
| Keeps its own state between loops | Runs system identification before control starts |
| Declares its parameters and diagnostics | Synthesizes the drive time history from the law's request (random phase, overlap-add) |
| Reports diagnostics each loop | Runs the level schedule, soft start and ramps |
| Enforces the drive ceiling and drive abort, the per-loop change cap, limit notching, the envelope alarm and abort, divergence, kinematic and overload checks | |
| Checks every output, and enforces the time and memory budget | |
| Records which law ran, with what parameters, in every run |
The core may reduce a law's request to satisfy a protection. It never makes a request more aggressive than the law asked for. A law's own diagnostics can add a trip (for example, a law that reports divergent lines), but never suppress one.
4. Requirements for a law file¶
| # | Requirement |
|---|---|
| R1 | Format. A law file is a WebAssembly component that implements exactly one world of the package hertzforge:control-law at a version the controller supports. The WIT files under wit/control-law/ are the authoritative interface. |
| R2 | One file for every platform. The same file runs on every operating system Hertzforge supports. |
| R3 | Manifest. The law describes itself: name, version (semantic versioning), author, a one-paragraph summary, its declared parameters and diagnostics, and for MIMO the channel shapes it supports, the optional inputs it needs and the layout of each diagnostic (section 7). |
| R4 | No system access. The controller grants a law no files, no network, no environment and no arguments. Its clock and random source are fixed, so a law must not depend on them. Anything it prints is discarded. |
| R5 | Deterministic. The same inputs and parameter values give the same outputs. This is what makes a recorded run replayable. |
| R6 | Budgets. A law gets a memory cap (256 MiB by default) and a time budget per call (by default a quarter of one loop's acquisition time). Exceeding either is a failed call. |
| R7 | Errors. A law that cannot compute a sound drive returns an error with a message instead of a value. A trap (for example a panic) is a failed call. |
| R8 | Valid outputs. Outputs have the stated dimensions and are finite. A single-output drive spectrum is non-negative; a MIMO drive SDM is Hermitian and positive semidefinite (the core repairs a small negative eigenvalue and refuses a large one, section 7). Lines outside the band are zero. An invalid output is a failed call. |
| R9 | Failure handling (core). On a failed call the core holds the previous drive. Three failed calls in a row (configurable) end the run with a controlled stop, recorded with the reason. |
| R10 | State. A law keeps its state in the resource the core constructs for each run. Nothing carries over between runs. |
| R11 | Parameters. Only the declared kinds in section 5. The core validates every value against the declaration before the law is constructed. There are no free-form strings for a law to parse. |
| R12 | Identity and records. A law file is identified by the SHA-256 of its bytes. Every run records the law's name, version, hash and parameter values, the law file itself, and each loop's law inputs and outputs. |
| R13 | Check before hardware. law check runs a law against a fixed set of simulated test articles (one mode, two close modes, a deep anti-resonance with low coherence, measurement noise, a level ladder) and records a pass against the file's hash. The simulator accepts any law; hardware arms only with a law that has passed. A multiple-output law is checked on its own set: the well-conditioned 4 x 4 and 12 x 6 modal plants, an ill-conditioned 12 x 6, a rigid plate, a plant with measurement noise and a level ladder from -20 dB, each a whole run under the core's guards (laws.check; the guide's "Checking a MIMO law before hardware"). A classical shock law is checked on seven simulated test articles, each a whole run under the core's guards (section 8; the guide's "Checking a classical shock law before hardware"), an SRS shock law on six (section 9; the guide's "Checking an SRS shock law before hardware"), and a Sine law on seven (section 10; the guide's "Checking a Sine law before hardware"). |
| R14 | Licensing. A law file is a separate work loaded at run time; its author chooses its license. Laws shipped with Hertzforge are MIT. |
| R15 | Versioning. While the interface is 0.x it may change. From 1.0, minor versions only add, and the controller loads the current and the previous major version. |
5. Common types¶
Parameters¶
A law declares each parameter with a key, a label, help text, and one of these kinds. The UI draws the input from the declaration; a law ships no UI code.
| Kind | Declares | Example |
|---|---|---|
| Number | Unit, minimum, maximum, step, default | Correction gain, 0 to 1 |
| Integer | Minimum, maximum, step, default | Singular values kept per line |
| Toggle | Default | Use the trust gate |
| Choice | The options; the first is the default | Regularization method |
| Curve | A value against frequency, as a breakpoint table, with unit and default | Gain against frequency |
| Per channel | One number per control channel, with unit, range and default | Control channel weights |
Diagnostics¶
A law may declare named diagnostics, each with a unit. A single-output law reports numbers; a MIMO law declares the layout of each one: a scalar per loop, a value per line, per control per line or per drive per line. They are shown to the operator and can be plotted like any other quantity. They are recorded with the run.
Calls¶
Every world has the same life cycle:
describe(): return the manifest. Called when the file is imported.- Construct the law's state with the test setup and the parameter values. Called once per run.
seed(inputs): called once after system identification; returns the first drive request.iterate(inputs): called once per control loop with a fresh estimate; returns the next drive request.- Single output only:
retarget-level(level-db, target-rms), called when the level schedule moves to a new level; returns the drive request at the new level, checked like any other.level-dbis the new level relative to the full reference,target-rmsthe reference's in-band RMS at that level. A failed call keeps the drive in force, which the core carries to the new level itself. A MIMO law works at full level and has no such call (section 7).
6. Single-output Random (random-single)¶
One drive, one or more control channels. The core combines the control channels into one composite spectrum by the operator's rule (weighted average, minimum or maximum per line) before the law sees it.
Inputs, per call. All arrays have one value per line of the full grid.
| Input | Meaning | Unit |
|---|---|---|
| Target PSD | The reference at full level (0 dB) | EU²/Hz |
| Measured PSD | The composite control spectrum from the latest estimate | EU²/Hz |
| Plant gain | |H|², drive to composite control response | (EU/V)² |
| Coherence | Ordinary coherence, drive to composite control | 0 to 1 |
| Current level | The scheduled level | dB re full |
| Line spacing | df |
Hz |
| Band | [lo, hi) |
lines |
| Notched lines | Lines the core's limiting held down last loop; a law must not try to raise them | flags |
| Degrees of freedom | Of the measured estimate | count |
| Loop index | Loops since control started | count |
Outputs. The drive PSD (V²/Hz per line, before the core's limiting), the level the law is commanding (dB re full), and its diagnostics.
The single-output law supplies magnitude only. The drive synthesizer draws a random phase per line.
7. MIMO Random (random-mimo)¶
n_c control channels, n_d drives, N lines in the full grid. The world is in
wit/control-law/random-mimo.wit, which states these
conventions in its comments too.
Conventions.
- Spectral matrix. An SDM is
G = lim (1/T) E[X X^H]per line, withXthe spectrum under the negative-exponent forward transform,X[k] = sum_n x[n] exp(-j 2 pi k n / N). The off-diagonal entry(i, j)isE[X_i conj(X_j)], its angle the phase of channeliminus the phase of channelj, and a responseY = H XhasG_yy = H G_xx H^H, withHresponse over drive andH^Hits conjugate transpose; the response-to-drive cross spectrum has entriesE[Y_c conj(V_d)], soH = S_yv inv(S_vv). Rattlesnake and SDynPy hold this form, so a law ported from either needs no conjugation. It is the complex conjugate of the Bendat and Piersol definition (G_xy = E[X* Y]) that Hertzforge's analysis files and much other software hold, under which the same relation readsS_yy = conj(H) S_vv transpose(H); mixing the two silently conjugates every cross-spectral phase. The core forms the boundary's form directly: its estimator conjugates the workspace FFT's positive-exponent spectra (SdmEstimatorinhertzforge-mimo-random, pinned by a known-delay test), and every reference import converts where its source holds the other form (docs/reference-file.md). A law never converts. - One-sided. The integral of a PSD over frequency is the signal's variance.
- Whole grid. One call covers every line, in line order, so a law may work across lines (for example, smoothing its correction in frequency). Lines outside the band carry no drive.
- Complex values are a record of two f64,
reandim. - Rectangular stacks (the FRF, the response-to-drive cross spectrum) are passed in full,
row-major within a line, lines in order: element
(r, c)of linelisdata[(l * rows + r) * cols + c]. The FRF is response over drive,n_cbyn_d. - Hermitian stacks (every SDM) are passed packed: the upper triangle of each line, row-major,
lines in order. For
r <= c, element(r, c)of linelisdata[l * n * (n + 1) / 2 + r * (2 * n - r + 1) / 2 + (c - r)]; an element below the diagonal is the conjugate of its mirror, and a diagonal value is real (its imaginary part is zero). This halves the largest copies. - Units. A control SDM in EU²/Hz, a drive SDM in V²/Hz, the FRF in EU/V.
- Full level. Everything a law sees and returns is at full level (0 dB). The reference is the
full-level specification, the measured response has been referred to its full-level equivalent
by the core, and the drive the law returns is the full-level drive. The core applies the level
schedule. A law never sees the level, cannot raise it, and has no
retarget-levelcall; an error-correcting law still sees the plant's level dependence through the measured response. - Spaces. The controls are the channels the reference is written in (physical channels, or virtual degrees of freedom after the response transformation); the drives are the drives the law commands (physical outputs, or virtual drives before the drive transformation). The core transforms both ways.
Manifest. describe() returns the manifest every law has (name, version, author, summary,
parameters, diagnostics) and three things more:
| Field | Meaning |
|---|---|
| Shapes | Which shapes the law supports: square (n_c = n_d), more controls than drives (least squares), fewer controls than drives (minimum norm). At least one, each at most once. The controller refuses a test of another shape. |
| Needs | The optional inputs the law reads (below), each at most once. The core passes only these; the others arrive as none. |
| Diagnostic layouts | For each declared diagnostic, exactly one: a scalar (one number for the loop), one value per line (N values), one per control per line (N * n_c values, line after line), or one per drive per line (N * n_d values, line after line). |
A per-channel parameter holds one value per control channel.
Calls. The constructor takes the setup (n_c, n_d, N, line spacing, band, the reference
SDM and the tolerance lines) and the parameter values: every declared parameter, already checked
against the manifest, in manifest order, with defaults for the values the operator left out. An
error refuses the run with the reason given. seed(inputs) is called once after system
identification with the identification response as the measured response, and returns the first
drive. iterate(inputs) is called once per control loop.
Inputs, per call.
| Input | Shape per line | Meaning |
|---|---|---|
| Reference SDM | n_c x n_c, packed |
The specification at full level |
| Alarm and abort lines | n_c, four of them (alarm upper and lower, abort upper and lower) |
Each control's tolerance lines as PSDs at full level, so a law can weight its effort by where the tolerance is tight; NaN where a control has none (N * n_c values each, line after line) |
| Measured response SDM | n_c x n_c, packed |
The latest control estimate, referred to full level |
| Degrees of freedom | scalar | Of the measured estimate |
| FRF | n_c x n_d |
The plant estimate the core is using, held or updated (question 2) |
| Multiple coherence | n_c |
Of each control channel on all drives, 0 to 1 (N * n_c values, line after line), of the estimate the FRF comes from: system identification's while the FRF is held, the loop's own while it is updated |
| Line spacing, band, loop index | scalars | As in section 6; the loop index is 0 at the seed, then 1, 2, ... for each iteration |
Optional inputs, passed only when the manifest declares them (at full scale each is tens of megabytes a loop, so a law that does not read one never pays for it):
| Need | Shape per line | Meaning |
|---|---|---|
| Last drive | n_d x n_d, packed |
The drive played last loop, after the core's limits, at full level |
| Response-drive cross spectrum | n_c x n_d |
This loop's measurement, E[Y_c conj(V_d)], so a law can adapt its own FRF estimate as H = S_yv inv(S_vv) |
| Identification response | n_c x n_c, packed |
The control SDM measured during system identification; used by laws that match the identification's coherence and phase |
| Identification drive | n_d x n_d, packed |
The drive SDM of system identification |
| Identification noise | n_c x n_c, packed |
The control SDM measured with the drives off |
Output. The next full-level drive SDM, n_d x n_d per line, packed (V²/Hz): finite, Hermitian
(real diagonal), positive semidefinite on every line, and zero on every line outside the band. Plus
the declared diagnostics, each at most once, finite, in its declared layout; they are shown and
recorded, never relied on for protection.
What the host checks. Every output, before the core sees it; a failure is a failed call that names the rule:
| Rule | Check |
|---|---|
| Dimensions | N lines of n_d x n_d, packed |
| Finite | Every value finite |
| Hermitian | ||G - G^H|| / ||G|| (Frobenius, per line) at most 1e-9. Packed, the only way to break it is an imaginary part on a diagonal |
| Out of band | Every line outside the band exactly zero |
| Diagnostics | Each declared, reported at most once, in its declared layout and length, finite |
The host passes a well-formed drive that is not positive semidefinite on to the core, which judges it (below). The inputs are checked too (dimensions, finiteness, declared needs present); a failure there is the caller's, never the law's.
What the core does with the output. The law proposes; the core disposes, for every law alike.
- Positive semidefinite. Eigenvalues below
-1e-6times the largest at that line are clamped to zero, the diagonal is restored to the requested drive PSDs by a positive diagonal congruence, and the clamps are counted and shown; a negative eigenvalue larger in magnitude than1e-3times the largest fails the call. - Per-loop change cap on each drive's PSD, by default +3.5 dB up and -6.0 dB down per loop,
applied as a diagonal congruence
D^(1/2) G D^(1/2), which keeps the matrix positive semidefinite and every pair's coherence. - Drive ceilings per drive, by the same congruence.
- Response limiting. Each limit channel's PSD is predicted from the FRF and the drive SDM, and where a prediction exceeds its ceiling the line's whole drive SDM is scaled down: the provable floor. Laws may limit more cleverly within it.
- Synthesis. Each line's SDM is factored (by its eigen square root, which handles the rank-deficient lines a MIMO reference often has), random phases are applied, and the drives are overlap-added in time.
- Tolerances. Alarm and abort judge each control channel's PSD, the diagonal of the measured response SDM. Coherence and phase errors are shown and recorded.
Built-in laws, all but band_average and broyden_congruence from the published literature, each run natively and also built as a law
file from the same source and held to the native law in the tests:
| Id | Law | Method |
|---|---|---|
pinv_closed (default) |
Pseudo-inverse, closed loop | The regularized pseudo-inverse drive H^+ G_ref H^+^H, then each loop a correction of a lower-triangular factor of the reference from the measured error (D. O. Smallwood, "Multiple Shaker Random Vibration Control: An Update", Proc. IEST 1999): autospectra first in channel order, an amplitude-only form for a control above its reference, each factor diagonal and each drive PSD held to the per-loop cap, no more independent sources than the plant carries. Every drive is positive semidefinite by construction. With fewer sources than controls the correction runs in the coordinates of the plant's reachable subspace and settles at the least-squares response P G_ref P^H, P = H H^+ |
pinv_open |
Pseudo-inverse, open loop | H^+ G_ref H^+^H every loop, truncated-SVD or Tikhonov regularization (R. Schultz, "A Demonstration of Force Estimation and Regularization Methods for Multi-Shaker Testing", IMAC proceedings), optionally weighting each control's error by its reference PSD: least squares with more controls than drives, minimum norm with fewer |
shape_svd |
Shape-constrained (SVD) | The drive held to the m leading right singular directions of the plant on each line, m fixed or set by a singular-value ratio (R. Schultz and P. Avitabile, "Shape-Constrained Input Estimation for Efficient Multi-shaker Vibration Testing", Experimental Techniques 44, 2020); closed loop by the default law's correction inside the constraint |
buzz_match |
Buzz-test matched | The reference's autospectra with each pair's coherence and phase taken from the identification response, pairs below a coherence floor left independent (after P. M. Daborn, C. Roberts, D. J. Ewins and P. R. Ind, "Next-Generation Random Vibration Tests", IMAC XXXII, 2014, as described by Schultz); then the default law's closed loop |
min_drive |
Minimum drive | The reference's autospectra, as far as a trade-off against drive power allows, with the cross terms of the drive that needs the least power to produce them: per line the drive minimizing the autospectrum residuals plus the trade-off times the drive power over the positive semi-definite cone, and the plant's predicted response to it as the target (K. Coletti, R. B. Davis and R. Schultz, "Pareto-optimal target definition for multi-axis random vibration testing", 2026; D. O. Smallwood, "Minimum Input Trace for Multiple Input Multiple Output Linear Systems", Journal of the IEST 56, 2013, at the exact-control end); then the default law's closed loop |
band_average |
Band average | Brandon Zwink's law, not from the literature. Per fractional-octave band, one drive SDM, flat within the band, whose band-averaged response matches the band-averaged reference through the band cross-power sensitivity <H_pi conj(H_pj)>; the threshold of each band's regularized solve chosen by a sweep at the seed and held; a fit over the positive semi-definite drives where clipping would move a response; then each loop a gain correction per band and control from the measured response over the predicted, and optionally a new solve from the updated FRF with the drive conditioned so the estimate sees every drive. It matches band averages: a control's line-by-line error is not driven to zero |
independent |
Independent drives | Uncorrelated drives: per line the drive autospectra g solved from the reference autospectra through the squared magnitudes of the frequency response, A_kd = |H_kd|^2, by the Tikhonov pseudo-inverse (A^T A + c I)^-1 A^T with c a set fraction (0.01) of the largest diagonal element of A^T A, a negative level set to zero; then each loop the levels played plus the solve of the autospectrum error, each level's change held to +100 and -67 percent (R. L. Mayes and D. P. Rohe, "Physical Vibration Simulation of an Acoustic Environment with Six Shakers on an Industrial Structure", IMAC XXXIV, 2016; R. Schultz, IMAC XXXVII, 2019; N. Hunter, K. Cross and G. Nelson, "The Cross Spectrum in Multiple Input Multiple Response Vibration Testing", IMAC XXXVI, 2018). It matches autospectra only: the response's coherence and phase are what the structure gives uncorrelated drives. The page says "voltage" for the limit; it is applied to the autospectrum, the quantity the iteration updates (+3.0 / -4.8 dB). Read as amplitude it would be +300 / -89 percent of the autospectrum (+6.0 / -9.6 dB), looser than the core's +3.5 / -6 dB cap; either reading can be set with the two limit parameters. A convergence factor, 1 by default (the published whole step), is a Hertzforge addition. The whole step passes measurement noise to the drive on any structure: on a feasible, well-conditioned 3 x 3 structure with 1 percent noise and the published solve, the drive changed 1.70 dB a loop on average and up to 3.01 dB while the worst control moved 0.11 dB; with a factor of 0.5, 0.74 dB on average and up to 1.25 dB. A level zeroed on one line while its drive is non-zero elsewhere rises again from 60 dB below the drive's in-band mean, doubling once a loop (about 19 loops for 60 dB); a drive zero on every line has no rise limit and the core's change cap governs it. Two refinements of N. Hunter's (his unpublished note "The Independent Drive Law, Step by Step", private communication, 2026, used with his permission) can replace two published steps; the non-negative solve is the default, the weighting is not. solve_weighting target (none, the published solve, is the default in this law: played directly, the weighted solve settles low where the targets cannot all be met, 3 to 7 dB low on the benchmark's tuning structures; Hertzforge's choice, to be confirmed with the author) divides each control's row of A and its target by that target, so every control's error counts in proportion to its own level, and c then multiplies each drive's own diagonal element of the weighted A^T A instead of the largest one (the scaling of D. W. Marquardt, "An Algorithm for Least-Squares Estimation of Nonlinear Parameters", J. SIAM 11, 1963), so every drive is regularized by the same relative amount whatever level it needs. solve nonnegative (default; set_to_zero is published) gives, where the plain solve has a negative level, the minimizer of the same objective over levels of zero or more (Lawson and Hanson's active-set method, at most 3n subproblems; if that is reached, a subproblem is singular, or an input or a step is not finite, the line takes the published rule and solve_fallbacks counts it); each feedback step minimizes the published step's objective the same way, and equals the published step where no level is held at zero. negative_floor applies with set_to_zero only. |
nearly_independent |
Nearly independent drives | The reference's autospectra with each pair's coherence and phase taken from the response the independent drives above would produce through the frequency response, H diag(g) H^H rescaled to the specified autospectra; then the default law's closed loop (J. S. Cap, S. Norman and D. O. Smallwood, "The Derivation of Multiple-Input-Multiple Output (MIMO) Acoustic Test Specifications to Simulate a Missile Flight", 86th Shock and Vibration Symposium, 2015, Appendix A, the spectral-density form of Hunter, Cross and Nelson's nearly independent drive algorithm). With more controls than drives the rescaled reference is in general out of reach, and the loop settles at the part of it the drives can produce. The trial levels take solve and solve_weighting as above, both refinements on by default (solve_weighting target here), and N. Hunter's exactness test, exact_tolerance 1e-10 by default (0 turns it off, the published form): on a line where the plain levels with no regularization are all zero or more and leave a relative residual at or below the tolerance, those levels are kept, and the loop starts there from the diagonal drive wherever its pseudo-inverse keeps every drive direction; elsewhere (more drives than controls, or a truncated direction) it starts there from its own drive, the least drive with the same response, and exact_not_held counts those lines (0 in the open form, which plays the diagonal drive). On every other line, with level_set on (the default; off is published), the loop's first drive X = H^+ G H^+^H is scaled by sum t / trace(H X H^H), the specified total power over the predicted, and handed to the loop as its first drive; the loop then sets the level from the response (on a square or wide structure of full rank the factor is 1). The published method is solve set_to_zero, solve_weighting none, exact_tolerance 0, level_set off. loop open (default closed) is N. Hunter's law as his note runs it: on every call the drive for the estimate handed in, the same drive while the estimate is held, the response not read; its error is whatever the model's error is, and the core's level, limits, ceilings and aborts act on it as on any law. |
broyden_congruence |
Broyden congruence | N. Hunter's law, not from the literature (his unpublished note "The Broyden Congruence Law, Step by Step", private communication, 2026, used with his permission). It specifies autospectra only. The first drive is the inverse of the reference, H^+ G_ref H^+^H (truncated, cutoff 1e-3), optionally capped so the model's total response starts a set level below the total specified (start_cap, off by default, -9 dB). After that each loop and line multiplies each drive by a gain and, with phase steering, turns its phase: X_new = D X D^H, D = diag(e^(u_i + j theta_i)), which keeps the coherence between every pair of drives and keeps the drive positive semi-definite. The step solves the log autospectrum error through a sensitivity of the log response to the log gains and phases: the model's, S_mi = 2 Re(a_mi) / y_m from the shares a_mi = H_mi (X H^H)_im, corrected each loop from what the last step did by a damped secant update (C. G. Broyden, Mathematics of Computation 19, 1965) weighted by the trust each control's measurement deserves, with three corrections, and pulled a set fraction toward the current model's (model_anchor). The error is split into a common level and a shape; the shape is solved by a ridge, weighted by each control's multiple coherence; the step is scaled by the convergence factor and by a cut at resonances, then limited so that none of three predictions of the change (the learned, the exact through the model, the drive's own) exceeds max_step_db, and the phase change max_phase_step_deg. A ceiling scales the drive down, in the same loop, when the expected response of a control would exceed its target by more than ceiling_db (or the model response of any specified control by more than 20 dB above that). The base of each step is the drive commanded, or the drive played when the two differ by more than realize_tol_db (the median over the band), and on any line where they differ by more than that (Hertzforge's, so a line the core holds back does not wind up). A line whose drive falls below 1e-8 of the trace of its model drive H^+ G_ref H^+^H is lifted to it, after the ceiling; that model drive is formed once, at the first drive, with the truncated inverse at a cutoff of 1e-3 whatever the regularization, so a drive at the floor answers, by the frequency response given at the first drive, with at most 1e-2 of the target's total, 20 dB under it (the note's floor is relative to the specification, which depends on the units of the frequency response). The resonance cut is Hertzforge's: each control's row size over its running median in a window of resonance_halfwidth_oct either side, the gain 1 / (1 + resonance_sensitivity (ratio - 1)) for the worst specified control, never below resonance_min_gain. Parameters: the first drive's regularization and amount, the drive-coherence cap (0.95), the start cap and its level, convergence (0.5), largest step (3 dB), ridge (0.1), resonance sensitivity (0.5), half-width (1/3 octave) and smallest gain (0), ceiling (12 dB), Broyden gain (0.6; 0 turns learning off), coherence power (1), model anchor (0.05), smallest change learned from (0.05 dB), level split (on), base on the command (on) and its tolerance (3 dB), phase steering (on) and its largest step (15 degrees), effective averages (0: from the response's degrees of freedom) |
Each declares the largest drive change of the loop as a diagnostic. All but band_average,
independent and broyden_congruence also declare the condition number and the singular values kept per line, and the
closed-loop laws among them count the clamped factor diagonals. independent instead counts per
line the drive levels solved below zero, before the negative rule and the change limit (at the seed
these mark lines where independent drives cannot meet the autospectra; on later loops they also
count a step that overshoots below zero, and a counted level may still be played above zero where
the fall limit holds it), and the levels its change limit held this loop. Both independent-drive
laws also count per line the levels the non-negative solve held at zero (held_at_zero), and as one
number the lines where that solve could not finish and the published rule was used (solve_fallbacks);
nearly_independent marks the lines its exactness test found exact (exact), gives the level
set's factor per line as a ratio (level_set_factor, 1 where it does not act), counts the lines
where the level set's sums were zero or not finite (level_set_guarded), and counts the exact lines whose
diagonal drive the closed loop cannot hold (exact_not_held). broyden_congruence gives the largest drive change in dB (correction_db) and per line the resonance gain, the factor the step limit scaled its step by (step_scale), the ceiling's factor (ceiling_factor), whether the secant update changed the learned sensitivity (broyden_updated), whether the base was the drive played (base_played), and whether the floor lifted the line (floor_lifted); as numbers, the lines built on the drive played by the line-by-line test (base_played_lines) and the updates that changed the sensitivity since the first drive (broyden_updates).
Versioning. The package stays at 0.1.0. Freezing this world changed only random-mimo, which
was published as an unstable draft no host loaded and no law could be built against;
random-single is unchanged, so every single-output law file keeps loading (R15).
8. Classical shock (shock-classical)¶
A classical shock law closes the loop between pulses: it proposes the next drive record, and the
controller checks it, scales it to the scheduled level, plays it, measures and judges the pulse,
and calls the law again. The world is wit/control-law/shock-classical.wit.
When it runs. Once after system identification (seed), then once after each fired, measured
and judged pulse (iterate), on the run's thread and never while a pulse plays. A train or a
gunfire burst fires the drive in force with no call inside it. Each call has a budget of a fraction
of the minimum time between pulses (law_budget, default 0.25: 250 ms at the default 1.0 s floor);
a law file's host deadline is the same number.
What it sees. Fixed for the run: the rate and the record length (a power of two), the
correction band, the full-level reference on the grid (the compensated pulse with its quiet
margins; the main pulse's first sample and length), the identified plant on the grid's bins
(H in EU per volt, coherence, the controller's regularized inverse
conj(H) / (|H|^2 + epsilon) with its epsilon, and the bins the controller trusts: in the band,
coherence at or over its floor, reference within its dynamic-range floor) and the drive ceiling.
Each call: the pulse index, the last response referred to full level by the scale the controller
actually commanded, the drive as played referred the same way, the controller's verdict (passed,
RMS error in percent, peak ratio, velocity-change ratio) and whether the controller scaled that
pulse down. Spectra are one-sided under the negative-exponent transform; the controller forms the
plant in that convention.
What it returns. The next full-level drive in volts, record-len finite samples, and up to
eight values its manifest declares. It does not decide the level, the ladder, when a pulse fires,
the spacing, a train, the polarity, the verdict or any abort.
What the controller enforces, for every law.
| Guard | Rule |
|---|---|
| Drive in volts | From the identified plant. Identification is band-limited random at a stated V rms, its peak held under the drive ceiling |
| Drive ceiling and abort | On the commanded record before it plays: over the abort it is refused and the run aborts (drive_vpk); over the ceiling it is scaled to it and the action logged. At proceed, the drive at the highest level the run is scheduled to reach over the abort ends the run before any pulse (predicted); a level move that would pass it is refused |
| Predicted response | Through H before every pulse: its peak against the drive limit, its velocity and displacement against the shaker's ratings (kinematic, predicted) |
| At rest | The outer half of each quiet margin tapers to zero, so every record starts and ends at 0 V |
| Output checks | Length, finite, at most eight declared values |
| Change caps | At full level, the drive's peak and any bin may rise at most max_peak_rise_db and max_bin_rise_db (default 10 dB each) over the drive in force, never tighter than the built-in's own limit plus 1 dB; bins under -40 dB of the largest count as that small |
| First drive | The seed's predicted response peak at most first_drive_ratio (default 2) times the reference's |
| Misses | A late, failed, crashed or refused call is a miss; the next pulse refires the drive in force. law_misses (default 3) in a row take the controlled stop (law_fault); a seed miss fires nothing |
| Measured pulse | Overshoot over 1 + overshoot_abort times commanded aborts at any level (default twice the standard's amplitude tolerance); a tolerance failure aborts at full level (full_level, the default) or at every level (every_level), never for an undershoot |
| Convergence | max_pulses_per_level (default 5) pulses at one level without a pass, or failing in a row at one manual level, end the run not_converged, as does the run's max_pulses (default 100); the error rising more than 1 dB on divergence_pulses (default 3) pulses in a row at one level trips divergence |
The built-in law, fd_correct. The frequency-domain correction time waveform replication
uses, applied to the compensated pulse: D0 = G R on the trusted bins, then D += beta G (R - Y)
after each pulse, each bin's growth limited per pulse; the drive is the inverse transform of D.
Parameters beta (0.05 to 1, default 0.5), max_db_per_pulse (1 to 9, default 6) and
initial_backoff_db (0 to 12, default 0). Its seed and correction are time waveform replication's
bin for bin; it runs natively and as the law file laws/shock-fdc, and the two give the same run.
Records. At the seed the run folder gets law.json (the law's identity and parameters, the
guards and the caps); every call goes to law_pulses (an index line per call: pulse, seed or
iteration, used or the miss reason, call time, capped bins, verdict, values; the response, the
drive in and the drive out as f32 in the payload), written between pulses. The report carries
the law's name, version and short hash and the guard counts.
The check. Seven simulated test articles, each a whole run under these guards: a wire (every pulse passes), one mode (400 Hz, Q 10), the simulated station's plant (200 and 550 Hz, Q 2.5) with a 6 ms haversine, one mode behind a 2 ms delay (each a pass by pulse 3 and every full-level pulse), an identification error (the identified gain +3 dB: a pass within eight pulses at the first rung), measurement noise (a pass by pulse 4) and a 30 dB notch at 300 Hz under the coherence floor (survive). Every case asks every call answered in time, with no miss and no refused output.
9. SRS shock (shock-srs)¶
An SRS shock law closes the loop between pulses on a synthesized pulse: the controller synthesizes
every pulse from a table of components (odd-half-cycle wavelets or damped sines, one per band by
default), and the law proposes one gain per component. The controller applies the gains, caps
them, checks the drive, plays it, measures and judges the pulse, and calls the law again. A law
never writes a drive record, so a pulse's zero net velocity and displacement hold whatever it
returns. The world is wit/control-law/shock-srs.wit.
When it runs. Once after system identification and before the controller plans its limit notch
(seed), then once after each fired, measured and judged pulse (iterate), on the run's thread
and never while a pulse plays. Each call has a budget of a fraction of the time between pulses
(law_budget, default 0.25: 250 ms at the default 1.0 s floor); a law file's host deadline is the
same number.
What it sees. Fixed for the run: the band centres every spectrum is on, the components'
frequencies in table order (a separate grid, of any length), the full-level target SRS, the Q every
SRS is computed at, and the identified gain at each component, |H| in EU per volt floored by the
controller (absent when nothing was identified). Each call: the pulse index, the target at the scale
the last pulse was commanded at (the level times the controller's safety trims, so a law aims at
what was asked of that pulse and never fights a limiter), the last pulse's measured SRS (zeros at
the seed) and that scale.
What it returns. One multiplicative gain per component, finite and above zero (at the seed, the starting gains relative to the table), and up to eight values its manifest declares. It does not decide the level, the ladder, when a pulse fires, the spacing, the envelope verdict or any abort.
What the controller enforces, for every law.
| Guard | Rule |
|---|---|
| Drive in volts | From the identified gain. Identification plays the synthesized pulse at its level (identification.level_db, default -20 dB), its peak held at identification.max_vpk (default a tenth of the drive ceiling) |
| Coherence hold | A mean in-band coherence under identification.min_mean_coherence (default 0.8) ends the run held before any pulse |
| Drive ceiling and abort | On the synthesized drive before it plays: over the abort it is refused and the run aborts (drive_vpk); over the ceiling it is scaled to it and the action logged. At proceed, the drive at the highest level the run is scheduled to reach over the abort ends the run before any pulse (predicted); a level move that would pass it is refused |
| Predicted response | Through the identified gain before every pulse: its peak against the drive limit, its acceleration, velocity and displacement against the run's kinematic aborts and the shaker's ratings (kinematic, predicted) |
| Output checks | One gain per component, every number finite, every gain above zero, at most eight declared values |
| Gain cap | No gain may rise more than max_gain_rise_db (default 6 dB) in one pulse; an output that asks for more is refused (gain_rise). It never binds on the built-in at its default |
| Limit cap | After the law, each gain is held to min(law gain, cap): the cap is the tightest allowed-over-predicted ratio over the limit channels and the bands within half an octave of the component, from the prediction for the last drive referred to the highest level the run is scheduled to reach; a rise toward the bound is damped to the square root, a binding cap is cut a further 0.5 dB, and nothing rises without a prediction. A falling gain always wins. A band the limit holds down (a band the arm-time notch cut, or within half an octave of one) that reads low does not fail a pulse |
| Misses | A late, failed, crashed or refused call is a miss; the next pulse refires the table in force. law_misses (default 3) in a row take the controlled stop (law_fault); a seed miss fires nothing |
| Measured pulse | The envelope at the level fired (alarm and abort bands), the measured kinematics and the drive monitors |
| Convergence and pacing | With advance: on_pass a pulse passes when no band is outside the alarm band; max_pulses_per_level (default 5) pulses at one level without a pass, or failing in a row at one manual level, end the run not_converged, as does the run's max_pulses (default 100). Pulses start no closer than the time between pulses |
The built-in law, srs_ratio. The classic per-band SRS iteration: the seed is 1 / |H(fc)|
per component (1 when nothing was identified); after each pulse each component is scaled by the
target over the measured SRS at the band nearest its frequency, held at 1 on a band with no
response or no target, limited to max_db_per_pulse (0.5 to 5 dB, default 3) either way. It
reports the worst band's error and frequency and the components at its limit. It runs natively and
as the law file laws/shock-srs-ratio, and the two give the same run.
Records. At the seed the run folder gets law.json (the law's identity and parameters, the
guards and the gain cap); every call goes to law_pulses (an index line per call: pulse, seed or
iteration, used or the miss reason, call time, the commanded scale, the components the limit cap
held, values; the target and measured SRS as f32 and the gains returned and applied as f64 in
the payload), written between pulses. The report carries the law's name, version and short hash and
the guard counts.
The check. Six simulated test articles, each a whole run under these guards on a flat 1/3-octave target from 100 to 2000 Hz at Q 10: one mode (400 Hz, Q 10), two close modes (240 and 260 Hz, Q 30) and one mode with measurement noise (each every band within 3 dB by the sixth full-level pulse and on every one after), a level ladder of -12, -6 and 0 dB with manual moves (every band within 3 dB after three pulses at each level), one mode with the identified gain +3 dB (within 3 dB by the eighth full-level pulse), and a wire with a limit channel whose supplied gain is 4 at 500 Hz under a flat bound (the prediction at most 0.5 dB over the bound on every pulse, and the control within 3 dB outside the bands the limit holds down). Every case asks every call answered in time, with no miss and no refused output.
10. Single-output Sine (sine-single)¶
A Sine law decides one number per control tick: the amplitude of the one tone the controller plays,
in drive units peak (volts peak on hardware). The controller keeps the tone's frequency, the sweep
and its direction, its phase (continuous), the level schedule, the second reference output and
every protection. The world is wit/control-law/sine-single.wit.
When it runs. Once per control tick on the controller's real-time thread: engage once, after
system identification and before anything is driven at test level, for the starting drive; tick
on every tick after it. The tick is tick_ms (default 10 ms), whole frames at the rate the station
adopted; a built-in law may run at a 2 ms tick, a law file at no less than 8 ms. Each call has a
budget of law_budget (default 0.25) of the tick, 2.5 ms at 10 ms; a law file's host deadline is
the same number, checked on each of the host's 1 ms epoch ticks, so a late call is stopped one or
two epoch ticks past its budget, inside its control tick. The law is not called while the drive
ramps down. A number parameter the manifest lists as live can be changed by the operator during a
run (adjust): the controller checks the key and the value's declared range first, and the value
applies from the next tick.
What it sees. Fixed for the run: the control channels in the composite, the tick, the band, the
drive ceiling, and the identification on its own grid (|H| in control units peak per drive unit
peak, coherence, the controller's trust mask, the full-level target at each grid frequency). Each
tick: its index (0 at engage), the time since the last call, the frequency, the sweep rate (signed;
0 at a dwell or while held), the scheduled level, the target at this frequency and level, the
measured composite, each control channel's tracked amplitude and phase against the drive, the drive
in force as played, the prediction (prediction-db: the controller's plant-inverse drive at this
frequency at full level, dB relative to one drive unit; absent where the identification is not
trusted), why the controller holds the drive (free, notch, probe), the notch ceiling, and
whether the settle window is open.
What it returns. The drive, finite and at least zero, its own fault judgement (shown and recorded, never relied on), and up to eight values its manifest declares. It does not decide the frequency, the sweep, the phase, the level schedule, the reference output or any abort.
What the controller enforces, for every law.
| Guard | Rule |
|---|---|
| Output checks | A drive that is not a finite number at least zero, a value that is not finite or not declared: refused, a miss |
| Time budget | Each call timed against law_budget of the tick; a late call is a miss |
| Misses | A late, failed, panicked or refused call is a miss: the drive in force is held. A usable call resets the count; law_misses (default 3) in a row take the controlled stop (120 dB/s of station time, then the drain) and the run ends law_fault. The law is not called again |
| Change cap | At most max_step_db (default 1 dB, 1 to 3) from the drive in force in one tick, either way |
| Rise cap | At most max_rise_db_per_s (default 240 dB/s) up |
| Divergence | The change or rise cap binding for divergence_s (default 1 s) without a break takes the same controlled stop, trip divergence |
| First drive | At most the prediction at the start frequency and level plus 6 dB, and never over the ceiling; without a trusted prediction there, at most 0.05 times the start level's scale |
| Holds | While a limit channel holds the drive (notch) the notch ceiling applies after the law, so the law cannot raise it; while a resonance search maps the plant (probe) the law's drive is not used |
| Notch | A limit channel is held at its limit (the level its profile states); its abort edge above that ends the run |
| Drive ceiling and abort, the alarm and abort bands, the kinematic monitor, the servo fault, the raw watchdog | As for every Sine run, after the law and the notch |
The built-in law, servo_blend. An amplitude servo (proportional-integral on the error in dB,
kp default 0.3, ki and its rate limit from compression: slow 2 and 20 dB/s (the default),
fast 6 and 60 dB/s, or custom) moves its own level each tick; the blend adds blend_w (default 0.5, live)
times the prediction's change since the last tick and clamps the total to 1 dB a tick; the drive is
the drive in force moved by that total. The servo is held while the controller holds the drive, and
where the drive in force is under what the law last asked (a cap, a ceiling or the notch held it
down), the servo's level follows it down, so a long clamp does not wind the servo up. The first drive is the prediction at the start level (0.05 drive units at the start level without one).
It reports the servo's step, the prediction's step, the total and the servo's own level, dB. It runs
natively and as the law file laws/sine-servo, and the two give the same run.
Records. At engage, with a capture running, the run folder gets law.json (the law's identity,
parameters, values, live parameters and the guards); every call goes to law_ticks.bin, 136-byte
little-endian records described by law_ticks.json beside it (tick, frequency, target, measured,
the drive in force, the prediction, the hold, used or the miss reason, capped, the call's
microseconds, the law's drive, the drive the controller took, the eight values), written between
batches, never on the loop thread. The report carries the law's name, version and short hash and
the guard counts.
The check. Eight simulated test articles, each a whole run under these guards at 16384 Hz and a 10 ms tick, a flat 1 g target, identification at -20 dB, the abort band 12 dB either way:
| Case | Plant and run | Asks for |
|---|---|---|
| slow sweep | One mode, 250 Hz, Q 50; a log sweep 100 to 800 Hz at 1 oct/min | Within 1.5 dB through the resonance (every judged tick within 30 Hz of it) |
| fast sweep | The same at 6 oct/min | Within 5 dB through the resonance, within 2 dB more than 30 Hz from it |
| close modes | 240 and 260 Hz, Q 30; 2 oct/min | Within 2 dB |
| anti-resonance | A flat plant cut 30 dB at 300 Hz, its coherence there under the trust floor; 2 oct/min | Survive: the run completes or ends on the controller's own divergence trip, the drive never over the ceiling |
| measurement noise | One mode; noise 30 dB under the full-level response; a 30 s dwell at 250 Hz | Within 1.5 dB |
| level ladder | One mode; -20, -12, -6 and 0 dB moved by hand, 10 s each, at a 250 Hz dwell, one live change to the middle of a live parameter's range | Every rung within 1 dB after its settle window |
| limit channel | One mode, and a limit channel reading up to 4 times the control at the mode under a flat 2 g limit; 2 oct/min | The limit channel at most 0.5 dB over its limit; the control at most 1 dB over its target after the notch releases |
| transport delay | A flat wire (1 g per volt) that plays the drive 50 ms late, a hardware station's measured lag rounded up (819 samples); engaged at -6 dB, a 6 s dwell at 100 Hz | The run completes, and every tick from 2 s after the engage on is within 0.5 dB of the target (settles) |
The other stations have no lag. A judged tick is one at full level (or, for the ladder, at a rung) outside the settle window and not held by the notch; for the transport delay case, every tick from 2 s after the engage, settle window or not. Every case also asks that every call is answered in time with no miss and no refused output, and reports the slowest call and the capped ticks.
11. Time waveform replication (twr-single)¶
A time waveform replication (TWR) law closes the loop between whole records: it proposes the next
drive record, and the controller checks it, scales it to the commanded level, plays it, measures,
aligns and judges the response, and calls the law again. The world is
wit/control-law/twr-single.wit; its plant is the classical world's (classical-types.plant).
When it runs. Never while a record plays. Once at proceed, after the identification and its
review (seed); then after each correction play that did not meet the gate, unless adaptation is
frozen, and after each playback play when adaptation during playback is on (iterate). A play
that gates is carried to the next level with no call. Each call has a budget of a fraction of the
record (law_budget, default 0.25, times the longer of the record and 4 s: 1.28 s for a 5.12 s
record); a law file's host deadline is the same number.
What it sees. Fixed for the run: the rate and the record length (a power of two), the
correction band, the full-level reference on the record grid (the prepared section between its
quiet pads, with the section's first sample and length), the identified plant on the grid's bins
(H in EU per volt, coherence, the controller's regularized inverse
conj(H) / (|H|^2 + epsilon) with its epsilon, and the bins the controller trusts: in the band,
coherence at or over its floor, reference within its dynamic-range floor), and the drive ceiling.
Each call: the play index (0 at the seed), whether the last play was a correction or a playback,
the last response referred to full level by the scale the controller actually commanded, the drive
as played (after the controller's clip and taper) referred the same way, the controller's verdict
(gated, RMS error in percent, peak error in percent, spectral error in dB) and whether the
controller clipped that drive. Spectra are one-sided under the negative-exponent transform; the
controller forms the plant in that convention. The identification's judgement is the
controller's for every law: the trust mask, the regularization floor and the coverage floor.
What it returns. The next full-level drive in volts, record-len finite samples, and up to
eight values its manifest declares. It does not decide the level, the ladder, the gate, when a
play starts, the playback schedule, adaptation, the trust mask or any abort.
What the controller enforces, for every law.
| Guard | Rule |
|---|---|
| Drive ceiling | On the record as it will play (scaled, clipped, tapered): over the ceiling it is refused and the run aborts (drive_vpk). At proceed in AUTO, the controller's own full-level drive (the inverse applied to the full-level reference) over the ceiling ends the run before any play (drive_vpk, predicted); in MANUAL a level move whose projected peak passes the ceiling is refused |
| Clip and RMS limits | The per-sample clip, the drive RMS limit and the response RMS limit, as configured |
| At rest | The outer half of each quiet pad tapers to zero on a raised cosine, so every play starts and ends at 0 V |
| Output checks | Length, finite, at most eight declared values |
| Change caps | At full level, the drive's peak and any bin may rise at most max_peak_rise_db and max_bin_rise_db (default 10 dB each) over the drive last played, never tighter than the built-in's own limit plus 1 dB; bins under -40 dB of the largest count as that small |
| Predicted response | Through H: each drive's predicted response peak at most 1 + envelope_abort_frac times the level target's; the seed's at most first_drive_ratio (default 2) times it, or the run ends first_drive before anything plays |
| Misses | A late, failed, crashed or refused call is a miss; the next play replays the drive in force. law_misses (default 3) in a row take the controlled stop (law_fault); a seed miss plays nothing |
| Envelope | Watched as each block of a play arrives, against the level target at the run's lag: outside the abort band (default 50% of the target's peak) for the debounce count of samples (default 8) cuts the play short with the emergency stop (envelope, during the play). Judged again over the whole record after it |
| Alignment | Each play's lag is fitted from its response against the response H predicts to its drive, on the trusted bins; a drift of more than alignment_frames (default 1) from the identification's ends the run (alignment) before anything is corrected from that play |
| Convergence | max_iterations correction plays at a level without a gate end the run not_converged (or hold, by policy); the error rising on divergence_plays plays in a row at one level trips divergence; the coverage floor and the coherence hold stop a run whose identification cannot support it |
The built-in law, twr_correct. The frequency-domain correction: D0 = G R on the trusted
bins, then D += beta G (R - Y) after each correction play, each bin's growth limited per call;
when the controller clipped the last drive, D first becomes the spectrum of the drive as played.
Parameters beta (0.05 to 1, default 0.5), max_db_per_iter (1 to 9, default 6) and
initial_backoff_db (0 to 12, default 0). It is classical shock's fd_correct over a whole
record, bin for bin; it runs natively and as the law file laws/twr-correct, and the two give the
same run.
Records. At proceed the run folder gets law.json (the law's identity and parameters, the
guards and the caps); every call goes to law_calls (an index line per call: play, seed or
iteration, used or the miss reason, call time, the rises it asked for, its predicted peak, the
play's fitted lag, its values; the drive it returned as f32 in the payload), written between
plays. Every play's row carries the call behind its drive. The report carries the law's name,
version and short hash and the call counts.
The check. Eight simulated test articles at 12 800 Hz, each a whole run under these guards on
a 2 s field-like reference through the AUTO ladder: a wire (every rung gates on its first play,
full level within 5%), one mode (400 Hz, Q 10), the simulated station's plant (200 and 550 Hz,
Q 2.5) and one mode behind a 2 ms delay (each: every rung gates within its eight plays, full level
within 10%), a wire on a station that keeps its output 512 frames ahead in 256-frame blocks, as a
hardware chassis does (as the wire, and the run aligned on the lag the identification measured),
an identification error (the identified gain +3 dB: the first rung gated by play 4, every later
on its first), measurement noise 30 dB under the first rung's response (full level within 10%)
and a 30 dB notch at 300 Hz under the coherence floor (survive: complete, or be ended by the
controller's own judgement; never over the ceiling, never an envelope abort). Every case asks
every call answered in time, with no miss and no refused output. A record clears a law file for
hardware only at the check in force (twr-check 1).
12. Later test types¶
Each test type gets its own world, built on the same mechanism.
| Test type | When the law runs | Note |
|---|---|---|
| Classical shock | Between pulses | Built: section 8 |
| SRS shock | Between pulses | Built: section 9 |
| Time waveform replication | Between plays | Built: section 11 |
| Sine | Every control tick | Built: section 10 |
| MIMO variants of the above | As above | After MIMO Random |
| MIMO Shock (classical and SRS, several drives) | Between pulses | Built: section 15 |
| MIMO Sine (sweep, dwell and stepped sine, several drives) | Every control update | Built: section 16; its check is not built yet |
| MIMO Mixed Mode (a random floor with sine tones and narrow bands, several drives) | The floor's law once a loop, the tones' law every control update | Built: the floor takes a MIMO Random law (section 7) and the tones a MIMO Sine law (section 16); on hardware an imported law also needs the MIMO Mixed check in its role (mimo-mixed-check 1) |
13. Writing a law¶
Hertzforge publishes a Rust crate for law authors (the interface bindings for both worlds, plus
helpers such as the default level servo and, for MIMO, the controller's own matrix types and
per-line linear algebra), a template project, and a worked example for each world. A law builds with
cargo build --target wasm32-wasip2 --release. Any language that can build a WebAssembly component
against the WIT files can produce a law file (C and C++ can, for example); only Rust is supported
for now. A law should pass law check before it is used on hardware.
14. Open questions for reviewers¶
- MIMO inputs. Answered: the inputs of section 7. The large optional ones (the last drive, the response-drive cross spectrum, the identification response, drive and noise) are declared in the manifest and passed only to a law that declares them. Per-frame spectra, other FRF estimators, an uncertainty on the FRF and time histories are not passed in this version.
- The FRF during the test. Answered: the operator's choice, per test. Hold (the default) keeps the identification FRF; Update lets the core re-estimate it every loop from the played drive and the measured response, blended with the identification estimate. A law receives whichever the setting selects, and a law that adapts on its own declares the response-drive cross spectrum.
- MIMO limiting. Answered: yes. The core predicts each limit channel's PSD from the FRF and the drive SDM and scales the line's whole drive SDM down where a prediction exceeds its ceiling; laws may limit more cleverly within that floor.
- MIMO tolerances. Should alarm and abort judge only each control channel's PSD, or also the cross terms (coherence and phase tolerances)?
- Repair or reject. Answered: both, by size. Eigenvalues below
-1e-6times the largest are clamped to zero, the requested drive PSDs restored and the clamps counted; one larger in magnitude than1e-3times the largest fails the call. The core does this, not the host, so every law is judged alike (section 7). - References that change. Some methods derive the reference during the test (for example a minimum-PSD reference). Should a law be allowed to change the reference, or should that be a separate kind of plug-in with its own checks?
- Who owns the level in MIMO. Answered: the core owns the level and the law the matrix. A MIMO law works entirely at full level; the core scales its drive to the scheduled level, so every law behaves alike under the level schedule and no law can raise the level.
- Unchecked laws on hardware. Block until
law checkpasses (as R13 proposes), or warn and allow? - Transport. Answered: Hermitian matrices travel packed, the upper triangle row-major; rectangular matrices in full. The SDK unpacks them.
- Cadence. One call per control loop. Does any law need a different cadence?
- Cross-term form. Answered: the boundary carries
S_ij = E[Z_i conj(Z_j)]under the negative-exponent transform (section 7), soS_yy = H S_vv H^Hand a law ported from Rattlesnake needs no conjugation. The core forms it directly and converts where a file holds the other form; the conversion is the core's, never a law's.
15. MIMO Shock (shock-mimo)¶
A MIMO Shock law closes the loop between pulses on several drives and several control channels at
once, for a classical waveform or a shock response spectrum (SRS) at every control. The world is
wit/control-law/shock-mimo.wit; one world serves both target kinds, and a law's manifest says
which kinds it accepts (targets: waveform, srs or both, each once). The controller refuses a
test of a kind the law does not accept, before the law is built.
When it runs. Never while a pulse plays. Once after system identification, for the first
level of the ladder (seed(level-db)), then once after each pulse has been fired, measured and
judged and the ladder has scheduled the next level (iterate). The ladder goes first so the law
knows the level it is building for. The law is built and seeded under a seed budget (60 s by
default), where a law may fit a model of the plant; each later call has the call budget, a
fraction of the time between pulses. A law file's host deadlines are the same numbers. Before the
first pulse the controller times one iteration of a second copy of the law on the identified
plant's predicted response, and ends the run (law_too_slow) if it is over the call budget.
What it is built with. Fixed for the run:
| Field | Meaning |
|---|---|
fs-hz, record-len |
The pulse grid: record-len samples (a power of two, 64 to 16384) at fs-hz. Every record starts with the quiet lead-in |
drives, controls |
1 to 8 drives, 1 to 16 control channels |
band-lo-hz, band-hi-hz |
The band the law corrects, inside the record's Nyquist frequency |
target |
waveform: each control's full-level record. srs: each control's SRS on ascending natural frequencies at quality factor q, the tolerance below and above it in dB, the full-level waveform the controller synthesized for each control, and the synthesis table behind it (frequency, amplitude, start, and a decay ratio or an odd number of half-cycles per component) |
timing |
free(window-s): each control is judged on its own and its delay reported. hold: each control is held to a set delay inside a window |
plant |
H, controls by drives on every line (record-len / 2 + 1 lines), from one identification shot with every drive played at once, so the path delays are in it; the multiple coherence of each control; the lines the controller trusts |
drive-ceiling-v |
Each drive's ceiling, volts peak |
ladder-db |
The level ladder, ascending, ending at 0 dB |
identification-level-db |
The level the plant was identified at, dB against full level: the largest, over the controls, of the identification's measured peak over the target's peak; not finite when it was not measured. A plant that changes with level was measured here, so a law that follows the plant may take it as the first point of the level trend. On a structure whose joints soften within a pulse it is only a rough guide: the identification's random excitation and a pulse load the joints differently |
Records of several channels travel flat, channel after channel: sample n of channel c is
data[c * record-len + n]. A matrix stack travels in full, row-major within a line, line after
line. Spectra are not passed: a law takes its own transforms, one-sided under the negative-exponent
convention, the one the plant is formed in. The SDK gives a Rust law plain rows and a matrix stack
instead of the flat lists, and the transforms, the regularized inverse, the SRS and delay tools.
What it sees after a pulse. The pulse count (1 for the first iteration), the level played and the level scheduled next, the drives as played after the controller's limits (volts), the measured responses, for an SRS target the measured SRS of every control on the target's frequencies, the controller's verdict per control (inside its tolerance or not, the worst deviation in dB, the measured delay, the measured peak over the target's), and whether the controller scaled the last pulse down. Drives and responses are at the level played; a law refers them to full level itself.
What it returns. The drives of the next pulse at the next level, in volts, one record of
record-len finite samples per drive: the controller does not rescale them. Optionally the delay
the law expects at each control (shown and recorded only). Up to eight values, each under a key its
manifest declares. The law does not set the level, the ladder, the judgement or any abort.
What the host refuses, each by name: not one record per drive (wrong_drive_count), not whole
records of record-len (wrong_length), a sample or a value that is not finite (non_finite),
delays that are not one finite delay per control (delays_shape), more than eight values
(too_many_values), a value the manifest does not declare or reported twice
(undeclared_value). A trap, a call past its budget or memory past the cap leave the instance
unusable, and every later call reports that first fault. The setup and each pulse's inputs are
checked against the limits and lengths above before the law sees them.
What the controller enforces, for every law. Each drive's ceiling (a drive over it is scaled
down, one past its abort is refused; the host names a drive over its ceiling, over_ceiling, and
passes it on), the growth of each drive's peak from one pulse to the next beyond the level step,
the predicted response against the abort lines before a fire, a divergence watch (an error that
rises on consecutive pulses at one level ends the run in the controlled stop), the kinematic checks
per control, and the call budget with its misses in a row, as in the single-output shock worlds.
The built-in laws. inverse (the default for a waveform target, accepts both kinds),
shape (the default for an SRS target, SRS only) and paired (both kinds; the template for
contributors). inverse and shape take a model parameter (frozen, the default; secant;
track; track_secant) that says how the law's model of the plant follows a plant that changes
with level; a further follower is a further name, with no change to this world. Each runs natively and as a law file (laws/mimo-shock-inverse,
laws/mimo-shock-shape, laws/mimo-shock-paired), and the law file gives the same drives as the
same mathematics called natively, within 1e-12 of each record's peak, over a run that holds and
steps the level, for every option that changes the mathematics. Their parameters are in
docs/control-laws.md.
The check. Eight cases, each run for every target kind the law accepts, on the simulator's
standard shock plants with the ladder -12, -9, -6, -3 and 0 dB, three pulses a level, and an SRS
tolerance of -1.5 and +3 dB: the linear 4 x 4, the jointed 4 x 4 moderate and severe, the jointed
6 x 3 (more controls than drives), the linear 4 x 4 with the law's model wrong by a 0.5 ms delay,
the moderate 4 x 4 identified 20 dB under the reference with the model 2 dB high, the moderate
4 x 4 with noise at 3 % of the target rms on every response, and the linear 4 x 4 with a limit
channel that binds from the -3 dB level. Every case asks: every answer used and no law fault; no
abort, safe stop or fault; a pulse at full level (the limit case excepted); the last pulse of the
last level passing jointly; the worst control's error on that pulse no more than 1 dB above its
best at that level; no drive's peak growing more than 6 dB over that level's pulses. The
requirements describe a good law; the facts of a built-in law list the cases it is known to fail.
A record clears a law file at the check in force (mimo-shock-check 1).
16. MIMO Sine (sine-mimo)¶
A MIMO Sine law decides, every control update, one complex amplitude per drive for a sine played
on several drives at once and tracked at several control channels. The world is
wit/control-law/sine-mimo.wit; one world serves sweeps, dwells and stepped sines, and a law's
manifest says which shapes (square, more-controls-than-drives, fewer-controls-than-drives),
which test types (sweep, dwell, stepped) and whether an amplitude-only reference it accepts.
The controller refuses a run the law does not accept, before the law is built.
What the controller keeps. The tone's frequency, the sweep and its direction, the tone's phase
(kept continuous), the level schedule, every protection and every abort. Drive i plays
Re{ D_i exp(j phi(t)) }; the law decides D.
When it runs. On the controller's real-time thread, once per control update (10 ms by
default): engage for the first drive after identification (the drive in force is zero then),
tick for every update after it. Building the law (its constructor) has a long budget, 120 s by
default for a law file, because a law may fit a model of the structure there; each update has the
call budget, a quarter of the update by default. A law file's host deadlines are the same numbers.
What it is built with. Fixed for the run:
| Field | Meaning |
|---|---|
controls, drives, limits |
1 to 16 control channels, 1 to 8 drives, 0 to 8 limit channels |
fs-hz, tick-s |
The sample rate and the control update interval (a whole number of samples) |
band-lo-hz, band-hi-hz |
The band the run sweeps, steps or dwells in, inside the Nyquist frequency |
test-type, shape |
The kind of test, and the controls against the drives |
drive-ceiling-v |
Each drive's ceiling, volts peak |
identification |
On its own ascending grid: the response of every control to every drive (controls by drives on every line, EU peak per volt peak), the same for the limit channels, each channel's multiple coherence, and the lines the controller trusts |
identification-level-db |
The level the identification was taken at, dB against full level: the largest, over the controls, of its measured response peak over the reference's; not finite when it was not measured |
reference |
Every control's full-level reference on the grid, complex, EU peak; phase-specified false means only the amplitudes are the test and the law chooses the phases |
limit-bounds |
Each limit channel's bound on the grid, absent where it has none |
tolerance |
Each control's alarm and abort bands below and above the reference on the grid, dB |
tracking |
The tracking filter's bandwidth: a share of the frequency capped in Hz, or fixed in Hz |
tracker-delay-factor |
The tracker's group delay times its bandwidth: a tracked amplitude lags its response by this over the bandwidth tracking gives. The controller's trackers state 0.625 (four one-pole sections); a setup that states none is read as 1 / pi (two sections) |
transport-delay-s |
The delay between a drive and its tracked reading that the identification does not show, seconds: the identification has the drive-to-response lag taken out, and the loop still waits that long for every answer. The built-in laws add it, with the tracker's delay and the structure's group delay, to the time the loop-speed rule divides the tick by |
params |
Every declared parameter, checked against the manifest, defaults filled in |
A channel's tracked amplitude C_c reads Re{ C_c exp(j phi(t)) }: the response's phase minus
the tone's, the negative-exponent convention of random-mimo, so a linear structure in steady
state gives C = H D with H the identification. A matrix stack travels in full, row-major within
a line, line after line; a list per channel and line is channel after channel. The SDK gives a Rust
law plain values (Setup, Inputs) with a MatrixStack and complex numbers, and the built-in
laws' mathematics (sine_mimo::math).
What it sees each update. The update index, the time since the last call, the frequency, the
sweep rate in Hz per second and in octaves per minute (signed, 0 at a dwell, a step or a hold), the
scheduled level as a fraction of full level, every control's reference at this frequency and level,
every control's and limit channel's tracked amplitude, each limit channel's bound here, the drive
in force as it was played after every guard, why the controller holds the drive (free, notch,
held, probe, or engage for the settle window after engage), the notch's scale, and whether a
settle window is open. The notch's scale is the share of the reference the controller judges the
controls against while the backstop notch is in (1 when it is out); a law aims for the reference
times it, so it does not push against the notch and its drive follows the notch out as the scale
comes back up (at no more than the setup's release rate, once the limit channels allow more than
its hysteresis).
What it returns. One finite complex amplitude per drive, in volts peak at the scheduled level: the controller does not rescale it. Its own judgement that it is faulted (shown and recorded, never relied on). Up to eight values, each under a key its manifest declares. Optionally a request to hold the sweep or slow it by a factor above 0 and at most 1 (recorded always; honoured only when the run allows requests, within its bounds). Optionally a notched reference, one per control, lower than the reference, which the controller accepts only when a limit channel is near its bound or the notch is releasing.
What the host refuses, each by name, each a miss with the drive in force held: not one drive
per drive (wrong_drive_count); a drive, a value, a request's factor or a notched reference value
that is not finite (non_finite); a slow request's factor not above 0 and at most 1
(bad_request); a notched reference that is not one value per control (wrong_reference_count);
more than eight values (too_many_values); a value the manifest does not declare or reported twice
(undeclared_value). A trap, a call past its budget or memory past the cap leave the instance
unusable, and every later call reports that first fault. The setup and each update's inputs are
checked against the limits and lengths above before the law sees them. A drive over its ceiling is
not refused: the controller scales the whole drive vector.
What the controller enforces, for every law. The answer checks and the miss rule (three in a row take the controlled stop); the call budget; a cap on each drive's change in dB per update and on its rise in dB per second; a rotation cap per update, off by default, with the largest rotation asked for recorded; a divergence stop when a cap binds without a break for a second; a bound on the first drive; the whole drive vector scaled down, its direction kept, for the limit channels and for a drive over its ceiling; the alarm and abort bands per control outside settle windows; the limit aborts; and the kinematic and shaker checks per shaker. The law is told the drive in force every update and must rebase on it. When the level moves, the controller carries the drive: the level the law is told follows the scheduled level at no more per update than the change and rise caps allow, and the drive in force is scaled by the same ratio before the law is called, so the law is told the scaled drive. A law that keeps readings or drives of its own scales them by the ratio of the level it is told.
The built-in laws. matrix (the default), paired (the contributor's template),
steepest_descent, secant and ratio. Each runs natively and as a law file
(laws/mimo-sine-matrix, laws/mimo-sine-paired, laws/mimo-sine-steepest-descent,
laws/mimo-sine-secant, laws/mimo-sine-ratio) from the same mathematics and the same
declaration. On the same inputs over whole recorded runs (sweeps on square, tall and wide
structures, dwells and stepped sines) the law file gives the native law's drives within rounding
(1e-12 of the update's largest drive), except matrix with its modal model, whose fit is an
iterative search that the platforms' rounding moves by up to about 1e-7 of the drive. Their
parameters, the test types they accept and their limits are in docs/control-laws.md.
The check. Not built yet. It will run each law through whole runs on the simulator's standard structures (slow and fast sweeps, close modes, a near-singular frequency, measurement noise, a level ladder, a limit channel, a transport delay, more controls than drives, more drives than controls), with requirements stated before any law is run, and it will gate a law file's arming on hardware as in every other world.