Enhancing Lambda Measurement in Hydrogen-Fueled SI Engines through Virtual Sensor Implementation

: The automotive industry is increasingly challenged to develop cleaner, more efficient solutions to comply with stringent emission standards. Hydrogen (H 2 )-powered internal combustion engines (ICEs) offer a promising alternative, with the potential to reduce carbon-based emissions and improve efficiency. However, hydrogen combustion presents two main challenges related to the calibration process: emissions control and measurement of the air excess coefficient ( λ ). Traditional lambda sensors struggle with hydrogen’s combustion dynamics, leading to potential inefficiencies and increased pollutant emissions. Consequently, the determination of engine performance could also be compromised. This study explores the feasibility of using machine learning (ML) to replace physical lambda sensors with virtual ones in hydrogen-fueled ICEs. The research was conducted on a single-cylinder spark-ignition (SI) engine, collecting data across a range of air excess coefficients from 1.6 to 3.0. An advanced hybrid model combining long short-term memory (LSTM) networks and convolutional neural networks (CNNs) was developed and fine-tuned to accurately predict the air– fuel ratio; its predictive performance was compared to that obtained with the backpropagation (BP) architecture. The optimal configuration was identified through iterative experimentation, focusing on the neuron count, number of hidden layers, and input variables. The results demonstrate that the LSTM + 1DCNN model successfully converged without overfitting; it also showed better prediction ability in terms of accuracy and robustness when compared with the backpropagation approach.


Introduction
The current regulations and guidelines on pollutant emissions are compelling the automotive industry to develop cleaner and more efficient solutions capable of reducing fuel consumption and emissions derived from internal combustion engines (ICEs) [1,2].Among the options explored, hydrogen (H 2 )-powered alternative propulsion has emerged as promising candidate for the fossil-fuel-free future of mobility [3].Hydrogen is a versatile, clean, and flexible energy source that can integrate renewables into the European grid by storing excess power, providing carbon-free fuel for transportation, replacing natural gas for heating, and supporting industrial feedstocks [4].By 2050, hydrogen deployment could fill half the gap between current technology and the Paris Agreement goals, with Europe aiming for ambitious targets.Up to 2250 TWh of hydrogen could be generated by 2050, requiring 15-40 GW of water electrolysis capacity by 2030 to produce renewable hydrogen at less than EUR 3 per kg [5,6].In a 2050 scenario, fuel cell electric vehicles (FCEVs) could dominate hydrogen demand, with over 4 million FCEVs on the road by 2030.The road transport sector, crucial for decarbonizing European economies, could see FCEVs reduce carbon emissions by over 40% in hydrogen applications by 2050 [6,7].Unlike conventional fuels, H 2 has the potential to eliminate carbon-based emissions while allowing for high efficiencies, also at challenging operating conditions like lean mixtures [8].This is due to its high flame front propagation speed (with a laminar burning velocity approximately six times greater than that of gasoline E5) and broad flammability limits [9].Hydrogen offers also multiple application modes within internal combustion engines [10], as explored in various studies focusing on its use either as a primary fuel or in combination with fossil fuels to boost efficiency and reduce emissions [11].The ability of hydrogen engines to sustain higher compression ratios, up to 14.5:1, due to highly diluted mixtures and a high autoignition temperature results in superior thermodynamic efficiency, potentially reaching 52% [12].For instance, Shi et al. [13] reported an increase in brake thermal efficiency from approximately 10.0% to 16.7% with a 6% hydrogen addition to gasoline under an excess air ratio of 1.3 in a modified Wankel engine.Dimitriou et al. [14] also observed a peak brake thermal efficiency improvement of approximately 3% with an 80% hydrogen energy addition.When pure hydrogen is used, emissions of hydrocarbons (HCs) and carbon monoxide (CO) are nearly eliminated, with only minor contributions from the combustion of lubricating oil [15,16].However, the intrinsic characteristics of hydrogen combustion makes the calibration of hydrogen-fueled engines difficult due to their combustion dynamics and emission control mechanisms [17].Ones of the challenges in hydrogen combustion regards the propensity for misfires and delayed combustion at the exhaust port, which leads to inefficiencies in engine operation as well as increased pollutant emissions [18,19].Verhelst et al. [20] reported that an unoptimized spark plug in a hydrogen engine caused misfires, leaving unburned hydrogen in the cylinder, which led to backfire in the next cycle.Gao et al. [21] discovered that a misfire in one cylinder could result in severe knocking in the same and other cylinders.The unburned mixture from the misfire cycle burns in the exhaust system, producing oscillating waves that cause knocking in the cylinders.These anomalies make the traditional lambda sensors unable to accurately identify the oxygen concentration in the exhaust gases to determine the air excess coefficient (λ) [22,23].
Within this context, machine learning (ML) solutions can be exploited to address such an issue.The capability of ML algorithms to analyze complex data patterns starting from input variables makes them well-suited for tasks such as λ prediction in H 2 -ICE.In such a way, the exploitation of virtual sensors [24][25][26] can mitigate the impact of lambda sensors malfunctioning and response delays [27,28].Wong et al. [29] proposed an adaptive air-fuel ratio control method employing extreme machine learning (EML), which was fine-tuned through simulations and experiments on a retrofitted spark-ignition (SI) dualinjection engine.The ELM-based controller outperforms traditional PID controllers, offering significant advancements in engine control technology.McGann et al. [30] developed a predictive model using an ML approach to detect the fuel-air equivalence ratio (ϕ) and pressure derived from the laser-induced plasma spectra.Quantitative outcomes showed R 2 values of up to 0.99996 for ϕ and 0.99975 for pressure, demonstrating high predictive performance and the efficacy of the presented model.Wong et al. [31] demonstrated, through simulations and experimental activities, the effectiveness of an initial-training-free online sequential extreme learning machine (ITF-OSELM) in identifying air-fuel ratio dynamics in real-time engine data and in calculating control signals for air-fuel regulation.

