2.1 Solar Photovoltaic (PV) System
                  A solar photovoltaic (PV) system is an advanced technology that converts sunlight
                     directly into electricity using semiconductor materials that exhibit the photovoltaic
                     effect. These systems are made up of several key components, including solar panels,
                     inverters, and mounting structures. Solar panels consist of many small solar cells,
                     which absorb sunlight and generate direct current (DC) electricity. This DC power
                     is then sent to inverters, which convert it into alternating current (AC) to make
                     it usable by homes, businesses, or the electrical grid.
                  
                  The mounting systems ensure that the solar panels are securely positioned at the optimal
                     angle for maximum sunlight exposure, enhancing efficiency. Modern PV systems often
                     include monitoring and control units to track performance and ensure the system operates
                     at peak capacity. Our specific solar PV system modeled with PSCAD/EMTDC is rated at
                     1 megawatt (MW), which is sufficient to power a large number of homes or a significant
                     portion of an industrial facility’s energy needs. The system plays a key role in contributing
                     to clean, renewable energy production, helping to reduce greenhouse gas emissions
                     and dependence on fossil fuels.
                  
                  
                  
                  
                  where, $I_{ph}$ is the generated photocurrent, $G$ is solar irradiance ($W\diagup
                     m^{2}$),  $I_{sc}$ is the short circuit current, $T_{cell}$, and $T_{ref}$ are the
                     cell and reference temperatures. $P_{out}$ denotes the output power, $V_{oc}$ is open-circuit
                     voltage and $FF$ is the fill factor. $\eta$ is the efficiency and $P_{\in}$ is the
                     input solar power, which is the product of solar irradiance and the area of the solar
                     panel.
                  
                
               
                     2.2 Grid-Forming Inverter (GFM)
                  The Grid-Forming Inverters used in this study are rated equivalently to the solar
                     panels and also been modeled . These inverters are connected to the grid via a step-up
                     transformer, which transitions voltage from low voltage (LV) to medium voltage (MV).
                     For controlling the inverters, we are implementing a power-frequency (p-f) droop control
                     strategy. This approach allows the inverters to adjust their output power in response
                     to grid frequency changes, thereby enhancing stability and supporting grid integration.
                     Additionally, the p-f droop method enables seamless operation with other power sources
                     in distributed energy systems, contributing to the overall reliability and resilience
                     of the grid.
                  
                  
                        
                        
Fig. 1. The p-f droop control strategy
                      
                  
                  
                  where, $\theta$ is the angle provided by the control, $\omega_{*}$ and $p_{*}$are
                     the nominal frequency and power values, $m_{p}$ is the droop gain, $p$ is the ac power
                     to the grid.
                  
                  
                  Here, $v_{*}$ is the reference voltage and  is the reference for the inner voltage
                     control loop.
                  
                  The measured voltage is compared with the reference voltage generated by the outer
                     voltage reference generator ($v_{dq}^{r}$), resulting in an error signal ($\dot{\zeta_{dq}^{v}}$)
                     that reflects the difference between the two, as described in equation (7).
                  
                  
                  
                  This error signal is then passed through a proportional-integral (PI) controller,
                     where $k_{p}^{v}$ represents the proportional gain and $k_{i}^{v}$ represents the
                     integral gain. The controller adjusts the control output to minimize the voltage error,
                     while also improving the system's dynamic response and accuracy within the voltage
                     control loop through the use of feed-forward gains. The final two terms in equation
                     (8) correspond to the feed-forward elements, where $C_{f}$ is the output filter capacitance,
                     and $i_{dq}$ is the actual measured current. The output from the PI controller and
                     feed-forward terms generates the reference current signal ($i_{dq,\: *}^{r}$), which
                     is subsequently sent to the current limiter for further processing.
                  
                  
                        
                        
