A multi-factorial mathematical model for the selection of electropolishing parameters with a view to reducing the environmental impact

Electrochemical metal processing is a process that generates harmful pollution. An important goal often disregarded by researchers is not only the achievement of the best possible quality of electropolished surface, but also minimising the load of metal ions in the wastewater generated in the process. The conducted experiments on the electropolishing of stainless steel in laboratory conditions, varied time, temperature and current density conditions, as well as process bath contamination (ranging from 0 to 6% Fe mass) allowed us to develop a multi-factorial mathematical model. This model offers the possibility of being able to select the process parameters recommended for achieving the desired effects. It takes into account such surface quality parameters as roughness and gloss, process duration and current density that determine power consumption, as well as the weight loss of the electropolished element that influence the rate of contamination in processing baths and wastewater. The study presents the composition of a passive film of stainless steel after the electropolishing process at the initial and final stages of the process bath’s exploitation. The results obtained from XPS tests were then correlated with the results of corrosion tests and resistance to pitting corrosion in the environment of 0.1 M NaCl.

Gloss tests. The Rhopoint IQ goniophotometer was used for gloss tests. The device enables gloss finish measurements at angles of 20/60/85°. Following the manufacturer's recommendations, 20° angle gloss for high gloss finishes was used as the main measurement parameter. Six measurements from one side were taken for each sample.
XPS surface analyses. The XPS analyses were performed using a PHI 5000 VersaProbe spectrometer (ULVAC-PHI) based on the procedures developed at the Institute of Physical Chemistry, Polish Academy of Sciences 29,30 . The spectrometer was equipped with a monochromatic Al Kα radiation (hv = 1486.6 eV) X-ray source operating at 100 µm spot size, 25 W, and 15 kV. The high-resolution (HR) XPS spectra were performed with the hemispherical analyzer. The pass energy was 117.4 and the energy step size was 0.1 eV. The X-ray beam was incident at the sample surface at an angle of 45° with respect to the surface normal, and the analyzer axis was located at 45° with respect to the surface. The Shirley background and a Gaussian peak shape with 30% Lorentzian character were used to conduct deconvolution of all HR XPS spectra. Characteristic sensitivity factors for X-ray monochromatic source were used to estimate the quantitative chemical composition of the investigated samples (MultiPak or Thermo database). The thickness of the passive film was determined using an Ar + ion beam, energy 500 V, time 0.5 min at a rate of 1.37 nm/min, which was calibrated by measuring the sputtering depth per minute in a standard specimen (SiO 2 ).
Corrosion tests. The corrosion tests were taken in 0.1 M NaCl solution at a temperature of 25 °C, applying a thermostated glass cell with a volume of 1000 cm 3 . Tests were performed with the use of Solartron SI 1287 potentiostat manufactured by AMETEK. Potentiodynamic tests were conducted in a tri-electrode setup. A saturated calomel electrode (SCE) as a reference electrode, a platinum plate that served as an auxiliary electrode, and a steel working electrode were all used. A potential sweep rate of 1 mV/s was applied for the potentiodynamic experiments. The surface area of the working 304 stainless steel electrode samples exposed to the electrolyte was 1 cm 2 . Potentiodynamic measurements were conducted after the open circuit potential test. The obtained data from the corrosion tests samples were analyzed using the dedicated CorrView software. ICP tests. The collected EP bath samples were investigated for their metal contents using the ICP-OES method. ICP-OES (inductively coupled plasma-optical emission spectroscopy) tests were conducted using the Thermo Scientific iCAP 7000 Series ICP-OES apparatus. Qtegra Intelligent Scientific Data Solution software was used for data processing.
Statistical methods. Prediction of gloss and roughness measurements using several variants of regression analysis was performed. Variables included in the analysis were the length of process, temperature, current density, and bath contamination.
As far as roughness analysis was concerned, all possible configurations of interactions between parameters were tested for several types of models, including the square model, third-and fourth-order models, and the logistic model. Due to the fact that the authors had noticed certain local anomalies that did not correspond to the specificity of the analysed process, and in order to eliminate the overfitting phenomenon that could have reduced the effectiveness of the model were actual data to be used, the analysis of roughness was performed using the linear model with a squared component of time. Its high variability relative to the number of time points rendered a higher order of function as nonviable. The model was constructed for a level of pollutants at up to 4% given that the number of defects affecting roughness was very high. Its fit was assessed using R 2 and the Akaike information criterion.
To analyse the gloss levels, the authors used a nonlinear logistic growth model which is commonly used in modelling population growth as given by the Eq. (1). Its S-like curve and upper limit fitted the overall behaviour of data points: To account for a logistic model starting in 0 gloss units, the outcome of the model needs to be shifted by 200 gloss units. In the case of Solution A and because of huge differences in behaviour based on the contamination level, we opted to split the model into two separate functions, depending on whether the contamination levels were lower than 4% or higher than 4% (or equal). Using a single model yielded a significantly lower fit. As for Solution B, there was no significant drawback for using a single model. The literature suggests that using R 2 to assess the fit of a nonlinear model is incorrect, since the total variance of a non-linear model is not equal to the sum of explained variance and error variance. The evaluation of R 2 is an inadequate measure for nonlinear models in pharmacological and biochemical research. Because of our model's nonlinear nature, its fit was assessed based on the RMSE (root-mean-squared-error) of the fitted model.

