Photoacoustic detection of phase transitions