Calculation of AC losses in stacks and coils made of second generation high temperature superconducting tapes for large scale applications