## Materials and Methods
### Optimization of the Stimulation Parameters  
The stimulation parameters, i.e., the electrode length \(h_{\mathrm{el}}\) and the stimulation voltage \(\varphi_{\mathrm{stim}}\) need to be optimized to achieve the best possible electric stimulation in the ROI. In this context, a goal function is defined concerning the volume of beneficially stimulated tissue in the ROI. Here, _beneficially stimulated_ means that in the considered region the following applies:  
\[5\,\mathrm{V}/\mathrm{m}\leq|\underline{\mathbf{E}}|\leq 70\,\mathrm{V}/ \mathrm{m}\,, \tag{6}\]  
whereas overstimulation would correspond to \(|\underline{\mathbf{E}}|>70\,\mathrm{V}/\mathrm{m}\) and understimulation would imply \(|\underline{\mathbf{E}}|<5\,\mathrm{V}/\mathrm{m}\). For optimizing the stimulation parameters for a most beneficial electric field distribution, the objective is a maximum volume of beneficially stimulated tissue in the ROI. At the same time,  
Figure 3: Boundary conditions applied in the simulation model: We assigned Dirichlet boundary conditions to the surfaces of both electrodes (black), homogeneous Neumann boundary conditions to the surface of the skin (blue), and a floating potential boundary condition to the surface enclosing the defect (red). the volume of overstimulated and understimulated tissue is to be minimized. In the _Optimization module_ of COMSOL these goals are expressed in terms of integral objective functions  
\[s_{\text{ben}}\cdot\int 1-\text{if}(|\mathbf{\underline{E}}|\geq 5\,\text{V}/ \text{m}\,\&\,|\mathbf{\underline{E}}|\leq 70\,\text{V}/\text{m})\,\text{d}V\,, \tag{7}\]  
\[s_{\text{over}}\cdot\int\text{if}(|\mathbf{\underline{E}}|>70\,\text{V}/ \text{m})\,\text{d}V\,, \tag{8}\]  
\[s_{\text{under}}\cdot\int\text{if}(|\mathbf{\underline{E}}|<5\,\text{V}/ \text{m})\,\text{d}V\,. \tag{9}\]  
Simply put, the objective functions represent the volume of beneficially stimulated (7), overstimulated (8), or understimulated (9) tissue and are only computed inside the ROI. The sum of the goal functions (7)-(9) is to be minimized to achieve the best possible stimulation impact. The goal functions are scaled with scale factors \(s_{\text{ben}}=s_{\text{under}}=4\times 10^{-5}\), \(s_{\text{over}}=2\times 10^{-4}\) so that the goal functions are in the order of one. This ensures stability of COMSOL's optimization methods. Because overstimulation is especially harmful as it might lead to tissue damage, goal function (8) is weighed with a higher factor than the other goal functions. We consider the goal functions only in the ROI because at the current application of electro-stimulation we are not interested in an optimal fixation of the electrodes inside the residual bone. In this case, one would also consider the cortical and cancellous bone domains. Instead, we are only interested in how the electric field evolves inside a large volume of tissue to be regenerated. The control variable is the stimulation amplitude \(\varphi_{\text{stim}}\) only, since optimizing both \(h_{\text{el}}\) and \(\varphi_{\text{stim}}\) simultaneously was unfortunately not possible due to the rather complicated model geometry. Instead, the electrode length \(h_{\text{el}}\) was varied parametrically for an exemplary stimulation amplitude of \(1\,\text{V}\). The parameter was varied between \(h_{\text{el}}=10.5\,\text{mm}\) and \(h_{\text{el}}=27\,\text{mm}\) in increments of a few \(\,\text{mm}\) which is admissible for the manufacturing tolerances to be expected. The \"optimal\" electrode length yielded \(h_{\text{el}}=25\,\text{mm}\) (see Section 3.2). This value was then further used during the optimization of the stimulation amplitude \(\varphi_{\text{stim}}\). The stimulation potential applied to the electrodes has been optimized using the _Optimization_ module of COMSOL. For this purpose, the Nelder-Mead-Simplex optimization algorithm [61; 62] was used. We specified an optimality tolerance of \(0.001\), representing the relative accuracy in the final values of the scaled control variables.