Introduction

Nowadays, 97% of Earth’s water is saline and contained in the oceans, while 2% is locked in glaciers. Only 1% constitutes accessible freshwater1. This limited freshwater supply contributes to the global water crisis, with approximately 703 million people lacking access to clean water a figure equating to 1 in 10 individuals worldwide as of 20222. Algeria is significantly investing in water desalination to address this issue to enhance its drinking water supply. Recent reports indicate that desalination plants contribute approximately 18% of the country’s drinking water. The government has outlined plans to increase this share to 42% by 2024 and to 60% by 20303.

Reverse Osmosis (RO) membrane desalination has emerged as one of the primary methods for desalting water, representing 65% of the total installed capacity of desalination technologies globally4. However, energy consumption remains a critical factor hindering the widespread adoption of desalination systems. In regions without access to electricity, implementing these systems becomes practically impossible, often forcing communities to migrate. Furthermore, the heavy reliance of RO desalination systems on fossil fuels raises environmental concerns, including greenhouse gas emissions5.

Renewable energy offers a sustainable pathway to decarbonize water production via Reverse Osmosis (RO)6. Solar energy, the most abundant and widely used renewable energy source, leads to powering RO systems globally7. However, relying solely on photovoltaic systems (PV) often necessitates integrating additional energy sources, such as wind turbines or wave energy, to ensure a reliable power supply. Despite their potential, these renewable sources face challenges due to their inherent intermittency and unpredictability. Consequently, energy storage devices are required to maintain a continuous and stable power supply, particularly in small-scale applications.

Literature review

Photovoltaic (PV) cells convert light into electrical energy, but their efficiency is affected by solar irradiation, temperature and load variations. These variations necessitate maximum power point tracking (MPPT) to optimize power output and maximize energy harvest8. The literature presents a wide range of MPPT methods, with9 providing a comprehensive overview. These methods are classified based on tracking speed, efficiency, cost, and complexity. Among the most commonly used techniques are Perturb and Observe (P&O) and Incremental Conductance (INC), known for their simplicity and ease of implementation. However, the P&O and INC methods struggle to effectively track the MPP under varying irradiation conditions, often failing to distinguish between the GMPP and Local Maximum Power Points (LMPPs) under partial shading10.

In recent years, to overcome the limitations of traditional MPPT techniques, various Soft Computing (SC) approaches such as artificial intelligence (AI), fuzzy logic, and neural networks have been introduced for PV systems due to their high tracking efficiency and fast dynamic response. However, these techniques often require complex control architectures, high computational resources, and substantial training datasets11,12,13. Alternatively, metaheuristic optimization algorithms, including Particle Swarm Optimization (PSO), Genetic Algorithm (GA), and Grey Wolf Optimization (GWO), have been proposed for their ability to locate global optima by effectively balancing exploration and exploitation. However, they tend to be computationally intensive and slower to converge due to extensive search phases14. To address these challenges, hybrid MPPT techniques have emerged as a promising solution, blending the simplicity and speed of conventional algorithms with the global search strength of metaheuristics to improve performance under dynamic environmental and partial shading conditions15. These hybrid strategies enhance the accuracy and convergence speed of MPP tracking by leveraging both local and global search capabilities16. Among them, combining Perturb and Observe (P&O) with metaheuristic methods has become one of the most practical and widely adopted approaches, where P&O provides real-time responsiveness and the hybridization boosts GMPP detection while minimizing oscillations. A summary of various MPPT techniques combined with P&O is presented in Table 117,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42.

Similarly, efficient power conversion is essential for optimizing energy utilization in PV-battery systems. Inverters and converters are crucial for effective energy management43. Traditional two-stage systems, which use DC/DC and DC/AC converters, are effective but come with increased complexity and costs due to multiple conversion stages44. The addition of a DC/DC converter to handle voltage variations further increases system cost and reduces overall efficiency. The Z-source inverter (ZSI) addresses these issues by offering a single-stage conversion process that simplifies the system, reduces the need for additional components, and lowers overall costs45. Additionally, ZSI exhibits better immunity to electromagnetic interference (EMI) noise compared to the standard Voltage Source Inverter (VSI)46. However, the ZSI has limitations, including high voltage stress across switches and passive components, limited boosting capability, and discontinuous input current, which can affect performance and reliability47. To overcome these drawbacks, the quasi-Z-source inverter (QZSI) has been proposed48. It enhances the original ZSI topology by incorporating an improved impedance network, enabling continuous input current, reducing voltage stress on components, and enhancing voltage boosting capability.

Recent advancements in Maximum Power Point Tracking (MPPT) techniques for photovoltaic (PV) and hybrid renewable energy systems have emphasized the integration of intelligent optimization algorithms and adaptive control strategies to enhance tracking efficiency under dynamic and challenging environmental conditions. Ibrahim et al.49 introduced a high-speed MPPT scheme based on Horse Herd Optimization with dynamic linear active disturbance rejection control, ensuring fast convergence and stability. Abdelmalek et al.50 validated a hybrid grey wolf equilibrium optimizer, while Deghfel et al.51 combined genetic and whale optimization within an MRAC framework, both showcasing superior adaptability. Bouguerra et al.52 expanded MPPT applications to PEM fuel cells using flying squirrel and cuckoo search methods, whereas Belghiti et al.53 designed an adaptive FOCV with robust IMRAC control for standalone PV systems. Further contributions explored specialized algorithms such as zebra54, hybrid MPPT under grid variability55, and coordinated MPPT for wind systems with hybrid storage56,57. Optimization-centric methods, including super-twisting control with grey wolf optimization58, AI-based MPPT with Z-source inverters59, and sliding mode control in triple-junction PV systems for EV charging60, offered significant improvements in real-world scenarios. Innovative nature-inspired algorithms like guided seagull61, accelerated Aquila62, and sooty tern optimization63 demonstrated effectiveness in partial shading conditions, while classical yet refined strategies such as perturbation and observation64 and buck-boost sliding mode MPPT65 ensured practical deployment readiness. Sibtain et al.66 developed an adaptive fractional-order PI controller for energy management in a multi-source hybrid electric vehicle (Battery/UC/FC), demonstrating the effectiveness of advanced control in balancing diverse energy sources. In another work, Sibtain et al.67 proposed a fuzzy robust variable step-size P&O algorithm for MPPT in standalone and grid-connected systems, which improved tracking stability under fluctuating irradiance. Similarly, Nasir et al.68 introduced an adaptive fractional-order PID-based MPPT controller for PV grid-connected systems, achieving faster convergence and improved efficiency under rapidly changing weather conditions. Extending this concept, Sibtain et al.69 presented a multi-control adaptive fractional-order PID strategy for PV/wind hybrid systems, highlighting the adaptability of fractional-order control to multi-source integration. Furthermore, Khan et al.70 proposed a variable step-size fractional incremental conductance algorithm to enhance MPPT performance under dynamic atmospheric conditions. Collectively, these studies affirm the growing trend toward robust, intelligent, and hybridized MPPT approaches aimed at achieving reliable power extraction across diverse renewable energy platforms.

Table 1 Comparative review of P&O techniques.

Beyond efficient power conversion in PV-battery, effective water desalination relies on robust high-pressure pumping mechanisms. In reverse osmosis (RO) desalination systems, high hydraulic pressures are required to overcome the osmotic pressure of saline feed water. High-pressure pumps, driven by electric motors, play a crucial role in pressurizing the feed water for desalination71. Various motor types are used in RO desalination, with induction motors being the most widely employed due to their high reliability, efficiency, and ability to handle the demanding loads of high-pressure pumps72. To ensure optimal performance and energy efficiency in RO systems, the control of the induction motor is pivotal for optimizing system performance. Traditional methods, such as Field-Oriented Control (FOC) and Direct Torque Control (DTC), have been widely utilized. FOC ensures precise torque and speed control by decoupling flux and torque components, providing fast response and high efficiency. However, its performance is sensitive to motor parameter variations. In contrast, DTC offers a simpler structure, rapid dynamic response, and robustness against parameter fluctuations but suffers from steady-state torque ripples and efficiency losses at lower speeds73. With advancements in digital control techniques, more sophisticated methods have emerged to enhance motor performance. Model Predictive Control (MPC) has become a promising alternative to traditional induction motor control methods74. MPC leverages predictive models to optimize control actions, reducing tracking errors and improving transient response. It is broadly categorized into Continuous MPC and Finite-Set MPC (FS-MPC)75. Among FS-MPC methods, Predictive Torque Control (PTC) and Predictive Current Control (PCC) stand out for their superior dynamic performance. PTC evaluates stator flux and electromagnetic torque within a cost function framework, offering rapid response and enhanced efficiency, making it a viable replacement for conventional approaches76.

On the other hand, modeling the Reverse Osmosis (RO) system is crucial for understanding its dynamic behavior and designing effective control strategies77. Accurate models enable the prediction of system performance under varying operational conditions, such as fluctuations in feed water quality, pressure, and flow rates. These models form the foundation for developing control algorithms that ensure optimal performance while meeting desired output specifications, such as permeate flow rate and water quality78. Effective monitoring and control are essential to enhance throughput, optimize energy consumption, and maintain safe operation. Therefore, an advanced control system is required to maintain operations close to optimal conditions79. Several control strategies have been explored in the literature to regulate RO systems, each offering distinct advantages and limitations80,81,82,83,84. Initially, PID controllers were widely adopted due to their simplicity and ease of implementation. However, the difficulty of fine-tuning them for varying conditions led to the development of hybrid PID controllers incorporating heuristic algorithms to enhance performance85. While these hybrid approaches improved efficiency, they were computationally intensive and required long settling times.

Advanced control methodologies have been introduced to overcome these challenges. Model Predictive Control (MPC) emerged as a powerful approach, capable of handling system nonlinearities and uncertainties effectively86. However, its real-time implementation is often constrained by high computational demands, as it requires solving complex optimization problems at each control interval. Among the various control strategies, the Linear Quadratic Regulator (LQR) stands out as a fundamental optimal control method, particularly suitable for multi-input, multi-output (MIMO) systems87. It minimizes a quadratic cost function that balances state deviations and control efforts, ensuring both stability and efficiency. Within a state-space framework, LQR determines the optimal feedback gain matrices by solving the algebraic Riccati equation, providing a structured and computationally efficient approach to control design88.

Paper contributions

To enhance system performance, this paper presents a novel high-performance, single-stage photovoltaic/battery-powered reverse osmosis (PV-Battery-RO) desalination system. The system harnesses solar energy through photovoltaic panels and incorporates battery storage to ensure continuous operation during nighttime or low solar availability. The generated power directly drives an induction motor coupled to a centrifugal pump, which supplies pressurized water to the RO unit. To maximize efficiency, a hybrid MPPT control strategy is employed to track the maximum power point under uniform, rapidly changing irradiance, and partial shading conditions, ensuring optimal energy utilization. Additionally, a dynamic control approach is introduced to regulate the desalination process in response to real-time load demands. The main contributions of this paper are manifested as follows:

  1. 1.

    A hybrid Spotted Hyena Optimizer (SHO) and Perturb and Observe (P&O) MPPT algorithm is implemented. SHO handles global exploration to avoid local maxima under partial shading, while P&O enhances tracking speed and real-time responsiveness. This dual-layer MPPT approach ensures fast, accurate convergence to the Global Maximum Power Point (GMPP) in dynamic irradiance conditions.

  2. 2.

    The proposed system uses a Quasi-Z Source Inverter (QZSI) to drive a three-phase induction motor connected to a centrifugal pump. The QZSI integrates voltage boost and inversion within a single-stage topology, eliminating the need for separate DC-DC and DC-AC converters. This reduces overall system complexity, switching losses, and enhances reliability.

  3. 3.

    The desalination process is modeled as a Two-Input-Two-Output (TITO) system, with control targets being the permeate flow rate and product water salinity. A Linear Quadratic Regulator (LQR) is designed to minimize an infinite horizon quadratic cost function. This approach provides fast dynamic response and minimal overshoot (2%) compared to conventional PID, FOPID, and Sliding Mode Control (SMC). Statistical comparison shows LQR achieves the best performance with lowest IAE, ISE, RMSE, and highest tracking efficiency (99.2%).

  4. 4.

    Experimental validation through hardware-in-the-loop (HIL) testing using the dSPACE-1104 platform confirms the real-time feasibility and efficiency of the proposed strategies under various operating conditions.

