Optimal renewable resources mix for low carbon production energy system in Morocco

The production of electrical energy has always been a subject of debate to fight against climate change and preserve natural resources. Several countries, including Morocco, have proposed ambitious policies to develop renewable energy sources of production in the short and medium term. The major problem of renewable sources production is their intermittent nature. Using storage units, particularly PETS’ and molten salt technologies, will increase the penetration rate of renewable energies. The balance between production and consumption will optimize production, and it represents an important aspect of smart grids. In this article, an electrical energy consumption prediction was developed for the period 2019-2025, and optimization of the renewable energies injected within the grid was made by introducing the algorithm used. The results show that the use of storage units will increase the rate of renewable energies integration to 47.189% of the total installed capacity.


Introduction
Electrical power is a major factor for the social and economic development of the countries. The consumption of electrical energy will reportedly be doubled in 2040 (IEA, 2018), where comes the need to install new electrical infrastructure.
In Morocco, electricity demand (ED) is experiencing an average increase of 6-7% annually, and the expected electricity consumption in 2030 is 95 TWh. Currently, Morocco consumes 37 TWh for an installed capacity of 9GW. The electricity production field has made it possible to meet 86% of the national ED, and the difference is compensated via the Moroccan Algerian (MA) and Moroccan Spanish (MS) interconnection (www.one.org.ma).
The Moroccan network is mono-directional, radial, and not robust. As more energy enters the market, the transition to a more efficient network with more flexible infrastructures becomes paramount, and the solution is the Smart Grid (SG) (Morad et al. 2013). There is no absolute definition to describe SG, but it can be characterized by its two-way communication, reliability and safety, ability to reduce peak power consumption via Demand Side Management Tool (DSM), ability to provide environmental benefits, locate and repair defects, integrate renewable energies, and manage storage units (Warren 2014) (Wu and Xia 2017). The SG can be summed up by a combination of electrical infrastructure and embedded intelligence associated with the software, automation, transmission, and information processing (Torriti 2012). This intelligence can be deployed at various levels of a network (Galván-López et al. 2015), and this network will be able to integrate data that control the operations that will be assigned to them (Sahbani et al. 2016) (Kuzemko et al. 2017). The basic essential element of SGs is to measure the real needs of consumers to produce the quantity they need. Electricity is very difficult to store. It is, therefore, necessary at all times to balance the network, to ensure that the production is equal to the consumption. If the gap between production and consumption increases too much, the network suffers from frequency deviations and damaging voltages for the network equipment and those of the consumers. The consequences can go as far as the disconnection of certain branches of the network, or even the generalized incident blackout. Where comes the need for DSM and Demand Response (DR). This shifting can effectively reduce the aggregate energy load during peak hours (Alasseri et al. 2017).
In Europe, the consumption of electrical energy is more interesting in winter than in summer, and this is due to the excessive use of heating. The electric variation varies from one country to another. The Belgian electricity sector is liberalized and unbundled. The country is using several business models, as the peak electricity consumption is around 13 GW. The Belgian electricity grid is quite advanced in the market, including decentralized generation, and the government plans to a possible phaseout of the nuclear power plants at the end of their lifetime. DR products are available for ancillary services and strategic reserve. Boogen et al. (2017) have conducted a study on the impact of DSM activities on residential ED in Switzerland. It has been found that the presence of DSM has a significant impact on the consumption of electricity, and their presence reduces the ED by 5%. (Paulus and Borggrefe 2009). Barbato et al. (2015) have proposed a distributed DSM system for SG infrastructure, specially adapted to reduce the demand for residential users using a dynamic pricing strategy. The authors used energy rates as a function of the overall power demand of customers. Mellouk et al. (2018) have used a genetic algorithm method to solve DSM and dynamic economic dispatch problems.
In North America, the specific needs of electric power reveal so many winter peaks that are due to the use of heating means in winter and air conditioning in summer. The American power grid is centralized, fragile, and old, and this makes it rather vulnerable. On August 14, 2003, the American power grid experienced a blackout in California affecting 55 million people and causing $ 6 trillion in losses (Gillingham et al. 2009). US utility grid-initiated DSM program that initially focused on load shifting and their increasing on electric end-use efficiency. Several studies were elaborate to a better implementation of demand-side management programs and modeling their roles to reach a balance between demand and supply in the presence of renewable energies generation considering their stochastic behavior. Alavi et al. (2015) have proposed the point estimate model for modeling wind and solar power uncertainties, and have made a comparison between deterministic and probabilistic management. Zakariazadeh et al. 2014aZakariazadeh et al. , 2014b have developed a conceptual model for a DR management system with an optimization tool using a stochastic multiobjective. The objective is to schedule distributed energy resources and aims at minimizing the total operational costs and emissions. Siano (2014) have presented a survey of DR potentials and benefits in SG. Zakariazadeh et al. (2014aZakariazadeh et al. ( , 2014b have used a stochastic multi-objective economic and environmental operational scheduling method to minimize the total operational costs and emissions and to generate a Pareto-optimal solution for the energy and reserve scheduling problem. Mohamed and Koivo (2010) have used the mesh adaptive direct search algorithm to minimize the cost function of the system. Cicek and Delic (2015) have studied DRM in a smart micro-grid (SMG) with wind power and founded the optimal deficit limiting conventional power production and consumption schedules. Rahimi et al. (2013) have investigated to compensate wind intermittency by introducing various technologies such as pumped hydro storage/ plug-in hybrid electric vehicle (HEV), solar energy, and batteries. Aghajani et al. (2017) have proposed a study of stochastic programming model to optimize the performance of a SMG in a short-term to minimize operating costs, and emissions with RES. The authors' used probabilistic density function to predict climatic data (wind speed, solar irradiation … ), and DR programming with the participation of residential, commercial, and industrial customers.
In Morocco, where air conditioning is very widespread, the seasonal peak takes place in summer. Electricity consumption also varies significantly on the scale of a day: As we can see from the data collected for the ED, there are two-peak consumption per day; Midday peak: this one reflects the launch of the economic and industrial works. Evening peak: begins at around 19h, corresponds to the increase in household consumption and coincides with the end of economic activity.
Network balancing is particularly crucial at the peak. The value of this peak that sizes the electricity network by ensuring the security of the network. The historical holder of most of the means of production is the National Office of Electricity and Water (NOEW). The transmission system operator provides the long-distance transport of large quantities of electricity on high and very high voltage lines. It is responsible for the overall balance of the network, and the instant equilibrium between supply and demand of electricity. The distribution network operator provides the connection and daily distribution of electricity to all consumers. This activity, also considered as monopoly, is under the responsibility of NOEW, and the suppliers are the companies responsible for marketing and billing electricity to consumers. This activity is open to competition in Morocco, and several boards hold the market such as LYDEC, AMEN-DIS, REDAL, RADEEMA ... At the end of the chain, electricity consumers can be different in nature, from very large industrial consumers to residential customers, though consumers in the tertiary sector.
The main contribution made in this paper is to consolidate a low-carbon energy mix by promoting renewable energies integration into the power grid by: Modeling and predicting monthly ED in Morocco by 2025 Propose a flexible and low carbon demand model by promoting the contribution of renewable energies within the power grid by 48% in 2025 The remainder of this paper is organized as follows: section 2 describes the problem and presents the data. In section 3, the regression model was studied and a 2025 ED forecasting scenario was elaborated. The proposed algorithm is analyzed in section 4, and the results are presented in section 5. The last section summarizes the results and draws conclusions.

Problem statement
In this study, a regression model is proposed for long-term energy management in order to promote the contribution of renewable energies resources in a SG. Due to the stochastic behavior of wind and solar energies, their accurate prediction is not possible and is always associated with uncertainties. The predictability of the data is analyzed to evaluate the relevance of keeping the parameters that have a low potential for the predictability. This is intended to determine carefully which criteria have a negative or negligible contribution to prediction accuracy. Therefore, to provide more compliance between planning and reality.The application and integration of ED prediction and generation of RES to SGs will optimize the management of the network. However, it is assumed that the distribution system's operator, which has the possibility of managing and controlling the grid using distribution management systems, performs planning for generation resources and consumer demands in a SMG and advanced metering infrastructure. The following section is dedicated to data examinations.

Analyzing and modeling monthly electricity demand
Analyzing data . This may be due to several factors, direct and indirect, such as the increase in the exploitation rate of electronic equipment, climate change, and the acceleration of growth dynamics and modernization. Figure 2 displays the annual evolution of the demand for electric energy in Morocco during the period 1971-2017. It can be seen that the series reveals a growing trend over the years. In the literature, several prediction methods are available according to prediction horizons. Every method has its strengths, weaknesses, and changes according to the context and environment of prediction. It is often difficult to identify a prediction method that differs widely from others (Doucouré 2015).

Modelling monthly electricity demand
Forecasting techniques are ranging from time series to hybrid models. Reviews research is presented by Bohi and Zimmerman (1984), and by Suganthi and Samuel (2012). In this study, a regression-based model has been used to predict electricity consumption in Morocco in the long-term.
The main objective of multiple regression is to learn more about the relationship between several independent or predictive variables and a dependent or criterion variable. A straight line in a two-dimensional space is defined by the equation (1) where Y is the variable described by a constant 'a' and slope 'b' multiplied by the variable X. Multiple regression is where a dependent variable is described by several parameters, as is shown in equation (2): Where (b, c, d … , n) are the coefficients of the regression R 2 describe the model fit goodness. If R 2 adjusted is close to one, it indicates that the model has managed to explain almost all the dispersion thanks to the independent's variables.
In this paper, a regression-based model has been used introducing gross national product (GNP), population, and 11monthly dummy variables as explanatory variables. The model development was done in excel, and the results are summarized in Table 1.
The P value designates the probability that measures certainty with which it is possible to invalidate the null hypothesis. The more P valued tends to one, the more the null hypothesis is invalidated with more certainty. Table 1 reports that the intercept coefficient with GNP and population are all highly significant with a confidence level of 99%. The coefficient for May is not significant which indicates that ED this month is similar to that of December. All the other dummy variables for the other months are significant, which means that more or less electricity is consumed during the corresponding months than in December.   However, the model still contains a large serial correlation despite its high predictive power. Autocorrelation occurs when the error term observations in regression are correlated. If those values follow a pattern, it means that the model contains autocorrelation. The Durbin-Watson (D-W) is widely used to test the first-order residues independence. The D-W statistic is calculated as follow: Where e i describe the residuals and n is the number of elements in the sample. D-W statistic value varies between zero and 4. If it is equal 2, it means that the model has no autocorrelation. If'd' is less than 2, especially a value less than 1, means that the data is positively autocorrelated. If'd' is substantially above 2 means that the data is negatively autocorrelated. The D-W statistic calculated in this model is estimated at 0.79730711, indicating the presence of positive autocorrelation.
In theory, if the residuals are serially correlated, then the estimate of the coefficients may be unstable. In this study, all the independent variables are statistically significant at a 1% error level. However, autocorrelation could be affecting the results, making it appear significant when it is not.
Back in reviews, two approaches can be used to deal with serial autocorrelation. The first method is eliminating the symptoms of autocorrelation by using another estimation method. Otherwise, preventing autocorrelation from occurring in the first place by adding relevant missing independent variables. There are situations in which autocorrelation cannot be eliminated if the omitted independent variable is not available or cannot be found. To reduce autocorrelation, several methods are presented in reviews, such as the AR (1) method used by (Mirasgedis et al. 2006), and Henley and Pierson (1994). Cochrane-Orcutt Method, feasible generalized least squares (FGLS) or estimated generalized least squares (EGLS). Cochrane-Orcutt regression is an iterative version of the FGLS method for addressing autocorrelation. This approach uses the following steps for estimating rho.
Step 1: Run Ordinary Least Square (OLS) regression on eq (2) and calculate the residualse 1 , e 2 … e n Step 2: Using these sample residuals e i , find an estimate for ρ using OLS regression on Step 3: Substitute this estimate for ρ in the generalized difference equation Step 4: Based on step 3, new residuals can be calculated. Go to Step 2. Continue this iteration until the change in the estimated value of 'ρ' is less than some predetermined amount. Note that an iterative approach is used since regression coefficient 'r' in step 2 is not necessarily an unbiased estimate of 'ρ' although it is known to be a consistent estimate of 'ρ'.
The use of the Cochrane-Orcutt method has eliminated the first-order autocorrelation. The new statistical value of the Durbin-Watson test is around 2.03, showing that the model has no longer autocorrelation in the error term. Fig. 3 represents the distribution of the error against time, the new distribution is rather random, and it oscillates around zero.
The coefficient of May is not significant, which means that electricity consumed in that month is similar to that of December, or less. All the other coefficients are significant, which indicates that more or less electricity is consumed during these months than in December. The adjusted R² has been updated and has increased slightly from (94.6%) to (96.23%), which designate an improvement of the predictive power of the model.
Both RMSE and MAPE are calculated for the model, and the results are summarized in Table 2.  Table 3.

a) Evaluation of the model
The model shows a very high predictive power as the overall prediction error is 0.3%. The maximum prediction error is 4%. However, the estimations' deviation between actual and forecasted monthly ED is 1% or less for 6 out of 12 months. On an annual basis, the model has shown a high predictive power as the forecasted ED is very close to the actual data. Fig. 4 shows forecasted electricity consumption against real electricity consumption for 2017.

b) Forecasting electricity demand for the period 2019-2025:
After executing the model on the desired period, the results summarized in Table 4 shows Monthly electricity consumption is modeled as the addition of 4 variables; monthly electricity consumed during working days, holidays, days near holidays and Saturdays. Eq (6) represent the modeled electricity consumption function.
Where E m , is the monthly electricity consumption, and 'i' vary from 1 to 12   Equation (6) can also be written in the following form: E wd is the rate of holidays E wd rate days near holidays

