An application of catastrophe theory to the closed and open macroeconomy