Results and discussion
Roughness and gloss measurements. Due to the large surface area of the electropolished elements, it is often impossible to achieve high current density values in industrial conditions. Additionally, it may lead to the overheating of elements while surface defects may emerge in areas of very intense oxygen emission on the anode. At this stage of studies on the exploitation of processing baths, the authors decided to limit the analysed current densities to 4 and 8 A/dm 2 . This selection was based on the fact that those process parameters are used in industrial conditions. An issue that is quite often disregarded in studies on electropolishing is the change in weight loss and gloss of the electropolished elements with the increasing time of operation of the bath. The values of the obtained surface gloss (GU) in relation to weight loss (mg) are presented in Fig. 1. Such a presentation should enable a relatively simple and swift comparison of the results for samples of the same exposed surface area. As presented in the diagrams, the obtained results fall within a range of 0-4.5 GU/mg. Each of the diagrams shows 28 measurement points for the current density of 4 and 8 A/dm 2 . Values, for which the surface gloss exceeded 800 GU, are marked by filled markers. In most cases, the gloss obtained in Solution A at 35 °C, both at 4 A/ dm 2 and 8 A/dm 2 , exceeded 1000 GU, while the contamination with iron ions ranged from 0 to 4. At a 3-4% contamination, a local extreme is noticeable as well as the best gloss to the weight loss ratio for 8 A/dm 2 , 15 min, at a temperature of 35 °C, and a 4% contamination with iron ions. However, a surface gloss exceeding 800 GU was not obtained for this result. At a temperature of 55 °C the relation is similar, but a 5% contamination of the bath results in a deteriorated surface quality. For 8 A/dm 2 , 55 °C, and 15 min, within a contamination range of 0-4%, the sample's value of the gloss to weight loss ratio is 1.25 GU/mg. A high level of this ratio is obtained at 4 A/dm 2 , 15 min, 55 °C, and a contamination of 2%. Solution B lost its quality fairly quickly. The results at lower temperatures were comparable, whereas for higher temperatures they were several times worse. The experimental data served as a basis for generating diagrams (Fig. 2) that represent the relation between the weight loss of 304 steel to the electric load of the analysed baths. The increasing bath contamination is accompanied by a decreasing weight loss. In the initial phase of the electropolishing process, the weight loss increases according to Faraday's equation, i.e. proportionally. As the electric load Amin increases, the bath composition www.nature.com/scientificreports/ changes while the values of weight loss begin to diverge from those that may be calculated from a linear proportion. The application of organic additives to process baths allows for reducing weight losses in comparison to baths without any additives 31 . The weight loss after the electropolishing process in Solution B, which contained triethanolamine, was lower than that in Solution A which did not contain this additive. With the increasing time of bath exploitation, this difference became higher. In order to achieve the same final total level of weight loss of samples for both baths, Solution B had to be operated for over 1200 A min longer, which accounted for nearly 30% of the total operation time. The weight loss analyses in laboratory conditions produced very similar results to those obtained in industrial conditions using the same process bath 32 . Thus, it is possible to predict the expected weight loss in industrial conditions, even for electropolished elements of a much larger surface area.