Present Contribution
This study examines the feasibility of replacing the physical lambda sensor with a virtual one to avoid problems due to sensor malfunctions, enhance the reliability of estimating the air excess coefficient, and compensate for any delays due to the probe time response.Tests were conducted on a SI single-cylinder research engine fueled with H 2 , spanning a wide range of relative λ from 1.6 to 3.0.The experimental setup involves collecting data coming from an indicated analysis system.These data are used as the input for the machine learning algorithms, which are trained to predict the air excess index based on the observed engine behavior.To perform this task, a long short-term memory (LSTM) [32,33] approach combined with a convolutional neural network (CNN) [34,35] has been used.Fukuoka et al. [36] utilized a combination of 1D-CNN and LSTM to forecast wind speed in Tokushima city.Typically, wind speed is monitored over a specific timeframe, and their method leverages historical data to predict current conditions.In a separate study, Rosato et al. [37] introduced a pioneering deep learning method combining long short-term memory networks and convolutional neural networks, which was developed to forecast energy patterns in a practical solar power plant.Following a thorough assessment, their framework emerged as a reliable and efficient solution for predictive applications.Its notable advantage lies in its utilization of effective and intelligent strategies to leverage various physical data sources.In our investigation, documented as [38], we devised a hybrid model employing LSTM and 1DCNN to explore the viability of replacing a physical sensor such as a torque meter with a virtual alternative.Successfully achieving this goal could result in substantial cost reductions and protect test bench components from damage caused by resonance phenomena, as noted in the references [39,40].This model accurately reproduces the natural frequency of recorded signals, assuring that the predicted values consistently deviate within the acceptable threshold of 10% from actual values.Furthermore, our research group evaluated the predictive performance of LSTM + 1DCNN in forecasting in-cylinder pressure traces of a three-cylinder sparkignition engine across various operational conditions.The results underscore the superior capability of LSTM + 1DCNN in capturing the trends in target signals.When compared to alternative benchmark architectures, our model consistently demonstrates superior performance, achieving average error rates below 2%.Notably, even as engine variability increases from cycle to cycle, LSTM + 1DCNN maintains average error rates below 1.5%, highlighting its robustness and reliability in predictive accuracy [41].
In the present work, research on fine-tuning parameters such as the number of neurons, hidden layers, and input variables in neural network models has been performed to maximize prediction accuracy.Through iterative experimentation and validation, the optimal configuration of the machine learning algorithms has been identified, as has its respective performance compared to those from other optimized machine learning architectures.
The results show that the LSTM + 1DCNN model successfully reaches convergence during training without experiencing overfitting, showcasing its ability to learn effectively from the data and produce precise predictions.Moreover, it exhibits superior accuracy, robustness, and prediction performance compared to the backpropagation structure.These findings indicate that LSTM + 1DCNN holds considerable promise for predicting exhaust oxygen concentrations in spark-ignition engines.

