## 3 Results
It  
Figure 3: Numerical comparison of Genetic Algorithm for different LC-based simple systems. (**a**) Twist angle distribution \(\theta(z)\) at various applied voltages for a PA-LCoS. (**b**) Twist angle distribution \(\phi(z)\) at various applied voltages for a TN-LCoS. is worth noting that the director vector is constrained in the \(xz\) at the surfaces; however, for vertical gratings, the director twists angle forces \(y\) components of the director angle. This out-of-plane phenomenon has important considerations regarding diffraction efficiency and polarisation [7]. The mean absolute errors of our method for the previously presented horizontal grating and the vertical grating, computed as mean absolute differences between \(\theta\) and reference \(\theta_{\text{FO}}\) (related to the application of the Euler-Lagrange equations for minimising the Frank-Oseen functional in Equation (2)) and \(\phi\) and reference \(\phi_{\text{FO}}\) for six different pixel voltages are shown in Table 1. It is worth mentioning that the errors for the tilt angle (\(\theta\)) are larger than those obtained for the twist angle (\(\phi\)) since, in this device, the director distribution tends to be aligned towards the electric field through the twist angle (as shown in Figure 4c,d). The twist angle, and hence the out-of-plane component, is almost absent in the horizontal grating (Figure 4e). In contrast, a significant out-of-plane distribution arises in vertical gratings (Figure 4f). Considering the tilt and twist angle behaviour for the different cases analysed, it can be stated that the error between the GA and the theoretical distribution of the director in LC is almost negligible, as can be qualitatively corroborated in Figure 4 and quantitatively in Table 1. Hence, the error values shown in Table 1 demonstrate the performance and reliability of our scheme. The higher errors  
Figure 4: Numerical calculations for a 2-pixel period binary grating of 4 μm. The external voltage applied to the electrode is 2.8 V on the top (\(z=l_{\text{LC}}\)) and the ground electrode is in the bottom (\(z=0\)). (**a,b**) represent the phase response computed by Equation (12) in [8] for horizontal (grating in \(x\)-direction) and vertical (grating in \(y\)-direction) gratings, respectively. (**c–f**) represents the visualisation of the distribution of the voltage \(\Phi\) (colour map) and the director orientation **n** (blue lines): (**c**) \(\hat{K}=\hat{x}\), \(y=2\) μm and \(xz\)-plane. (**d**) \(\hat{K}=\hat{y}\), \(x=2\) μm and \(yz\)-plane. (**e**) \(\hat{K}=\hat{x}\), \(x=2\) μm and \(yz\)-plane. (**f**) \(\hat{K}=\hat{y}\), \(x=2\) μm and \(xz\)-plane. observed in the \(\theta\) as observed in Table 1 are likely due to FO free energy function being generally less sensitive to variations in the tilt direction compared to the twist direction, at least for these configurations leading the genetic algorithm to produce large errors when optimizing this variable. This discrepancy thus likely stems from the inherent nature of the FO function and the approximation-based optimization process, which tends to perform better in directions with steeper functional variations. Regarding simulation time and computational performance, both the GA-PCA-based method and the Euler-Lagrange minimisation of the Frank-Oseen functional were fully implemented in MATLAB and executed on a computer with the following specifications: Intel(r) Core(tm) i7 13700, 16 GB RAM DDR4-3200 MHz, and 512 GB PCIe NVMe. It is worth noting that the GA algorithm proposed here is currently slower than the Euler-Lagrange method. The GA-PCA-based method is in a seminal stage, whereas the Euler-Lagrange solution takes advantage of MATLAB capabilities in handling matrix operations. Under these conditions, the GA-PCA needs 146.5 s/iteration, achieving good accuracy (see Table 1) after ten iterations. The Euler-Lagrange method takes 34.7 s on average in its running time simulations for the considered convergence criteria (variations in the output smaller than \(10^{-4}\)).