Fig. 2. The inner voltage control loop.
                      
                  
                  
                  The current regulator (equation 9) serves as the second stage in the cascaded control
                  loop, ensuring that the current reference signal stays within safe limits ($i_{dq,\:
                  *,\: lm}^{r}$) to protect the inverter from operating beyond its capacity.
                  
                  
                  
                  
                  Final stage of the inner control system is a current control loop, which ensures that
                     the inverter’s output current accurately follows the precisely limited reference current
                     signal. Real-time measurements of the inverter's actual output current are provided
                     by current sensors, allowing for precise tracking and control.
                  
                  The current at the output filter, $i_{dq}^{r}$, is compared with the limited reference
                     current, $i_{dq,\: *,\: lm}^{r}$, generating an error signal, $\dot{\xi_{dq}^{v}}$,
                     as outlined in equation (10). This error signal is processed by a proportional-integral (PI) controller, with
                     $k_{p}^{i}$ as the proportional gain and $k_{i}^{i}$ as the integral gain, which adjusts
                     the control output to minimize the current error. Additionally, feed-forward gains
                     are applied to enhance the control response, $v_{dq,\: *}^{r}$, resulting in the signal
                     . The final two terms in equation (11) represent the feed-forward components, where $L_{f}$ refers to the inductance of
                     the output filter.
                  
                  
                        
                        
Fig. 3. The inner current control loop.
                      
                  
                  The signal $v_{dq,\: *}^{r}$ is ultimately modulated and transformed into a Pulse-Width
                     Modulation (PWM) signal, which drives the inverter switches to generate the overall
                     control signal for the grid, as described in equation (12).
                  
                
               
                     2.3 Proton Exchange Membrane (PEM) Electrolyzer
                  A PEM electrolyzer is a device that uses electrical energy to break water down into
                     hydrogen and oxygen through electrolysis. It consists of three main components: an
                     anode, a cathode, and a proton-conducting membrane that separates them. PEM electrolyzers
                     are known for their high efficiency, operating at relatively low temperatures, and
                     their ability to rapidly adjust to fluctuations in power input, making them ideal
                     for integration with renewable energy sources. In our research, we developed a PEM
                     electrolyzer model in Simulink/ EMT which is rated at 100 kW, 10% of the power source's
                     capacity, while the remaining power is supplied directly to the grid.
                  
                  The PEM electrolyzer model in Simulink was constructed with the following key components
                     and considerations:
                  
                  Electrolyzer Stack: Represented the individual cells within the electrolyzer, each
                     contributing to the overall electrolysis process. The stack was modeled based on real-world
                     parameters such as cell voltage, current density, and operating pressure.
                  
                  Anode and Cathode Reactions: Modeled the electrochemical reactions at the anode and
                     cathode, where water is split into hydrogen and oxygen. The reaction dynamics were
                     key to understanding how power input from the solar PV system influenced hydrogen
                     production.
                  
                  Proton-Conducting Membrane: This component enabled proton transport while isolating
                     the hydrogen and oxygen gases. The membrane’s resistance and its impact on system
                     efficiency were incorporated into the model.
                  
                  Thermal Management and Control Systems: Implemented thermal models and control algorithms
                     to maintain optimal temperature and pressure levels within the electrolyzer, ensuring
                     consistent performance even under variable power conditions.
                  
                  
                  
                  
                  
                  
                  Equation (13) represents the overall electrochemical reaction where water is split into hydrogen
                     and oxygen gas. Equation (14) is the Nernst equation of cell voltage, where, $E_{cell}$ is the cell voltage, $R$
                     is the gas constant, $T$ is the temperature, $F$ is Faraday’s constant and $P_{O_{2}}$
                     and $P_{H_{2}}$ are the partial pressures of Oxygen and Hydrogen. The amount of Hydrogen
                     produced is calculated by equation (15) where, $\dot{m_{H_{2}}}$ is the mass flow rate hydrogen produced in kg/s, $N_{cell}$
                     denotes the number of cells in the electrolyzer stack, $M_{H_{2}}$ is the molar mass
                     of Hydrogen, $A_{cell}$, and $I_{cell}$ are the area and current density of the cells
                     respectively. Equation (16) and (17) calculates the Lower Heat Value (LHV) efficiency and Higher Heat Value (HHV) efficiency
                     of the electrolyzer under study respectively, where $P_{elec}$ is the amount of electric
                     power consumed.