Mine sweeping comes in two flavours: normal sweeping and scooping. Scooping is selected using the msc friendly code or the Scoop Torpedoes extended mission. Mine sweeping scans all minefields in range, and destroys hostile minefields if possible. Mine scooping, in addition, gathers up torpedoes from a minefield owned by the same player as the ship, and turns it back into torpedoes.

Units_swept =
   Beam_contribution + Fighter_contribution

Beam_contribution =
   Beam_count * Beam_type^2 * Sweep_rate
   ...where Sweep_rate is WebMineSweepRate or MineSweepRate
                     ...if ship has beams, is within range, and field not
                        hidden by ion storm
   0                 ...otherwise

Fighter_contribution =
   Fighter_count * FighterSweepRate
                     ...if ship has bays, and is within FighterSweepRange,
                        and minefield is a normal minefield
                            or ship is owned by colonies and AllowColoniesSweepWebs is enabled
   0                 ...otherwise

Torps_scooped =
   Min(Trunc(Mine_units / Conversion_rate), Free_cargo_room, Mission_limit)
   ...where
      Conversion_rate =
         Trunc(Torp_type^2 * UnitsPerTorpRate[Ship_owner] / 100)

Units_scooped =
   Mine_units        ...if Trunc(MineUnits / Conversion_rate) = Torps_scooped
   Torps_scooped * Conversion_rate
                     ...otherwise

The Units_scooped formula put in other words: If, after scooping the requested number of torpedoes, the equivalent of a fractional torpedo remains (i.e. less than Conversion_rate mine units), the minefield is completely removed.

If the Scoop Torpedoes mission is used, the parameter specifies the maximum number of torpedoes to scoop from each applicable minefield, not the total amount. This is denoted by the Mission_limit variable above. If the regular Mine Sweep mission together with the msc friendly code is used, there is no Mission_limit.

This is a testing version.
It may be incomplete, and have more bugs (or features) than the public live version at planetscentral.com.