E wd rate of Saturdays
After calculating these rates, they will be used to calculate the hourly power of each type of day of the year.
Once the daily energy of the working day is determined, the other values are multiplied by the corresponding ratio of the type of the day.
Therefore, daily ED is summarized in Table 5. The conversion of energy into power is done by calculating the hourly effect of the day when the consumption is maximum (Table 6). This method was used by Grand et al. (2015) and aimed to extrapolate the hourly load deducing by homothetic from the previous years, and it is calculated as is shown by the equation (7).
Where, e h is the hourly ratio E i hourly energy P 24 i¼1 E i daily consumption Scaling is the multiplication of these factors by the corresponding daily energy for each category of days.
Hourly energy consumption is summarized in Fig. 5: c) Generation-demand balance in 2025

Conventional generation sources
A very large part of electricity generation is provided by conventional generation sources, including coal-fired power plants where the fuel is burned in a boiler using the heat generated either by combustion, or in a combustion turbine. In Morocco, the power supplied by coal-fired power plants is 1785 MW (2017). Oil-based production unit's burn oil in a boiler producing steam that turns a turbine, which drives an alternator and produces electricity. The power supplied by these units is 600 MW (2017). Combined-cycle power plants use natural gas as a fuel in a two-stage production system: the first step is to put the alternator in motion by burning natural gas. Then, in a second cycle, the heat from the first cycle is recovered to the max to generate steam that rotates a second steam turbine to generate additional electricity. The total power of the system is defined in equation (8) The efficiency of the system is around 59%. In Morocco, 1184 MW is installed in a combined cycle for the production of electrical energy. A gas turbine power plant is a heat engine performing the various stages of its thermodynamic cycle in a succession of members traversed by a gaseous fluid in a continuous flow. In Morocco, a gas turbine power plant is functional and develops a power of 315 MW.