XPS analysis.
The chemical composition of the sample surface was analysed with the use of XPS tests. Those studies describe the composition of passive films obtained after electropolishing in baths with various amounts of contaminants-0% and 6% Fe by mass. The chemical compositions (at%) of the analysed samples' surface before and after sputtering with Ar + ions are presented, respectively, in Tables 1 and 2. The forms (Cr 0 , Ni 0 , Fe 0 ) were not taken into account in calculations of the passive film content. Table 1 presents the XPS results of the chemical composition of the surface before sputtering with Ar + ions. CrN has energy bonds between 575.1 and 575.4 eV, while the range of energy bond CrN as presented in the literature is 575.6 eV 33 . The formation of PO 4 2− , SO 4 2− with Cr(III) and Fe (II) species at the electropolished surface samples is possible 34 . The phosphorus in the metallurgical composition of 304 stainless steel may be oxidized at the surface during the electropolishing process 18 . The deconvolutions conducted for O1s, P2p, and S2p confirm the presence of phosphates and sulphates on the surface of the electropolished samples.  www.nature.com/scientificreports/   (Table 2). Other studies have outlined iron XPS peaks in the range of Fe 2+ oxides (FeO) between 709 and 709.6, Fe 3+ oxides (Fe 2 O 3 ) between 710.5 and 711.5 eV 35,36 , and FeOOH between 711.0 and 711.8 eV 37,38 .
As shown in Fig. 3 40 . The Ni signal appears for the 304 samples after sputtering with Ar + (Table 2) and the signals were quite low. XPS peaks are from Ni 2+ oxide (NiO) 853.6-853.8 eV and Ni 3+ oxide (Ni 2 O 3 ) 854.6-855.6 eV. Sometimes the nickel oxide and nickel oxide hydroxide contents are so small that in some studies they were not even detected in the passive film of stainless steel 42 . According to other publications, Ni 2+ oxide (NiO) is 854.3 eV 43 , Ni 3+ is 855.6 eV 44 , and hydroxide Ni(OH) 2 is 857.9 eV 45 . Figure 4 shows the atomic depth profiles (in %) of Fe, Cr, Ni, and O in the passive films. The content of Fe is higher than that of Cr. After cleaning the surface with Ar + ions, we received a higher content of chromium and reduced the content of nickel (< 4 nm), while the zone was enriched with nickel content (< 4 nm) and the bulk 46 . After sputtering with Ar + , the content of free oxygen was lower than on the top of the surface sample. The procedure of sample cleansing after the electropolishing process, consisting in three stages of rinsing in distilled water and 20 min of cleansing in an ultrasonic bath, did not guarantee the total removal of contaminants (sulphates and phosphates) from the surface of the steel processed in Solution B Fe-6% , even though it was sufficient for the other samples.
The changes in the surface composition of stainless steel, which are observed by analyzing the deconvolution and depth profiles, are related to the reactions taking place during the electropolishing process. The components of the steel dissolve on the anode upon which, with the appropriate oxygen and current density, oxygen gas is released simultaneously with hydrogen on the cathode. The mechanism of the electrochemical polishing process has been presented in previous studies 47 . The process of water particles' diffusion and the migration of anions towards the anode is a result of the simultaneous formation of an oxide layer and a diffusion layer. They enable the simultaneous electrochemical formation and chemical dissolution of the passive oxide layers. Due to the uneven structure of the electropolished surface, the obtained layer has a variable thickness. In the peak areas, the rate of chemical reactions is faster due to the easier access of water particles and anions, which reduces the thickness of the oxide layer, while in the indentations the process is slower, resulting in a thicker layer. The difference in the rate of migration and diffusion of acceptors of the dissolution process springs from the competitiveness of formation and dissolution of the oxides. As a result, even small changes in the rate of these processes have a considerable impact on the dissolution rate of unevenness on the anode surface and its final smoothing. Marcus et al. 48 used STM images for high resolution surface analysis to investigate at small time and length scales the nucleation and growth mechanisms of the surface oxide on a model stainless steel. The described process takes place in several stages. On the initial oxide-free surface, the process of Cr(III) oxide nucleation takes place. Cr atoms present at each atomic edge are consumed and remoted, leaving behind vacancies in the top layer. Due to the formation of vacancies, the chromium from the lower layers is shifted while regions depleted in Cr are rearranged. This process takes place first at the terrace borders, while away from the step edges delayed Cr(III) oxide nucleation takes place. Iron oxidation can take place in regions where all initially presented chromium is oxidized. This leads to the formation of local centers of iron oxides, which differ in structure and morphology from chromium oxide rich nuclei. The increased amount of chromium in the passive layer has a positive effect on corrosion resistance. Based on the XPS measurements, the total Cr/ Fe ratio in the surface film formed, concerning the different compositions of electrochemical polishing baths, has been calculated ( Table 3). For samples as received, this value was 0.75-0.86. The highest chromium-to-iron ratio of 1.88 was observed on the sample polished in solution A Fe0% . Other samples had a similar level of the Cr/Fe ratio of about 1.4. Oxide film formed on the sample surfaces after EP was characterized by a significantly higher atomic Cr/Fe ratio in comparison to the samples untreated "as received" with naturally-grown passive oxide film (Table 3). A similar increase can be seen in the work of Lee and Lai 49 who observed that the Cr/Fe ratio increased from 0.97 to 2.58 after EP 316L stainless-steel.
Corrosion test results. Samples for corrosion tests were electropolished in baths in the initial phase of exploitation A Fe0% , B Fe0% , and after a period of intensive exploitation A Fe6% , B Fe6% . Process parameters: time 15 min, current density 8 A/dm 2 , and temperature 55 °C. Potentiodynamic tests were conducted in a tri-electrode setup: at a temperature of 25 °C ± 1°, in a solution of 0.1 M NaCl, and at a scanning rate of 1 mV/s. Raw samples were characterised by a lower value of pitting potential (Epit: 0.42-0.55 V SCE ) than the samples after electrochemical processing (Fig. 5). The highest values of pitting potential Epit were obtained in samples after electropolishing in Solution A Fe0% , where the median for ten measurements was 0.68 V SCE . The application of the same bath, although after a long-term exploitation Solution A Fe6% led to a deterioration of the results, was manifested in the form of a median of 0.56 V SCE for this series. As far as the bath with an addition of triethanolamine was concerned, similar results were obtained both for the bath at the initial stage (Solution B Fe0% ) and after a long exploitation (Solution B Fe6% ). For both the analysed baths, it was noted that for baths after long exploitation, the Epit values within a single series were highly varied, and their range was significantly larger than for samples from the series tested in baths at the initial stage of exploitation. This might confirm the unevenness of surface and potential defects that may emerge in baths with a high concentration of metal (mainly iron) ions. The obtained results allow us to conclude that the process of electropolishing 304 stainless steel samples contributes to the increase in pitting potential and improves resistance to corrosion. The results of the corrosion tests and XPS analyses of the chemical composition of the passive film correspond to those presented in the work mechanism In all cases of the analyzed electropolishing solutions, a better composition of the passive layer was obtained than for the as-received sample, which is related to the process mechanism and enrichment of this layer with chromium. Even intensive and long-term exploitation of the process bath in the range of up to 6% Fe, although it significantly worsens the quality of surface smoothing, has a positive effect on its corrosion resistance.
However, the passive layer on the surface of electropolished samples is highly resistant, especially in the case of environments containing chlorides, where it is susceptible to damage. Marcus et al. 50 have presented a model of passivity breakdown that takes into account the nanostructure of the oxide layer. In the case of electrolyte containing chlorine, Cl − ions compete with OH − ions, which in turn increases the dissolution rate and inhibits the growth of the passive film. This leads to a faster thinning of the passive layer and the depassivation of less resistant places. Taking into account the composition of the passive layer and the results of corrosion resistance, electropolishing of 304 steel in an electrolyte consisting mainly of sulphuric (VI) acid and phosphoric (V) acid allows for better results compared to untreated surfaces. This dependence was observed both in the case of the baths at the initial stage of exploitation without contaminants and after long-term exploitation, when the amount of contaminants increases significantly. Due to the assessment of the obtained surface in terms of the expected visual result of electropolishing, the mathematical model makes it possible to determine the level of bath contamination for which these effects can be achieved, as well as when it may become impossible. However, even using a contaminated electrolyte that resulted in a surface of unsatisfactory gloss and roughness still gave rise to a surface with better corrosion resistance than the untreated sample.
Mathematical model. The experimental input data concerning roughness and gloss were the basis for creating logistic and square models for Solution A and Solution B, respectively. Detailed characteristics of model parameters are presented in an electronic supplementary in Tables S1 and Tables S2. Then, for the analysed ranges of parameters (i = 4-8 A/dm 2 , T = 35-55 °C, t = 0-45 min, %Fe = 0-5), the results were generated with temperature steps of 1 °C, for 1 min time intervals, current density at a step of 1 A/dm 2 , and contamination at a step of 1% Fe. For each of these points, the models made it possible to calculate the values that determine surface quality, i.e. roughness and gloss, as well as the weight loss per surface area unit. Solution B was characterised by higher values for RMSE and R 2 , respectively for gloss and roughness models, than for Solution A.
Gloss models were prepared based on the logistic function (see electronic Supplementary Table S1). Due to the fact that the results for Solution A differed significantly, the authors decided to divide them into groups corresponding to contamination from 0% to less than 4% and from 4 to 5%, inclusively. This enabled improving the RMSE value in the respective ranges. The model developed for Solution B was based on the whole data range for contamination from 0 to 5%, inclusively. As far as the gloss models were concerned, 28,980 results were generated for each of the baths. For Solution A, the degree of process bath contamination up to the level of 4% Fe had only a marginal influence on the electropolishing results obtained. After this threshold is exceeded, the time required to obtain satisfactory surface gloss results becomes longer. As for temperature, its influence was stronger in the lower ranges of the applied temperatures. For baths at the initial stage of exploitation, with contamination already reaching approx. 2% Fe, the application of either high temperature and low current density or low temperature combined with high current density led to similar results. It was noted that higher current www.nature.com/scientificreports/ density values are more stable as contamination increases, such that they can bring positive results even if the Fe concentration exceeds 4%. The results of tests on samples electropolished in Solution B demonstrated that the negative influence of contamination on the obtained gloss result increased much faster, which was particularly noticeable in higher temperatures. The application of a temperature of 55 °C and low current density resulted in a significant deterioration of gloss already at a degree of contamination of 1% Fe, while for higher current densities similar results were obtained even at a contamination of 3% Fe. The model takes into account so many variables and dependencies between them that presenting it in a readable graphic form required simplification. A simplified visualization (Fig. 6) of the gloss model, made on the basis of values obtained for the averaged conditions of temperature and current density, makes it possible to observe general trends and differences between the tested solutions. In the case of Solution A, similar results were obtained in the range of 0-3% Fe, before a slight deterioration for 4% Fe was observed, followed by a sudden decrease in the value of the obtained gloss in the final stage of bath exploitation. In the case of Solution B, changes in the obtained gloss values depending on the contamination of the bath are more uniform. There are no sudden jumps, but only a slow decrease in surface quality with the operating time and increasing contamination.
Roughness models were constructed based on the square functions for time. The basis for both models, i.e. for Solution A and Solution B, was the range of contamination data from 0 to 4%, inclusively. As far as roughness is concerned, the variability of test results was relatively high compared to differences caused by the influence of variable process parameters. Due to the specificity of surfaces obtained in the electropolishing process and roughness measurements, even the measurement results of the sample are characterised by a high variability, resulting in a high variance of the roughness model. For the roughness models, 24,150 results were generated for each of the baths. Roughness always decreased with the prolongation of the process regardless of other parameters. This was true for both baths. For Solution A, the current density was more important for the description of the dynamics of changes. For lower current density values, a significant decrease in roughness was achieved after approx. 15 min, while for higher densities the process was visible from the very beginning which started to slow down gradually after approx. 30 min. These changes were more dynamic for higher bath contamination at lower current density. For Solution B, the course of this process was similar except for a combination of low temperature and high current density, wherein a monotonous increase in roughness was noted for the contamination level exceeding 2%. The lowest roughness values were obtained for a combination of high temperature and high current density.
The latter has a decidedly stronger influence on the increase in weight loss than temperature. Additionally, it is strongly linked to contamination. For all the analysed measurement series, the application of low current densities resulted in lower weight loss values. The weight loss increased with growing current density. The lowest weight loss was noted for the combination of low temperatures and low current densities. For higher current densities, at the initial stage of bath exploitation (up to approx. 3% Fe), the contamination did not have a significant influence on changes in the samples' weight loss. However, as the exploitation time increases, these changes start to grow exponentially, such that at 6% contamination the weight loss was lower by half than the value for the low contamination level. Table 4 presents ten roughness and gloss results generated by means of the created model for each of the analysed baths. The selected results meet the adopted criterion of the obtained surface's satisfactory quality (gloss above 800 GU and roughness lower than 140 nm), while at the same time attempting to achieve the lowest weight loss possible. The application of such values in the process of selecting the optimum criteria takes into account both the need to obtain a sufficiently glossy and smooth surface and the need to minimise the contamination of the bath with metal ions. For Solution A, the main factor that determined the selection of parameters was weight loss. Due to the fact that gloss and roughness results were similar and satisfactory in the bath contamination range from 0 to 4%, meeting the boundary conditions (Ra < 140 nm, gloss > 800 GU) posed no real challenge. As the process of anodic dissolution slowed down with an increasing bath contamination, in the next stage which considered the need to maintain the lowest weight loss among the obtained results, all the selected values corresponded to a 4% contamination. As for Solution B with good gloss and roughness results in the contamination range from 0 to 2% Fe, the operational efficiency of the bath deteriorated. The obtained results worsened as contamination increased. As a result, the key element in choosing the optimum parameters www.nature.com/scientificreports/ for Solution B was the need to meet the adopted boundary conditions. The generated sets of optimum parameters fluctuated within the low temperature range 35-37 °C and highest analysed current density of 8 A/dm 2 . Ensuring a sufficiently high gloss and low roughness in these cases would be possible using baths at the initial stage of exploitation 0-1% Fe, while the samples' low weight loss may be achieved by shortening the duration of the process. The suggested optimum electropolishing time was 16-19 min. Another parameter worth considering when selecting the optimum parameters is the electric load per unit expressed in A min/cm 2 . This parameter directly influences the energy consumption of the process. Minimising the A min/cm 2 value allows for reducing the power consumption, which is an important aspect in terms of environmental protection.