Experimental Setup
The experimental campaign was performed on a 500 cc single-cylinder engine, depicted in Figure 1, equipped with four valves and featuring a pent-roof combustion chamber and a reverse tumble intake port system.The latter is specifically designed for operation in both direct injection (DI) [38] and port fuel injection (PFI) [42] modes.Additional specifications regarding the test engine are available in Table 1 [43].The tests were carried out at 1000 rpm in PFI mode with centrally positioned igniters.A throttle valve positioned upstream of the intake manifold regulated the airflow rate, with its configuration remaining constant for all the test points, specifically taking into account a throttle valve opening (TVO) of 10%.This ensured consistent airflow towards the combustion chamber and unchanged in-cylinder charge motion [42].The air excess coefficient was adjusted exclusively by modifying the quantity of hydrogen fuel injected, maintained at a fixed injection pressure of 4 bar absolute.Below, the remaining components of the experimental apparatus are listed and outlined, with their schematic arrangement and associated connections depicted in Figure 2.An Athena GET HPUH4 engine control unit (ECU) has been used to regulate the timing of injector activation and ignition timing.This ECU achieved control by sending a trigger signal to the ignition control unit.For combustion analysis, the Kistler KiBox system was employed, featuring an angular resolution of 0.1 CAD.This system gathered several critical data types: intake port pressure was measured using a Kistler 4075A5 (Kistler Group: Winterthur, Switzerland) A throttle valve positioned upstream of the intake manifold regulated the airflow rate, with its configuration remaining constant for all the test points, specifically taking into account a throttle valve opening (TVO) of 10%.This ensured consistent airflow towards the combustion chamber and unchanged in-cylinder charge motion [42].The air excess coefficient was adjusted exclusively by modifying the quantity of hydrogen fuel injected, maintained at a fixed injection pressure of 4 bar absolute.Below, the remaining components of the experimental apparatus are listed and outlined, with their schematic arrangement and associated connections depicted in Figure 2.An Athena GET HPUH4 engine control unit (ECU) has been used to regulate the timing of injector activation and ignition timing.This ECU achieved control by sending a trigger signal to the ignition control unit.For combustion analysis, the Kistler KiBox system was employed, featuring an angular resolution of 0.1 CAD.This system gathered several critical data types: intake port pressure was measured using a Kistler 4075A5 (Kistler Group: Winterthur, Switzerland) piezoresistive transducer; in-cylinder pressure was recorded with a Kistler 6061B (Kistler Group: Winterthur, Switzerland) piezoelectric transducer; and the absolute crank angle position was determined using an AVL 365C optical encoder (IndiaMART: Noida, India).Additionally, the oxygen percentage was measured with a Horiba Mexa 720 fast probe (HORIBA, Ltd.: Kyoto, Japan), with an accuracy of ±0.5%, while the ignition signal was provided by the ECU.
For the study, a conventional spark plug prototype was chosen as the igniter.
Group: Winterthur, Switzerland) piezoelectric transducer; and the absolute crank angle position was determined using an AVL 365C optical encoder (IndiaMART: Noida, India).Additionally, the oxygen percentage was measured with a Horiba Mexa 720 fast probe (HORIBA, Ltd.: Kyoto, Japan), with an accuracy of ±0.5%, while the ignition signal was provided by the ECU.
For the study, a conventional spark plug prototype was chosen as the igniter.

Estimation of the Relative Air Excess Coefficient
Throughout the course of the engine's operations, the activation time value of the injector (ton) was finetuned to attain the desired target of λ, guided by the concentration of O2% in the combustion process furnished by the Horiba MEXA-720, as specified in the previous paragraph, using the equation derived from the complete combustion of hydrogen and oxygen and rearranged by Azeem et al. [22] as reported in Equation (1): where  represents the oxygen wet concentration in the exhaust gas and  indicates the corresponding concentration in the intake air, which stands at around 21%.Such a type of regulation is deemed necessary owing to the impossibility of flushing the injector and the absence of a "fuel meter", which allows the quantification of the injected fuel mass flow rate ( ) and therefore direct adjustment of the λ value.

Estimation of the Relative Air Excess Coefficient
Throughout the course of the engine's operations, the activation time value of the injector (t on ) was finetuned to attain the desired target of λ, guided by the concentration of O 2 % in the combustion process furnished by the Horiba MEXA-720, as specified in the previous paragraph, using the equation derived from the complete combustion of hydrogen and oxygen and rearranged by Azeem et al. [22] as reported in Equation ( 1): where X O 2 represents the oxygen wet concentration in the exhaust gas and Y O 2 indicates the corresponding concentration in the intake air, which stands at around 21%.Such a type of regulation is deemed necessary owing to the impossibility of flushing the injector and the absence of a "fuel meter", which allows the quantification of the injected fuel mass flow rate ( .m c ) and therefore direct adjustment of the λ value.

Definition of the Case Study for the Output Prediction 2.3.1. Definition of the Involved Parameters
In this work, the performance of an LSTM-CNN structure in predicting the λ at the exhaust pipe of a spark-ignition engine (Figure 3) has been evaluated and compared with the ones coming from other ML architectures.
The initial dataset is composed by data coming from experiments conducted at different λ values, from 1.5 to 3.5 (Figure 4).Each tested operating point is characterized by the coefficient of variance (CoV) of the indicated mean effective pressure (IMEP) being lower than 3% [44].The threshold enables the operating point to be considered as fully stable.In this work, the performance of an LSTM-CNN structure in predicting the λ at the exhaust pipe of a spark-ignition engine (Figure 3) has been evaluated and compared with the ones coming from other ML architectures.The initial dataset is composed by data coming from experiments conducted at different λ values, from 1.5 to 3.5 (Figure 4).Each tested operating point is characterized by the coefficient of variance (CoV) of the indicated mean effective pressure (IMEP) being lower than 3% [44].The threshold enables the operating point to be considered as fully stable.the ones coming from other ML architectures.The initial dataset is composed by data coming from experiments conducted at different λ values, from 1.5 to 3.5 (Figure 4).Each tested operating point is characterized by the coefficient of variance (CoV) of the indicated mean effective pressure (IMEP) being lower than 3% [44].The threshold enables the operating point to be considered as fully stable.The initial dataset, described in Table 2, is composed of 42 operating cases.For each operating case, a total of 100 consecutive combustions were recorded by the Kibox analysis system.For each combustion event, the following 8 parameters served as an input for the ML structure:

•
CAD aTDC in correspondence of the maximum in-cylinder pressure, APmax (CAD aTDC).

•
Injector activation time, t on (µs).Due to the inability to retroactively control the injector activation time, it has been fixed based on the target lambda value.Therefore, it is essential to predict the exhaust oxygen concentration accurately with an ML approach to enable the control of the injector timing.
Considering the observations reported in Figures 4 and 5 and the subdivision of the initial dataset shown in

