# When does a result agree with a reference?

Channel: release; package: 2.2.0; source: 084b5032b7d014f12b65b4b947cf61a840970bf4

Page: https://remilab.ai/rfx/check/agreement/
Source: https://github.com/bk-squared/rfx/blob/084b5032b7d014f12b65b4b947cf61a840970bf4/docs/public/check/agreement.mdx

rfx is an open-source simulator with basic feature support, not production
software. Whether a result agrees with a reference is decided by terms stated
in advance, not by how small a residual can be made. rfx judges its own
cross-solver cases on these terms, and you can judge your results on them too.

## The terms

A comparison of an rfx result with a reference (a closed form, a measurement or
another solver) agrees when all of these hold:

1. **The mesh has converged.** The result was computed on at least three
   meshes and the trend is stated. A comparison on a mesh that has not been
   shown to converge says nothing either way: it is neither agreement nor a
   defect. See [Is the mesh fine enough?](https://remilab.ai/rfx/check/mesh-convergence/).
2. **The trend over frequency agrees.** The curve's shape against the
   reference — where its features are and how they move — agrees across the
   band. A single frequency, a band maximum or a band mean does not decide it.
3. **Power and magnitude within 2 dB** of the reference, compared after the
   frequency axis is scaled so the judged feature lines up with the
   reference's (the frequency error is judged by item 4). Bins where either
   curve is below −20 dB (a deep null) are judged by position only.
4. **Frequencies within 1 %**: resonances, cutoffs, notches and nulls. A
   band edge defined by where a curve crosses a level (a −3 dB corner) is
   judged by the 2 dB magnitude term instead: its frequency may move as far as
   2 dB along the reference curve's own slope there.
5. **Group delay within 1 %**: the least-squares slope of the unwrapped
   transmission phase against frequency, over the bins where |S21| is above
   −20 dB (for a one-port, the reflection phase). On a dispersionless line this
   equals the electrical length βl; on a microstrip or a waveguide the two
   differ, and these terms read the group delay. The phase at a single frequency
   is not judged.
6. **Narrow features also against their bandwidth.** For a resonance, passband
   or notch whose fractional bandwidth is 5 % or less, the frequency error must
   also be within 10 % of the reference's bandwidth. For a filter with a 2 %
   bandwidth that means within 0.2 %, because 1 % of the centre frequency is
   half the passband.
7. **One number does not decide it.** A statement of agreement or disagreement
   names the curve, the mesh statement and the reference together.

The same applies to the checks you make on your own run: whether the
[simulation time](https://remilab.ai/rfx/check/simulation-time/) is long enough, or the mesh
fine enough, is read from how the result moves over at least three run lengths
or meshes, and whether it moves the way the physics predicts.

A result within these terms that converges with the mesh is not a defect. Some
structures cannot be judged this way because of what they are: a high-Q
resonance, a deep null, a phase-only comparison, or a reference that is itself
good to only a few percent. State that, and the criterion you used instead.

## Where the terms are in code

Items 1, 3, 4 and 5 are written in code, so a check cannot move the terms it is
judged by. Items 2, 6 and 7 are applied by the person reading the comparison;
no check implements them yet.

- `tests/crossval/_v2_judging.py` holds the frequency limit (1 %), the magnitude
  limit (2 dB), the deep-null level (−20 dB), the level-crossing rule, and the
  mesh statement: the last two meshes agree within 1 %, and every step larger
  than 0.1 % moves the same way. It judges two or more meshes; the terms ask
  you to state the trend over three.
- `tests/_electrical_length.py` holds the group-delay limit (1 %) and its −20 dB
  level.
- The cross-solver cases under `tests/crossval/` compare rfx with frozen
  reference data from another solver on these terms.

## How to read an accuracy statement

Pages on this site state accuracy one line at a time: the statement, its
[status](https://remilab.ai/rfx/support/) and the file in the repository that checks it, or the
published paper it is taken from. A number with neither is not printed. A clean preflight or a run that completes
does not move a feature's status.

## See also

- [Is the mesh fine enough?](https://remilab.ai/rfx/check/mesh-convergence/) and
  [Is the run long enough?](https://remilab.ai/rfx/check/simulation-time/): the two checks a
  converged result needs.
- [Support](https://remilab.ai/rfx/support/): the status of each feature.
- [Validation](https://remilab.ai/rfx/validation/): how rfx itself is checked.
