  We use a model of vortex dynamics and collective weak pinning theory to study
the residual dissipation due to trapped magnetic flux in a dirty
superconductor. Using simple estimates, approximate analytical calculations,
and numerical simulations, we make predictions and comparisons with experiments
performed in CERN and Cornell on resonant superconducting radio-frequency NbCu,
doped-Nb and Nb$_3$Sn cavities. We invoke hysteretic losses originating in a
rugged pinning potential landscape to explain the linear behavior of the
sensitivity of the residual resistance to trapped magnetic flux as a function
of the amplitude of the radio-frequency field. Our calculations also predict
and describe the crossover from hysteretic-dominated to viscous-dominated
regimes of dissipation. We propose simple formulas describing power losses and
crossover behavior, which can be used to guide the tuning of material
parameters to optimize cavity performance.