Evaluating the Influence of the Input Parameters on the Output Prediction
By removing variables with minimal correlation, the model's dimensions can be effectively reduced, thereby improving its accuracy.To accomplish this goal, an initial analysis utilizing the Shapley value was performed on the entire dataset.SHAP is used to clarify the prediction of an instance by assessing the contribution of each feature.By excluding variables with weak correlation, the model's dimensions can be effectively reduced, thereby improving its accuracy.The researchers also evaluated the average abso-  By removing variables with minimal correlation, the model's dimensions can be effectively reduced, thereby improving its accuracy.To accomplish this goal, an initial analysis utilizing the Shapley value was performed on the entire dataset.SHAP is used to clarify the prediction of an instance by assessing the contribution of each feature.By excluding variables with weak correlation, the model's dimensions can be effectively reduced, thereby improving its accuracy.The researchers also evaluated the average absolute Shapley values (ABSVs) to determine the influence of individual measured quantities on the objective function [45,46].The results shown in Figure 6 indicate that t on is the most influential parameter for predicting λ, followed by the maximum in-cylinder pressure (percentage of impact: 47%), APmax, AI50, and IMEP.On the other hand, AI05, AI90, and IT, highlighted in red in Figure 6, are the least influential parameters, with impact percentages below 5%.

Evaluating the Influence of the Input Parameters on the Output Prediction
By removing variables with minimal correlation, the model's dimensions can be effectively reduced, thereby improving its accuracy.To accomplish this goal, an initial analysis utilizing the Shapley value was performed on the entire dataset.SHAP is used to clarify the prediction of an instance by assessing the contribution of each feature.By excluding variables with weak correlation, the model's dimensions can be effectively reduced, thereby improving its accuracy.The researchers also evaluated the average absolute Shapley values (ABSVs) to determine the influence of individual measured quantities on the objective function [45,46].The results shown in Figure 6 indicate that ton is the most influential parameter for predicting λ, followed by the maximum in-cylinder pressure (percentage of impact: 47%), APmax, AI50, and IMEP.On the other hand, AI05, AI90, and IT, highlighted in red in Figure 6, are the least influential parameters, with impact percentages below 5%.Consequently, these three parameters were excluded from the final dataset, reducing the count of inputs from 8 to 5. Earlier studies conducted by the same team of research [38,41] revealed improvements in predictive capabilities when parameters with marginal influence were excluded.Accordingly, this study centers on evaluating the predictive accuracy of the architecture using the five previously identified input parameters: AI50, APmax, IMEP, Pmax, and t on .After analyzing the input parameters, a normalization procedure is implemented to mitigate prediction errors and expedite the architecture's convergence.This method mitigates discrepancies between input and output parameters by scaling values to the range [0, 1].Following the prediction procedure, a data de-normalization process must be undertaken to enable direct comparison between the predicted values and the original target values.

Definition of the Final Dataset for the Output Prediction
On the basis of the sensitivity analysis results outlined in the preceding paragraph and summarized in Figure 5, Figure 7 offers a detailed summary of the final dataset and, additionally, for each case examined, the arrangement of input and output parameters.As shown in Figure 7a, the dataset consists of 42 experimental cases specified in Table 2, with every single case characterized by 6 variables.Each variable includes 100 samples, corresponding to the number of combustion cycles.The input parameters, AI50, APmax, IMEP, Pmax, and t on , form a 42 × [5 × 100] matrix, while the output parameter forms a 42 × [1 × 100] matrix (Figure 7b).The dataset was divided such that 80% of the data was utilizing for training, 10% for validation, and the remaining 10%, 3 × [5 × 100], was used for testing to predict the output, 3 × [1 × 100] (Figure 7c).

LSTM + 1DCNN Structure
Figure 8a illustrates the forecasting model of LSTM + 1DCNN utilized for predicting the output and subsequently determining the operative λ value.The process begins with a sequence input layer that feeds the dataset inside the neural network, defining its dimensions and creating the required structures.Following this, a one-dimensional CNN layer employs a "1D convolutional filter" on each frame of input, which is composed of neurons and uses a "ReLu activation function".[47,48].The procedure then involves an "average pooling layer" that computes the mean values of patches in a feature map,

