Supervisory Real-Time Multidomain Modeling and Hardware Emulation of Fuel-Cell Hybrid Electric Bus Behavioral Transients

Real-time device-level multi-domain emulation can provide an accurate insight into behavioral transients of the hydrogen fuel-cell hybrid electric bus (HEB). However, the conventional electromagnetic transient (EMT) simulation suffers from the computation burden caused by the complex multi-domain subsystems. This paper develops a hybrid recurrent neural network (RNN) and EMT method for device-level multi-domain emulation for fuel-cell and battery HEB. Two recurrent neural networks (RNN) are designed and trained to create device-level models of permanent magnet synchronous motor (PMSM) and the modular multilevel converter (MMC), respectively. The IGBTs’ behavioral transients and thermal performance are integrated into the RNN-based MMC model. Moreover, the EMT models represent the energy behaviour of onboard fuel-cell stacks and battery stacks. The proposed multi-domain hybrid models are implemented on the Xilinx Versal™ adaptive compute acceleration platform (ACAP), where multiple AI engines and the programmable logic deal with the RNN and EMT models, respectively. The real-time hardware emulation is carried out at the time-step of 0.1 $\mu \text{s}$ for device-level transients. The results show that the hybrid model has 96.3% accuracy; furthermore, it significantly reduces the HEB emulation time compared to conventional EMT methods.

INDEX TERMS Adaptive compute acceleration platform, device-level real-time emulation, electromagnetic transients, fuel-cell, hybrid electric bus, insulated-gate bipolar transistor, multidomain modeling, real-time systems, recurrent neural networks.

I. INTRODUCTION
Modern public transportation sectors rely highly on hydrocarbon fuels, giving rise to enormous energy costs and a fair amount of carbon dioxide emissions [1], [2]. Hence recent years have seen the increasing trend for automobile manufacturers to develop the advanced energy storage techniques into the hybrid electric bus (HEB) [3]- [6], which is regarded as an appropriate substitute for conventional vehicles. Li-ion batteries are widely used in commercial electric vehicles due to their high efficiency and safety; however, they suffer from the strict charging time [3]. As a consequence, the hydrogen fuel-cell becomes another potential candidate for HEB, since the large space and fixed route of HEB can meet the requirements for fuel-cell and hydrogen tank deployment [7]. As shown in Fig. 1, the global hydrogen powered transport is expected to grow from 3.27 billion in 2021 to 5.15 billion in 2022 at a compound annual growth rate (CAGR) of 57.5% [8].
Due to the complex interconnection between multi-domain subsystem and their control system, it is more difficult to simulate, emulate, and analyze the device-level electromagnetic transient behaviour in HEB. In this case, it is essential to enhance the real-time hardware emulation technique for HEB at multi-domain level, i.e., electrical system [9], energy storage system [10], control system [11], [12] and mechanical system.
Electromagnetic transient (EMT) emulation is a practical approach to reveal the behavioral transients of power systems and the power converters [13], [14]. Unfortunately, the EMT models naturally cause a tremendous computational burden for real-time emulation of the multi-domain system at the microsecond-level emulation time interval [15]. Moreover, complex subsystems in HEB, including the hydrogen fuelcell packs, batteries, permanent magnet synchronous motor (PMSM), and modular multilevel converter (MMC), require more hardware resources, which has been one of the biggest challenges of the current HEB emulation technique [16], [17].
The artificial intelligence (AI) method has already become a new path to reduce the computation complexity and maintain the model accuracy as well in recent years [18]- [22]. As the typical AI algorithm, the recurrent neural network (RNN) was implemented for the diagnosis of electric vehicle batteries in [18]. The RNN was designed as the controller to regulate the three-phase photovoltaic system in [19]. The convolutional neural networks are utilized to detect and identify the MMC operation fault in real-time [20], while the deep neural network is used for voltage estimation of MMC in [21]. In addition, the deep learning method is used for energy management in [22].
Not only for the system-level emulation but neural network algorithms can also be implemented in device-level emulation. An adaptive dynamic surface control method based on neural network is proposed for PMSM drive systems in [23]. In [18], the insulated-gate bipolar transistors (IGBTs) temperature measurement is modeled by the neural network and k-means clustering. However, the existing methods did not focus simultaneously on both system-level and devicelevel, revealing the device behaviour and simulating the overall multi-domain system operation.
This paper proposes a hybrid EMT and supervisory RNN real-time emulation scheme for the HEB's multi-domain subsystems, i.e., electrical, control, thermal, and mechanical domains. Initially, the RNN algorithm is applied for the device-level modeling of MMC and PMSM. In particular, only one RNN model is used in this paper for both MMC and its submodules, along with the IGBT and power diodes' transient and thermal behaviour. In this case, the solution time consumption can be significantly reduced compared to the traditional EMT simulation method, where the MMC is mathematically divided into several submodules and solved step-by-step. Another independent RNN model is trained to represent the relationship between three-phase MMC output and torque and speed of PMSM. The training data is obtained from the commercial simulation software Ansys R Electronics. Second, the conventional EMT model represents fuel-cell stack and battery stack energy and power behaviour. Third, the transfer function model is implemented to represent the mechanical system. The hardware emulation is carried out on the Xilinx Versal TM adaptive compute acceleration platform (ACAP), which contains hardware AI engines and programmable logic blocks [24]. The RNN model was solved in parallel on the AI engines, while the other subsystems ran in the FPGA units at the same time. The HEB from New Flyer Xcelsior Charge TM is introduced, and a complete driving cycle of New York City Cycle (NYCC) [25] is chosen for the study case. The hardware emulation time-step is set to 0.1 µs at the device-level and 1 ms at the system-level. This paper is organized as follows. Section II introduces device-level modeling of the HEB electrical domain using the RNN algorithm. The multiple domains, including electrical, control, and mechanical, are modeled in Section III. The ACAP hardware design and implementation are provided in Section IV. Real-time emulation and validation results are shown in Section V, and Section VI provides conclusions.

