Generalization of the Maier-Saupe theory to the ferroelectric nematic phase