  Open cavities are often an essential component in the design of ultra-thin
subwavelength metasurfaces and a typical requirement is that cavities have
precise, often low frequency, resonances whilst simultaneously being physically
compact. To aid this design challenge we develop a methodology to allow
isospectral twinning of reference cavities with either smaller or larger ones,
enforcing their spectra to coincide so that open resonators are identical in
terms of their complex eigenfrequencies. For open systems the spectrum is not
purely discrete and real, and we pay special attention to the accurate twinning
of leaky modes associated with complex valued eigenfrequencies with an
imaginary part orders of magnitude lower than the real part. We further
consider twinning of 2D gratings, and model these with Floquet-Bloch conditions
along one direction and perfectly matched layers in the other one; complex
eigenfrequencies of special interest are located in the vicinity of the
positive real line and further depend upon the Bloch wavenumber. The
isospectral behaviour is illustrated, and quantified, throughout by numerical
simulation using finite element analysis.