II. SUPERVISORY DEVICE-LEVEL MODELING OF HEB POWER SYSTEM
The RNN algorithms, which are a generalization of feed-forward neural network that has an internal memory, are designed to learn from sequential data and succeed in 85976 VOLUME 10, 2022 FIGURE 2. Conventional EMT system for HEB: (a) overall HEB system topology; (b) MMC-based PMSM driving system; (c) multi-domain system; (d) MMC control system. many time series tasks. In this section, the device-level power components of MMC and PMSM are introduced and modeled by two RNN models.

A. BACKGROUND ON RECURRENT NEURAL NETWORK
The RNN algorithm can be designed to predict MMC and PMSM output since it can work with sequential history data. Nodes along a directed or undirected time-series graph allow dynamic temporal behavior in the basic RNN framework. It repeats the same process on each element of the input sequence in one step, maintaining a state in its hidden layer that implicitly contains historical information about all past elements of the sequence, which provides good performance for short sequences. Some crucial issues arise due to the real-time emulation for HEB is a long-term dependence problem. Thus, improved RNN methods, such as long shortterm memory (LSTM) and gated recurrent unit (GRU), have been widely applied in many applications with time series or sequential data [26].
As shown in Fig. 3, the LSTM has the three elements, i.e., forget gate, input gate, and cell state. The forget gate determines whether information should be thrown away or kept, which can carry relevant information throughout the processing of the sequence. Since the HEB multi-domain emulation is time-varying, RNN combined with LSTM structure is utilized for electrical domain modeling, which results in a better overall performance. The GRU only uses a reset and update gate to control the past information using the previous information. Both two gates decide how much past information should be considered in the next step. In this paper, the LSTM architecture is designed to achieve devicelevel multi-domain emulation of HEB. The recurrent depth, feed-forward depth, and recurrent skip coefficients are three critical parameters of the complexity measurement. The accuracy and execution time for the LSTM RNN model mainly depends on the feed-forward depth [27], [28], which can be derived as: where x t and h t are the system input sequence and the neural network output at time step t, respectively. The index t ranges from 1 to τ . W z is the parameters of the hidden layer,h t is the candidate values. VOLUME 10, 2022