The organization of this paper is as follows: First section introduces the motivation, objectives, and background of the study. Section “Literature review” presents a detailed literature review and outlines the specific contributions of this work in “Paper contributions”. Section “Proposed RO system configuration” describes the configuration of the proposed solar-powered RO desalination system. Section “Description and mathematical modelling of the proposed reverse osmosis (RO) system” provides mathematical modeling of all major subsystems, including the photovoltaic array, battery, quasi-Z-source inverter, induction motor, centrifugal pump, and reverse osmosis unit. Section “Control strategy for the proposed system” explains the control strategies implemented in the system, such as the SHO–P&O-based MPPT, battery management, predictive control for the QZSI, and LQR control for the RO process. Section “Results and discussion” presents both simulation results and real-time implementation outcomes. Section “Discussion and future work” discusses the key findings, interprets the performance of the system, and outlines directions for future research. Finally, “Conclusion” concludes the study by summarizing the major contributions and outcomes.

Proposed RO system configuration

The proposed brackish water reverse osmosis (BWRO) desalination system, powered by a PV-battery setup, integrates multiple components to ensure efficient and stable freshwater production. As shown in Fig. 1, the system begins with solar energy conversion through a PV array, which supplies power to a quasi-Z-source inverter (QZSI) for efficient voltage regulation. A battery storage unit stabilizes power availability under fluctuating solar conditions, managed through a buck-boost converter that maintains a stable DC link voltage. To further optimize energy utilization, a hybrid SHO-P&O MPPT algorithm is employed, generating a reference inductor current (\(\:{I}_{Lref}\)), which is utilized in the predictive torque control (PTC) cost function. The QZSI drives a three-phase induction motor (IM), which powers a centrifugal pump to pressurize brackish water before it enters the reverse osmosis (RO) membrane. For precise motor control and efficiency, a predictive torque control (PTC) strategy governs motor speed and torque by optimizing stator and rotor flux, torque, and inductor current. The control process includes flux estimation using motor current and voltage measurements, followed by a prediction block that forecasts system behavior over the next control interval. The cost function ensures minimal torque error, flux deviation, and inductor current ripple while maintaining stability and fast dynamic response. In parallel, a linear quadratic regulator (LQR) controls the permeate flow rate (\(\:{Q}_{p}\)) and product water salinity (\(\:{C}_{p}\)) by adjusting the reference pressure (\(\:{P}_{f}\)), ensuring optimal desalination efficiency. Once \(\:{P}_{f}\) is determined, an optimized reference speed (\(\:{W}^{\text{*}}\)) is computed and used for motor control via PTC.

Fig. 1
Fig. 1
Full size image

The proposed RO system .

Description and mathematical modelling of the proposed reverse osmosis (RO) system

Model of the photovoltaic generator

Photovoltaic (PV) cells convert light into electricity via p-n junctions. When connected to a resistive load, they generate direct current until irradiance stops89. Their behavior is modeled using one, two or three-diode models, with the two-diode model offering better efficiency under varying conditions90. The equivalent circuit is shown in Fig. 2, and the I–V characteristic is given by91:

$$\:{I}_{pv}={I}_{ph}-{I}_{D1}-{I}_{D2}-\frac{{V}_{pv}+{I}_{pv}{\:R}_{s}}{{R}_{sh}}$$
(1)

The Photo generated current is given as:

$$\:{I}_{ph}=\left[{I}_{sc}+{K}_{i}\left(T-{T}_{ref}\right)\right]\frac{G}{{G}_{ref}}$$
(2)

The diode current is given as:

$$\:{I}_{d,i=\left\{\text{1,2}\right\}}={I}_{0i}exp\left(\frac{{V}_{pv}+{I}_{pv}{R}_{s}}{{a}_{i}\times\:{V}_{T}}\right)$$
(3)

with

$$\:{V}_{T}=\frac{k\times\:T}{q}$$
(4)

where \(\:{I}_{pv}\:\)and \(\:{v}_{pv}\) are the output current and voltage \(\:\left(A,V\right)\),\(\:T\) is the temperature of the p-n junction \(\:\left(K\right)\), \(\:G\) is the solar irradiance \(\:\left(\text{W}/{\text{m}}^{2}\right).\:\:\:{\text{V}}_{\text{T}}\) is the thermal voltage, \(\:\text{q}\) is the electron charge \(\:\left(\text{q}={1.60210}^{-19}\text{C}\right),\text{k}\) is the Boltzmann constant \(\:\left(\text{k}=1.38\:{10}^{-23}\text{}\text{J}/\text{k}\right),{T}_{r}\) is the reference temperature, in Kelvin (K) (= 25 °C + 273), \(\:{I}_{sc}\:\)is the short-circuit current, \(\:{G}_{ref}\:\) is the reference insolation of the cell (= 1000 W/m2), \(\:Ki\) is the short circuit of the temperature coefficient,\(\:\:{R}_{sh}\) is the array shunt resistance, \(\:\:{R}_{S}\:\)is the array series resistance. Figure 3 shows the simulated P–V and I–V characteristics under varying irradiance at 25 °C.

Fig. 2
Fig. 2
Full size image

Equivalent circuit of solar PV module.

Fig. 3
Fig. 3
Full size image

(a) P–V (b) I–V Characteristics for different irradiation levels for the constant temperature 25 °C.

Quasi-Z source inverter

The quasi-Z-Source Inverter (QZSI), has been derived from the original ZSI92. The main parts of the qZSI are the three-phase inverter bridge and the impedance network. The three-phase inverter bridge consists of insulated gate bipolar transistors (IGBTs) with integrated free-wheeling diodes (FWDs), which are responsible for converting the DC voltage from the input into a three-phase AC voltage. The impedance network in the qZSI is designed using components, the parasitic resistance of the inductors (r1,r2), inductors (L1,L2), capacitors (C1, C2) and a diode (D)93.

The QZSI operates in two distinct modes: the non-shoot-through state and the shoot-through state94. In the non-shoot-through state, the inverter functions similarly to a conventional VSI, with diode D conducting to transfer the PV voltage to the DC link, as shown in Fig. 4. During the shoot-through state, at least one inverter leg is short-circuited, causing diode D to turn off, which allows the inductors to charge the capacitors, thereby boosting the voltage, as illustrated in Fig. 5.

In a steady state, the capacitor voltages, the peak value of the DC-link, and the output peak phase voltage from the inverter are given as:

