Heterocyclic corrosion inhibitors for acid environments