B. PMSM RNN MODELING
The PMSM has become commonplace in electric vehicle driving systems, especially for public transportation, since it has the advantages of high efficiency and high power density. In this work, the PMSM is the HEB's only traction source. The traditional EMT model can be derived from the following d-q model: where v d , i q , v q , and i d are the voltage and current in d axis and q axis of PMSM; L d , L q , and λ m are the stator's flux linkage; ω e is the power supply frequency in rad./s. Then, the electric torque T e is given as: while the mechanical rotor speed of PMSM ω m can be calculated based on where J M is the moment of inertia and ω r is the rotor's angular velocity.
In order to achieve the microsecond-level emulation, the supervisory neural network algorithm is implemented for PMSM modeling to avoid solving the complex matrix in a sequential manner. The inputs of the RNN-based model are three-phase input voltages and currents of PMSM, while the PMSM model's outputs are the required mechanical torque T mref , rotor speed ω r . The parameters of PMSM from EMT model are listed in Table 2 in the Appendix.

C. MMC RNN MODELING
IGBTs and power diodes are the fundamental components in the MMC submodules. According to [29] and [30], the nonlinear behavioral model of IGBT and power diodes pair can be represented by a 5 × 5 time-varying conductance matrix, leading to an 8 × 8 matrix for one MMC submodule. However, the increasing number of the MMC submodules and the complexity of the EMT model will cause a heavy computation burden. Furthermore, the MMC phase shift control strategy and the IGBT model need to be computed in a sequential manner, which also significantly increases the emulation time consumption. To solve this problem, the RNN algorithm is also utilized for the MMC modeling. As shown in Fig. 2 (b), the half-bridge submodule has two IGBT and power diodes. There is only one neural network implemented for all submodules along with the IGBT thermal information T junc and transient behaviour, i.e., the collector to emitter voltage V ce .
However, the mathematical relationship between submodules' input and output has high reproducibility, implying a low correlation between them. The voltage, current, and junction temperature error at the history time, (t − 2) and (t − 1) are required to increase the RNN model accuracy. Thus, the input sequence is extended into eight lines, as shown in Fig. 2. In addition, the min-max normalization technique is adopted to preprocess the input data.
Assuming all the submodules have the same electrical behaviour, only one RNN model can represent the device-level modeling of the IGBT and power diodes. The MMC submodule can be assembled according to the physical connections using the EMT nodal analysis method, while the control system generates the gating signals. In particular, the control strategy is independently analyzed and trained in the control system, which is further developed in Section III due to flexibility and extensibility.

III. MULTI-DOMAIN SUBSYSTEMS MODELING OF HYBRID ELECTRIC BUS
The multi-domain models are further established using the above-mentioned device-level models. First, the fuel-cell and battery hybrid energy storage system is designed. Then, the mechanical system is modeled using transfer functions.

A. ELECTRICAL DOMAIN
Hydrogen fuel-cell stacks and battery stacks are the main energy storage devices of HEB. Unlike all battery-based buses, the fuel-cell transfers hydrogen into chemical energy and charges the batteries to drive the HEB. In addition, the batteries can absorb electrical braking energy, which is also known as regenerative braking. Fig. 4(a) shows the equivalent circuit model of hydrogen fuel cells, which includes the three nonlinear current controlled voltage sources f 1 (I HFC ), f 2 (I HFC ), and f 3 (I HFC ), in series with resistance and capacitance module.

1) FUEL-CELL MODELING
The nonlinear term can be obtained from the following equations: where I HFC is fuel-cell current, the P H 2 , P O 2 , and P H 2 O are the pressure of hydrogen gas, oxygen and water. gas constant multiplied by temperature, and F stands for Faraday constant.
In particular, this work assumes that HEB's weight is fixed during the operation even the hydrogen gas consumption.

2) BATTERY MODELING
As shown in Fig. 2, the fuel-cell stacks are serially connected with battery stacks. The fuel-cell is the main energy source, while the batteries act as an energy buffering in this work.
For the purpose of device-level emulation, Fig. 4(a) shows the second-order resistance-capacitance model, which is introduced for device-level behavioral transients emulation of the battery stacks. The equivalent resistance of the battery stack at a steady state is represented by R 0 bat . R bt branch represents the long term behavioral transients. Then, the inner voltage U bt can be derived as: where U bt . Since the battery and fuel-cell are connected in series, the regenerative brake only works on the batteries.

