SPICE modelling of microwave cavities using a circuit
The answer to this question depends on why you want to model the cavity in SPICE.

A cavity resonator has a very simple equivalent circuit - it's just an LC network. If you're trying to add a cavity filter to a nonlinear simulation (such as a microwave amplifier or oscillator), then this is probably going to be the easiest way with free tools - assume ideal behaviour and model it as an LC circuit.

If you don't need nonlinear simulation (for example, you're doing frontend matching), I would recommend looking at a linear simulation tool like QUCS. The simulation will be much faster as it boils down to essentially just multiplying a bunch of s-matrices.

If, on the other hand, you want to actually model the microwave resonator itself, things get a little trickier. Most EM simulation tools fall under the "not cheap" category. If you want to do it for free, there's only a few options:


emGine (non-commerical use only) is a free finite difference time domain (FDTD) tool, but it hasn't been updated in a while.
OpenEMS is another free FDTD solver, but the frontend is a real pain in the ass to use - there's no geometry builder, so you have to specify all geometry from MATLAB or Octave scripts.
FEKO is an excellent commercial tool which has a free edition limited on mesh size. It does full-field FEM, MoM, and FDTD. The free edition would probably be good enough for a microwave resonator.


In terms of paid software, there really isn't anything cheap. If you're at a university, you might be able to get a cheap academic license for one of the big packages. The "big three" 3D field simulators are ANSYS HFSS, CST Microwave Studio, and Altair FEKO. They all have their pluses and minuses, but for doing a microwave resonator they should all be about equivalent.

All 3D field simulators will give S-parameters. If you're unfamiliar with S-parameters (scattering parameters), they're a set of coefficients which describe the amplitude and phase of inputs and outputs to a multiport network.

S-parameters are defined in the frequency domain, and are easiest to use with a linear simulator (like QUCS).

If you need to do a nonlinear simulation with your S-parameters extracted from the EM simulation, your options are again somewhat limited. SPICE is a time-domain simulation, and S-parameters are defined in the frequency domain. There are tools which can generate approximate SPICE models from S-parameter data, but I don't know if any of them are free.

Alternatively, you could do a nonlinear harmonic balance simulation (faster at microwave frequencies anyway), but I don't think there any free tools that do this. The two "industry standard" tools for this are Agilent ADS (expensive) and AWR Microwave Office (also expensive). If you're a student, though, you can get them for free.

Hope this helps!