Renewable energy sources generation
Renewable sources of production, particularly solar and wind have great potential. The installed capacity of the wind power plant will reach 2000 MW in 2020, spread over several sites. With a very strong solar field, Moroccan kingdom can produce a power of 20 GW just by solar, (www.onee.org.ma) but this capacity is not exploited yet. However, 2 GW of solar is planned to be operational by 2020 divided into concentrating thermal power plants and photovoltaic power plants.

Hydroelectric generation
A hydroelectric power plant is the process of producing electricity by using water as the driving force to turn the turbines that drive generators to produce electrical power. These stations can also be used for energy storage as a pumped energy transfer station. The total installed capacity of these units in Morocco should be around 1400 MW around 2020.

Generation-consumption balance
Electricity consumption is highly unsteady, and this variability is sensitive during a season with peaks of consumption, more or less strong, this variation can also be on the scale of the day. In Morocco, generally warm country, widely equipped in air conditioner, the peak in electrical consumption is in summer.
Network balancing is crucial at the peak. Consumption peak value sizes the network to ensure electricity energy quality and complementary production capacities. Moroccan production units currently in operation are summarized in Fig. 6.
The forecasted ED is denoted as (Fi, i=1 … .m). The devices that produce electricity are divided into three groups. Basic production units, decentralized production units, and peak production units. They are classified according to their priority. High, medium, low. When the demand is low, the manager would use the base source (coal = low), the more the demand increases, the more the manager would have to resort to another source of production, notably RES and gas-based production (Table 7).
Basic production units are scheduled to be operational in full-time. These units require a very high investment cost, but the operating cost is relatively low. In Morocco, as shown in Fig. 6, a preponderance of the production sources are based on coal and oil, 50% of the total installed capacity. During an electrical peak, utility grid manager uses auxiliary sources to meet ED. Those capacities have a fast startup and a high operating cost which explains the high cost during peak hours.
Production group maintenance is a periodic action programmed to detect latent anomalies in equipment and guarantee their proper functioning. Maintenance can reduce the probability of failure and increase equipment life. In this study, the maintenance schedule is supposed to be known.
The proposed algorithm is based on the promotion of renewable sources integration. The base capacities will be coal power plants operating with the minimum technical requirements. Coal plants are chosen because of their stability, reliability, and low production costs, where RES will be connected to be injected to meet required consumption in mid-peak time. The gas-based production units are characterizing by their fast start and flexibility, denoted as high because its request arrival time is in peak hour.  The objective of shifting electricity consumption can be various. The objective of electricity suppliers is to avoid the appearance of high peak load demand. In consumers' point of view, the objective is to minimize electricity bill, and offer a better electricity quality.
In order to provide optimal schemes to regulate controllable devices to meet some desired properties, the demand load is forecasted based on the previous usage. The period of estimation is a forecasted window. It can be one day, a week, or even longer. In that case, the algorithm can run beforehand to generate a scheme for organizing the production units. In this paper, the algorithm is designed for one day ahead of planned load shifting, and it can be easily extended to the other sizes of forecasted windows.
Utility grid manager objective is to balance ED and production, to smooth the load curve by eliminating electrical peaks, and regress the energy bill. The approach used in this paper is to predict daily consumption by 2025, transform energy into hourly power, and optimize the use of conventional power sources. The algorithm is based on the use of coal-based sources of production with their technical minimum to ensure the base, and adding production units when needed by promoting RES injection.
Eq (9) describes the distribution of national production according to different sources of production. 'a, b, c ... k' are the coefficients that describe each source of production.
Eq (9) is the equation to be maximized; with 'i' the coefficient of wind turbines production and 'j' is the coefficient of solar energy production. The objective is to integrate renewable energies into the power grid, without exceeding 48% of the total production due to technical standard.