$$\:\left\{\begin{array}{l}{V}_{C1}=\frac{1-D}{1-2D}{V}_{PV}\\\:{V}_{C2}=\frac{D}{1-2D}{V}_{PV}\end{array}\right.$$
(5)
$$\:{\stackrel{\prime }{v}}_{dc}=\frac{1}{1-2D}{V}_{PV}=B{V}_{PV}$$
(6)
$$\:{\stackrel{\prime }{v}}_{ac}=M\cdot\:B\cdot\:\frac{{V}_{PV}}{2}=M\frac{{\stackrel{\prime }{v}}_{dc}}{2}$$
(7)
$$\:B=\frac{1}{1-2D}$$
(8)

where \(\:\:D\)is the shoot-through duty ratio, defined as \(\:D={T}_{\text{s}\text{h}}/T,T\) is the switching cycle, and \(\:{T}_{\text{s}\text{h}}\) is the shoot-through time per the switching period, B is the boost factor and M is the modulation index.

Fig. 4
Fig. 4
Full size image

Non-shoot-through state of Q-ZSI.

Fig. 5
Fig. 5
Full size image

Shoot through state of Q-ZSI.

Model of the battery

Energy storage devices have enhanced the reliability and efficiency of the electricity distribution system95. The equivalent model as show in Fig. 6 consists of a regulated voltage source (\(\:{E}_{Batt}\)) in series with an internal resistor (\(\:{R}_{Batt}\)). The battery voltage is given by:

$$\:{V}_{Batt}={E}_{Batt}-{R}_{Batt}{I}_{Batt}$$
(9)

where \(\:{I}_{Batt}\) is the battery current. The controlled voltage source is expressed as:

$$\:{E}_{Batt}={E}_{0}-K\frac{Q}{Q-\int\:{I}_{Batt}dt}+A{e}^{B}\int\:{I}_{Batt}dt$$
(10)

where \(\:{E}_{0}\) is the constant voltage, \(\:K\) is the polarization voltage, and \(\:Q\) is the battery capacity. The SOC, which indicates the available charge, is defined as:

$$\:SOC=100\left(1-\frac{\int\:{I}_{Batt}dt}{Q}\right)$$
(11)
Fig. 6
Fig. 6
Full size image

Equivalent model of the battery.

Dynamic equation of the machine

By using simplifying assumptions, the mathematical model of the induction machine can be represented as a set of 2-axis (α, β) form complex equations in a stator reference frame according to the magnitude invariant principle96.

$$\:{\stackrel{-}{v}}_{s}={R}_{s}{\stackrel{-}{l}}_{s}+\frac{d{\stackrel{-}{\psi\:}}_{s}}{dt}$$
(12)
$$\:0={R}_{r}{\stackrel{-}{i}}_{r}+\frac{d{\stackrel{-}{\psi\:}}_{r}}{dt}-j{\omega\:}_{r}{\stackrel{-}{\psi\:}}_{r}$$
(13)
$$\:{\stackrel{-}{\psi\:}}_{s}={L}_{s}{\stackrel{-}{l}}_{s}+{L}_{m}{\stackrel{-}{l}}_{r}$$
(14)
$$\:{\stackrel{-}{\psi\:}}_{r}={L}_{r}{\stackrel{-}{l}}_{r}+{L}_{m}{\stackrel{-}{l}}_{s}$$
(15)

where \(\:{\stackrel{-}{v}}_{s}\) is the stator voltage, \(\:{\stackrel{-}{l}}_{s}\) is the stator current and \(\:{\stackrel{-}{l}}_{r}\) is rotor current, \(\:{\stackrel{-}{\psi\:}}_{s}\) and \(\:{\stackrel{-}{\psi\:}}_{r}\) are the stator and rotor flux respectively, \(\:{\omega\:}_{r}\) is the rotor angular speed, \(\:{R}_{s}\) and \(\:{R}_{r}\) are the stator and rotor resistances, respectively, \(\:{L}_{s},{L}_{r}\) and \(\:{L}_{m}\) are the stator, rotor and mutual inductance, respectively.

The electromagnetic torque in the reference frame \(\:({\upalpha\:},{\upbeta\:})\) and the movement are expressed as follows:

$$\:{T}_{e}=\frac{3}{2}p{\stackrel{-}{\psi\:}}_{s}\times\:{\stackrel{-}{i}}_{s}$$
(16)
$$\:J\frac{d{\Omega\:}}{dt}+f{\Omega\:}=={T}_{\text{e}}-{T}_{\text{L}}$$
(17)

where\(\:\:p\) is the number of pole pairs of the motor \(\:J\) is the motor’s inertia, \(\:f\) is the motor’s friction constant and \(\:{T}_{L}\) is the load torque.

Centrifugal pump

In reverse osmosis (RO), multi-stage pumps create high pressure to overcome the membrane osmotic pressure. An induction motor powers the pump, turning its speed into high-pressure water flow. The pump transfers energy as pressure (to increase pressure) and kinetic energy (to increase water speed), The centrifugal pump model is described by Eqs. (20) and (21)97.

$$\:\:P =a{W}^{2}+bQW+cW$$
(18)
$$\:{T}_{L}\:=a{Q}^{2}+bQW$$
(19)

where \(\:P\) is the pressure of the fluid, \(\:{T}_{L}\) is the load torque of the pump,\(\:\:Q\) is the discharge flow rate, \(\:W\) is the rotation speed of the induction machine, (a, b) are the pump parameters, (c) is a parameter presenting the losses in the pump.

The water flow and pressure of the pump are contingent on the head and available mechanical power at the rotating impeller. Applying Affinity laws, which solely necessitate the pump ratings and real input parameters such as rotor speed and torque98, offers a potential simplification for estimating the pump’s output characteristics. These laws can be expressed as follows:

$$\:\left\{\begin{array}{l}{H}^{{\prime\:}}={\left({\text{w}}_{r}/{\text{w}}_{rn}\right)}^{2}\cdot\:H\\\:{Q}^{{\prime\:}}=\left({\text{w}}_{r}/{\text{w}}_{rn}\right)\cdot\:Q\\\:{P}^{{\prime\:}}={\left({\text{w}}_{r}/{\text{w}}_{rn}\right)}^{3}\cdot\:P\end{array}\right.$$
(20)

where, H, Q, and P denote the rated parameters of the pump at the rated speed, while\(\:\:{\text{W}}_{rn},{H}^{{\prime\:}},{Q}^{{\prime\:}}\), and \(\:{\text{P}}^{{\prime\:}}\) represent the parameters of the pump at a speed \(\:{\text{W}}_{r}\) different from the rated speed.

Figure 7 shows the pressure-flow P(Q) and total head-flow H(Q) characteristics provided by the manufacturer for different frequencies. These curves were obtained either by deriving using the pump affinity laws. The data were processed and visualized using MATLAB to illustrate the variation in hydraulic behavior for motor speed.

Fig. 7
Fig. 7
Full size image

Hydraulic characteristics of the motor pump. (a) Pressure-flow P(Q), (b) total head-flow H(Q).

Model of reverse osmosis (RO) plant

Reverse osmosis is a membrane-based technique that employs ultrafiltration under pressure through semi-permeable membranes effectively removing ions, molecules, and larger particles from a water source99. Multiple dynamic models for reverse osmosis (RO) plants are discussed in77. The present study proposes the TITO model, which presents the brackish water desalination small unit as a multi-input multi-output system. The output variables or set variables are the permeate flow rate (Qp) and the product water salinity (Cp).

These two parameters are fundamental to control water quality, while the input variables or manipulated variables are the feed water pressure (\(\:{P}_{f}\)) and the brine flow rate (Qb). The transfer function representing the reverse osmosis (RO) unit model can be expressed as follows82:

$$\:G\left(s\right)=\frac{Y\left(s\right)}{U\left(s\right)}$$
(21)

where the outputs vector Y and the control vector U are denoted by the following representations:

$$\:Y=\left[\begin{array}{l}{Q}_{p}\\\:{C}_{p}\end{array}\right]\text{\:et\:}U=\left[\begin{array}{c}\:\:{P}_{f}\\\:{Q}_{b}\end{array}\right]$$
(22)

The transfer matrix \(\:G\left(s\right)\) is represented by:

$$\:G\left(s\right)=\left[\begin{array}{ll}{G}_{11}&\:{G}_{12}\\\:{G}_{21}&\:{G}_{22}\end{array}\right]$$
(23)

Precisely, the relationships between output and input variables are structured according to basic first and second-order models, outlined as follows:

$$\:{G}_{11}\:\left(\text{s}\right)\:=\frac{{k}_{11}}{{\tau\:}_{11\:}s+1}$$
(24)
$$\:{G}_{12}\:\left(\text{s}\right)=\frac{{k}_{12}{\omega\:}_{1}^{2}}{{s}^{2}+2{\xi\:}_{{\xi\:}_{1}}{\omega\:}_{1}s+{\omega\:}_{1}^{2}}$$
(25)
$$\:{G}_{21}\:\left(\text{s}\right)=\frac{{k}_{21}{\omega\:}_{2}^{2}}{{s}^{2}+2{\xi\:}_{{\xi\:}_{2}}{\omega\:}_{2}s+{\omega\:}_{2}^{2}}$$
(26)
$$\:{G}_{22}\:\left(\text{s}\right)\:=\frac{{k}_{22}}{{\tau\:}_{22\:}s+1}$$
(27)

The ratio of permeate flow output to the total feed water flow defines the Membrane Recovery Rate, a key parameter in reverse osmosis performance. It is calculated as100:

$$\:R\:=\frac{Qp}{Qf}\:\times\:100$$
(28)

Control strategy for the proposed system

The control system designed for the proposed setup incorporates multiple strategies to manage and optimize the system’s performance under various operating conditions. The control scheme is organized into four loops:

  • The SHO-P&O-based MPPT algorithm ensures maximum energy extraction from the photovoltaic (PV) system under varying climatic conditions, enhance PV energy conversion efficiency and maintain a consistent energy supply.

  • A cascaded PI controller regulates the buck-boost converter, maintaining the DC-link voltage at a specified reference value. This ensures proper inverter operation and stable power transfer.

  • MPC controls the QZSI feed of an induction motor, ensuring electromechanical power conversion.

  • The LQR control loop ensures efficient operation of the reverse osmosis (RO) desalination system by regulating the permeate flow rate and water quality to maintain a consistent freshwater supply rate with optimal conductivity.

Proposed hybrid spotted hyena optimizer and perturb and observe (SHO-P&O) based MPPT

The Perturb and Observe (P&O) algorithm adjusts the operating point of a PV system to track the Maximum Power Point (MPP). It perturbs the system and observes the power change, shifting the operating point accordingly. If power increases, the reference current is incremented; otherwise, it is decremented. This simple trial-and-error approach ensures continuous MPP tracking. Mathematically, the P&O algorithm can be expressed using Eqs. (29) and (30) for increment and decrement, respectively37:

Increment:

$$\:{I}_{\text{new\:}}={I}_{\text{prev\:}}+{\Delta\:}I\:\text{\:if\:}\:{I}_{\text{new\:}}>{I}_{\text{prev\:}}$$
(29)

Decrement:

$$\:{I}_{\text{new\:}}={I}_{\text{prev\:}}-{\Delta\:}I\:\text{\:if\:}\:{I}_{\text{new\:}}<{I}_{\text{prev\:}}$$
(30)

where \(\:{I}_{\text{new\:}}\) is the updated current reference,\(\:{I}_{\text{prev\:}}\) is the previous current reference and \(\:{\Delta\:}I\) is the predefined step size for perturbation.

The P&O method is simple and requires little computation but has drawbacks, including steady-state oscillations around the MPP, sluggish dynamics, steady-state error, and fluctuations under changing sunlight. It often gets trapped in local peaks LMPP, failing GMPP convergence under partial shading101.

To overcome these limitations, nature-inspired optimization techniques such as the Spotted Hyena Optimizer (SHO) have been explored for MPPT. SHO is based on the hunting behavior of spotted hyenas, where the algorithm models their cooperative hunting strategies to enhance search efficiency and convergence speed29. In this approach, the prey’s position represents the optimal solution, and other search agents adjust accordingly. The SHO technique enables effective exploration and exploitation, making it well-suited for tracking the GMPP under complex shading conditions102,103,104.

  • 1. Encircling the prey.

Initially, the algorithm considers the optimal solution as the prey, with each search agent (hyena) adjusting its position relative to this target. The distance ( \(\:{\text{D}}_{\text{h}}\) ) between a hyena and the prey is calculated using:

$$\:{\text{D}}_{\text{h}}=\left|\text{B}\times\:{\text{P}}_{\text{p}}\left(\text{x}\right)-\text{P}\left(\text{x}\right)\right|$$
(31)

where, \(\:{\text{P}}_{\text{p}}\left(\text{x}\right)\) represents the prey’s position, and \(\:\text{P}\left(\text{x}\right)\) denotes the hyena’s current position. The hyena then updates its position as follows:

$$\:\text{P}(\text{x}+1)=\text{P}\left(\text{x}\right)-\text{E}\times\:{\text{D}}_{\text{h}}$$
(32)

The coefficients \(\:\text{B}\) and \(\:\text{E}\) are determined by:

$$\:\text{B}=2\times\:\text{r}$$
(33)
$$\:\text{E}=2\times\:\text{h}\times\:\text{r}-\text{h}$$
(34)

where \(\:\text{r}\) is a random vector in \(\:\left[\text{0,1}\right]\), and \(\:\text{h}\) decreases over iterations, balancing exploration and exploitation.

2. Hunting the prey.

During this phase, hyenas adjust their positions based on the best-known location of the prey. The distance ( \(\:{\text{D}}_{\text{h}}\) ) is recalculated as:

$$\:{\text{D}}_{\text{h}}=\left|\text{B}\times\:{\text{P}}_{\text{h}}\left(\text{x}\right)-\text{P}\left(\text{k}\right)\right|$$
(35)

where \(\:{\text{P}}_{\text{h}}\left(\text{x}\right)\) is the position of the leading hyena, and \(\:\text{P}\left(\text{k}\right)\) represents other hyenas. The position update rule is:

$$\:\text{P}\left(\text{k}\right)={\text{P}}_{\text{h}}-\text{E}\times\:{\text{D}}_{\text{h}}$$
(36)

3. Attacking the prey.

As the algorithm progresses, the coefficient \(\:\text{h}\) decreases, causing \(\:\text{E}\) to fluctuate between positive and negative values. When \(\:\left|\text{E}\right|<1\), hyenas move closer to the prey, refining the search for the optimal solution.

4. Searching for prey.

If \(\:\left|\text{E}\right|>1\), hyenas explore the search space more broadly, avoiding local optima and enhancing global search capabilities. This balance between exploration and exploitation enables the SHO algorithm to navigate complex optimization landscapes effectively.

The proposed P&O-SHO technique integrates the strengths of both algorithms for improved performance. The SHO technique first determines the Global Maximum Power Point (GMPP), preventing entrapment at Local Maximum Power Points (LMPP) and minimizing power loss. The P&O algorithm then refines tracking, ensuring faster convergence and settling time. This hybrid approach is effective under all weather conditions, including uniform insolation, rapid sunlight changes, and partial shading. The pseudocode for the P&O-SHO algorithm is presented in Algorithm 1.

figure b

Algorithm 1 Pseudocode of Hybrid P&O-SHO MPPT algorithm.

Fig. 8
Fig. 8
Full size image

(a) Flowchart of the hybrid SHO-P&O-based MPPT. (b) Bidirectional DC/DC converter with battery.

Figure 8a presents the flowchart of the proposed hybrid SHO-P&O-based Maximum Power Point Tracking (MPPT) algorithm, designed to enhance photovoltaic (PV) system efficiency under dynamic environmental conditions. The algorithm begins with the Spotted Hyena Optimizer (SHO), which performs a global search by initializing a population of candidate solutions, each representing a reference inductor current (ILref). Using measurements of PV voltage and current, the algorithm evaluates the power output of each solution to determine fitness, guiding the search toward the global maximum power point (GMPP). Once convergence is achieved, the optimal ILref is passed to the Perturb and Observe (P&O) stage. The P&O method then performs fine-tuning by adjusting ILref based on incremental changes in power and current, ensuring stable operation with minimal oscillations around the MPP. If a significant power deviation is detected, suggesting a change in irradiance or shading, the system automatically switches back to the SHO phase to re-locate the GMPP. This coordinated switching mechanism ensures fast convergence, high tracking accuracy, and adaptability to varying solar conditions.

Battery control strategy

The Battery Energy Storage System (BESS) operates in two modes: storing excess solar energy and supplying power when solar generation is insufficient or unavailable. A buck/boost DC-DC converter manages power exchange between the battery and the DC bus, ensuring a stable DC link voltage of 600 V, as shown in Fig. 8b105.

To maintain DC bus stability, a two-loop cascaded PI control strategy is employed as shown in Fig. 9106. The outer voltage loop regulates the capacitor voltage ( \(\:{V}_{c1}\) ) by minimizing the error between the reference voltage ( \(\:{V}_{c1ref}\) ) and the actual voltage. The resulting control signal sets the reference battery current ( \(\:{I}_{battref}\) ). The inner current loop then adjusts the battery current by comparing \(\:{I}_{\text{ref\:}}\) with the actual battery current \(\:\left({I}_{bat}\right)\), generating control pulses for switches \(\:{K}_{1}\) and \(\:{K}_{2}\).

The converter operates in two modes:

  • Discharge Mode (Buck Operation): \(\:{K}_{1}\) is active, \(\:{K}_{2}\) is inactive, and the battery supplies power to the load.

  • Charge Mode (Boost Operation): \(\:{K}_{2}\) is active, \(\:{K}_{1}\) is inactive, storing excess energy in the battery.

The BESS ensures dynamic power balancing while keeping battery current within safe limits ( \(\:{I}_{batmin}\) and \(\:{I}_{\text{batmax\:}}\)). Additionally, the State of Charge (SOC) is maintained between 0.3 and 0.9 to prevent overcharging or deep discharging. Fig. 10 presents a flowchart illustrating the coordinated control between the PV system and the battery107.

Fig. 9
Fig. 9
Full size image

PI Control for bidirectional converter.

Fig. 10
Fig. 10
Full size image

DC link voltage control algorithm.

Model predictive control (MPC) of a Qzsi feeding an induction motor (IM)

As previously mentioned, the control of the QZSI primarily relies on the switching states, whether in a shoot-through or non-shoot-through state. In addition to the six active states and two zero states of a traditional inverter, the QZSI introduces seven possible shoot-through states, as outlined in Table 2108.

Table 2 Switching states of a three-phase QZSI.

The space vectors of the output voltage in a QZSI system, based on the possible switching states, can be defined for any sector \(\:x\) as follows:

$$\:{V}_{x}(k+1)=\frac{2{V}_{DC}}{3}\left({S}_{a}+a{S}_{b}+{a}^{2}{S}_{c}\right)$$
(37)

where \(\:x\) {0–15}, VDC is the peak value for the DC link voltage. \(\:{S}_{a},{S}_{b}\), and \(\:{S}_{c}\) are the switching states of the three-phase legs. \(\:k\) represents the current time step and \(\:k+1\) corresponds to the next sampling time.

The switching states of the QZSI are determined by the gating signals \(\:{S}_{a},{S}_{b}\), and \(\:{S}_{c}\), which can be expressed as follows:

$$\:\begin{array}{rr}&\:{S}_{a}=\left\{\begin{array}{ll}1,&\:\text{\:if\:}{S}_{1}\text{\:is\:on\:and\:}{S}_{4}\text{\:is\:off\:}\\\:0,&\:\text{\:if\:}{S}_{1}\text{\:is\:off\:and\:}{S}_{4}\text{\:is\:on\:}\end{array}\right.\\\:&\:{S}_{b}=\left\{\begin{array}{ll}1,&\:\text{\:if\:}{S}_{3}\text{\:is\:on\:and\:}{S}_{6}\text{\:is\:off\:}\\\:0,&\:\text{\:if\:}{S}_{3}\text{\:is\:off\:and\:}{S}_{6}\text{\:is\:on\:}\end{array}\right.\\\:&\:{S}_{c}=\left\{\begin{array}{ll}1,&\:\text{\:if\:}{S}_{5}\text{\:is\:on\:and\:}{S}_{2}\text{\:is\:off\:}\\\:0,&\:\text{\:if\:}{S}_{5}\text{\:is\:off\:and\:}{S}_{2}\text{\:is\:on\:}\end{array}\right.\end{array}$$

The mathematical model for the control objectives involves establishing an inductor current model to predict its future values under each switching state. For the ST state and the NST state, the model is described by (Eq. 38) and (Eq. 39), respectively109:

$$\:{L}_{1}\:\frac{d{i}_{L1}\left(k\right)}{dt}={v}_{C1}\left(k\right)+{r}_{\text{1}}\:{I}_{{L}_{1}}\left(k\right)$$
(38)
$$\:{L}_{1}\:\frac{d{i}_{L1}\left(k\right)}{dt}={v}_{C1}\left(k\right)-{v}_{pv}\left(k\right)+{r}_{\text{1}}{I}_{{L}_{1}}\left(k\right)$$
(39)

where, \(\:{L}_{1}\) is the inductance of L network in QZSI circuit, \(\:{r}_{\text{1}}\) is the stray resistance of the inductor, \(\:{v}_{pv}\left(k\right)\) is the input DC source which is the output voltage of PV .

Predictive torque control (PTC) calculates the future values of controlled variables motor stator flux, torque and QZSI inductor current to optimize system performance. Reference conditions are defined using a cost function that evaluates the future behavior of these variables. Predictions are computed for all possible switching states, and the cost function selects the voltage vector that best tracks the references. The process involves three main steps: estimating unmeasurable variables such as rotor flux \(\:{\psi\:}_{r}\left(k\right)\) and stator flux \(\:{\psi\:}_{s}\left(k\right)\), predicting future plant behavion such as torque \(\:{T}_{e}^{p}\left(k+1\right)\), stator flux \(\:{\psi\:}_{s}^{p}\left(k+1\right)\), and inductor current \(\:{I}_{L1}^{p}\left(k+1\right)\), and optimizing outputs by minimizing the cost function \(\:g\) to ensure precise reference tracking as shown in Fig. 11109.

a. Flux estimation.

Estimating stator and rotor flux is fundamental in predictive torque control (PTC), as it forms the basis for predicting controlled variables. An equation for flux estimation is derived from the Eq. (12) as follows:

$$\:{\overrightarrow{\psi\:}}_{s}\left(k\right)={\overrightarrow{\psi\:}}_{s}(k-1)+{T}_{s}(\overrightarrow{{v}_{s}}\left(k\right)-{R}_{s}\cdot\:\overrightarrow{{l}_{s}}\left(k\right))$$
(40)

The rotor flux n \(\:{\overrightarrow{\psi\:}}_{r}\left(k\right)\)is subsequently calculated using the flux linkage equation 

$$\:{\overrightarrow{\psi\:}}_{r}\left(k\right)=\frac{{L}_{r}}{{L}_{m}}\cdot\:\overrightarrow{{\psi\:}_{s}}\left(k\right)+\overrightarrow{{l}_{s}}\left(k\right)\cdot\:\left({L}_{m}-\frac{{L}_{r},{L}_{s}}{{L}_{m}}\right)$$
(41)

where \(\:{L}_{r},{L}_{s}\) and \(\:{L}_{m}\) are the rotor, stator, and mutual inductances, respectively.

Once the rotor and stator flux estimations are obtained, the next step is to compute the predictions for the controlled variables. These predictions involve calculating the future values of parameters such as stator flux, inductor current and motor torque based on the estimated flux values.

b. Prediction of stator flux, electromagnetic torque, and QZSI inductor current.

Predictive torque control (PTC) requires predictions for the stator flux \(\:{\psi\:}_{\text{s}}\) electromagnetic torque \(\:{T}_{e}\:\)and the inductor current \(\:{I}_{L1}\) of the Quasi-Z-Source Inverter (QZSI) at the next sampling instant \(\:k+1.\)The predicted stator flux \(\:{\psi\:}_{s}^{p}\left(k+1\right)\) is obtained using the discrete-time stator voltage equation as:

$$\:{\psi\:}_{s}^{p}\left(k+1\right)={\psi\:}_{s}\left(k\right)+{T}_{s}\left({\text{v}}_{s}\left(k+1\right)-{R}_{s}\:{\text{i}}_{s}\left(k\right)\right)$$
(42)

The electromagnetic torque prediction depends on the predicted stator flux \(\:{\psi\:}_{s}^{p}\left(k+1\right)\) and the predicted stator current \(\:{i}_{s}^{p}\left(k+1\right)\), as expressed by:

$$\:{T}_{e}^{p}\left(k+1\right)=\frac{3}{2}p{L}_{m}\hspace{0.25em}{{\uppsi\:}}_{s}^{p}\left(k+1\right)\:{\text{i}}_{s}^{p}\left(k+1\right)$$
(43)

The stator current \(\:{\text{i}}_{s}^{p}\left(k+1\right)\) is predicted using a discrete representation derived from the motor’s dynamic model:

$$\:{i}_{s}^{p}\left(k+1\right)=\left(1+\frac{{T}_{s}}{{\tau\:}_{\sigma\:}}\right){I}_{s}\left(k\right)+\frac{{T}_{s}}{{\tau\:}_{\sigma\:}+{T}_{s}}\left\{\frac{1}{{R}_{\sigma\:}}\left[\left(\frac{{K}_{r}}{{\tau\:}_{r}}-\:\:\:{K}_{r}jW\right)\widehat{{\psi\:}_{r}}\left(k\right)+{V}_{s}\left(k\right)\right]\right\}$$
(44)

where, \(\:\sigma\:=1-\frac{{L}_{m}^{2}}{{L}_{s}{L}_{r}},{k}_{r}=\frac{{L}_{m}}{{L}_{r}},{\tau\:}_{r}=\frac{{L}_{r}}{{R}_{r}},{R}_{\sigma\:}={R}_{s}+{R}_{r}{k}_{r}^{2}\) and \(\:{\tau\:}_{\sigma\:}=\frac{\sigma\:{L}_{s}}{{R}_{\sigma\:}}\:\) are constants values computed from motor’s parameters and \(\:{T}_{s}\) is the sample time.

To regulate the inductor current of the QZSI for improved inverter performance, it is essential to predict the next time step inductor current and incorporate these predictions into the cost function with appropriate weighting factors. Using the equivalent circuit of the QZSI, the inductor current at the next time step can be expressed as a function of the switching state. The predictive inductor current \(\:{I}_{L1}^{p}\left(k+1\right)\), can be estimated for the non-shoot-through ( NST) and the shoot-through (ST) using (Eq. 45) and (Eq. 46). respectively.

$$\:{I}_{L1}^{p}\left(k+1\right)=\frac{{T}_{s}.\left({v}_{pv}\left(k\right)-{v}_{{C}_{1}}\left(k\right)\right)+{L}_{1}.{I}_{{L}_{1}}\left(k\right)}{{L}_{1}+{r}_{\text{1}}{T}_{s}}$$
(45)
$$\:{I}_{L1}^{p}\left(k+1\right)=\frac{{T}_{s}.{v}_{{C}_{1}}\left(k\right)+{L}_{1}.{I}_{{L}_{1}}\left(k\right)}{{L}_{1}+{r}_{\text{1}}{T}_{s}}$$
(46)

where, \(\:{v}_{c1}\) and \(\:{i}_{L1}\) are QZSI capacitor voltage and inductor current, respectively; \(\:{L}_{1}\) is the QZSI inductance.

c. Cost function optimization.

The optimal switching state minimizes:

$$\:{g}_{i}=\left|{T}_{e}^{\text{*}}-{T}_{e}^{p}{\left(k+1\right)}_{i}\right|+{\lambda\:}_{\psi\:}\left|{\psi\:}_{s}^{\text{*}}-{\psi\:}_{s}^{p}{\left(k+1\right)}_{i}\right|+{\lambda\:}_{I}\left|{I}_{L1ref}-{I}_{L1}^{p}{\left(k+1\right)}_{i}\right|$$
(47)

where\(\:{T}_{e}^{\text{*}},{\psi\:}_{{s}^{{\prime\:}}}^{\text{*}}\)and \(\:{I}_{L1ref}\) are the reference values for torque, stator flux, and inductor current, respectively, and \(\:{\lambda\:}_{\psi\:},{\lambda\:}_{I}\) are weighting factors. The voltage vector corresponding to the minimum \(\:{g}_{i}\) is applied to the inverter.

Fig. 11
Fig. 11
Full size image

Flow chart of the model predictive control (MPC).

Control of a reverse osmosis plant

This section focuses on the control strategies for the reverse osmosis (RO) system, specifically regulating the permeate flow rate \(\:\left({Q}_{p}\right)\) and product water salinity \(\:\left({C}_{p}\right)\). The permeate flow rate is adjusted by controlling the feed pressure \(\:\left({P}_{f}\right)\), which regulates the velocity of water entering the membrane unit, ensuring optimal desalination performance. In this study, the feed water salinity \(\:\left({C}_{f}\right)\) is considered constant at \(\:5580\mu\:\text{}\text{S}/\text{c}\text{m}\), as measured at the University of Biskra. To maintain the desired water quality, the product water salinity is stabilized by adjusting the brine flow rate \(\:\left({Q}_{b}\right)\). The design of PID, FOPID, and SMC controllers for the Two-Input Two-Output (TITO) RO desalination system is presented in Fig. 12, followed by the design of the Linear Quadratic Regulator (LQR) control strategy in Fig. 13, which enhances system stability, improves performance under uncertainties, and extends membrane lifespan for sustainable operation.

Design of decoupler

The Two-Input Two-Output (TITO) model of the RO system often exhibits strong interactions between variables, making controller design more challenging. To mitigate these interactions, a decoupling mechanism is employed, effectively transforming the TITO system into independent Single Input Single Output (SISO) loops. The decoupler transfer function is defined as110:

$$\:{G}_{d}\left(s\right)=\left[\begin{array}{cc}{g}_{d11}\left(s\right)&\:0\\\:0&\:{g}_{d22}\left(s\right)\end{array}\right]$$
(48)

where:

$$\:{g}_{d11}\left(s\right)=-\frac{{G}_{21\:}\left(s\right)}{{G}_{22\:}\left(s\right)},\:{g}_{d22}\left(s\right)=-\frac{{G}_{12\:}\left(s\right)}{{G}_{11\:}\left(s\right)}$$
(49)

where \(\:{g}_{pij}\left(s\right)\) represents the elements of the original TITO plant transfer function matrix. These decoupling transfer functions cancel the cross-interaction terms, enabling the system to operate as two independent control loops.

Fig. 12
Fig. 12
Full size image

Classic control structure of a reverse osmosis (RO) system.

Linear quadratic controller (LQR)

The linear quadratic controller (LQR) is a widely used optimal control strategy for linear dynamic systems engineering111. It operates on state-space models and uses feedback gain matrices derived from solving the Riccati equation. It minimizes a specific performance criterion that balances system performance and control effort.

a. TITO State-Space Representation.

The RO membrane model is described as a two-input-two-output (TITO) system in state space form:

$$\:\stackrel{\prime }{X}=AX+BU$$
(50)

where the state vector \(\:X\) and the control vector \(\:U\) are defined as:

$$\:X=\left[\begin{array}{c}{Q}_{p}\\\:{\stackrel{\prime }{Q}}_{p}\\\:{C}_{p}\\\:{\stackrel{\prime }{C}}_{p}\end{array}\right],\:U=\left[\begin{array}{c}{P}_{f}\\\:{Q}_{b}\end{array}\right]$$
(51)

The system matrices \(\:A\) and \(\:B\) are given as:

$$\:\varvec{A}=\left[\begin{array}{cccc}-\frac{1}{{\varvec{\tau\:}}_{11}}&\:1&\:0&\:0\\\:-{\varvec{\omega\:}}_{1}^{2}&\:-2{\varvec{\xi\:}}_{1}{\varvec{\omega\:}}_{1}&\:0&\:0\\\:0&\:0&\:-\frac{1}{{\varvec{\tau\:}}_{21}}&\:1\\\:0&\:0&\:-{\varvec{\omega\:}}_{2}^{2}&\:-2{\varvec{\xi\:}}_{2}{\varvec{\omega\:}}_{2}\end{array}\right]\:\:\varvec{B}=\left[\begin{array}{cc}\frac{{\varvec{K}}_{11}}{{\varvec{\tau\:}}_{11}}&\:0\\\:0&\:{\varvec{K}}_{12}{\varvec{\omega\:}}_{1}^{2}\\\:0&\:\frac{{\varvec{K}}_{22}}{{\varvec{\tau\:}}_{22}}\\\:{\varvec{K}}_{21}{\varvec{\omega\:}}_{2}^{2}&\:1\end{array}\right]\:\:\:$$
(52)

b. Augmented dynamic system.

To ensure perfect tracking of the reference values \(\:{Q}_{pref}\) and \(\:{C}_{pref\text{,\:\:}}\) the state-space model is augmented with two additional integral states:

$$\:{x}_{5}={\int\:}_{0}^{t}\:\left({x}_{1}-{x}_{1-\text{r}\text{e}\text{f}}\right)dt,\:{x}_{6}={\int\:}_{0}^{t}\:\left({x}_{3}-{x}_{3-\text{r}\text{e}\text{f}}\right)dt$$
(53)

These represent the accumulated errors in \(\:{Q}_{p}\) and \(\:{C}_{p}\), respectively. Their dynamics are:

$$\:{\stackrel{\prime }{x}}_{5}={x}_{1}-{x}_{1-\text{r}\text{e}\text{f}},\:{\stackrel{\prime }{x}}_{6}={x}_{3}-{x}_{3-\text{r}\text{e}\text{f}}$$
(54)

The augmented system is then expressed as:

$$\:{\stackrel{\prime }{X}}_{\text{aug\:}}={A}_{\text{aug\:}}{X}_{\text{aug\:}}+{B}_{\text{aug\:}}U+{{D}_{\text{aug\:}}}_{\text{}}Z$$
(55)

where \(\:{A}_{\text{aug.\:}}{B}_{\text{aug\:}}\) and \(\:{D}_{\text{aug\:}}\) are augmented matrices incorporating the original dynamics and the integral states. The augmented matrices are defined as:

$$\:{A}_{\text{aug\:}}=\left[\begin{array}{cccccc}-\frac{1}{{\tau\:}_{11}}&\:1&\:0&\:0&\:0&\:0\\\:-{\omega\:}_{1}^{2}&\:-2{\xi\:}_{1}{\omega\:}_{1}&\:0&\:0&\:0&\:0\\\:0&\:0&\:-\frac{1}{{\tau\:}_{21}}&\:1&\:0&\:0\\\:0&\:0&\:-{\omega\:}_{2}^{2}&\:-2{\xi\:}_{2}{\omega\:}_{2}&\:0&\:0\\\:1&\:0&\:0&\:0&\:0&\:0\\\:0&\:0&\:1&\:0&\:0&\:0\end{array}\right]$$
(56)
$$\:{\varvec{B}}_{\text{aug\:}}=\left[\begin{array}{ccc}\frac{{\varvec{K}}_{11}}{{\varvec{\tau\:}}_{11}}&\:&\:0\\\:0&\:&\:{\varvec{K}}_{12}{\varvec{\omega\:}}_{1}^{2}\\\:0&\:&\:\frac{{\varvec{K}}_{12}}{{\varvec{\tau\:}}_{22}}\\\:{\varvec{K}}_{21}{\varvec{\omega\:}}_{2}^{2}&\:&\:1\\\:0&\:&\:0\\\:0&\:0&\:0\end{array}\right]\:{\varvec{D}}_{\text{aug\:}}=\left[\begin{array}{cccccc}0&\:0&\:0&\:0&\:0&\:0\\\:0&\:0&\:0&\:0&\:0&\:0\\\:0&\:0&\:0&\:0&\:0&\:0\\\:-1&\:0&\:0&\:0&\:0&\:0\\\:0&\:0&\:-1&\:0&\:0&\:0\end{array}\right]$$
(57)

c. Linear quadratic controller design.

The control law minimizes the infinite horizon quadratic cost function:

$$\:J={\int\:}_{0}^{{\infty\:}}\:\left({X}_{\text{a}\text{u}\text{g}}^{T}Q{X}_{\text{a}\text{u}\text{g}}+{U}^{T}RU\right)dt$$
(58)

where \(\:Q\) is a symmetric positive-definite matrix that penalizes deviations in states,\(\:R\) is a symmetric positive-definite matrix that penalizes control effort.

$$\:Q=\sigma\:\left[\begin{array}{llllll}1&\:0&\:0&\:0&\:0&\:0\\\:0&\:1&\:0&\:0&\:0&\:0\\\:0&\:0&\:1&\:0&\:0&\:0\\\:0&\:0&\:0&\:1&\:0&\:0\\\:0&\:0&\:0&\:0&\:1&\:0\\\:0&\:0&\:0&\:0&\:0&\:1\end{array}\right],\:R=\left[\begin{array}{ll}1&\:0\\\:0&\:1\end{array}\right]$$
(59)

The control input is derived as:

$$\:U=-K{X}_{\text{aug\:}}$$
(60)

where:

$$\:K={R}^{-1}{B}_{\text{a}\text{u}\text{g}}^{T}P$$
(61)

and \(\:P\) is the solution of the algebraic Riccati equation:

$$\:P{A}_{\text{aug\:}}+{A}_{\text{aug\:}}^{T}P-P{B}_{\text{aug\:}}{R}^{-1}{B}_{\text{aug\:}}^{T}P+Q=0$$
(62)

using MATLAB LQR function:

$$\:[K,S,e]=\text{l}\text{q}\text{r}\left({A}_{\text{aug\:}},{B}_{\text{aug\:}},Q,R\right)$$
(63)

where \(\:S=P\) is the Riccati matrix and \(\:e\) are the closed-loop eigenvalues.

d. Closed-loop system and control inputs.

The closed loop can now be expressed as:

$$\:{\text{X}}_{\text{aug\:}}^{\text{*}}=\left({\text{A}}_{\text{a}\text{u}\text{g}}-{\text{B}}_{\text{a}\text{u}\text{g}}\cdot\:\stackrel{\text{-}}{\text{}\text{K}}\right){\text{X}}_{\text{a}\text{u}\text{g}}$$
(64)

The control inputs \(\:{P}_{f}\) and \(\:{Q}_{b}\) are then deduced as:

$$\:\left[\begin{array}{c}{P}_{f-\text{r}\text{e}\text{f}}\\\:{Q}_{b-\text{r}\text{e}\text{f}}\end{array}\right]=-K{X}_{\text{a}\text{u}\text{g}}$$
(65)

where \(\:K\) is the feedback optimal gain matrix.

e. Controllability analysis.

For the LQR to be effective, the augmented system must be fully controllable. The controllability matrix is given by:

$$\:\text{R}\text{a}\text{n}\text{k}\left(\left[\begin{array}{llllll}{A}_{\text{aug\:}}&\:{A}_{\text{aug\:}}^{T}{B}_{\text{aug\:}}&\:{A}_{\text{aug\:}}^{2}{B}_{\text{aug\:}}&\:{A}_{\text{aug\:}}^{3}{B}_{\text{aug\:}}&\:\dots\:&\:{A}_{\text{aug\:}}^{n-1}{B}_{\text{aug\:}}\end{array}\right]\right)=n$$
(66)

The rank of the matrix is 6, which matches the dimension of the augmented state vector \(\:{X}_{\text{aug\:}}\). Consequently, all state variables will converge to the set values within a finite time.

Fig. 13
Fig. 13
Full size image

Structure of the Linear Quadratic Regulator (LQR) controller.

Results and discussion

This section evaluates the dynamic performance of the proposed Reverse Osmosis (RO) system under various conditions. First, the system is simulated under partial shading conditions with fluctuations in solar irradiation while maintaining a constant reference permeate flow rate (Qpref) of 0.2 m³/h and a constant reference product water salinity (Cpref) of 5.2 g/m³. Next, real-world conditions are considered by incorporating actual solar irradiation data from Biskra and load demands for \(\:{Q}_{ref}^{f}\) derived from a hospital setting. The entire control system, including the RO components, is modeled using MATLAB/Simulink™ with a PV array consisting of four modules connected in a 2 × 2 (series-parallel) configuration. The power-voltage and current-voltage characteristics of the PV array are illustrated in Figs. 3a,b. Finally, the system undergoes experimental validation through a Hardware-in-the-Loop (HIL) setup to assess real-time performance. The parameters used in the simulations are detailed in Supplementary Material. Table A1 (Supplementary Material) lists the parameter values for the system dynamics, and Table A2 (Supplementary Material) lists the parameters for the system.

Case 1: Partial Shading Condition.

The irradiation values for the four cases studied in this paper are presented in Fig. 14. The corresponding P-V and I-V curves of the PV array for these irradiation values are shown in Fig. 15, where (a) illustrates the P-V curves and (b) shows the I-V curves.

Fig. 14
Fig. 14
Full size image

Irradiation profiles for four case.

In the standard test condition (STC), all panels are irradiated at 1000 W/m2 and 25 °C, exhibiting a single Maximum Power Point (MPP) on their P-V characteristic curve. However, under partial shading conditions, such as in Case I, Case II, and Case III, the PV array exhibits two MPPs. Specifically, in Case I, the local MPP is 290 W and the global MPP is 582 W, in Case II, the LMPP is 248 W and the GMPP is 467 W, and in Case III, the LMPP is 204 W and the GMPP is 314 W.

Figure 16 illustrates the output power of the PV array under (a) Case STC and (b) Case I, displaying the photovoltaic power response using the P&O, SOH, and SOH-P&O techniques. In Case STC, the power follows the Global Maximum Power Point (GMPP), with the P&O method showing higher oscillations at the GMPP.

The SOH technique reaches the GMPP at 0.87s, taking longer to converge, while the SOH-P&O method exhibits smaller, almost negligible oscillations, with a much faster response, reaching the GMPP at 0.08s. In Case I, the P&O method shows higher oscillations and fails to reach the GMPP, instead stabilizing at a local Maximum Power Point (LMPP) of 420 W. The SOH technique reaches the GMPP but takes 0.74s to stabilize, while the SOH-P&O method exhibits smaller oscillations and reaches the GMPP much faster at 0.28s.

Figure 17 illustrates the output power of the PV array under (a) Case II and (b) Case III, showing the photovoltaic power response using the P&O, SOH, and SOH-P&O techniques. In Case II, the P&O method fails to reach the GMPP, instead stabilizing at a local Maximum Power Point (LMPP) of 248 W. The SOH technique takes longer to converge, reaching the GMPP at 0.86s, while the SOH-P&O method exhibits smaller, almost negligible oscillations, with a much faster response, reaching the GMPP at 0.13s. In Case III, the P&O method also fails to reach the GMPP, stabilizing at a LMPP of 204 W. The SOH technique reaches the GMPP but takes 0.74s to stabilize, while the SOH-P&O method shows smaller oscillations and reaches the GMPP much faster, at 0.23s.

Fig. 15
Fig. 15
Full size image

(a) P–V curves, (b) I–V curves for the four case.

Fig. 16
Fig. 16
Full size image

Output power of PV (a) Case STC (b) Case I.

Fig. 17
Fig. 17
Full size image

(a) Output power of PV (a) Case II (b) Case III.

Case 2: Under variable irradiance and constant temperature.

Case 2 evaluates the performance of the proposed Reverse Osmosis (RO) system under variable irradiance with a constant temperature of 25 °C. Figure 18 illustrates the irradiance variation over a 2.7-second interval. Initially, the irradiance is 400 W/m2, remaining stable until 0.9 s, resulting in a PV output power of 272 W, voltage of 70 V, and current of 3.88 A. The irradiance then increases to 600 W/m2 by 1.8 s, yielding a PV output power of 410 W, voltage of 70 V, and current of 5.85 A. Finally, the irradiance rises to 1000 W/m2 and remains constant until the end of the operation, producing a PV output power of 700 W, a voltage of 70 V, and a current of 10 A.

The PV behavior under varying irradiance conditions plays a crucial role in determining the system overall efficiency. Simulation responses, including PV power, voltage, current, inductor current, inverter input voltage, and capacitor voltage, are analyzed to assess the performance of each control technique. Additionally, the battery role in ensuring system continuity is evaluated through its state of charge (SOC), voltage and current profiles, which reflect the effectiveness of energy storage under dynamic conditions. The induction motor-pump system is also analyzed, focusing on phase current, voltage, speed, torque, and flux responses, as these parameters are essential for achieving efficient and reliable water pumping.

Figure 19 illustrates the simulation responses of the PV array using the P&O technique. The PV power fluctuates significantly between 50 W and 70 W at the MPP for each irradiance level. The voltage response exhibits oscillations, taking 0.8 s to stabilize at 70 V, with large oscillations across all irradiance conditions. Meanwhile, the PV current fluctuates between 2 A and 4 A at the optimal current. The reference inductor current also exhibits oscillations of ± 10%, and the capacitor voltage peaks ± 10% above its steady-state value of 600 Which leads to suboptimal energy harvesting and reduced system reliability.

Figure 20 presents the battery responses under the P&O technique. The unstable PV output causes significant fluctuations in the battery SOC, with variations of up to 8%. Similarly, the battery current and voltage exhibit substantial oscillations, negatively affecting energy storage efficiency and reducing the battery lifespan over time.

Figure 21 illustrates the motor-pump system behavior under the P&O technique. The motor phase current exhibits irregularities, particularly during the first second, before partially stabilizing. The motor speed lags significantly behind its reference value, reaching 210 rad/s only after 0.9 s. Similarly, the electromagnetic torque displays ripples of ± 12% while attempting to follow the load torque. Furthermore, the stator flux exhibits considerable oscillations and fails to accurately track its reference value of 1 Wb, stabilizing instead at 0.08 Wb.

Figure 22 illustrates the simulation responses of the PV array using the SOH method. Compared to the P&O technique, the SOH approach significantly reduces oscillations at the MPP, resulting in a more stable power output. The PV power stabilizes efficiently, with minimal oscillations and smoother transient behavior in both voltage and current responses. The reference inductor current (L1ref​) stabilizes with minor variations across different irradiance levels but exhibits a longer settling time. Meanwhile, the capacitor voltage reaches 600 V within 0.2 s, with a 5% overshoot.

The battery responses using the SOH method, as shown in Fig. 23, demonstrate significant improvements compared to the P&O method. SOC fluctuations are minimized to within ± 2%, and the battery current stabilizes rapidly within 0.4 s. Additionally, the battery voltage reaches a steady state without noticeable overshoot, ensuring more efficient and reliable energy storage performance.

Figure 24 presents the IM motor pump system responses using the SOH method. The three phase stator currents \(\:{\varvec{I}}_{\varvec{a}\varvec{b}\varvec{c}}\) stabilize within 0.5 s, while the motor speed reaches its reference value of 210 rad/s in 0.4 s. The electromagnetic torque \(\:{\varvec{T}}_{\varvec{e}}\) shows deviations of ± 5% while closely following the load torque, and the stator flux \(\:{\varvec{\psi\:}}_{\varvec{s}}\:\)exhibits minimal oscillations, accurately tracking its reference value of 1 Wb. This enhanced performance ensures efficient and reliable operation under dynamic conditions.

Figure 25 illustrates the simulation responses of the PV assembly using the hybrid SOH-P&O method. The power, voltage, and current of the PV system exhibit minimal oscillations, with the system achieving the MPP for each irradiance level significantly faster than the standalone P&O or SOH methods, stabilizing within just 0.08 s for each irradiance level. Furthermore, the inductor current reference (L1ref) remains free from oscillations, while the capacitor voltage smoothly reaches and stabilizes at its reference value of 600 V. This demonstrates the superior efficiency of the SOH-P&O method in extracting maximum power under varying irradiance conditions.

In Fig. 26, The battery has the most stable performance according to SOH-P&O, with fluctuations in SOC limited to 1%. The voltage and current dynamics are stable, ensuring a smooth energy flow and efficient use of stored energy. The increased stability of PV output power achieved by the SOH-P&O method directly enhances the battery efficiency and reliability in energy storage.

Figure 27 shows the IM motor-pump system responses according to SOH-P&O. The three phase stator currents \(\:{\varvec{I}}_{\varvec{a}\varvec{b}\varvec{c}}\) stabilizes rapidly, with a harmonic-free sine wave shape converging in 0.2 s. The motor speed reaches its reference value of 210 rad/s in just 0.1 s. Meanwhile, the electromagnetic torque \(\:{\varvec{T}}_{\varvec{e}}\) closely follows the load torque with deviations of less than 0.5%. Additionally, the stator flux \(\:{\varvec{\psi\:}}_{\varvec{s}}\:\)response remains stable at its reference value of 1 Wb.

Fig. 18
Fig. 18
Full size image

(a) Solar radiation variation (b) Temperature variation signal profile.

Fig. 19
Fig. 19
Full size image

Simulation responses of PV array (a) PV-power (b) PV-voltage (c) PV current (d) Reference Inductor Current L1 (e) input voltage to the inverter (f) Capacitor voltage C1, by using P&O.

Fig. 20
Fig. 20
Full size image

Simulation responses of battery (a) State of charge SC (b) Battery voltage (c) reference Battery current (d) Battery Current, by using P&O.

Fig. 21
Fig. 21
Full size image

Simulation responses of IM motor-pump (a) Motor phase current. (b) Motor phase Voltage (c) Motor and reference speed (d) motor and load torque (e) motor and reference flux, by using P&O.

Fig. 22
Fig. 22
Full size image

Simulation responses of PV array (a) PV-power (b) PV-voltage (c) PV current (d) reference Inductor Current L1 (e) input Voltage to the Inverter (f) Capacitor Voltage C1, by using SOH.

Fig. 23
Fig. 23
Full size image

Simulation responses of battery (a) State of charge SOC (b) Battery voltage (c) reference Battery current (d) Battery Current, by using SOH.

Fig. 24
Fig. 24
Full size image

Simulation responses of IM motor-pump (a) Motor phase current. (b) Motor phase Voltage (c) Motor and reference speed (d) motor and load torque (e) motor and reference flux, by using SOH.

Fig. 25
Fig. 25
Full size image

Simulation responses of PV array (a) PV-power (b) PV-voltage (c) PV current (d) reference Inductor Current L1 (e) input Voltage to the Inverter (f) Capacitor Voltage C1, by using SOH-P&O.

Fig. 26
Fig. 26
Full size image

Simulation responses of battery (a) State of charge SOC (b) Battery voltage (c) reference Battery current (d) Battery Current, by using SOH-P&O.

Fig. 27
Fig. 27
Full size image

Simulation responses of IM motor-pump (a) Motor phase current. (b) Motor phase Voltage (c) Motor and reference speed (d) motor and load torque (e) motor and reference flux by using SOH-P&O.

Case 3: Under real solar irradiation data and actual load demands.

In the third scenario, the PV system is subjected to real weather conditions using actual solar irradiation data from Biskra, Algeria, two days are considered: one in January and another in March. The average daily solar irradiation levels for Biskra, shown in Fig. 28, provide a realistic assessment of the system performance. The load demands are based on the permeate flow rate reference (Qpref) required by a hospital, as illustrated in Fig. 29. Maintaining a salinity ratio of 5.2 g/m³ to meet water quality standards.

Fig. 28
Fig. 28
Full size image

Average daily solar irradiation in Biskra, Algeria.

Fig. 29
Fig. 29
Full size image

Average daily permeate flow rate demand.

Fig. 30
Fig. 30
Full size image

Simulation responses of PV array for 17/03/2024.

This scenario evaluates the system ability to maintain performance and efficiency under varying real-world irradiation conditions and actual operational requirements.

Figures 30, 31, 32 and 33 present the simulation results from March 17, 2024, and January 18, 2024, comparing the performance of the three techniques: SOH-P&O (black), SOH (blue) and P&O (pink).

Figures 30 and 31 illustrate the PV array responses, including PV power, voltage, current, and reference inductor current (L1). The SOH-P&O method exhibits superior performance by ensuring faster convergence and significantly reducing oscillations, outperforming both the SOH and P&O techniques under real solar radiation and operating load conditions.

Figures 32 and 33 show the motor pump system responses, showcasing motor speed, stator flux, three phase stator current, electromagnetic torque with load torque and the cost function (g). The SOH-P&O method ensures consistent and stable power output under real solar radiation and varying load conditions.

This stability not only enhances energy storage efficiency in the battery but also ensures reliable system operation during periods of low or no solar radiation, as observed over the two studied days. By providing precise reference tracking, minimal torque ripple, and a lower cost function, the SOH-P&O technique delivers fast, accurate, and efficient performance, outperforming other methods.

Fig. 31
Fig. 31
Full size image

Simulation responses of IM motor-pump for 17/03/2024.

Table 3 summarizes the results obtained from the three MPPT algorithms, considering Case 2 (variable irradiance and constant temperature) and real solar radiation with operating load conditions. As observed, the SHO-P&O MPPT algorithm spent less time reaching the MPP. While the conventional P&O and SHO MPPT algorithms exhibited reduced power and high oscillations in steady-state, only the SHO-P&O MPPT algorithm was able to effectively handle small variations in solar irradiance (transitions from 400 W/m2 to 600 W/m2 and then to 1000 W/m2), as well as real solar radiation. In particular, the SHO-P&O MPPT algorithm demonstrated the best performance in PV array power extraction, as it achieved the highest Tracking Factor (TF). The TF is calculated as the ratio of the extracted power sum to the available power sum in the PV array, as follows112:

$$\:\text{T}\text{F}=\frac{\sum\:{P}_{\text{e}\text{x}\text{t}\text{r}\text{a}\text{c}\text{t}\text{e}\text{d}}}{\sum\:{P}_{\text{a}\text{v}\text{a}\text{i}\text{l}\text{a}\text{b}\text{l}\text{e}}}$$
(67)

In Fig. 34, the simulation responses of the RO system for (a) permeate flow rate (Qp) and (b) product water salinity (Cp) demonstrate the enhanced dynamic performance of the LQR controller compared to the SMC, FOPID and PID controllers. The LQR controller achieves a rapid settling time of 0.1 s with minimal overshoot, accurately maintaining the reference value (Qpref). In contrast, the FOPID and PID controllers exhibit significant oscillatory behavior and extended settling times of 4 and 5 s, respectively, indicating reduced control effectiveness for RO operation. While the SMC controller achieves improved performance relative to the FOPID and PID controllers, its settling time of 2 s and moderate precision indicates inferior dynamic response and regulation compared to the LQR controller.

Fig. 32
Fig. 32
Full size image

Simulation responses of PV array for 18/01/2024.

In Fig. 35, the simulation responses for the RO system (a) feed pressure (Pf), (b) feed flow rate (Qf), (c) brine flow rate (Qb), (d) recovery ratio (R%), and (e) reference motor speed (W*) demonstrate the enhanced control dynamics and superior performance of the LQR controller. The LQR controller exhibits rapid stabilization and reduced oscillatory behavior compared to the prolonged settling times and pronounced oscillations observed with the FOPID and PID controllers. Specifically, the LQR controller limits the maximum overshoot to 2%, whereas the SMC, FOPID, and PID responses exhibit overshoots of up to 18% ,22% and 52%, respectively. For feed pressure (Pf), the LQR controller exhibits robust dynamic performance, maintaining fluctuations within 2%. This results in a reference motor speed (W*) with minimal oscillations, effectively mitigating mechanical stress on the motor and prolonging the lifespan of the RO membrane. In contrast, the SMC, FOPID, and PID controllers demonstrate deviations of up to 25% during dynamic operation, potentially causing increased mechanical stress and accelerated membrane degradation, thereby reducing the RO system’s operational longevity. Meanwhile, the water recovery rate (R%) achieves steady-state stabilization at 22% under maximum load conditions (Qpref) with the LQR controller, within fluctuations of 0.5%. By comparison, the SMC, FOPID, and PID controllers exhibit inferior regulation, with variability ranging from 2 to 9%, reflecting reduced control precision under dynamic operating conditions. The performance evaluation of various control techniques for the reverse osmosis desalination plant system is presented in Table 4. Techniques such as PID, FOPID, SMC, and LQR were compared in terms of rise time, settling time, and overshoot. The analysis further demonstrates that the LQR method is highly effective for control the reverse osmosis process.

Fig. 33
Fig. 33
Full size image

Simulation responses of IM motor-pump for 18/01/2024.

Table 3 Main results for performance comparison between the MPPT techniques.
Fig. 34
Fig. 34
Full size image

Simulation responses for RO system (a) permeate flow rate Qp and (b) product water salinity Cp.

Fig. 35
Fig. 35
Full size image

Simulation responses for RO system (a) feed pressure (Pf), (b) feed flow rate (Qf), (c) brine flow rate (Qb), (d) water recovery rate (R%) and (e) reference speed motor (W*).

Real-time implementation

This section discusses the experimental results obtained through Hardware-in-the-Loop (HIL) testing, aimed at evaluating and comparing the real-time performance of the proposed Reverse Osmosis (RO) system. The study examines the efficiency of three Maximum Power Point Tracking (MPPT) techniques: P&O, SOH and the hybrid SOH-P&O method. These techniques were implemented to optimize the power extraction from the photovoltaic (PV) system under varying operating conditions. Furthermore, the RO system control performance was validated using four different controllers: PID, FOPID, SMC, and Linear Quadratic Regulator LQR.

Fig. 36
Fig. 36
Full size image

Hardware in loop (a) configuration (b) experimental.

Figure 36a illustrates the experimental HIL setup used for validating the simulation results. The HIL system provides a practical approach to account for real-world challenges, such as communication delays and controller computational limitations. In this study, parameters for all elements in the laboratory RO system were identified and obtained to ensure that the results closely represent the actual performance of the RO system under real operating conditions. A dSPACE DS1104 platform was employed for HIL implementation, configured with a controller sampling time of 50 µs and a buck-boost inverter switching frequency of 12 kHz. The measured input to actuation delay, which includes data acquisition, processing, and actuation response, was approximately 87 µs, confirming that the control loop operates well within real-time constraints. The system consists of two independent units: one (DS1104-1) dedicated to implementing the control algorithms and another (DS1104-2) responsible for simulating the plant model. Real parameters for each component, including PV system, RO unit, induction motor, and battery, were obtained through a detailed identification study. These units communicate through a dedicated channel, enabling real-time interaction. At each sampling interval, DS1104-1 acquires the state variables from DS1104-2 via the communication channel. Based on these variables, DS1104-1 computes the optimal control actions and transmits them back to DS1104-2 for execution. The control and system parameters used in the HIL experiments match those in the simulations to ensure consistency and reliability. Experimental data were captured using a 100 MHz Tektronix TDS3014B Digital Oscilloscope and the ControlDesk interface.

Figure 36(b) presents the communication and interconnection between the DS1104-1 and DS1104-2 within the HIL setup. These units are linked through the DS1104 DAC and ADC interfaces, along with DS1104 RS232 and the Digital I/O Connector (CP17). Specifically, the RS232 channel is dedicated to transmitting critical signals with heavy dynamic response, such as the state of charge (SOC), reference motor speed (W*), and capacitor voltage (Vc1). Meanwhile, the Digital I/O channels are dedicated to transmitting high-frequency signals, including the switching signals for the QZ-source inverter switches (S1–S6 derived from the MPC control and buck-boost converter switches (K1, K2) obtained from the cascaded PI control. Additionally, various parameters are exchanged via the DAC and ADC channels, including photovoltaic voltage (Vpv), photovoltaic current (Ipv), three phase currents (Ia, Ib, Ic ), battery current (Ibatt), and inductor reference current (IL1ref). Operational variables like permeate flow rate (Qp), the product water salinity (Cp), their respective references (Qpref , Cpref), and the reference stator flux (ψs) are also transmitted for precise real-time monitoring and control.

Figures 37, 38 and 39 compare the MPPT performance of the proposed RO system under varying irradiance conditions. The SOH-P&O algorithm demonstrates superior performance by achieving faster MPP convergence with negligible steady-state oscillations, outperforming the SOH and P&O methods. While the SOH algorithm ensures precise MPP tracking, it exhibits slower response times, as shown in Fig. 39. In contrast, the P&O algorithm, presented in Fig. 38, achieves MPP tracking but suffers from significant steady-state oscillations, reducing its efficiency and reliability. HIL implementation of the SOH-P&O MPPT confirms the simulation results, validating its effectiveness in balancing fast convergence and stable steady-state performance.

Fig 0.40 presents the HIL responses of the DC-link voltage Vdc ​ for the proposed RO system under the P&O, SHO, and SHO-P&O methods, with the capacitor voltage command Vc1 set to 600 V. The SHO-P&O method ensures a stable output voltage Vpv ​ from the solar panel, which acts as the input DC source. It achieves accurate voltage regulation with minimal ripple, exhibiting smooth behavior and negligible oscillations during irradiance changes, thereby maintaining a stable DC-link voltage. In contrast, the P&O and SOH methods exhibit significant overshoots and longer settling times in Vpv ​, which in turn lead to high oscillations and overshoots in the DC link voltage Vdc ​, degrading the overall system performance.

The SHO-P&O method ensures stability with minimal ripple, exhibiting smooth behavior and negligible oscillations in the inductor current ( \(\:{I}_{L1ref}\) ) during irradiance changes. In contrast, the standalone \(\:\text{P}\&\text{O}\) and SHO methods experience significant overshoots, longer settling times, and oscillations in \(\:{I}_{L1ref}\) under the same conditions. The SHO-P&O method utilizes \(\:{I}_{L1ref},{T}_{\text{eref\:}}\), and stator flux \(\:\left(\left|{\psi\:}_{s}^{\text{*}}\right|=1\text{}\text{W}\text{b}\right)\) in the cost function \(\:g\) for the MPC-based control of switches \(\:{S}_{1}\) to \(\:{S}_{6}\) in the QZ source inverter.As a result, the SHO-P&O method achieves relatively small and negligible stator flux and torque ripples, along with minimal distortion in the stator current \(\:\left({I}_{a}\right)\). On the other hand, the P&O and SHO methods exhibit relatively large stator flux and torque ripples, as well as significant current harmonics, as shown in Fig. 41.

The HIL responses of the motor pump flow, membrane response represented in by reference permeate flow rate, actual permeate flow rate, reference product water salinity, and actual product water salinity for the PID, FOPID, SMC, and LQR controllers are shown in Fig. 42. These HIL results align closely with the simulation results presented in Fig. 34. Notably, the LQR controller demonstrates a slight improvement in permeate flow rate, as evidenced by its accurate step response and absence of phase delay. Additionally, it achieves high precision and no oscillations in product water salinity over the long term. In contrast, the PID, FOPID, and SMC controllers exhibit less precise performance. The LQR controller shows the highest permeate flow rate and superior product water salinity quality, highlighting its effectiveness in maintaining both flow rate and salinity levels.

Figure 43 presents the HIL responses for the reference speed, permeate flow rate, water recovery rate, and feed flow rate for the PID. FOPID, SMC and LQR controllers. These HIL results closely mirror the simulation outcomes shown in Fig. 35. The LQR controller exhibits the most precise control, maintaining minimal oscillations and steady-state errors across all parameters. In comparison, the SMC, FOPID, and PID controllers show varying levels of performance, with noticeable deviations in the system response and longer settling times. The consistency between the simulation and HIL results further validates the robustness of the proposed control strategies in achieving optimal performance in both simulated and practical scenarios.

The LQR controller is an optimal control strategy designed to minimize a quadratic cost function, ensuring efficient regulation of system states. Experimental findings confirm that LQR control offers a simple, fast, and effective performance compared to conventional techniques such as PID, FOPID, and SMC. This section provides a mathematical basis to demonstrate the advantages of the LQR control approach. To comprehensively evaluate the performance of the proposed controllers, a statistical analysis was conducted using a range of control performance metrics, including the Integral of Absolute Error (IAE), Integral of Squared Error (ISE), Root Mean Square Error (RMSE), Tracking Efficiency (%), and Steady-State Error (SSE). The definitions of these metrics are presented in the following equations:

Fig. 37
Fig. 37
Full size image

HIL responses of the PV voltage, current and power for (a) P&O (b) SOH (c) SOH-P&O.

Fig. 38
Fig. 38
Full size image

Zoom-in view of Fig. 37 during a step decrease in the irradiance level (400 W/m2–600 W/m2).

Fig. 39
Fig. 39
Full size image

Zoom-in view of Fig. 37 during a step decrease in the irradiance level (600 W/m2–1000 W/m2).

Fig. 40
Fig. 40
Full size image

HIL responses of the DC link voltage for (a) P&O (b) SOH (c) SOH-P&O.

Fig. 41
Fig. 41
Full size image

HIL responses of the reference speed, electromagnetic torque, Stator flux and Ia Phase stator current for (a) P&O (b) SOH (c) SOH-P&O.

Table 4 Performance comparison of PID, FOPID, SMC and LQR controllers for RO desalination.
Fig. 42
Fig. 42
Full size image

HIL responses of the reference the permeate flow rate, the permeate flow rate, reference the product water salinity and the product water salinity for (a) LQR (b) SMC (c) FOPID (d) PID.

Integral of Absolute Error (IAE):

$$\:\text{IAE}={\int\:}_{0}^{T}\left|e\left(t\right)\right|\hspace{0.17em}\text{d}t$$
(68)

Integral of squared error (ISE):

$$\:\text{ISE}={\int\:}_{0}^{T}{e}^{2}\left(t\right)\hspace{0.17em}\text{d}t$$
(69)

Root mean square error (RMSE):

$$\:\text{RMSE}=\sqrt{\frac{1}{T}{\int\:}_{0}^{T}{e}^{2}\left(t\right)\hspace{0.17em}\text{d}t}$$
(70)

Tracking efficiency (\(\:\eta\:\)):

$$\:{\eta\:}_{\text{tracking}}=\frac{{y}_{\text{tracked}}}{{y}_{\text{setpoint}}}\times\:100\text{\%}$$
(71)

The steady-state error (SSE):

$$\:\text{SSE}={\text{l}\text{i}\text{m}}_{t\to\:{\infty\:}}\left|e\left(t\right)\right|$$
(72)

where: \(\:e\left(t\right)=r\left(t\right)-y\left(t\right)\) is the instantaneous tracking error. \(\:T\) is the total duration of the experiment and \(\:{y}_{\text{tracked}}\) is the final output value achieved. \(\:{y}_{\text{setpoint}}\) is the desired reference value.

Fig. 43
Fig. 43
Full size image

HIL responses of the reference speed, the permeate flow rate, water recovery rate and the feed flow rate t for (a) LQR (b) SMC (c) FOPID (d) PID.

Table 5 Comparison of statistical results of PID, FOPID, SMC and LQR controllers for RO desalination.

As shown in Table 5, the statistical results confirm the superiority of the proposed LQR control strategy. It significantly outperforms the conventional PID, FOPID, and SMC controllers across key performance metrics, including overshoot, settling time, and error indices such as IAE, ISE, and RMSE. The LQR approach effectively minimizes oscillations and enhances dynamic response, achieving a high tracking efficiency of 99.2% under real operational conditions.

Comparison of simulated and hardware results

To validate the accuracy of the proposed PV-RO desalination system, a comparative analysis was conducted between simulated and Hardware-in-the-Loop (HIL) experimental results. The comparison, shown in Table 6, evaluates key performance metrics for both the SHO-P&O MPPT method and the LQR-based RO control system. The results reveal close agreement between simulation and HIL responses, with minor deviations attributed to measurement noise, unmolded nonlinearities, and practical delays in real-time implementation.

Table 6 Comparison of statistical results of PID, FOPID, SMC and LQR controllers for RO desalination.

Discussion and future work

This study addresses challenges in solar energy-powered desalination systems, presenting solutions to improve efficiency, stability, and performance under real-world conditions. The integration of advanced control techniques, and power conversion topology to enhance energy efficiency and improve the operation of small-scale BWRO desalination systems. This research incorporates a battery to stabilize energy delivery, ensuring continuous operation and uninterrupted water production.

Since solar energy is inherently intermittent and variable, optimizing the energy extracted from the PV system is critical to ensuring consistent performance and minimizing energy waste. This study focuses on enhancing energy extraction from photovoltaic cells using an advanced algorithm to achieve Global Maximum Power Point (GMPP) tracking under varying operating conditions. Specifically, the hybrid MPPT-based SOH-P&O algorithm is employed, enabling efficient and reliable extraction of maximum energy. In contrast, many prior studies have overlooked this aspect, often relying on traditional Maximum Power Point Tracking (MPPT) algorithms, such as Perturb and Observe (P&O), which aim to extract maximum power from PV panels under varying solar irradiance conditions. However, these traditional algorithms may fail to optimize energy delivery to the desalination system over extended periods, particularly when energy consumption fluctuates due to varying water demand or environmental conditions.

Significantly, previous studies, predominantly utilized the traditional two-stage power converters (DC-DC and DC-AC) with RO systems. The conventional cascaded topology of a DC-DC converter and inverter adds complexity to the power circuit and the control system. In contrast, this research introduces a single-stage QZSI-fed RO system, offering a more streamlined and efficient power conversion strategy.

In addition, this research focuses on the application of a dynamic model for the RO system, ensuring greater realism and accuracy in system behavior. The Linear Quadratic Regulator (LQR) technique is applied to the RO process, demonstrating high performance in terms of permeate flow rate, water quality, and operational stability. While many previous studies have primarily relied on simulations without sufficient validation, this work incorporates Hardware-in-the-Loop (HIL) validation, bridging the gap between theoretical designs and real-world applications. The HIL validation ensures practical reliability by enabling system testing under real operating conditions.

Moving forward, transitioning from HIL validation to full-scale experimental implementation is a crucial next step. This transition will provide deeper insights into the energy flow dynamics between the PV system, battery and QZSI under varying operational conditions. Furthermore, improving energy exchange between the PV array and battery will be crucial, and this can be achieved by implementing advanced control power management strategies to address challenges related to power management and enhance system robustness.

While this study incorporates battery storage to ensure a continuous power supply, future work should focus on exploring other energy storage technologies. The inclusion of supercapacitors and hybrid storage solutions (both electrical and hydraulic) could enhance the system’s ability to manage the intermittent nature of renewable energy. Additionally, integrating supplementary sources like wind energy would make the system more adaptable for large-scale desalination applications. A comprehensive economic analysis of different energy storage options, including long-duration solutions, is also recommended to support the development of cost-effective and sustainable desalination systems.

Finally, the application of LQR control to Linear Parameter Varying (LPV) models of RO systems represents a promising direction for future research. These models could address the non-linearity and parameter variations caused by factors such as membrane fouling, thereby improving control precision and overall system robustness.

Conclusion

This study focused on optimizing the performance of a proposed reverse osmosis (RO) desalination system powered by a PV/battery setup, aiming to enhance system efficiency, stability, and practical applicability. A hybrid Maximum Power Point Tracking (MPPT) algorithm combining the Spotted Hyena Optimizer and Perturb and Observe (SHO-P&O) was implemented, demonstrating superior tracking efficiency under various operating conditions. Under uniform irradiance at Standard Test Conditions (STC) (1000 W/m2 and 25 °C), partial shading, variable irradiance, and real solar irradiation data with actual load demands, the hybrid SHO-P&O MPPT achieved a maximum power point (MPP) tracking efficiency of 99.9%, with only minor fluctuations observed during shading transitions. In contrast, traditional P&O and SOH methods exhibited lower tracking efficiency, significant oscillations, and adverse impacts on battery performance, DC-link voltage stability, and motor pump operation. These issues led to inconsistent DC-link voltage, excessive three-phase voltage and current variations, unstable motor speed, elevated torque ripples, and increased stator flux ripple.

To further streamline the system, a Quasi-Z Source Inverter (QZSI) was incorporated, integrating the functions of a boost converter and inverter into a single stage, thereby eliminating the need for separate components. The QZSI was regulated using Model Predictive Control (MPC), which delivered enhanced performance and precise control, ensuring efficient power conversion and stable operation.

In the control of the RO system, various strategies were evaluated to regulate the permeate flow rate (Qp​) and product water salinity (Cp​). Among these, the Linear Quadratic Regulator (LQR) demonstrated superior performance, achieving less than 1% error in tracking the reference values (Qpref​ and Cpref​) and ensuring optimal system operation. In contrast, Proportional-Integral-Derivative (PID), Fractional Order PID (FOPID), and Sliding Mode Control (SMC) approaches were less time-efficient and less effective in maintaining accurate control under varying operating conditions.

The effectiveness of the proposed system was validated through Hardware-in-the-Loop (HIL) experiments, which confirmed its ability to handle varying irradiance and load demands while maintaining high stability and efficiency. Key achievements include:

  • The hybrid SHO-P&O MPPT method achieves 99.9% tracking efficiency, stabilizing the DC-link voltage during rapid irradiance changes, and ensuring reliable motor pump performance.

  • The QZSI topology reduces system complexity while enhancing power conversion efficiency.

  • The LQR control strategy achieves precise regulation of the RO process, with accurate control of permeate flow rate and product water salinity.

Building upon these promising results, future research may focus on integrating adaptive or artificial intelligence based controllers to further improve real-time decision-making under highly dynamic environmental and load conditions. In addition, long-term field deployment studies are essential to assess system reliability, aging effects, and maintenance requirements. Finally, scaling the architecture to accommodate multi-unit RO arrays and conducting economic feasibility analyses, particularly for deployment in remote or off-grid regions, would significantly advance the practical implementation of this sustainable desalination solution.