Protection and security of energy systems from all types of threats, including threats of a complex nature, are of primary importance in Ukraine today. Therefore, the management of technogenic risks in energy systems related to critical infrastructure and, first of all, in thermal energy systems of thermal power plants and thermal power plants, the failure of which can lead to the impossibility of living in the specified territory or object, carrying out economic activities there, loss of life or significant material damage is important and relevant. In order to justify the use of reversible water supply systems of thermal power facilities to increase the reliability and safety of their operation, a generalized algorithm of optimal quality management during water purification was proposed in order to minimize technogenic risk for any water purification system. The analysis of the obtained results showed that the generalized algorithm of optimal quality management during water treatment in order to minimize technogenic risk for any water treatment system can be obtained in the case of using the following methodology: drawing up a structural and functional block diagram of the water treatment system; analysis of technological modes affecting quality; technical and economic analysis of the values that limit the values of the regimes that give minimal pollution; obtaining mathematical expressions that reflect the dependence of the amount of pollution and the amount of restrictions on specific technological modes; entering data into the computerized control system, the input port of which is supplied with the current value of stiffness, at the output of the water treatment plant, from the output port of which the specific values of the technological modes supported by the control bodies of the water treatment plant are taken.