Implementation of the proposed algorithm
In this paper, an algorithm was implemented by programming language C to address the optimization problem in the power grid by shifting RES to start working at the appropriate time.
The flowchart of the proposed algorithm is presented in the illustration below Fig. 7. The initialization step initializes the parameters, time, type of day, the forecasted electricity consumption, coal production, RES production, gas production, Spain-Morocco interconnection, Algeria-Morocco interconnection. In each iteration, the priority change according to the required demand and the utility grid react according to the available sources of production.
The program starts with the initialization of the inputs: the day T i , month M i , forecasted consumption F d , available production units A i , their degree of importance I i , and their downtime C i .
With day and month acknowledged, the forecasted electricity consumption would be determined, consequently, the production units' status: low, medium, and high, as needed. After the determination of production units' status, the connected units will be chosen according to the need for consumption. If all the objectives were realized, the program would shut down showing the results. Otherwise, an incremental loop is created to continue the calculation. When the production meets the demand, the program will stop, print results, and shows the percentage of renewable energies integration within the power grid. Fig. 8 shows that the use of RES production varies according to the hours of the years. The graph represents a monotonous hourly load, classified from the greatest to the smallest value. Based on equation (9), the max of production to be connected is 40% in 2019, 48% in 2025 (www.one.org.ma). Figure 9 represents the load monotone expected in 2025 in hourly volume, represented in the descending curve. The bottom of the graph represents basic generation power plants that operate in technical minimum during the same period. After the execution of the program, the calculation of the small integrable value by renewable energies over the whole period was calculated, P res, min =1248.793 MW.
This value represents a penetration rate of 17.54502 % of the total installed capacity, distributed on wind farms and solar fields. The integrable capacity of renewable energies can be increased by adding storage capacity, PETS' to store the energy produced by wind turbines, and molten salt technology to store solar energy. The capacity of the storage units in Morocco in 2025 will reach 2110 MW, 1110 MW of PETS', 1000 MW of molten salts (www.onee.org.ma).
RES are intermittent, so their storage is mandatory for better utilization of these resources. The integrable RES capacity is 3358,793 MW, which corresponds to a maximum penetration rate of 47,189%. The capacity of the electrical system to absorb the surplus of RES generation is increased. As a result, demand increases and the maximum power that can be produced by RES power plants increase, and the penetration rate is improved.

