Thermodynamic considerations in the formation of ergot alkaloids