1 Introduction

The deep square hole in the equipment manufacturing industry is widely used. For example, in the aviation industry, the slender shaft is a key part of the high-speed rotation of aircraft engines and typical thin-walled shaped hole parts, its internal square blind hole has been a difficult processing process, due to the special mechanical properties of the square hole, in a variety of instrumentation also has a very wide range of applications [1]. In weaponry, electromagnetic rail launch technology has great potential advantages and broad application prospects in both military and civilian fields, among which the processing of square electromagnetic rail gun tubes is a key technology for electromagnetic rail gun equipment [2]. In the mechanical structure, there are a large number of parts that need to be machined square holes, square holes in a variety of practical mechanical engineering applications have an irreplaceable role, it has a large transmission torque, good guidance, and other characteristics is a key part of the structural design and assembly to play a positioning anti-rotation [3]. However, machining a square hole in an engineering material is a more complicated process compared to a round hole, especially when machining an impassable square hole, which is time-consuming and labour-intensive. Traditional mechanical processing methods are difficult or even impossible to process, and there are problems such as poor surface quality, difficulty controlling straightness, high cutting stress, and easy tool wear during the processing of square deep holes. Wire-cutting and EDM, although the processing accuracy is high, after processing the surface produces a recast layer, the surface quality is not high. The processing speed is slow, high cost, and wire-cutting requires manual threading, there are positioning errors [4]. Electrochemical machining technology has the advantages of no loss of cathode, wide machining range, high machining accuracy, and no cutting stress, which is widely used in processing shaped deep holes [5].

Over the years, many scholars at home and abroad have done numerous explorations and research on the electrochemical processing of shapes in deep holes, among which the design of the cathode structure has been a difficult point for the electrochemical processing of shapes deep holes [6, 7]. Wang et al. to improve the consistency of deep and narrow grooves in electrochemical processing of TB6 titanium alloy, the design and experimental study of a sheet cathode was carried out, and the uniformity of the cathode exit flow rate was significantly improved by changing the geometry of the reinforcement bars [8]. Xu et al. designed cathodes with different numbers of spiral outlets, different rotation angles and different tapers of the manifold according to the structural characteristics of the stepped bore, and successfully processed the stepped bore to meet the requirements [9]. Tang et al. the cathode profile was investigated and the cathode structure was optimised to solve the problem of uneven gap distribution and flow pattern in complex parts with multi-stage internal tapered holes in electrochemical machining [10].

The shaped deep-hole electrochemical processing is affected by several physical fields such as electrolyte field and flow field [11], and the physical field characteristics in electrochemical processing are explored by the method of finite element simulation to predict the workpiece forming [12,13,14], which can shorten the cathode development cycle and greatly reduce the design and manufacturing cost. Klink et al. verified this phenomenon by simulation of the susceptibility to cavitation near the narrow openings of the machining gap [15]. Li et al. used coupled multi-physical field simulation and experimental observation to investigate the electrochemical forming mechanism of cooling holes and to obtain the gas–liquid two-phase distribution pattern in the machining gap [16]. Lin et al. developed a three-dimensional multi-physical field coupling model using a single cross-cross slot to obtain the bubble rate, temperature and current density distributions at process equilibrium [17]. Wang et al. investigation of the influence of electrolyte flow mode, tool cathode structure and electrolyte parameters on the flow field distribution based on numerical analysis to improve the uniformity of electrolyte flow rate distribution at the entrance [18]. Yang et al. studied the distribution state of deep helical holes with a gradual slotted flow field in the machining gap by establishing a mathematical and geometric model of the flow field in the electrochemical machining gap, which led to a secondary improvement of the structure [19]. Demirtas et al. proposed a simplified mathematical model for the difficult problem of electrochemical processing of free-form surfaces with high curvature and used the finite element method (FEM) for solving the three-dimensional Laplace equation and determining the potential distribution between the anode and cathode surfaces to accurately obtain the cathode surface profile [20]. Chai et al. developed and analysed the flow paths of a geometric model of the interstitial flow field based on CFD simulations of the electrolyte flow state and determined the effect of the flow pattern on the accuracy and stability of the cooled hole-making process [21].

However, in electrochemical processing of deep profiled holes, the large difference in removal margin at different locations is very likely to cause uneven gap distribution, which in turn affects the moulding accuracy. In this paper, we propose a bi-directional liquid supply two-section square cone combination cathode, through the simulation of electrochemical processing gap flow field and electric field simulation, to achieve the optimization of cathode liquid supply structure and profile, and finally use different processing parameters for process experiments and analysis of experimental results, to realize the efficient and stable processing of square deep holes, the processed parts meet the design accuracy requirements, effectively shorten the cathode development cycle and save costs.

