Temperature-dependent IR and Raman scattering studies of phase transitions in K2MgWO2(PO4)2