B. CONTROL DOMAIN
The energy storage strategy, PMSM control and MMC main circuit control system are key parts in the control domain. The energy storage system adopts the double-loop proportional-integral (PI) controller to maintain the required DC voltage. The PMSM and MMC controller takes the demanded mechanical angular velocity ω mref as input, while the output is the control signal for MMC submodules. The feedback measurements include ω mref , I abc , and rotor position angle θ m . Then the RNN model is analyzed and trained along with the PMSM and MMC main circuit.

C. MECHANICAL DOMAIN
The mechanical domain deals with the energy and forces and their effect on HEB under the conditions of different speed profiles. In general, HEB can be regarded as a particle affected by a set of resistance forces [25]. There are three typical forces of an HEB, i.e., acceleration force F acc , the equivalent resistance F res , gravitational resistance by the slope in the road F gx , which can be derived as: where acc is the HEB's accelerated speed, β is the slope of the roadway, C R and C AE are the coefficients of the rolling resistance and penetration air respectively, ρ is the air density, and A F is the front area of HEB. The electrical domain is supposed to provide traction power to overcome the resistances, which can be presented as: Then, the requested energy from the electrical domain can be derived by Furthermore, the PMSM's mechanical velocity and HEB speed follow the relationship as: where η gr is the gearbox coefficient. The required PMSM's mechanical velocity for system-level emulation can be calculated using equation 19, since the HEB's speed is available from the driving cycle. VOLUME 10, 2022

D. THERMAL DOMAIN
The thermal system mainly considers the electro-thermal performance of IGBTs and power diodes. In the traditional EMT computational model, the power consumption on IGBT will produce heat diffused through its case, which can be modeled as the transient electro-thermal impedance [29]. In this work, the thermal system is also embedded in the RNN model, which is studied and trained independently other than being embedded in the MMC submodule. In this case, the thermal system can provide more accurate thermal behaviour of IGBTs. Therefore, there is no extra time for temperature calculation of IGBTs and diodes, shortening the computation time.

IV. ADAPTIVE COMPUTE ACCELERATION PLATFORMS
Since the proposed HEB real-time emulation scheme consists of both RNN models and EMT models, the Xilinx Versal TM ACAP can be one of the best options for hybrid model implementations [31]. As shown in Fig. 5, the top-level architecture is partitioned into three areas: 1) Programmable logic blocks, 2) AI Engine Array, 3) Processor system. In general, the programmable logic blocks, i.e., fieldprogrammable gate array (FPGA), take the responsibilities to deal with the EMT model, while the AI engine array can solve the RNN model in parallel so that they are efficient at AI algorithms with diverse decision trees and a broad set of libraries, however, it is limited in performance scaling. As shown in Fig. 5, the programmable logic mainly includes three parts: a digital signal processing unit, a configurable logic block, and random access memory.

A. AI ENGINE ARRAY
As shown in Fig. 5 (a), the AI engine array consists of multiple AI engine tiles, and each tile has direct memory, data memory, and steaming interconnection with other tiles. Each AI engine contains a scalar, fixed-point, and floating-point vector unit. Each AI Engine incorporates a high-performance and single-instruction vector processor [24]. An adaptive data flow is the communication network with multiple AI Engine kernels connected by data streams, while direct memory access is only available for neighbouring tiles.
Moreover, a heterogeneous computation architecture is also utilized in the ACAP platform, which delivers all three processing elements. In addition, a high-bandwidth networkon-chip (NoC) is also utilized to provide memory-mapped access, which allows devices to memory and allows memory to map access to the AI engine array.

B. MULTI-DOMAIN DEVICE-LEVEL SYSTEM DECOMPOSITION
In order to implement both EMT and RNN models for HEB, the hardware resources are optimized for different types of models, as shown in Fig. 5 (a): 1) The conventional EMT models from HEB's mechanical domain are implemented in programmable logic, which has the advantage for real-time emulation of fixed models. The programmable logic provides comprehensive embedded compute resources for emulating EMT models.
2) The AI engines executed two RNN models for HEB's fuel-cell stacks, battery stacks, electrical, control and thermal domain, where multiple kernels can handle a large-scale matrix computation. The AI engine can accelerate RNN-based models by parallel matrix computation.
In addition, the high-bandwidth inner NoC between the programmable logic and AI engines can provide microsecond data communication, which also guarantees real-time emulation.

