A model for calculating the AC losses of second-generation high temperature superconductor pancake coils