Results
In order to define relevant scenarios, several factors are relative and which must be taken into account. The total character of the energy system will impose the elected choice. The world price of the energy that depends directly on the estimated balance offers and demand on a world level. The second character refers to the relations foreign of Morocco and the evolution of its integration in various regional contexts. This variable is particularly determining for the future of the Moroccan energy system that suffers from a notorious insufficiency of primary resources in this sector. The process of decarbonizing of the electrical supply network bases the fall of price by putting in exploitation new technologies of production of electrical energy leading in the long term to a surplus of offer and capacity installed.  The electricity production field in Morocco is mainly based on centralized production based on coal, while the production based on renewable energies does not exceed 13%, Fig. 10.
After the implementation of the program, the share of renewable energies has increased. By regressing the share of decentralized generation sources and putting them in technical minimum, the production of renewable energy injected into the network has reached 17,545 %. Storage units represent an effective way to increase the percentage share of renewable energies. The aim of these units is to store the excess of production from REPP, and use it when needed. By adding the generation stored in these units, the share of renewable energies has increased to 47.18963%.
By using thermal sources of production with their nominal values, production would exceed demand in 42.796% of the time, and only 1.554% of the time when thermal production would be in line with consumption, Fig. 11. The renewable energy threshold was calculated for the remaining 55.650% of the sample, and the calculated value vary between 0.36% and 31.7%.
The program used will help to manage the production units better, to promote renewable energy integration, and to reduce greenhouse gas emissions. First, reduce the nominal power of the thermal power plants, and use them with their technical minimums, Fig. 12. The insufficiency, in this case, will be compensated by means of renewable energies. The integrable capacity calculated is 17.545% over the entire period. By adding the storage units, which totalize 2110 MW, Table 8, the integrable threshold will increase to 47.189%.
The program has therefore helped to increase the renewable energy threshold in 2025 from 31.733% out of 4875 hours, Fig. 13, to 47.189% out of 8760 hours, Fig. 14. This value corresponds to a significant decrease in conventional sources, and the

Conclusion
Summarizing what was done, the regression-based model was used to predict electricity demand in Morocco for 2025. The method has shown a high predictive capacity with a significant adjusted R², 96.23%. The forecasted energy was scaled by converting the values obtained into time powers, for the 8760 hours of the year, based on the type of days, the time and seasonal variations. An algorithm based on the promotion of renewable sources integration was elaborated. After the integration of basic power plant, the program has to promote directly the integration of renewable energies within the power grid and indirectly via storage units. The calculated integrable threshold is 17.545%. With storage capacities added, the new integrable power by renewable energies will border 3358.793 MW, with a percentage of integration of 47,189%. A value that converges with the policy of the country who have proposed 42% of the installed capacity power of RES by 2020, and 52% by 2030. Among the perspectives that can be identified on the purpose of this work would be to develop more complex modeling of the intermittency, and the balance of the electrical network by integrating the hourly climatic and meteorological data to calculate the electric power generated by the natural flow. Thus, our study will allow developing more deeply the economic and environmental consequences.