LSTM + 1DCNN Structure
Figure 8a illustrates the forecasting model of LSTM + 1DCNN utilized for predicting the output and subsequently determining the operative λ value.The process begins with a sequence input layer that feeds the dataset inside the neural network, defining its dimensions and creating the required structures.Following this, a one-dimensional CNN layer employs a "1D convolutional filter" on each frame of input, which is composed of neurons and uses a "ReLu activation function" [47,48].The procedure then involves an "average pooling layer" that computes the mean values of patches in a feature map, reducing the maps size (i.e., "down-sampling"), utilizing the mean value in 2 × 2 cell squares.This is followed by another 1D convolutional layer, similar to the earlier one.An LSTM layer with hidden units then handles the feature maps.Gates play a vital role in the inner structure of the LSTM network, as depicted in Figure 8b.Using data from the prior layer (h t−1 ) and the current input (x t ), the "forget gate" determines which information should be kept or removed.A sigmoid function processes this data, yielding an output between 0 and 1 to determine if the information should be retained.This gate modifies the prior cell state value (C t−1 ).The "input gate" then identifies which information to save in the "cell state" through several steps.Initially, the "input port layer" employs a Sigmoid function (σ) to decide which values to update.Subsequently, a new set of candidate values (C t ) is created using a Hyperbolic Tangent function (tanh).These two sets of values are combined and updated using the Forget function (f t ), replacing the old cell state (C t−1 ) with the new one (C t ).The updated cell state is then multiplied by the Forget function (f t ).The output gate retains a filtered version of the processed data, with the Sigmoid function determining which parts of the cell state to output.The cell state undergoes a tanh operation to limit values between −1 and 1, which are subsequently multiplied by the "Sigmoid gate output", resulting in the final output (y t ) of only the selected parts.LSTMs feature a unique structure with a "Forget gate activation", allowing the network to encourage desired behavior through frequent updates at each learning stage.After the LSTM layer completes its process, the "time-distributed layer" segments the feature map into a sequence of temporal vectors.Finally, the "regression output layer" calculates the "mean square error loss" to solve the regression problem, with h t representing the new layer and y t the current output, i.e., the predicted value.
unique structure with a "Forget gate activation", allowing the network to encourage desired behavior through frequent updates at each learning stage.After the LSTM layer completes its process, the "time-distributed layer" segments the feature map into a sequence of temporal vectors.Finally, the "regression output layer" calculates the "mean square error loss" to solve the regression problem, with ht representing the new layer and yt the current output, i.e., the predicted value.

Definition of the Procedures to Determine the Structural Parameters of the Proposed Models
The optimized neural architectures are defined based on preliminary analysis of training session performance.The effectiveness of the model's parameters is measured using the mean square error (MSE) as the loss metric (Equation ( 2)): where:

Definition of the Procedures to Determine the Structural Parameters of the Proposed Models
The optimized neural architectures are defined based on preliminary analysis of training session performance.The effectiveness of the model's parameters is measured using the mean square error (MSE) as the loss metric (Equation ( 2)): where: • N = number of combustion cycles; The network is trained for 10,000 epochs, allowing the final loss function value, for each prediction model, to be computed upon reaching the maximum learning iteration.
For the LSTM + 1DCNN architecture, various structural parameters are investigated: the number of neurons in the 1DCNN layers (N c ) ranges from 50 to 200, the neurons in the LSTM hidden layers (N h ) also span from 50 to 200, the batch size (B s ) varies between 8 and 64, and the model depth (M d ) extends from 1 to 5 layers.
The "Adam optimizer", which includes adaptive learning rate adjustments during training, is utilized to refine the weight matrix and biases in the LSTM model.
A "MaxPooling1D layer" composed of pool_size = 2 and strides = 2 has been located between the CNN and LSTM layers.
A "time-distributed layer" has been used after the LSTM layer.It applies a "fully connected (dense) layer" with one unit to each time step of the input sequence independently.This is useful for sequence data where each time step needs to be processed separately, such as in sequence prediction tasks where each time step has its own prediction.
A "dense (units = 1) layer", a standard fully connected layer with one unit, has ultimately been used as the output layer since a single scalar output is required.
The most effective configurations, identified by the lowest mean square error (MSE) values, were selected for predicting λ, resulting in N c = 134, N h = 38, B s = 1, and M d = 2.
For the sake of completeness, Figure 9 displays the validation loss and training loss for the best-performing LSTM + 1DCNN structure.
A "dense (units = 1) layer", a standard fully connected layer with one unit, has ultimately been used as the output layer since a single scalar output is required.
The most effective configurations, identified by the lowest mean square error (MSE) values, were selected for predicting λ, resulting in Nc = 134, Nh = 38, Bs = 1, and Md = 2.
For the sake of completeness, Figure 9 displays the validation loss and training loss for the best-performing LSTM + 1DCNN structure.The performance of this proposed architecture is evaluated against an alternative approach, specifically the backpropagation model.The BP algorithm [49][50][51] features an architecture with one input layer; three hidden layers containing 50, 87, and 11 neurons, respectively; and a single output layer.Similar to the LSTM + 1DCNN architecture, this configuration was fine-tuned through a thorough preliminary analysis.

Results and Discussion
Figure 10 depicts the predictions of λ, starting from the prediction of oxygen concentration according to Equation (1), for the three testing cases performed by the two neural structures analyzed.The performance of this proposed architecture is evaluated against an alternative approach, specifically the backpropagation model.The BP algorithm [49][50][51] features an architecture with one input layer; three hidden layers containing 50, 87, and 11 neurons, respectively; and a single output layer.Similar to the LSTM + 1DCNN architecture, this configuration was fine-tuned through a thorough preliminary analysis.To ensure clarity, prediction, concerning the entirety of events, was carried out for operational cases 13, 21, and 38, each characterized by 100 combustion cycles.For all of the aforementioned cases, both test structures are capable of reproducing the trend in the oxygen concentration over the considered combustion cycles.Examining the details more closely, it is evident that the LSTM + 1DCNN architecture achieves predictions that are closer to the target across all three analyzed cases compared to the BP structure.Furthermore, as corroborated by the error graphs in Figure 11, the LSTM + 1DCNN architecture progressively improves the prediction performance as the mixture becomes leaner, with the RMSE (Root Mean Square Error) [41] decreasing from 3.16% (case 13, Figure 10a) to 2.72% (both cases 21 and 38, Figure 10b and Figure 10c, respectively).Conversely, while the BP model shows slightly different trends from LSTM + 1DCNN for cases 13 and 21, it performs significantly worse for case 38, with an RMSE of 8.27%, greatly underestimating the target value.

