A general treatment of losses in multifilamentary superconductors