2 Experimental preparation

2.1 Experimental system

Electrochemical machining is a method of machining parts into shape by removing excess material from the workpiece using the anodic dissolution reaction of the metal in the electrolyte. The schematic diagram of the experimental setup for electrochemical machining of square deep holes is shown in Fig. 1. The workpiece is connected to the positive pole of the power supply and the tool is connected to the negative pole of the power supply during processing. The metal of the anode workpiece is gradually etched away. The cathode produces bubbles, and the electrolysis products are carried away by the electrolyte until the processing is completed.

Fig. 1
figure 1

Schematic diagram of the principle of the experimental system

2.2 Cathode material selection

The choice of cathode material requires corrosion resistance, good electrical conductivity, and easy processing and repair; the commonly used materials are stainless steel, brass, copper, etc. Among them, brass has good electrical conductivity, high strength, and hardness, and the cathode has the advantage of resistance to repair.

2.3 Analysis of anode material properties and electrochemical reaction principles

The workpiece material is 40CrNiMoV alloy, and the workpiece blank is a bar with a prefabricated hole of R13.5 mm in the centre.

40CrNiMoV steel is further developed based on 40CrNiMo steel with ultra-hardenability alloy steel, and the specific chemical composition and content as shown in Table 1.

Table 1 40CrNiMoV chemical composition and content (%)

As can be seen from Table 1, the content of Si and Mn is less than 2%, which is mainly used as a deoxidizer and reducing agent in the refining process of 40CrNiMoV alloy steel. With the highest Ni content, the addition of Ni can effectively improve the low-temperature properties of the steel, while improving wear resistance and fatigue resistance. The addition of Cr increases the strength and hardness of the steel. Mo improves the mechanical properties of the steel, ensuring sufficient strength and creep resistance while increasing hardenability. The addition of element V enables the steel to obtain excellent overall performance even under slow cooling conditions, and the compound formed by V and C improves the resistance to hydrogen corrosion at high temperatures and pressure.

40CrNiMoV alloy steel during electrochemical machining, in addition to the metal Fe, the small amount of metal contained in it also participates in the electrode reaction. During the electrochemical machining of the NaCl electrolyte, an ionization reaction will occur after electricity is applied, NaCl will be dissociated into Na+ and Cl, and H2O will be dissociated into H+ and OH. Fe and a small amount of Cr, Mn, Ni, Mo, and V on the surface of the anode will release electrons under the action of current and change to Fe2+, Fe3+, Cr3+, Ni2+, Mn2+, and V2+. After reviewing the data, the above ion standard electrode potentials are shown in Table 2. According to the principle of electrode reaction, the smaller the electrode potential, the more electrochemical reaction occurs first, in which the reaction order of each metal ion is: Mn2+ > V2+ > Cr3+ > Fe2+ > Ni2+ > Mo3+. Since the content of V is very small and the Mo electrode potential is high, the reaction mainly occurs between Mn, Cr, Fe, and Ni metal ions and OH to produce MnO(OH)2, Cr(OH)3, Fe(OH)2, Fe(OH)2 and Ni(OH)2 insoluble precipitates.

Table 2 Ion standard electrode potential

3 Cathode design

3.1 Analysis of research subject

Machining a square deep hole has the characteristics of long depth, uneven machining allowance, thick metal layer removed, and high requirement of finish, and it is technically difficult to machine this deep square hole from the perspective of the electrochemical machining process. Due to a large amount of material removal during the forming process of the square deep hole, there is a huge difference in the amount of residual at each place in the same cross-section, as shown in Fig. 2, the amount of residual removed at the diagonal is large, and the amount of residual removed at the long side is small, and the difference in the amount of residual between the two is as much as 2 times. The non-uniformity of the machining margin leads to the non-linear change of the flow field and the electric field during the machining process, which is difficult to control.

Fig. 2
figure 2

Machining allowance diagram

This paper proposes a two-section square cone combined cathode processing method. The front square cone cathode processes the 27 mm diameter prefabricated round holes to a 28 mm * 28 mm square hole; the rear square cone cathode expands the 28 mm * 28 mm square hole to a 32 mm * 32 mm square hole, as shown in Fig. 3.

Fig. 3
figure 3

