A Phenomenological Theory of Ferroelectric and Antiferroelectric Liquid Crystals Based on a Discrete Model