Optimization of electrocoagulation technology of purifying wastewaters of ions of heavy metals