Schematic diagram of the two-section square cone combined cathode processing method

3.2 Cathode structure design

The cathode structure is different from the design of rifling and spline cathodes with equal machining section allowance because of the long machining time of square deep hole and uneven machining section allowance. In this paper, a bi-directional liquid supply two-section square cone combination cathode as shown in Fig. 4 is used, which is machined and formed at one time, and the balance clearance is taken as 0.5 mm. The external part of the cathode includes the cathode body, front guide device, middle guide device, rear guide device, front nut, rear screw cover, seal ring, and insulating layer, and the internal part of the cathode includes the return bushing and liquid separator.

Fig. 4
figure 4

Schematic diagram of the cathode structure

3.3 Design of cathode liquid supply method

The electrolyte flows from the hollow tie rod into the internal flow channel of the cathode body, and the liquid separator the electrolyte to the liquid supply hole located in the middle guide device to flow out, respectively, in two directions: part of the electrolyte is discharged from the rear guide device, and part of the electrolyte flows into the internal flow channel of the liquid separator through the front guide device return bushing to be discharged, as shown in Fig. 5. This two-way parallel flow makes the elimination of anode dissolution products and temperature very different from the structure of a unidirectional liquid supply. The distribution pattern is bounded by the supply hole in the middle guide device and distributed in both directions so that the air bubbles and anode dissolution products generated by the rough processing of the front square cone cathode no longer pass through the rear square cone cathode finishing area, and the supply to the rear square cone cathode finishing area is a lower temperature and clean electrolyte, as shown in Fig. 6.

Fig. 5
figure 5

Schematic diagram of electrolyte flow form

Fig. 6
figure 6

Schematic diagram of bi-directional liquid supply electrolysis product

4 Modeling

4.1 Geometric model

4.1.1 Geometric model of the gap flow field

The gap flow field model is filled with an electrolyte between the tool cathode and the workpiece and fixture during machining, and the flow field calculation area can be derived from the workpiece and the tool cathode and fixture of the Boolean operation, as shown in Fig. 7.

Fig. 7
figure 7

Schematic diagram of the flow field of the gap

4.1.2 Geometric model of gap electric field

The electric field distribution affects the etching effect of the workpiece during the electrolysis process, and a reasonable electric field distribution can ensure the dimensional accuracy of the machined workpiece. The rear square cone cathode determines the forming accuracy of the deep square hole after processing. To explore the electric field distribution of the deep square hole electrochemical processing, 1/4 of the end face of the rear square cone cathode is intercepted to establish the gap electric field model, as shown in Fig. 8. Among them, Г1, Г5 is the cathode straight edge, Г2, Г4 is the cathode chamfer, Г3 is the cathode four corners at the straight edge; Г10, Г6 is the processed anode straight edge, Г9, Г7 is the processed anode rounded corner, Г8 is the processed anode four corners at the straight edge. Г1, Г2, Г3, Г4, Г5 grounded, Г10, Г9, Г8, Г7, Г6 applied voltage 15 V, Г11, Г12 applied symmetric boundary conditions.

Fig. 8
figure 8

Schematic diagram of the electric field model of the gap

4.2 Mathematical model

4.2.1 Flow field model

In the electrochemical processing, the processing gap is nonlinearly varying and easily affected by several factors such as electrolyte flow, current density, temperature, etc. The following assumptions are made for the gap flow field: the fluid is incompressible and constantly Newtonian fluid; the fluid is constrained by mass conservation and momentum conservation.

The flow patterns of electrolytes are laminar and turbulent, and the Reynolds number \({R}_{e}\) is used as a criterion for determination, with \({R}_{e}>\) 2300 being turbulent and \({R}_{e}<\) 2300 being laminated. Reynolds number, \({R}_{e}=\frac{V{D}_{h}}{v}\), V is the electrolyte flow rate, \({D}_{h}\) is the hydraulic diameter, and v is the electrolyte viscosity coefficient. In this simulation, the inlet flow velocity is 15 m/s. The outlet pressure is atmospheric, the electrolyte is selected as a 5% NaCl solution by a mass fraction, and the electrolyte parameters are shown in Table 3, where the hydraulic diameter \({D}_{h}\)= 8 mm. The calculated Reynolds number \({R}_{e}>\) 2300, so the flow pattern is turbulent.

Table 3 Electrolyte parameters

Incompressible fluids satisfy the Navier–Stokes equation [22].