C. VITIS TM AI QUANTIZATION AND COMPILATION
In this paper, the RNN program is established using Python language, then the Docker R and Vitis TM AI Image are used to quantize and cross-compile the RNN model. There are three main steps for RNN model compilation [32]: 1) As shown in Fig. 5 (b), initially, the training and test dataset is prepared for the compiler. Then, the RNN model is trained on the graphics processing unit or CPU of the computer, which generates standard RNN model parameters in the format of the float model.
2) Since the AI engine can not deal with the float model, it is necessary to parse the neural network computation graph from the Python framework to intermediate representation.
The quantization and graph optimization is handled in this stage. In this term, a standard long short-term memory quantizer is used for two RNN models. Then, a xmodel file is generated by Vitis TM AI [32].
3) The modified intermediate representation is deployed on Versal TM VCK190 ACAP board. There are 60 AI engines for each RNN model, when the hidden layer is 1 and the hidden nodes are 100.

V. REAL-TIME MULTI-DOMAIN HARDWARE EMULATION OF HYBRID ELECTRIC BUS
To test and verify the advantages of the proposed real-time multi-domain emulation framework, in this work, the New Flyer Xcelsior R H2 city bus is chosen as the case study, whose parameters are listed in Table 4 in the Appendix. The hardware setup includes oscilloscope, analog-to-digital converters (DAC), Versal TM VCK190 ACAP board, and their power supplies as shown in Fig. 6.

A. DEVICE-LEVEL EMULATION VERIFICATION
The device-level emulation reveals the IGBT turn-on and turn-off transient processes and thermal performance. In the case study, the gate voltage is ± 15 V and the switching frequency of 10 kHz. The IGBTs' parameters are listed in Table 3 in the Appendix. Fig. 8 demonstrates the IGBT switching transient including voltage and current between collector to emitter as long as the junction temperature of IGBT and diode at 0.2 ms time window. During this period, the IGBT turned off and then 85980 VOLUME 10, 2022  turned on twice. The voltage between collector to emitter V ce is around 150 V, while the operating current is around 4 A.
The junction temperature of the IGBT suddenly increased during the period when the MMC started to operate, as shown in Fig.8(b). The RNN model has some noise compared to the EMT model; however, the accuracy is still acceptable. The junction temperature goes down when the operating current is reduced. The RNN model has a significant ripple, and the model error is still around 3 % compared to the EMT model. Figs  shows the IGBT current when the IGBT turns off. The current through IGBT suddenly increases in the reverse direction due to the diode reverse recovery and then decreases to around 0 A. V CE increased from 0 V to 150 V within around 1 µs, and the voltage waveform has a tiny overshoot of 0.1 V. In addition, there is also a slight overshoot of current which is caused by instinct diodes.
Similarly, during the IGBT turn-on period, the collector current increased rapidly to around 3.5 A with a more apparent overshoot for RNN and EMT models. In addition, there is also a voltage overshoot of V ce . Then the current maintains about 3 A.
Both the RNN and EMT models have a similar trend and almost the same static values, which verifies that the RNN model was more accurate than the traditional EMT model.