Results and Discussion
The percentage error of the ith operating case, indicated as Err, defined as the dis- To ensure clarity, prediction, concerning the entirety of events, was carried out for operational cases 13, 21, and 38, each characterized by 100 combustion cycles.For all of the aforementioned cases, both test structures are capable of reproducing the trend in the oxygen concentration over the considered combustion cycles.Examining the details more closely, it is evident that the LSTM + 1DCNN architecture achieves predictions that are closer to the target across all three analyzed cases compared to the BP structure.Furthermore, as corroborated by the error graphs in Figure 11, the LSTM + 1DCNN architecture progressively improves the prediction performance as the mixture becomes leaner, with the RMSE (Root Mean Square Error) [41] decreasing from 3.16% (case 13, Figure 10a) to 2.72% (both cases 21 and 38, Figures 10b and 10c, respectively).Conversely, while the BP model shows slightly different trends from LSTM + 1DCNN for cases 13 and 21, it performs significantly worse for case 38, with an RMSE of 8.27%, greatly underestimating the target value.As illustrated in Figure 11a,b, BP demonstrates an Erravg of 8.88% for case 13 and 6.50% for case 21, both of which are below the critical threshold of 10%.Specifically, 33 cycles and 11 cycles, respectively, or approximately 33% and 11% of the predicted combustion cycles, exhibit an Err(i) exceeding 10%.However, in case 38 (Figure 11c), BP exhibits an Erravg of 12.67%, significantly exceeding the critical threshold of acceptability.The LSTM + 1DCNN model enhances BP performance, consistently demonstrating an Erravg below that of the BP architecture and the critical threshold.Specifically, the Erravg is 6.97% for case 13, 5.09% for case 21, and 4.01% for case 38.Furthermore, it is important to emphasize that as the mixture is leaner, the LSTM + 1DCNN structure progressively improves the prediction performance, achieving zero cycles beyond the critical threshold of 10% for case 38.
The regression accuracy (R 2 ) pertaining to the predictions generated by the two architectures tested, illustrated in Figure 12, has been calculated using Equation (5).
where  = mean of the target values.The percentage error of the ith operating case, indicated as Err, defined as the distance between the approximate value and the exact value as a percentage of the actual value, has been determined using Equation (3): The average percentage error, referred to as Err avg and evaluated utilizing Equation (4), is computed to evaluate the overall accuracy of predictions: To ensure accurate predictions, a strict upper limit of 10% is set for these calculated errors to maintain high-quality standards.
As illustrated in Figure 11a,b, BP demonstrates an Err avg of 8.88% for case 13 and 6.50% for case 21, both of which are below the critical threshold of 10%.Specifically, 33 cycles and 11 cycles, respectively, or approximately 33% and 11% of the predicted combustion cycles, exhibit an Err(i) exceeding 10%.However, in case 38 (Figure 11c), BP exhibits an Err avg of 12.67%, significantly exceeding the critical threshold of acceptability.The LSTM + 1DCNN model enhances BP performance, consistently demonstrating an Err avg below that of the BP architecture and the critical threshold.Specifically, the Err avg is 6.97% for case 13, 5.09% for case 21, and 4.01% for case 38.Furthermore, it is important to emphasize that as the mixture is leaner, the LSTM + 1DCNN structure progressively improves the prediction performance, achieving zero cycles beyond the critical threshold of 10% for case 38.
Energies 2024, 17, 3932 13 of 17 The regression accuracy (R 2 ) pertaining to the predictions generated by the two architectures tested, illustrated in Figure 12, has been calculated using Equation (5).
where Y target = mean of the target values.
cycles and 11 cycles, respectively, or approximately 33% and 11% of the predicted combustion cycles, exhibit an Err(i) exceeding 10%.However, in case 38 (Figure 11c), BP exhibits an Erravg of 12.67%, significantly exceeding the critical threshold of acceptability.
The LSTM + 1DCNN model enhances BP performance, consistently demonstrating an Erravg below that of the BP architecture and the critical threshold.Specifically, the Erravg is 6.97% for case 13, 5.09% for case 21, and 4.01% for case 38.Furthermore, it is important to emphasize that as the mixture is leaner, the LSTM + 1DCNN structure progressively improves the prediction performance, achieving zero cycles beyond the critical threshold of 10% for case 38.
The regression accuracy (R 2 ) pertaining to the predictions generated by the two architectures tested, illustrated in Figure 12, has been calculated using Equation (5).
where  = mean of the target values.As can be observed, the data points in all charts are plotted with the predicted values on the y-axis and the target values on the x-axis.The closer the points are to the diagonal dashed line, the more accurate the predictions are.Each plot uses a scale appropriate to the data range of the respective case.Both models demonstrate high accuracy in the lowerto-medium range of analysis, specifically at low λ levels.As the oxygen concentration increases, BP shows greater dispersion (R 2 = 0.9802, case 38), whereas LSTM + 1DCNN exhibits a consistent distribution along the interpolation line without significant deviations (R 2 = 0.9974, case 38).Notably, this architecture exhibits minimal dispersion, with an R² value approaching unity, specifically R² = 0.9996 for case 21, which is higher than the value achieved for the same case using BP (R 2 = 0.9992).These findings underscore the superior linear fitting and predictive accuracy of the LSTM + 1DCNN architecture compared to the BP architecture across all three cases examined.The findings underscore the strong learning capabilities of the LSTM + 1DCNN architecture, demonstrating its proficiency in faithfully reproducing the target trend throughout the learning process.