$$\rho \frac{dV}{dt}=\uprho \mathbf{g}-\nabla {p}+\upmu {\nabla }^{2}V$$
$$\nabla \cdot V=\frac{\partial u}{\partial x}+\frac{\partial v}{\partial y}+\frac{\partial \omega }{\partial z}=0$$

In the formula: \(\rho\) is the fluid density; \(u\) is the component of the vector velocity in the x-direction; \(p\) is the fluid microcircular pressure value; \(\mu\) is the dynamic viscosity; g is the acceleration of gravity; \(\nabla\) is the gradient operator; \({\nabla }^{2}\) is the Laplace operator; \(\nabla \cdot V\) is the volume expansion rate.

Without considering the effect of gravity, the standard \(k-\varepsilon\) model is used, the standard \(k-\varepsilon\) mathematical model:

$$\frac{\partial (\rho K)}{\partial t}+\frac{\partial (\rho K{u}_{i})}{\partial {x}_{i}}=\frac{\partial }{\partial {x}_{j}}\left[\left(\mu +\frac{{\mu }_{i}}{{\sigma }_{k}}\right)\frac{\partial K}{\partial {x}_{i}}\right]+{G}_{k}-\rho \varepsilon$$
$$\frac{\partial (\rho \varepsilon )}{\partial t}+\frac{\partial (\rho \varepsilon {u}_{i})}{\partial {x}_{i}}=\frac{\partial }{\partial {x}_{j}}\left[\left(\mu +\frac{{\mu }_{i}}{{\sigma }_{\varepsilon }}\right)\frac{\partial \varepsilon }{\partial {x}_{j}}\right]+\frac{{C}_{C1}}{K}{G}_{k}-{C}_{c2}\rho \frac{{\varepsilon }^{2}}{K}$$
$${G}_{k}=\rho {C}_{\mu }\frac{{K}^{2}}{\varepsilon }\left[\frac{\partial {u}_{i}}{\partial {u}_{j}}+\frac{\partial {u}_{j}}{\partial {x}_{i}}\right]\frac{\partial {u}_{i}}{\partial {x}_{i}}$$

In the formula: \({\mu }_{i}\) is the turbulent viscosity; \({G}_{k}\) is the average velocity gradient caused by the turbulence \(k\) generation term; \(\varepsilon\) is the turbulent dissipation rate, the constant value is taken in Table 4.

Table 4 Values of constant terms

4.2.2 Electric field model

The electrochemical machining applied power source is connected to the cathode and anode with conductive wires and maintains a constant current, but the added power source is located outside the studied gap electric field, so the electric field in the electrochemical processing gap covered in this section is treated as the electric field in the passive conductive point medium. Before the electric field simulation, it is necessary to assume that the electrolyte flow is isotropic and that the process has entered the state of equilibrium processing when the electric field parameters do not change with time, and the gap electric field is a steady current field.

According to the basic theory of electric field, it is known that the distribution of electric field conforms to Laplace’s equation.

$${\nabla }^{2}\varnothing =0$$
$$\frac{{\partial }^{2}\varnothing }{\partial {x}^{2}}+\frac{{\partial }^{2}\varnothing }{\partial {y}^{2}}+\frac{{\partial }^{2}\varnothing }{\partial {z}^{2}}=0$$

Anode surface boundary conditions:

