  We perform 3D finite element calculations of the fields in microwave cavities
and analyze the distributed cavity phase errors of atomic clocks that they
produce. The fields of cylindrical cavities are treated as an azimuthal Fourier
series. Each of the lowest components produces clock errors with unique
characteristics that must be assessed to establish a clock's accuracy. We
describe the errors and how to evaluate them. We prove that sharp structures in
the cavity do not produce large frequency errors, even at moderately high
powers, provided the atomic density varies slowly. We model the amplitude and
phase imbalances of the feeds. For larger couplings, these can lead to
increased phase errors. We show that phase imbalances produce a novel
distributed cavity phase error that depends on the cavity detuning. We also
design improved cavities by optimizing the geometry and tuning the mode
spectrum so that there are negligible phase variations, allowing this source of
systematic error to be dramatically reduced.