Challenges and Opportunities
While machine learning shows promise for enhancing emission control in hydrogen combustion engines, several challenges remain.One key challenge is the need for large amounts of high-quality data for training and validating machine learning models.Collecting representative data from diverse operating conditions and engine configurations is essential to ensure the robustness and generalization of the models.
Additionally, the integration of machine learning algorithms into real-time engine control systems presents technical and logistical challenges.Ensuring the reliability, As can be observed, the data points in all charts are plotted with the predicted values on the y-axis and the target values on the x-axis.The closer the points are to the diagonal dashed line, the more accurate the predictions are.Each plot uses a scale appropriate to the data range of the respective case.Both models demonstrate high accuracy in the lowerto-medium range of analysis, specifically at low λ levels.As the oxygen concentration increases, BP shows greater dispersion (R 2 = 0.9802, case 38), whereas LSTM + 1DCNN exhibits a consistent distribution along the interpolation line without significant deviations (R 2 = 0.9974, case 38).Notably, this architecture exhibits minimal dispersion, with an R 2 value approaching unity, specifically R 2 = 0.9996 for case 21, which is higher than the value achieved for the same case using BP (R 2 = 0.9992).These findings underscore the superior linear fitting and predictive accuracy of the LSTM + 1DCNN architecture compared to the BP architecture across all three cases examined.The findings underscore the strong learning capabilities of the LSTM + 1DCNN architecture, demonstrating its proficiency in faithfully reproducing the target trend throughout the learning process.

Challenges and Opportunities
While machine learning shows promise for enhancing emission control in hydrogen combustion engines, several challenges remain.One key challenge is the need for large amounts of high-quality data for training and validating machine learning models.Collecting representative data from diverse operating conditions and engine configurations is essential to ensure the robustness and generalization of the models.
Additionally, the integration of machine learning algorithms into real-time engine control systems presents technical and logistical challenges.Ensuring the reliability, safety, and compatibility of machine-learning-based systems with existing engine architectures requires careful consideration and validation.
Despite these challenges, the potential benefits of machine learning for emission control in hydrogen combustion engines are substantial.By providing accurate and reliable λ predictions, virtual lambda sensors can enable more precise control of combustion processes, leading to improved engine performance and reduced emissions.Furthermore, machine-learning-based approaches have the flexibility to adapt to changing operating conditions and optimize engine performance in real time, offering opportunities for continuous improvement and innovation in emission control strategies.

Conclusions
The current study assessed the LSTM + 1DCNN model's efficacy for the λ prediction at the exhaust pipe of a single-cylinder spark-ignition engine across different operational scenarios.The aim was to explore the potential of advanced machine learning techniques as substitutes for physical sensors and to assess the feasibility of integrating virtual lambda sensors into onboard control systems.This approach may reduce the need for costly and time-intensive structural alterations.

Main Findings
The findings gleaned from the present comparative analysis demonstrate the superior performance of the LSTM + 1DCNN model in replicating target signal trends.In particular, compared to the backpropagation approach, this model consistently exhibits the highest accuracy, with average error percentages below 10%.As the air-fuel mixture is progressively leaned, the LSTM + 1DCNN model achieves average error percentages equal to approximately 4%, while that of the BP structure increases by up to roughly 13%.This research found that the LSTM + 1DCNN architecture can achieve convergence during training without experiencing overfitting, showcasing its ability to learn efficiently from input data and predict with high precision.Additionally, it demonstrates superior accuracy and robustness compared to the backpropagation structure.These findings suggest that LSTM + 1DCNN holds great potential for accurately forecasting the air excess coefficient (λ) in SI engines.
In conclusion, integrating machine learning in hydrogen combustion engines shows great promise for advancing emission control.Virtual lambda sensors can address sensor malfunctions and response delays.Experimental validation on single-cylinder engines demonstrates the potential of these techniques for improving performance and reducing emissions, paving the way for a cleaner, more sustainable automotive future.

3 .
Definition of the Case Study for the Output Prediction 2.3.1.Definition of the Involved Parameters

Figure 3 .
Figure 3.The trend in the oxygen concentration (O2%) at the exhaust pipe pertaining to an operational case taken as an example, consisting of 100 combustion cycles.

Figure 4 .
Figure 4. Values of λ for each operating point.The cases highlighted in green were used for training, those in red were used for validation, the cases for which the prediction was made are highlighted in blue.

Figure 3 .
Figure 3.The trend in the oxygen concentration (O 2 %) at the exhaust pipe pertaining to an operational case taken as an example, consisting of 100 combustion cycles.