$$\left\{\begin{array}{c}{\varnothing }_{a}=U\\ \frac{\partial \varnothing }{\partial n}=\frac{{\mu }_{0}}{\mu }\frac{{i}_{0}}{k}cos\theta \end{array}\right.$$

Cathode surface boundary conditions:

$${\varnothing }_{c}=0$$

In the formula: \(\varnothing\) is the potential at each point of the electric field; \(U\) is the anode surface potential; \(n\) is the anode surface normal to coordinate; \(\theta\) is the angle between the feed rate and the anode surface normal. The material parameters are shown in Table 5.

Table 5 Materials and properties

4.3 Simulation parameter conditions

Simulation parameter conditions are set as shown in Table 6. To show the flow characteristics of the electrolyte in the gap more intuitively, the simulation results of the flow field in the front square cone cathode region and the rear square cone cathode region in the gap flow field model are extracted and displayed as shown in Fig. 9.

Table 6 Simulation parameters
Fig. 9
figure 9

Schematic diagram of the front square cone cathode and rear square cone cathode gap flow field area

5 Simulation results analysis and discussion

5.1 Gap flow field simulation results

From Fig. 10, it can be seen that the difference between the electrolyte flow rate and pressure in the gap area between the front square cone cathode and the rear square cone cathode processing is large, and this phenomenon is produced because the electrolyte discharge process in the front square cone cathode processing area is long, and the electrolyte in the gap cannot be discharged quickly, which causes the electrolyte pressure in this area to be large and makes the flow rate lower. The electrolyte flow velocity in the rear square cone cathode processing area is distributed from 12.7 to 21.6 m/s, showing high electrolyte flow velocity in the four corners processing area and low electrolyte flow velocity in the straight edge processing area. The electrolyte flow rate distribution in the front square cone cathode processing area is 1.6–14 m/s, and the electrolyte flow rate in the front square cone cathode processing area is low overall, and there are areas with a flow rate of less than 5 m/s. In the actual processing, the electrolyte flow rate of less than 5 m/s in the gap is prone to passivation, which causes the anode dissolution products and temperature cannot be discharged in time, thus affecting the stability of the processing process and processing accuracy. Therefore, the flow rate of electrolytes in the gap should be greater than 5 m/s.

Fig. 10
figure 10

Flow rate and pressure distribution of electrolyte in the machining gap of front square cone cathode and rear square cone cathode

5.2 Optimization of cathode liquid supply structure

Given the above analysis and discussion results, the front square cone cathode processing area has a large variety of removal residuals, the gap flow field is not uniform, and the overall flow rate is low, which makes the workpiece anode dissolution products and heat cannot be discharged in time, therefore, the cathode liquid supply structure should be optimized. Four different cathode supply structures are designed, as shown in Figure 11, structure 1 is 8 holes of 3mm diameter with a 45° interval angle; structure 2 adds 16 additional holes of 1.5mm diameter with a 20° slope in the direction of the front square cone cathode based on the original supply structure, with 22.5°interval angle; structure 3 adds 16 holes of 1.5mm diameter in the direction of the front square cone cathode based on structure 1. Structure 3, based on structure 1, adds 16 liquid-boosting holes with a diameter of 1.5mm and a slope of 20°in the direction of the front square cone cathode, and the interval angle of the liquid-boosting holes is 22.5°; structure 4 sets 2 groups of 16 liquid-boosting holes with a diameter of 1.5mm and a slope of 20°in the direction of the front square cone cathode, and the interval angle of the liquid-boosting holes is 22.5°. Simulation of the flow field of the above four liquid supply structures was carried out, and the simulation results are shown in Figure 12.

Fig. 11
figure 11

Four different structures for providing electrolyte

Fig. 12
figure 12

Electrolyte flow rate distribution in the processing area for four different structures of front square cone cathode and rear square cone cathode

As can be seen from Fig. 12, electrolyte supply form using structure 1, the minimum flow rate of electrolyte in the front square cone cathode processing area is raised to 6.6 m/s, and the minimum flow rate of electrolyte in the rear square cone cathode processing area is 17.2 m/s, meeting the minimum flow rate of electrolyte. In electrolyte supply form using structure 2, the minimum electrolyte flow rate is increased to 5.7 m/s in the front square cone cathode processing area, and the minimum electrolyte flow rate is 16.3 m/s at the rear cathode, which also meets the minimum electrolyte flow rate requirement. Electrolyte supply form using structure 3, the minimum electrolyte flow rate in the front square cone cathode processing area is reduced to 0.95 m/s, the minimum electrolyte flow rate in the rear square cone cathode processing area is 10.5 m/s, and the flow rate of electrolyte in the whole front square cone cathode processing area is less than 5 m/s, which does not meet the minimum electrolyte flow rate requirement. Electrolyte supply form using structure 4, the minimum electrolyte flow rate in the front square cone cathode processing area is raised to 7.4 m/s, and the minimum electrolyte flow rate in the rear square cone cathode processing area is 14.6 m/s, meeting the minimum electrolyte flow rate requirement. In summary, except for structure 3, the remaining three structures were able to improve the electrolyte flow rate in the front square cone cathode processing area, and the overall flow rate was greater than 5 m/s. To investigate the uniformity of electrolyte flow rate in the gap, two cutoff lines at the inlet and outlet of electrolyte in the processing area between the front square cone cathode and the rear square cone cathode, and the distribution of electrolyte flow rate on the cutoff line is shown in Fig. 13.

Fig. 13
figure 13

Distribution of electrolyte inlet and outlet flow rates in the front square cone cathode processing gap area

As can be seen from Fig. 13, the cutoff line 1 is at the entrance of the electrolyte in the front square cone cathode processing area, electrolyte supply form using structure 3, the electrolyte flow velocity distribution is poorly symmetrical, and the electrolyte in the gap interferes with each other in the flow process, and the flow field is in an unstable and uneven state. Electrolyte supply form using structure 2 and electrolyte supply form using structure 4, symmetry of electrolyte flow rate distribution and good flow uniformity in the processing gap. Moreover, the overall electrolyte flow rate in the gap of structure 4 is higher than 14 m/s, while the flow rates of structure 1 and structure 2 in the middle of the cutoff line are relatively low, indicating that the use of structure 4 can provide electrolyte with higher flow rate and better uniformity to the front square cone cathode processing area. The cutoff line 2 is the electrolyte outlet in the front square cone cathode processing area, and the electrolyte flow velocity distribution in the gap area of structures 1, 2, and 4 is uniform and smooth, with no obvious fluctuation changes and no turbulence and cavitation. In electrolyte supply form using structure 4, the average electrolyte flow rate in the gap is the largest, and the electrolyte flow rate is higher at the four corners processing position compared with structure 1 and structure 2. Therefore, electrolyte supply form using structure 4 has the most significant effect on improving the electrolyte flow rate distribution in the front square cone cathode processing area.

As can be seen from Fig. 14, the cutoff line 3 is the electrolyte inlet at the rear square cone cathode processing area, and the electrolyte flow rate in the processing gap area of structures 1, 2, and 4 is above 14 m/s, the overall flow rate is high. In electrolyte supply form using structure 2, the symmetry of electrolyte flow rate distribution is relatively poor, indicating that the uniformity of electrolyte flow is poor in the rear square cone cathode processing area. The symmetry of electrolyte flow rate distribution within the gap of the liquid supply structure 1 and liquid supply structure 4 is relatively good, and the uniformity of electrolyte flow in the rear square cone cathode processing area is good. The symmetry of electrolyte flow rate distribution within the gap using structure 1 and structure 4 is relatively good, and the uniformity of electrolyte flow in the rear square cone cathode processing area is good. Cutoff line 4 is at the exit of the electrolyte in the rear square cone cathode processing area, since the rear guide device is the same size as the rear square cone cathode end face, it avoids the confusion of electrolyte flow rate due to the sudden decrease of pressure in the gap, and the electrolyte flow velocity was higher in the rear square cone cathode compared to the front square cone cathode processing area. In summary, electrolyte supply form using structure 4 can greatly increase the electrolyte flow rate in the front square cone cathode processing area and significantly improve the uniformity of the flow field.

Fig. 14
figure 14

Distribution of electrolyte inlet and outlet flow rates in the rear square cone cathode processing gap area

5.3 Electric field simulation analysis of rear square cone cathode processing gap

In electrochemical machining, the current density is a very important index, and the current density distribution affects the workpiece anode etching speed, machining accuracy, and surface quality. The electric field model of the rear square cone cathode machining gap was established, and the results of potential and current density simulation of a machining voltage of 15 V are shown in Fig. 15.

Fig. 15
figure 15

Potential and current density distribution of the rear square cone cathode processing gap

As can be seen from Fig. 15, the magnitude of the potential gradually decreases from the workpiece anode to the tool cathode, and the current density is evenly distributed at the straight edge of the square hole, but the current density increases at the cathode surface and decreases at the anode surface at the rounded corners. As can be seen from Fig. 16, the current density at the straight edge of the anode surface is 34.8 A/cm2, while the current density at the rounded corners decreases to 29 A/cm2, and the change in current density at the anode surface reaches 9.4 A/cm2, which makes the rounded corners slow in etching during processing and easily causes the rounded corners to be too small after processing, which does not meet the accuracy requirements and requires structural optimization and shaping of the rounded corners of the cathode.

Fig. 16
figure 16

Workpiece anode surface current density

Firstly, the clearance at the four corner arcs is reduced to 0.4 mm, and this clearance is the balance clearance there. With the help of the formula of \(cos\theta\) method: \(\Delta =\frac{\Delta y}{cos\theta }\), the clearance value corresponding to each data point is calculated, where \(\Delta\) is the clearance at each point, \(\Delta y\) is the balance clearance, \(\theta\) is the angle between the normal at any point of the workpiece and the feed direction of the tool cathode. \(\theta\) is taken in the range of 0–34°, and a coordinate point is taken on every 2° interval near the middle, and a coordinate point is taken on every 5° interval near the outer side. To make the circular arc with both sides of the straight edge round and smooth transition, two coordinate points are taken at the two straight edges respectively, and the coordinate points after processing, as shown in Fig. 17. The simulation of the electric field model of the gap after the repair is carried out, and the simulation results are shown in Fig. 18.

Fig. 17
figure 17

Comparison of the rounded curve before and after shaping

Fig. 18
figure 18

Potential and current density distribution of the machined gap after rear square cone cathode profile trimming

As can be observed in Fig. 19, the magnitude of the potential has not changed, and the current density at the four corners of the workpiece anode after shaping has increased significantly compared with the unshaped one, and the distribution is more uniform. The current density distribution on the anode surface after shaping ranges from 33.7 to 35.4 A/cm2 and the current density variation is reduced to 1.7 A/cm2, which is a significant improvement compared with the unshaped current density variation of 9.4 A/cm2. Therefore, the cos\theta method is used to realize the shaping of the cathode surface structure, which significantly improves the shaping accuracy of the deep square hole.

Fig. 19
figure 19

Comparison of current density distribution on the anode surface of workpiece before and after shaping

6 Experimental

6.1 Experimental design

To obtain the best combination of machining process parameters and improve the machining accuracy, the experiment was conducted on a horizontal electrochemical machining machine, and a 15% NaCl solution was selected as the electrolyte, and the experimental conditions were shown in Table 7. The orthogonal table L16(45) was selected to design a 4-factor, 4-level experimental, as shown in Table 8, and the two process objectives of the square deep hole bore machining result size and surface roughness were optimized by using grey correlation analysis to achieve the best matching and optimal combination of machining parameters.

Table 7 Experimental conditions
Table 8 Table of factor levels

6.2 Measurement equipment and measurement methods

After the experiment, the two process targets of square hole size and surface roughness were measured, and the measuring instruments used were trilinear coordinates measuring instrument and white light interferometer, as shown in Fig. 20.

Fig. 20
figure 20

Diagram of the measuring instrument

Trilinear coordinates measuring instrument X-axis measurement range ≥ 400 mm, Y-axis measurement range ≥ 500 mm, Z-axis measurement range ≥ 400 mm, resolution of 0.1 μm, device type select global state. The coordinates of the square hole contour of the section at 10 mm, 20 mm, and 30 mm from the end face of the workpiece were measured by the Trilinear coordinates measuring instrument as shown in Fig. 21, and the average value of the measured square hole coordinates of the three sections was calculated as the final square hole size.

Fig. 21
figure 21

Schematic diagram of square hole profile coordinate measurement

$$\delta =\frac{{\sum }_{i=1}^{3}{\delta }_{i}}{3}$$

The white light interferometer can be used for 3D surface inspection and surface roughness inspection. The 10X Mirau lens is used for the measurement, and the vertical scanning range is 847 μm × 847 μm, and the movement range of the lens is 160 mm × 160 mm, with vertical resolution up to 0.01 nm. Take two sampling lines at 10 mm and 20 mm from the end face to form 3 sampling areas, measure the surface roughness of the three sampling areas respectively, as shown in Fig. 22, and take the average value of the measured surface roughness of the 3 sampling areas as the final surface roughness value.

Fig. 22
figure 22

Schematic diagram for measuring the surface roughness of the inner wall of a square hole

$$Ra=\frac{\sum_{i=1}^{3}{Ra}_{i}}{3}$$

6.3 Experimental results

The experiment was conducted in 16 groups of parameter combinations, and each group of parameter combinations was averaged four times, and the experimental results are shown in Table 9.

Table 9 Experimental results

6.4 Preferred machining process parameters based on grey correlation analysis

The grey correlation analysis method is based on the degree of similarity or dissimilarity of development trends between factors. Electrochemical machining involves several process parameters such as process voltage, inlet flow rate, duty cycle, and feed rate. In the multi-objective parameter optimization, the grey correlation method has the advantages of not requiring too many samples, not requiring a typical distribution law, and having a relatively small amount of computation, which is more adaptable to the high cost and long processing cycle required for electrochemical machining. It has a high practical value in actual production. As a method of measuring the degree of association between factors, the best combination of processing parameters is preferred with the help of the magnitude of grey correlation. The steps for calculating the grey correlation degree are as follows.

  1. 1.

    Determination of reference data

The reference data is a set of ideal comparison criteria, which can be constituted by the optimal value of each indicator parameter data, or other reference values can be selected according to the purpose of the reviewer. Notated as \({x}_{0}(1),{x}_{0}(2),\cdots ,{x}_{0}(n)\). Therefore, the reference data of square hole size for this experiment is chosen as the design standard of 32 mm, and the reference data of surface roughness are chosen as the optimal value of 1.26 μm after processing for each experimental.

  1. 2.

    Data dimensionless processing

The main methods of dimensionless processing are initialization and homogenization, and there is no difference between the two methods for calculating the grey correlation dimensionless processing of the data, so the initialization method is chosen for processing.

Initialization: The data of the sequence are divided uniformly by the very first value (reference data). Since the magnitude of the sequences of the same factor does not differ much, the values can all be sorted out to around the magnitude of 1 by dividing them by the initial value.

$${x}_{i}(k)=\frac{{x}_{i}(k)}{{x}_{i}(1)} , k=\mathrm{1,2},\cdots ,n\;;\;i=\mathrm{0,1},2,\cdots ,m$$
  1. 3.

    Calculate the absolute value, maximum value and minimum value of the difference between the indicator data and the reference data of each evaluated object

    $$\left|{\widehat{x}}_{0}(k)-{\widehat{x}}_{i}(k)\right| , k=\mathrm{1,2},\cdots ,m ; i=\mathrm{1,2},\cdots ,n$$
    $$min=min(i) min(k)\left|{\widehat{x}}_{0}(k)-{\widehat{x}}_{i}(k)\right|$$
    $$max=max(i) max(k)\left|{\widehat{x}}_{0}(k)-{\widehat{x}}_{i}(k)\right|$$
  1. 4.

    Calculation of correlation coefficient

    $${\epsilon }_{i}(k)=\frac{min+\rho max}{\left|{\widehat{x}}_{0}(k)-{\widehat{x}}_{i}(k)\right|+\rho max}$$

In the formula, \(\rho\) is the resolution factor, usually taken as 0.5.

5. Relevance calculation

The mean values of the correlation coefficients between each index of each evaluation object and the corresponding elements of the reference series are calculated separately for each evaluation object to reflect the correlation between each evaluation index object and the reference series.

$${r}_{i}=\frac{1}{m}\sum_{k=1}^{m}{\epsilon }_{i}(k)$$

The results of the grey correlation analysis are shown in Table 10, and the grey correlation values of each group of parameters are shown in Fig. 23.

Table 10 Grey correlation analysis data
Fig. 23
figure 23

Grey correlation values for 16 groups of trials

As can be seen from Fig. 23, among the 16 groups of orthogonal experimental results, the grey correlation value calculated for the 16th group of parameters is the largest, and the effect of this group of parameters on the target is the most significant, and the optimal combination of parameters is obtained: machining voltage 17 V, duty cycle 55%, inlet flow rate 20 m/s, feed rate 0.4 mm/min, and the square deep-hole product part section after machining with this combination of parameters is shown in Fig. 21. The slice of the square deep-hole product machined with this combination of parameters is shown in Fig. 24, which meets the machining requirements.

Fig. 24
figure 24

Slice of the square hole after machining

7 Conclusion

This paper solves the problem of electrochemical machining of deep square holes, designs a bi-directional liquid supply two-section square cone combination cathode, establishes a gap flow field and electric field model for simulation analysis, and carries out structural optimization of the liquid supply structure and cathode type surface, and optimizes the machining process parameters through the grey correlation method, and draws the following conclusions.

  1. 1.

    Adopt the bi-directional liquid supply two-section square cone combination cathode structure, which makes the temperature distribution of electrolyte flowing through the front and rear square cone cathodes more uniform.

  2. 2.

    The optimized cathode structure adopts two rows of 16 liquid booster holes with 1.5 mm diameter, 20° slope, and 22.5° interval, which can significantly increase the electrolyte flow rate in the front square cone cathode processing area; the \(cos\theta\) method is used to realize the shaping of the cathode structure, and the minimum current density of the anode surface at the four corner arcs is reduced from 9.4 to 1.7 A/cm2 compared with that on the straight side. The minimum current density on the surface of the anode at the four corner arcs was reduced from 9.4 to 1.7 A/cm2 compared with the straight side.

  3. 3.

    Through the grey correlation method analysis, the machining process parameters were reasonably matched and optimally combined. Under machining process parameters of machining voltage 17 V, duty cycle 55%, an inlet flow rate of 20 m/s, and feed rate 0.4 mm/min, the machined parts meet the product production requirements.