Conclusion
Based on laboratory tests of electropolishing steel in variable time, temperature, current density and bath contamination conditions, the authors have created a multi-factorial mathematical model. The ranges of analysed parameters were selected based on the specificity of the process in industrial conditions and related limitations, e.g. the possibility to apply only low current densities due to the fairly large surface area of electropolished details. The presented mathematical model enables generating results within the range selected by the user. Depending on the expected result and requirements, the model also makes it possible to select the values of parameters that influence them. As such, the authors have selected the values of parameters that allowed them to achieve satisfactory surface quality (roughness Ra < 0.14 and gloss above 800 GU), while at the same time maintaining the lowest weight loss possible. Minimising the weight loss of electropolished details is an important issue related to the electropolishing process, as it directly influences the amount of contaminants that emerge during the process. These conditions were fulfilled for both Solution A and Solution B when high current density of 8 A/dm 2 and low temperatures in the range of approx. 35-40 °C were used. The duration of the process necessary to obtain satisfactory results in all cases ranged from 15 to 19 min. However, the selected ranges of bath contamination differed significantly. For Solution A, boundary conditions were met by individual values throughout the analysed contamination range, but those with the lowest weight loss fell within the range of 3-4% Fe. For Solution B, points that met the boundary conditions were observed in the bath contamination range of 0-3% Fe, whereas those with the lowest weight loss fell within the range of 0-1% Fe. This difference stems from the diverse working characteristics of the applied baths during their exploitation.
XPS analyses of samples electropolished in Solution A and Solution B were conducted both at the initial and final stage of exploitation. The highest value of the Fe/Cr ratio (1.88) was noted for Solution A Fe=0% . These results were also reflected in the pitting corrosion resistance tests, where the application of Solution A Fe=0% resulted in the highest median values of Epit = 0.69 V SCE among all the analysed samples. The other variants were characterised by similar Fe/Cr ratios of approx. 1.4 V SCE and a median Epit value in the range of 0.56-0.61 V SCE . Table 4. List of the best results that meet the set objectives (Ra < 140 nm, gloss > 800 GU, Δm tending to a minimum value) generated based on the models.