Application of catastrophe theory to phase transitions of trapped particles