First-principles description of magnetovolume instabilities in intermetallic compounds