Inverse photopyroelectric detection of phase transitions