# Enhancing Photovoltaic Power Predictions with Deep Physical Chain Model
## 2 Methodology and Resources
### Features Engineering
#### 2.4.5 Deep Chain Model  
Our approach to deep chain models replaces each block in the physical chain with a Transformer Bi-LSTM model. Our proposed model works with the flow described by the following steps:  
* First, from the inputs of GHI, besides the exogenous variables related primarily to solar positioning, once \(\text{NWP}_{\text{GHI}}\) data go through a statistical calibration, they pass through the first instance of the Transformer Bi-LSTM architecture that we call the Deep GHI Model (DGM). The output from that first instance is a more accurate GHI forecast value, and it is called \(\text{GHI}_{\text{Forecast}}\). At the same time, we use from the inputs of GHI the LMD version of this quantity, \(\text{LMD}_{\text{GHI}}\). Thus, a concatenation between the \(\text{LMD}_{\text{GHI}}\) data and \(\text{GHI}_{\text{Forecast}}\) besides the exogenous variables is performed, creating a new vector that we call \(\text{Output}_{\text{GHI}}\). These exogenous variables are described in greater detail in the following paragraphs. * Then, \(\text{Output}_{\text{GHI}}\), besides another variable like the exogenous variables -again-, passes through a decomposition model to obtain, from the GHI quantity, the best DHI values for forecasting. Now, we occupy a second instance of the Transformer Bi-LSTM model, which is used to learn the underlying physics of the decomposition process. This second instance is called the Deep Decomposition Model (DDC). At last, the result of the use of this second instance of the model is concatenated with the original \(\text{NWP}_{\text{DHI}}\) data to form a new vector that we call \(\text{Output}_{\text{DHI}}\). For future convenience, we define another new vector, called \(\text{Output}_{\text{DSCP}}\), as the concatenation between \(\text{Output}_{\text{GHI}}\) and \(\text{Output}_{\text{DHI}}\). * To take into account the tilt angle of the solar panels, both global irradiance and diffuse irradiance from \(\text{Output}_{\text{DSCP}}\) have to go through a transposition method. Once the transposition over those irradiances is complete, the result of this process is the Global Tilted Irradiance (GTI) calculated by the third instance from the Transformer Bi-LSTM architecture, which we call the Deep Transposition Model (DTM). Then, those values are concatenated with the \(\text{LMD}_{\text{GTI}}\). This new concatenation creates a new vector called \(\text{Output}_{\text{GHI}}\). Figure 6: Attention mechanism diagram. Finally, using a concatenation between all the previous variables, and again beside the exogenous variables, and using a direct transformation method through a final instance from the Transformer Bi-LSTM architecture that we call the Deep Power Model (DPM), we perform the final power photovoltaic forecasting. Figure 7 represents the proposed model. The green boxes denote the input models responsible for processing different irradiance and meteorological variables (GHI, DHI, GTI, Power). The orange boxes represent the concatenation of the previous hour's measurements with the forecasted hour. The red boxes highlight the deep learning models that transform these inputs into more accurate predictions. The blue dashed lines represent the input-output framework, guiding the data through the stages and feeding the output from one model as input to the next. Although there are more complex approaches in the literature, our objective is to evaluate the effectiveness of the proposed architecture in a simplified context. Each model is trained independently, and specific data from the photovoltaic plant are integrated to improve forecast accuracy, exploring two methodologies: one direct and the other based on the proposed chain model. The quality of the predictive model largely depends on the preparation and selection of data variables. The _PVLIB_ library is used to extract active hours of solar irradiation, applying the Solar Position Algorithm (SPA) [38]. Anomalies are detected and corrected by cubic spline interpolation.