B. SYSTEM-LEVEL EMULATION VERIFICATION
The multi-domain system emulation results of HEB are shown in Fig. 9, where the HEB electric torque, mechanical speed, the three-phase MMC output voltage, and current are provided. The three-level MMC output source frequency is 60 Hz. The RNN model is trained with 50 epochs with 100 hidden layers and initial learning rate (ILR) is 0.0005. In addition, the hidden layers and ILR impact on RNN model accuracy are also investigated.
The complete NYCC driving cycle is chosen for the testing, where the required HEB speed and power are shown in Fig. 7. The average speed of the NYCC cycle is 11.4 km/h, and the most significant speed is around 45 km/h, which is close to the city bus daily routine. Moreover, there are numerous stops and restarts in the course of its city routine.
Figs. 9(a) and 9(b) demonstrate the HEB torque and angular velocity under the driving condition of the NYCC cycle. At the very beginning, the torque decreased from 38 Nm to 16 Nm as shown in Fig. 9(a). The HEB angular velocity keeps increasing from 0 to 250 rad./s and then does not change until 0.3 s. During this period, the HEB is in startup mode. Then the HEB enters the cruise mode where the speed is around 250 rad./sec. and the T e is fixed at 10 Nm between 0.1 s to 2.9 s.
In this paper, the MMC submodule has a 5.4 m capacitor and 1 mH inductance is on each arm. Fig. 9(c) and 9(d) demonstrate the capacitor voltage and current in the first submodule of the upper arm during the first 0.2 seconds. The submodule voltage reference in the three-level MMC is supposed to be 150 V, because the battery stacks' voltage is 300 V. During 0.1 s and 2.9 s, the HEB maintains the same cruise speed; the MMC output current reduces to 10 A at around 0.1 s as shown in Fig. 9(d).
During the MMC start-up period, the voltage across the MMC module capacitor significantly rippled twice between 130 V and 180 V as shown in Fig. 9(e). Then the capacitor voltage keeps at around 150 V after the MMC finished start-up at around 0.2 s. A more detailed waveform is zoomed in, which shows the emulation results of the RNN model is almost the same as that of the EMT model, where the RNN model error is around 0.13 %, and the maximum error is 3.7%. In addition, the capacitor current waveform also has a similar shape during and after MMC start-up, as shown in Fig. 9(f). The detailed current curve is zoomed-in from 0.5 s to 0.55 s. Fig. 9(g) shows the IGBT junction temperature during the first 1 s. There is also a vibration of junction temperature since the MMC voltage ripples during the start-up. However, the largest overshoot appears at around 0.8 s since the temperature is time delayed compared to voltage and current. Moreover, the temperature is also accumulative, which is why the temperature keeps increasing during the operations.
The comparison of the RNN model parameters in terms of nodes and ILR are shown in Fig. 9(h). Considering the impact on hidden layers, it can be concluded that the more nodes, the less model loss is. At the condition of 30 nodes, the RNN model loss is reduced when the ILR is set to 0.0001 and 0.0005. The higher the ILR, the less RNN model loss is. The increasing ILR and nodes require more hardware resources and time for training. However, this work deployed the off-line RNN model; thus, training efficiency is not considered. 85982 VOLUME 10, 2022  Table 1 summarized the time consumption for the traditional EMT model, behavioral model and the proposed RNN and EMT hybrid model. The length of the HEB multi-domain dataset is 100 s, while the device-level emulation time steps are 1 µs and 0.1 µs. The proposed hybrid RNN and EMT hardware emulation scheme spent much less time than the EMT and behavioral model. In particular, the time consumption of the RNN model is sensitive to the emulation time-step if the nodes and hidden layer are fixed. As long as the hardware platform can compute the RNN model within 0.1 µs, the proposed method can achieve real-time emulation for HEB's multi-domain systems.

VI. CONCLUSION
Due to the increased focus on sustainable transport alternative buses, this paper developed a real-time emulation for hybrid HEB multi-domain systems at both system-level and devicelevel using hybrid EMT and RNN models. The HEB is mathematically divided into several domains, including electrical, control, mechanical, and thermal. The MMC and its control domain strategy are modeled using the RNN algorithm, while another RNN model is used for PMSM emulation. The traditional EMT models are used for fuel-cell stacks and battery stacks. The RNN-based MMC model can reveal the IGBT transient and thermal behaviour at 0.1 µs time-step, providing essential information for the thermal management system. The AI engines of Xilinx Versal TM ACAP compute the RNN models while the programmable logic unit deals with the EMT models. The hardware emulation time-step is 0.1 µs for device-level and 1 ms for system-level. The emulation results show that the average and maximum errors of the RNN model are around 0.13 % and 3.7%, respectively. Future work will extend to developing the detailed computational model of the fuel-cell stack for the hydrogen-based transportation sector. Table 2 summarized the HEB's PMSM parameters, the Siemens BSM300GA160D IGBT model parameters from [29] is listed in Table 3, and the New Flyer city bus parameters from [33] are listed in Table 4.