Figure 3 .
Figure 3.The trend in the oxygen concentration (O2%) at the exhaust pipe pertaining to an operational case taken as an example, consisting of 100 combustion cycles.

Figure 4 .
Figure 4. Values of λ for each operating point.The cases highlighted in green were used for training, those in red were used for validation, the cases for which the prediction was made are highlighted in blue.

Figure 4 .
Figure 4. Values of λ for each operating point.The cases highlighted in green were used for training, those in red were used for validation, the cases for which the prediction was made are highlighted in blue.

Figure 5 .
Figure 5. (a) Overview of the entire dataset including the number of cases analyzed and variables, along with combustion cycles; (b) detailed listing of input and output parameters for each case based on initial sensitivity analysis; (c) division of the dataset into training, testing, and validation sets.Specifically, 80% of the data was allocated to training, 10% to validation, and the remaining 10% to testing for predicting the output variable O2% and deriving the λ value.

Figure 5 .
Figure 5. (a) Overview of the entire dataset including the number of cases analyzed and variables, along with combustion cycles; (b) detailed listing of input and output parameters for each case based on initial sensitivity analysis; (c) division of the dataset into training, testing, and validation sets.Specifically, 80% of the data was allocated to training, 10% to validation, and the remaining 10% to testing for predicting the output variable O 2 % and deriving the λ value.

2 .
Evaluating the Influence of the Input Parameters on the Output Prediction

Figure 5 .
Figure 5. (a) Overview of the entire dataset including the number of cases analyzed and variables, along with combustion cycles; (b) detailed listing of input and output parameters for each case based on initial sensitivity analysis; (c) division of the dataset into training, testing, and validation sets.Specifically, 80% of the data was allocated to training, 10% to validation, and the remaining 10% to testing for predicting the output variable O2% and deriving the λ value.

Figure 6 .
Figure 6.The Shapley analysis provides a thorough understanding of the importance of each input feature in predicting the global oxygen concentration.The red line delineates the threshold below which a parameter is deemed insignificant for the purposes of prediction.

Figure 6 .
Figure 6.The Shapley analysis provides a thorough understanding of the importance of each input feature in predicting the global oxygen concentration.The red line delineates the threshold below which a parameter is deemed insignificant for the purposes of prediction.

Figure 7 .
Figure 7. (a) Overview of the final dataset including the number of cases analyzed and variables, along with combustion cycles; (b) detailed listing of input and output parameters for each case based on initial sensitivity analysis; (c) division of the dataset into training, testing, and validation sets.Specifically, 80% of the data was allocated to training, 10% to validation, and the remaining 10% to testing for predicting the output variable O2% and deriving the λ value.

Figure 7 .
Figure 7. (a) Overview of the final dataset including the number of cases analyzed and variables, along with combustion cycles; (b) detailed listing of input and output parameters for each case based on initial sensitivity analysis; (c) division of the dataset into training, testing, and validation sets.Specifically, 80% of the data was allocated to training, 10% to validation, and the remaining 10% to testing for predicting the output variable O 2 % and deriving the λ value.

Figure 8 .
Figure 8.(a) Predictive scheme and (b) the internal structure of the LSTM and its division into gates.

Figure 8 .
Figure 8.(a) Predictive scheme and (b) the internal structure of the LSTM and its division into gates.

Figure 9 .
Figure 9.The pattern of loss values for the LSTM + 1DCNN architecture, which demonstrated the highest performance during the training session.

Figure 9 .
Figure 9.The pattern of loss values for the LSTM + 1DCNN architecture, which demonstrated the highest performance during the training session.

Figure 10
Figure 10 depicts the predictions of λ, starting from the prediction of oxygen concentration according to Equation (1), for the three testing cases performed by the two neural structures analyzed.Energies 2024, 17, x FOR PEER REVIEW 12 of 18

Figure 10 .
Figure 10.Predictions of λ for the three 'testing cases' selected by both neural structures: (a) prediction case n.13,(b) prediction case n.21 and (c) prediction case n.38 (refer to Figure4).The black dotted lines represent the measurement accuracy range of the target, i.e., 0.5%.

Figure 10 .
Figure 10.Predictions of λ for the three 'testing cases' selected by both neural structures: (a) prediction case n.13,(b) prediction case n.21 and (c) prediction case n.38 (refer to Figure4).The black dotted lines represent the measurement accuracy range of the target, i.e., 0.5%.

Energies 2024 , 18 Figure 11 .
Figure 11.Percentage error Err (see Equation (3)) for the three 'testing cases' selected and both the BP and LSTM + 1DCNN models, to underline the prediction quality, with the corresponding average percentage error Erravg in the legends.(a) prediction case n.13,(b) prediction case n.21 and (c) prediction case n.38 (refer to Figure 4).

Figure 11 .
Figure 11.Percentage error Err (see Equation (3)) for the three 'testing cases' selected and both the BP and LSTM + 1DCNN models, to underline the prediction quality, with the corresponding average percentage error Err avg in the legends.(a) prediction case n.13,(b) prediction case n.21 and (c) prediction case n.38 (refer to Figure 4).

Table 2 .
Dataset general description and values.