Optimization of Electrical and Thermal Storage in a High School Building in Central Greece

: Nearly zero-emission buildings (nZEBs) are increasingly being constructed in Europe. There are also incentives to refurbish older buildings and transform them into nZEBs. However, permission is not always granted for their connection to the grid to infuse surplus photovoltaic electricity due to the grid being overloaded with a large number of renewables. In this study, the case of a refurbished school building in Central Greece is examined. After refurbishing it, a signi ﬁ cant amount of photovoltaic electricity surplus is observed during the summer and neutral months, which cannot be exported to the grid. The absence of an adequate ba tt ery storage capacity resulted in the rejection of an application for exporting the school’s surplus to the network and the photo-voltaic installation staying idle. An alternative approach is proposed in this work, involving a shift in the export of the photovoltaic electricity surplus to the evening hours, in order for the school to be granted permission to export it to the network. To this end, an optimal ba tt ery storage size is sought by employing a building energy system simulation. The mode of operation of the ba tt ery designed for this application is set to discharge daily, in order to export the electricity surplus in the afternoon hours to the evening hours, when it is favorable for the network. Additionally, the optimal size of the thermal energy storage of the heating system is studied to further improve its energy e ﬃ ciency. Our ba tt ery and storage tank size optimization study shows that a signi ﬁ cant ba tt ery capacity is required, with 12 kWh/kWp photovoltaic panels being recommended for installation. The ever-decreasing cost of ba tt ery installations results in the net present value (NPV) of the additional investment for the ba tt ery installation becoming positive. The solution proposed forms an alternative path to further increase the penetration of renewables in saturated networks in Greece by optimizing ba tt ery storage capacity.


Introduction
Global efforts to face climate change by reducing greenhouse gas (GHG) emissions involve the further penetration of renewables.In Europe, climate policies regarding the energy mixture aim for net-zero emissions by 2050.In Greece, specific objectives have been put into legislation to cut GHG emissions by 55% by 2030 and by 80% by 2040, as well as to phase out lignite-fueled electricity generation by 2028 [1].The Greek transport sector was accountable for 38% of the amount of energy consumed in 2018, followed by the residential sector with 27% and the industrial, service and agricultural sectors with 18%, 16% and 3%, respectively [2].The expansion of renewables in Greece has been remarkable over the last twenty years.Yet, nowadays, the electricity grid is overloaded by renewables' penetration, retarding the further expansion of renewables, especially of rooftop photovoltaic installations.This problem especially affects and involves the interaction of microgrids, energy storage and energy communities.Energy communities in Greece can participate in net-metering or virtual net-metering applications, either in neighboring buildings or in buildings in the same municipality.They may consist of companies, municipalities and individuals.
A net-zero energy community (NZEC) is a group of neighboring buildings with renewable energy sources.Their self-production covers their aggregate energy demand [3].Examples of these are large complexes of residential houses or offices, education buildings, shopping centers, small villages or island communities.Microgrids are vital in addressing the problem of grid saturation.A microgrid comprises specific loads, energy storage, self-generation and communication systems for real-time management.They are able to operate autonomously or interact with the external grid after balancing the power supply with the demand to a certain extent [4,5].To this end, a strategy to increase the selfconsumption ratio (SCR) involves the installation of various kinds of short-and long-term storage systems [6].The operation of photovoltaic (PV) systems in combination with electrical and heat storage is a known means of reducing the total energy expenditure.The minimization of annual costs and increase in the self-consumption ratio are influenced by prices, local insolation conditions and policy measures for PV prosumers [7].Policy support is critical for economic viability.Kumar et al. presented a battery storage system within a PV system in India comparing a zero-export system with a net-metering scheme.The optimal size of a commercially viable system with zero feed-in is smaller than that of the respective net-metering scheme [8].
Energy storage helps to resolve the mismatch of renewable energy supply and demand profiles.Although thermal storage, pumped hydro storage, batteries, super-capacitors and hydrogen storage have financial and technical limitations, [9], their involvement remains critical to face the peak in energy demand [10].Thermal energy storage (TES) is affected by heating or cooling media.This allows us to use stored amounts later for heating or cooling [11].This includes sensible energy storage in buffer tanks, boreholes, aquifers, caverns or pits.It also includes phase-change materials (PCMs) and storage via chemical reactions [12].The main characteristics of TES are its capacity, power, efficiency, storage, charge, discharge and cost [13].PCMs can also be profitably incorporated in buildings' shells to increase their heat capacity [14].Common PCMs include plaster, gypsum boards, bricks, concrete, etc. [15].
Heat pumps are the main engine behind building electrification.The substitution of combustion boilers by heat pumps significantly increases the electricity self-consumption ratio in buildings.The efficiency of air source heat pumps is continuously improving.They can operate at outdoor temperatures reaching −15 °C with backup electrical resistances, implying, however, a severe coefficient of performance (COP) penalty [16,17].Coelho et al. assessed the effectiveness of phase-change materials installed on an nZEB residential building in Austria [18].Aneli et al. analyzed a system comprising a heat pump and a PV installation with thermal and electrical storage for residential buildings.The use of storage resulted in a significant increase in self-consumption and self-sufficiency [19].Nicoletti et al. studied a system consisting of a boiler, a PV with battery storage and an air source heat pump using EnergyPlus.Simulations were performed for five Italian locations with different climatic typologies.The optimal size of the PV installation was proven to depend on the heat pump's size.On the other hand, the optimal size of the batteries is affected by the location and the size of the PV installation [20].Meriläinen et al. studied the renovation of an oil-heated home into a carbon-neutral one by shifting to a heat pump, an on-grid PV system and a battery energy storage system (BESS).The system was simulated in Matlab.The ground-coupled heat pump with the PV achieved the lowest life cycle cost [21].Research has also focused on the simulation and sizing of hybrid systems with electrical, thermal or hydrogen storage [22].
Hybrid systems are the usual choice to reduce emissions and improve overall system energy efficiency [23].Mancò et al. examined the use of traditional and green technologies in the renovation of an old building.Cost reductions of 27-29% were achieved with the size optimization of Li-ion batteries, thermal storage and a biogas facility, carried out by non-linear programming [24].Energy management is crucial for hybrid systems, especially in systems with different types of storage.Bigdeli et al. studied a hybrid system that consisted of PV panels, a fuel cell and batteries as storage, using a fuzzy controller.The combination of the fuzzy logic controller with quantum-behaved particle swarm optimization performed best [25].Möller et al. employed Matlab v.9.11 to analyze annual energy flows.They used loads, weather data and heating energy profiles as their input data.The hybrid energy storage system comprised lithium-ion batteries (short-term) and hydrogen storage (long-term).The rejected heat from the electrolyzer and fuel cell were modelled.The remaining heating loads were covered by a heat pump [26].Stamatellos et al. examined the interactions between short-term electric car battery storage and long-term green hydrogen storage in a building [27].Liu et al. proposed a method for sizing the PV BESS system.They took into account the impact of uncertainties.This was expressed by means of climatic effects and battery degradation from irregular cycling.Their approach included optimal sizing, a component output analysis, state prediction and parameter tuning.Energy management strategies were examined by updating the components' output to maximize energy savings [28].Wu et al. proposed a reinforcement learning model approach for the performance optimization of existing zero-energy houses.Taking into account the PV output, consumption and energy costs, it was found that a deterministic policy gradient algorithm achieves a 49.4% PV self-consumption ratio and a 36.7%selfsufficiency ratio [29].
Micro-grids in nZEBs [30] are designed for self-sufficiency.Grid transactions can be optimally controlled to keep the grid stable.European standards limit the net primary energy import from the grid to 20-30 kWh/m 2 y [31].These buildings are well insulated and characterized by smart control features.Space heating and cooling are supplied by efficient heat pumps.Electricity comes from rooftop PV installations.The Energy Performance of Buildings Directive 2010/31/EU [32] mandates nZEBs from 2021 onwards.In parallel, most European countries incentivize the refurbishment of older public buildings to approach nZEBs.The most popular strategies involve adding insulation and shading measures, efficient lighting and the replacement of oil or gas boilers by heat pumps [33].In Greece, many public school buildings are renovated with this philosophy, which results in a significant amount of PV electricity surplus for export, after the coverage of in-house loads.This happens especially during weekends and extended holidays.The optimal sizing of self-production installations and storage facilities is critical in such cases.
The current study is based on the case of a high school in the small municipality of Gonnoi, near Larissa, Thessaly, which was constructed in 1990.The original building lacked adequate insulation and was heated by an oil-fueled boiler.A refurbishing project was carried out in the period of 2018-2019.Moving towards electrification, the boiler was replaced by an array of air-to-water heat pumps.Heat storage was provided by two buffer tanks, each with a 1000 lit capacity.The old lighting system with fluorescent lamps was replaced by LED lights with a total of 14 kW of peak power installed.A rooftop PV system was installed, consisting of 95 PV panels rated at 535 Wp, in order to profit from a netmetering program.The system was initially aimed to operate with a significant amount of energy injected into the grid, without providing for electricity storage due to budget limitations and the very high cost of batteries.However, the Hellenic Energy Distribution Network rejected the electricity's injection into the external grid.Thus, the PV installation is not yet operative.Greek legislation supports the addition of battery energy storage systems aimed at increasing the self-consumption of prosumers.Yet, the operation of the BESS is limited to increasing self-consumption by shifting the PV electricity to be consumed during the evening hours to avoid its export to the grid, which is saturated by the high PV capacity installed in most regions (with a zero feed-in requirement).The high school building produces significant quantities of electricity, especially during the spring, summer and autumn, which are characterized by a large percentage of sunny days.Only during the winter does the building's consumption match its PV production on average.The initially suggested scheme was rejected to safeguard the grid's stability because the grid was overloaded at this location.Choosing an optimal electrical and thermal storage system is a challenging task.The right choice should maximize the school's self-consumption ratio, increase its energy efficiency and decrease imports from the grid.It should allow for injections into the grid during specific hours of the day that are favorable to the grid's stability.
In this study, an alternative approach is proposed that supports the further penetration of renewables in already congested networks.To this end, a significant amount of storage capacity will need to be installed to shift the dispatch of PV electricity to the evening hours.The battery size must be optimized.This task requires the use of a building energy simulation for the entire year, in order to address the variability in solar radiation on the PV panels and the building's electricity consumption profiles.Additionally, the optimal size of the buffer tanks of the heating installation is studied, aimed at further improving the energy efficiency.The decreasing cost of battery installations is proven to result in the net present value of battery investments breaking even.The proposed approach is based on the observed downward trend in battery prices and creates an alternative path towards increasing renewable installations in saturated networks in Greece.This would further reduce the significant quantities of natural gas consumed during the evening ramp of the Greek electricity system and reduce electricity prices that suffer from instabilities in the natural gas markets.Based on the findings of this work, a modification of the terms and conditions of the Greek network operator is proposed so that it might accept the infusion of PV electricity from buildings with a significant surplus, provided that an adequate battery capacity is installed to shift electricity exports to the evening hours.
The remaining paper has the following structure: Section 2 presents the building's architecture and its energy system's design and simulation.The input data and the battery and storage tanks' capacity optimization procedure are included.Section 3 discusses the simulation results on an hourly and seasonal basis and grid interactions.The initial (reference) system's performance is compared to that of the optimized system.Our conclusions are discussed in Section 4.

Materials and Methods
The building's energy simulation was carried out in TRNSYS v. 16.This software is capable of modeling the transient performance of a large variety of energy systems [34].A system of linear equations results from the component models' interactions.The reliable performance of TRNSYS in building simulation has been confirmed in an extensive number of studies [35].The model structure in TRNSYS and the building's details are briefly presented below.

Building Description
The 9-zone high school building of Figure 1 has a ground trace of 857 m 2 .It consists of three levels: the basement, with classrooms that are partly above ground towards the southeast; the ground level with classrooms, gymnasium and auditorium; and the first floor with classrooms and offices.The building was renovated in 2019.External insulation was added to the walls, resulting in a thermal transmittance of U = 0.35 W/m 2 K, and the roof was insulated up to U = 0.29 W/m 2 K.The windows were not changed.They are double glazed with standard aluminum frames, and their thermal transmittance is 3.27 W/m 2 K.No insulation was added to the basement floor (slab on ground), resulting in U = 3.24 W/m 2 K.More building data are presented in Appendix A. A maximum number of 200 students is assumed on workdays.The total heated zones' area is 2180 m 2 .Ceiling height is 3 m (ground and first floor).The consumption profiles of the school building are peculiar, because of the existence of two-week holidays at Christmas and Easter, as well as due to the long summer holidays (more than two and a half months long).During these periods, the school is a significant electricity exporter to the grid and the battery is designed exactly with this situation in mind to be acceptable and favorable to the grid.
The structure of the system's model is presented in Figure 2. Type 56 multi-zone building model is the central component in this simulation.A typical meteorological year (TMY) was compiled based on available meteorological data for Gonnoi, Thessaly, Greece.This is a necessary input for the TRNSYS model.It contains hourly time series of ambient temperature, humidity, wind direction and speed.The total/direct solar horizontal radiation for the full year is included.Space heating is supplied by four 30.1 kW nominal capacity air-to-water heat pumps.Their rated heating output is 120.3 kW at 7 °C DB ambient temperature.The heat pumps' leaving water feeds two storage tanks with total volume of 2 m 3 .The tanks feed a hydronic network with radiators inside offices, corridors, classrooms and other spaces.The gym and auditorium theater are heated by fan heaters.LED lighting and A+ efficiency office equipment are employed.The air source heat pump model is a modified version of Type 668 [36].

Photovoltaic Installation
A total of 95 photovoltaic panels are arranged to fill the southwest-facing (50) and the southeast-facing (45) parts of the tilted roof of the building (panels' total area is 245.5 m 2 ).The PV panels' tilt angle is 17.9 degrees, following the slope of the tilted roof (Figure 1).The panels have a 535 Wp nominal output [37] (data in Appendix A).A total of 50.825 kWp is attained in this way.The photovoltaic panels' performance is modeled by a standard model in TRNSYS [38].A reconstruction of the current-voltage curve is made by fitting data from the manufacturer's technical datasheet.Each cell is modeled by an equivalent one-diode circuit with five parameters:  (the light current); 0 (the reverse diode current);  (the module series resistance);  (the shunt resistance); and  (a modified ideality factor).The modified ideality factor depends on the cell temperature , the number of cells in series , the usual ideality factor  , the Boltzmann constant  and electron charge .

Electricity Storage Batteries
A generic lithium-ion battery model is employed.It shows the battery voltage, current and state of charge (SOC).The model employs the modified Shepherd equations (Hyman's model).The specific TRNSYS routine requires power as input [39].Charging efficiency is assumed to be constant.The main battery categories are lead-acid, lithium-ion, sodium-sulfur and flow batteries [40].BESSs require accurate modelling to enable accurate SOC and health level estimations [41].Optimization of BESSs based on capacity, SOC and output power may extend their lifespans [42].Some indicative battery types are presented in Table 1.In the initial building simulations, a lithium-ion battery aggregate with total capacity of 500 kWh is assumed.The study of the system's performance on a daily basis for the different seasons will indicate directions for battery capacity optimization.

Air-to-Water Heat Pumps
Space heating is provided by four identical heat pumps (in heating-only mode) which are connected to two buffer tanks.The total heating capacity in kW of each one is presented in Figure 3 as function of the source temperature (ambient air temperature) and the leaving water temperature (load).The charts are based on the manufacturer's data (Appendix A).As can be seen in the graph, their performance severely deteriorates at source temperatures below about −7 °C, at which point the COP is reduced to 1.The associated electric power consumption as function of source and load temperature of the heat pump is additionally presented in Figure 4.The electricity consumption below −7 °C is almost exclusively electricity dissipation in a backup electrical resistance, which reduces the heat pump's operation to that of a simple electric heater.More data on the heat pumps' performance are included in Appendix A.

Dispatch Logic for the Electricity Sources
The usual control strategies for battery dispatch in hybrid systems are load following and cycle charging [53].The low limit  min is introduced along with a charge to discharge limit at the inverter's control unit.For low battery Soc battery recharging is of the highest priority.Second highest priority is satisfying the building's loads.The available battery charge power ( ) and discharge power ( ) depends on its instantaneous state of charge ( ).This is defined as the ratio of the remaining capacity ( , ) to its maximum capacity ( ) [54].The battery discharge power level is expressed by the C-rate.This rate refers to the power that can be discharged hourly, relative to the battery's capacity.This reference value is defined as 1-C.In addition to the Soc and C-rate, the maximum discharge power depends on the  min allowed for the battery as follows:  = , × 100% (1) Here,  and  min are percentages. is in kWh, and  and  are in kW.Power is supplied by the PV installation, the batteries and the positive or negative power flow to/from the external grid.A sequential dispatch is assumed, aimed at zeroing any unmet load.First priority is PV energy dispatch.The net required load  net (kW) is computed as follows: where  req is the load to be met (kW) and  * denotes the PV generation (kW). , is the PV inverter' s efficiency (%), and  , is the DC power (kW).The net required load could be zero, negative or positive.If  net is negative, excess power is produced by the PV.This excess power charges the battery if Soc < 1.Otherwise, it is exported to the grid.If the net load  net is positive, additional load has to be met.This can be accomplished either by discharging the battery, provided that SOC >  min , or by importing electricity from the grid.Thus, the battery's power exchange  * in kW is computed as follows: where  binv and  brec are the battery's inverter and rectifier's efficiency, respectively. * is negative when battery is discharging.It is positive when it is charged.
In the optimized system, the above dispatch logic is modified in its last steps, in order to avoid electricity being exported in the hours around noon.This would happen with the above-described dispatch logic whenever the battery is loaded up to its 100% capacity.To avoid this non-permissible export to the grid, the inverter is programmed to export battery electricity only during the hours from 17:00 to 01:00 for the period from April to October.During these months, the heat pump consumption is negligible, and a significant surplus of electric power becomes available.The power levels of electricity export to the grid should be modulated according to the season and maximized during the summer.They are also varied in proportion to the battery state of charge.

Storage Tank Capacity and Battery Capacity Optimization
The optimal sizing of the battery and the control of battery discharge limit are critical to the system's performance and lifespan (Table 2).The optimal values for battery size and storage tank volume are determined following a statistical analysis of the building's energy system's performance.This will be presented in the next section.However, it is also important to check the financial viability of the additional installation and maintenance costs induced, mainly for the batteries but also for the storage tanks.
For the economic analysis, one must keep in mind that the starting point is the highschool building with rooftop PVs installed but without batteries installed.In this situation, all electricity is purchased from the electric power company.When the batteries are installed, the building's electricity demand is mainly covered in-house.Positive cash flows are introduced, equal to the cost of purchasing the self-consumed electricity demand.Further, there is a positive cash flow from selling the exported quantities to the grid, minus a negative cash flow for the annual purchase of the electricity imported from the grid.
The net present value for the battery investment is expressed as follows: where: N is the lifetime of the batteries, assumed to be 10 years; i is a specific year in the lifetime of the battery; d is the discount rate, assumed at 2%.Cash Flow for year 0 subtracts the battery package cost, currently around 150 USD/kWh for this category of battery size [55].The additional storage tanks' investments can be neglected in this approximation.For years i = 1 through 10, positive cash flows are the savings and profits from exploitation of the PV electricity, as explained above.Negative cash flows are the cost of electricity imported and the operation and maintenance costs (0.75 USD/kWh).No investment tax credit is applied for year 0, because this investment will be eligible for government funding.
For economic viability, the NPV of Equation ( 7) for N = 10 years should be a positive value.The Sankey diagram in Figure 5 is provided to better understand the system's operation.Thus, for economic viability of the additional investment, the cost of the battery installation, which leads to negative cash flow for the first annual period, must be offset by the added present values of the net annual gains from self-consumption and export of PV electricity, minus the costs of purchasing the import quantities and the annual battery maintenance costs for the period of ten years, which is assumed to be the lifetime of the battery.

Results and Analysis
Our starting point is the transient simulation of a reference system, which includes, in addition to the system that was actually installed, a battery pack with a capacity of 500 kWh that is allowed to discharge above  min = 0.36.The results are presented in the form of hourly time series and monthly energy balances.

Transient Performance of the Initial System
A TRNSYS simulation of a full year with a 0.1 h time step was performed to assess the initial system's performance.The following variables were recorded: the ambient temperature, typical zone temperature, heat pump consumption, PV electricity production, battery SoC, power imported from the grid and power exported to the grid.As our first example, Figure 6 presents the variation in these variables for the second week of January.Significant electricity import from the grid is noted especially from Wednesday to Friday, due to the low battery SOC and cloudy days.As soon as the SOC exceeds  min , the battery is allowed to discharge to cover the additional building load.As our next step, we compare the behavior of the external grid during a similar period.To this end, the system's load curve in a week in January 2024 is presented in Figure 7.In addition to the Greek system's demand curve, the part of the load met by traditional power sources, whenever the PV contribution is subtracted, can also be seen.The school's energy systems' performance will be significantly different during the heatingneutral and the summer months.To understand these different situations, the hourly variation in the main system's variables during a week in July is presented in Figure 8.This week is characterized by a heat wave with a duration of two days (Monday and Tuesday).During the summer, PV production is maximized due to clear skies and the low tilt angle (17.9 degrees) of the PV panels.As a result, the battery SOC is close to 100% most of the time.Thus, power must be exported to the grid at noon almost daily.Since no space cooling exists in the building, the indoor temperatures stay above 30 °C over the whole week.In order to understand the needs of the external grid, the Greek system's load curve during a week in July 2023 can be seen in Figure 9.The morning peaks of the load curve are quite impressive in this period, reaching up to 10.5 GW.The high PV production of the Greek system during the morning hours and hours around noon save the firing of conventional power sources in order to address the steep morning ramp.Additionally, the building's internal grid is predicted in Figure 8 to export electricity during the hours around noon.These export quantities are not generally welcome, as explained above, due to grid saturation.On the other hand, the electricity demand covered by conventional sources remains very high during the late afternoon and evening hours, when a steep load curve must be met.Thus, if the smart grid is able to export electricity from its batteries to the external network during these hours, it would save natural gas, help increase green energy usage and suppress electricity prices.
Following an inspection of the transient behavior during the cold and hot seasons of the year, the monthly energy balances of the school building are presented in Figure 10.The PV electricity production is seen to be maximized in July with 8340 kWh.The lowest photovoltaic output is in December with 2050 kWh.Heat pump consumption (heating-mode only) significantly varies with weather conditions.The heat pump's total consumption reaches 18,900 kWh.No heat pump consumption is predicted for the six-month period from May to October.The detailed performance of the heat pump is presented in Figure 11.This includes the electrical energy consumption; the heating energy supplied to the buffer tanks and the associated school's heating system; and the heat pumped from the ambient air.The building's electricity consumption apart from the heat pump averages to about 1200 kWh per month (Figure 10).The school's annual consumption is predicted to be 33,900 kWh.For comparison, the respective actual consumption of the school in 2023, as extracted from its monthly electricity bills, is presented in Figure 12.It totals 38,700 kWh.As already mentioned, the high school in its current state of operation is not equipped with any battery storage systems.The above-mentioned annual electricity consumption corresponds to 45.1 kWh/m 2 y of primary energy consumption.European legislation specifies 80-90 kWh/m 2 y of total primary energy consumption for buildings to be designated as nZEBs [31].The electrical energy output of the PV installation is computed at 60,300 kWh.The building's annual imports from the grid are 11,800 kWh and its exports are 32,200 kWh.The annual electricity self-production of the high school significantly exceeds its annual consumption.However, the specific periods of power exports will need special attention and will need to be identified in consideration of the respective needs of the external grid.
This situation is presented in Figure 13.Electric power imports frequently occur in late December, January and February.The maximum rate observed reaches 58 kW.The remaining nine months are associated with frequent exports to the grid, at a maximum rate of 42 kW.Next, it is important to understand the hourly performance of the energy system over one full year.The variation in the batteries' SoC is critical to optimize the battery size.This situation is presented in Figure 14.At the beginning, the batteries are completely discharged.After recharging rapidly during the first week of January, the battery aggregate is seen to fluctuate with an SOC range of 0.4-0.5 until the end of February.Next, the batteries are charged during March and reach their highest state of charge due to the reduced need of the heat pump for space heating.From April to September, the batteries remain steadily close to their fully charged state due to the high performance of the PV panels and the lack of electricity consumption for the heat pump, since there is no space cooling.The daily timing of grid imports should be studied in detail as a function of the hour of day.As observed in Figure 15, a significant amount of electrical energy is imported from the grid during December, January and February during the operating hours of the school.As already reported, the maximum power levels reach 55 kW during a few cold, cloudy days.Next, the daily electricity exports to the grid are mapped in Figure 16 as a function of the hour of day.During January, February and half of March, no electricity would be exported to the grid due to the dispatch logic, because all of the surplus cannot fully charge the batteries.From mid-March onwards, exports are increasingly frequent during the hours around noon on sunny days.From June to September, significant export power levels to the grid are seen nearly every day.The maximum power levels occur in the middle of the day, reaching 40-45 kW.Electricity exports are reduced from October and are negligible from mid-November to the end of the year.The significant electricity quantities exported to the network need to be managed in an optimal way.These remarks will be expanded upon further by studying the optimized system's performance.

Battery Storage Capacity and Tank Volume Optimization
Based on the results of the reference system's simulation, a statistical distribution of the daily PV production is presented in Figures 17 and 18 for the heating season (November to April) and the heating-free season (May to October), respectively.During the heating season, the PV production averages 108 kWh/day according to Figure 17.The heating season operation is characterized by a significant number of cloudy days.During these days, the battery capacity must be capable of fulfilling the building's electricity needs, the majority of which is caused by the operation of the heat pump.On the other hand, a certain quantity of electricity is exported to the grid during sunny days with high temperatures in November, March and April.During the heating-free season, PV production is high, averaging 221 kWh/day (Figure 18), due to the mostly clear days, the longer duration of sunlight and the very low tilt angle of the PV panels.Moreover, the level of electricity self-consumption is low due to the holiday season and the heat pump not being in operation.Significant quantities are available for export, averaging 165 kWh/day.However, as already explained, the specific time interval when large quantities of electricity are available for export is not suitable for the system's operator.The reason is that there is usually plenty of electricity being offered during this period of the day, especially from renewables.This is mirrored in the very low prices on specific days in dayahead electricity auctions.An example is presented in Figure 19, in which the day-ahead auction for a specific day resulted in zero wholesale electricity prices between the hours of 09:00 and 16:00.On the other hand, there exists another time slot when exports to the grid are mostly favorable to the network.Electricity exports to the grid during this time slot, which is between 17:00 and 01:00, need to be significantly delayed against the time slot of maximum PV electricity production, which is centered around noon, as seen in Figure 18.Thus, it is a critical requirement for the battery capacity to be capable of time shifting this slot for about 8 h during the summer.Under these circumstances, the electricity might be permitted to be exported to the grid.With a safe margin for a battery that is 100% full and an Socmin of 30%, a total battery capacity of about three times the abovementioned average photovoltaic production of 221 kWh would be necessary.On the other hand, the battery capacity should be large enough in order to not be filled to a capacity over 90% on days with very high insolation during the summer.This is because the electricity surplus must be dumped in these cases, since exporting to the grid is not permitted during the hours around noon.Based on these remarks and according to our reasoning, the battery capacity needs to be increased to the order of 600 kWh.
Figure 19.Greek day-ahead market, showing an electricity auction on 24 March 2024.The variation in wholesale electricity prices (blue curve) resulted in the price per MWh being zero between 09:00 and 16:00 on this specific day [56].
Shifting our attention now to the optimal sizing of the storage tanks, Figure 20 presents the statistical distribution of the daily heat pumps' loads during the heating season.In order to avoid the heat pumps being operated on days with very low outdoor temperatures, the storage tanks must have the capacity to supply the maximum heating load for at least 12 h without the heat pumps needing to switch on.
This storage tank capacity level would allow the heat pump to limit its operation over several hours with temperatures below zero.This results in an increase in the average COP and a subsequent reduction in annual electricity consumption.
Based on the above reasoning, the optimization of the battery capacity and the storage tanks' capacity was based on a significant number of building simulations and resulted in the following optimal values for the optimization parameters presented in Error!Reference source not found.:

•
Storage tanks' capacity = 13 m 3 The interaction between the electricity and thermal storage variables is implicitly taken into account in the manual optimization process.This is seen, for example, by the fact that the optimal value of thermal storage in Table 3 results in a reduced level of annual heat pump electricity consumption.This, in turn, affects (increases) the optimal value for electricity storage.Further, SOC cycling can decrease further to a minimum value of 0.30, which is the lowest permissible in regards to limiting the battery's degradation, based on vast studies of electric vehicle Li-ion batteries tested for degradation performing vehicleto-grid services [57].A new building is now designed, after modifying the above system's parameters to their optimized values.The results of the most important performance indices are compared in Table 3.The optimized building's annual electricity consumption is now reduced to 30,700 kWh (Table 3), due to the improved performance of the heat pump.The total annual PV output is predicted to be 60,300 kWh.The building with the optimized energy system would import 10,100 kWh and export 31,000 kWh annually.The monthly energy balances of the optimized system are shown in Figure 21.Overall, Figure 21 shows the significant exports to the grid taking place from March to October.They are maximized from June to September, matching the maximum demand of the Greek network.
Exports to the grid occur in the revised system during the evening hours, as required by the external grid operator.This can be clearly observed in Figure 22 for all the days of the week.The battery SOC fluctuates daily between a maximum of 90% and a minimum of 50% during the week.This is due to the large amount of sunshine, the favourable PV panel tilt angle and the reduced electricity consumption of the school due to the summer holidays.As explained above, the large storage tank volume of 13 m 3 results in quite a significant reduction in cycling for the heat pumps.This is clearly observable during the Electricity export to Grid heating system's operation in the second week of January (Figure 23).The heat pump operated with significantly less frequent cycling during the same week than the initial system with the 2 m 3 storage tanks, as can be seen in Figure 7.

Figure 22.
Hourly performance of the optimized system in a week in July.The lowest limit for batteries is Socmin = 0.30.Battery capacity is 600 kWh.The electricity exports are shifted to the favorable evening zone, as can be seen by comparing this figure with Figure 8. Further, it is useful to explore the hourly evolution of energy exports during the full year and compare this with that of the Greek system during the evening ramp.

Cumulative Distributions of Grid Interaction
The hourly distribution of the power levels imported and exported to the grid are examined next in Figure 24.These are presented as a function of the day for the cold season.The integration of the annual electricity imported and exported to the grid for each time slot during the six months from November to April can be seen in Figure 24.The total amount of energy exported to the grid per hour for this six-month period reaches a maximum of 63 kWh in the 17:00-18:00 time slot.On the other hand, the total hourly electricity imports are maximized to 150 kWh in the 08:00-09:00 time interval.The annual behavior of the optimized system is better understood by looking at the graph in Figure 25.As already reported, no imports from the grid are observed during this period.A comparison of the results in Figure 25 with the respective results of the initial system in Figure 16 clearly shows the complete shift in the electricity export hour slot to the evening zone, as required by the system's operator.An alternative view of the behavior of the optimized system's batteries can be seen in the comparison of the battery SOC variation over the course of one full year (Figure 26).As already reported, at the beginning, the batteries are completely discharged in both cases.After rapidly recharging during the first week of January, the battery aggregate is seen to fluctuate with an Soc range of 0.4-0.5 until the end of February.Next, the batteries are charged during March and reach their highest state of charge, due to the reduced consumption of the heat pump for space heating.From April to October, the batteries remain close to their fully charged state due to the high performance of the PV panels and the lack of electricity consumption for the heat pump, since there is no space cooling.Last but not least, the NPV of the additional investment for the battery pack (Equation ( 7)) is close to zero, if one considers a cost of about 90,000 USD for the battery and a positive cash flow of about 0.2 USD per kWh produced by the rooftop PV installation.Thus, this battery size begins to become economically viable in this special case.The results of similar studies confirm that a battery capacity setting of 12 kWh/kWp is reasonable for the operation of this type of system with a delayed export to the grid.Regarding the 0.11 m 3 total storage tank volume per kW nominal heating rate of the heat pumps, this is judged to be reasonable for air source heat pump installations, based on the experience of other researchers.According to the electricity bills and the simulation results, the high school building, without PV panels and batteries, must purchase 35,000-40,000 kWh of electricity annually.The situation does not change considering the current state of the building with the PV panels but without the battery storage.That is, the PV installation is left open-circuit and produces no electricity; an investment worth 200,000 USD stays disconnected.As explained above, this situation would be radically changed with the installation of the battery, since the school would negate its electricity bill and additionally gain money from selling an annual surplus of almost 20,000 kWh to the external grid operator.
The proposed solution forms an alternative path to further increase the penetration of renewables in saturated networks in Greece.This would further reduce the significant quantities of natural gas consumed during the evening ramp of the Greek electricity system and reduce electricity prices, which suffer from instabilities in the natural gas markets.However, it should be noted that design guidelines for storage should be particular to buildings' typologies (e.g., multi-story office buildings, traditional low-rise school buildings, etc), year-round electricity demand profiles (the use of compressor cooling, etc.) and rooftop PV installation capacities.That is, optimal electricity storage depends on the seasonal evolution of the electricity surplus of the specific building in question.In addition, optimal thermal storage is affected by a building's specific climatic conditions, as seen in the context of Figure 20.Thus, any expansions or potential applications of the results of this study to different building and use typologies must take into account the combined effect of load profiles against electricity self-production and prevailing climatic conditions.

Conclusions
An electricity and heat storage optimization study was carried out for a renovated high school building with a 50 kWp rooftop PV installation.Initially, the system lacked a battery storage system, which resulted in the rejection of its license to export its electricity surplus to the network.First, the system's performance was simulated by TRNSYS, with a battery storage capacity initially assumed to be supplied by Li-ion batteries.Its thermal storage capacity is furnished by thermal storage tanks, initially sized at 2 m 3 .A favorable timing of the optimized system's exports is sought for the months from March to October, when an electricity surplus exists.This is determined by studying the demand curves of the Greek system during specific seasons.The proposed approach involves a shift to the export of its photovoltaic electricity surplus to the evening hours.To this end, the optimal battery size was selected by employing a building energy simulation.Additionally, the optimal sizing of the thermal energy storage of the heating system is studied to further improve its energy efficiency.Our battery and storage tank size optimization study showed an adequate battery capacity could be obtained with the installation of 12 kWh/kWp photovoltaic panels.The ever-decreasing cost of battery installations results in the net present value of the additional investment for the battery installation to approach zero.Currently, the high school's administration is obliged to purchase 35,000-40,000 kWh of electricity annually.No profit is incurred by the significant investment of 200,000 USD for the installation of the rooftop PV panels.This is because the PV installation is left open-circuit and produces no electricity.As suggested by the simulation results, this situation would significantly improve with the installation of a battery.In this case, the high school's administration is expected to negate its electricity bill and additionally gain money from selling an annual surplus of almost 20,000 kWh to the external grid.The solution proposed forms an alternative path to further increase the penetration of renewables in saturated networks in Greece.The proposed change in policy measures allowing for the expansion of rooftop PV installations in public buildings would further reduce the significant quantities of natural gas consumed during the evening ramp of the Greek electricity system and reduce electricity prices, which suffer from instabilities in the natural gas markets.longitude 22.46975°, 111 m height).It has a temperate climate, with average temperatures ranging between 7 and 8 °C in winter months and 28 and 29 °C in mid-summer.Annual precipitation stays close to 500 mm.Available data cover the period of 03/2019-today, recorded from an in situ meteorological station.The typical meteorological year for the specific location was constructed based on the specific data set, using the algorithms included in TRNSYS (Type 54a).The building shell insulation data are summarized in Table A1.It has double-glazed windows with U = 3.27-3.50W/m 2 K and g = 0.702 (solar heat gain coefficient).The average window/wall ratio is 0.25.Shading is applied to the vertical openings.Adequate ventilation is afforded by manually opening the windows at prescribed intervals.The employee's working hours are 8:00-17:00 on weekdays and 09:00-14:00 on Saturdays for specific activities.It has high-efficiency LED lighting with a peak electric power consumption of 5 W/m 2 .The most important technical specifications of the PV panels employed in this study are listed in Table A4 (from the manufacturer's datasheet).These data are used to tune the model of PV panel operation, which is based on the reconstruction of the photovoltaic panel's voltage-current curves.

Figure 1 .
Figure 1.Southwest view of the high school building showing the SW-facing wing of the rooftop PV installation (a), plan of the ground floor level (b), and typical section (c).

Figure 2 .
Figure 2. The energy system's diagram in the modeling studio.

Figure 3 .
Figure 3.Total heating capacity (W) of the heat pump.

Figure 4 .
Figure 4. Total electric power input (W) of the heat pump.

Figure 5 .
Figure 5. Annual energy balance of the school building in the form of a Sankey diagram.

Figure 6 .
Figure 6.Hourly variation in the main system's variables in a week in January.Low limit for batteries' SOCmin = 0.36.Temperature set at 20 °C.

Figure 7 .
Figure 7. Demand curve of the Greek system during a week in January 2024 with low ambient temperatures.

Figure 8 .
Figure 8. Hourly variation in the main system's variables in a week in July.Batteries' capacity is kWh.SOCmin = 0.36.

Figure 9 .
Figure 9. Electricity demand curve of the Greek system in July 2023 during a heat wave episode.The total demand is the blue curve and the part covered by non-photovoltaic power is in red.

Figure 10 .
Figure 10.Monthly energy balances of annual PV production, building energy use and export to the grid (17.9° panel tilt angle, 500 kWh battery capacity, 2 m 3 storage tank capacity).

Figure 11 .
Figure 11.Monthly heat pump consumption, energy from source and heating energy supplied to the load on a monthly basis.
Consumption, Heating, Cooling [kWh] Month HP Electrical Consumption HP Heat from Source HP Heat to load

Figure 12 .
Figure 12.Actual electricity consumption from monthly school electricity bills in 2023.

Figure 13 .
Figure 13.Computed evolution of instantaneous electric power imports and exports in one full year.

Figure 14 .
Figure 14.Battery state of charge for each hour of the day (vertical axis) and the day of the year (horizontal axis).The battery is assumed to start at zero state of charge.

Figure 15 .
Figure 15.Electricity imports of the reference system per day (horizontal axis) and the hour of day (vertical axis).Imports from the grid are mainly observed during the winter months, due to the low battery state of charge.

Figure 16 .
Figure 16.Daily exported power to grid (kW) of the reference system.It is presented as function of the hour of day (vertical axis).Battery capacity is 500 kWh, and storage tank volume is 2 m 3 .

Figure 17 .
Figure 17.Hourly variation in photovoltaic production and electricity exported to the grid, integrated for the 181 days of the heating season (November to April).

Figure 18 .
Figure 18.Hourly distribution of the total PV output and power exported to the grid, integrated for the 184 days of the heating-free season (May to October).
Total electricity (May to October) per hour slot [kWh] Hour of day Total_hourly_from_PV Total_hourly_to_Grid

Figure 20 .
Figure 20.Annual distribution of the daily heating loads (kWh) of the high school building.Since the 95% maximum daily heating load is of the order of 604 kWh, a storage tank volume of 13 m 3 , initially at 60 °C, would drop to 40 °C by supplying half the above maximum daily heating energy,  , to the hydronic network of the building as shown below:  = 13,000 kg.4.184 kJ kgK .20 K = 1088360 kJ = 302 kWh (8)

Figure 21 .
Figure 21.Monthly electricity imported and exported to the grid, gained from the rooftop PV panels and consumed by the school (13 m 3 buffer storage tank, 600 kWh batteries and  min = 0.30).

Figure 23 .
Figure 23.Operation of the optimized system in January.Storage tank volume increased to 13 m 3 .Lowest threshold for batteries' Socmin = 0.30.Indoor temperature set to 20 °C.

Figure 24 .
Figure 24.Optimized system: computed hourly distribution of the total annual electricity imported from the grid and exported to the grid during the months from November to April.

Figure 25 .
Figure 25.Optimized system: Electric power exported to the grid (kW) as function of the day and the hour of day.Battery capacity of 600 kWh, Socmin = 0.30, and storage tank volume of 13 m 3 .

Figure 26 .
Figure 26.Hourly values of battery fractional state of charge over a full year, starting with an empty battery.Initial system's behavior (500 kWh capacity, Socmin = 0.36) compared to the optimized system's behavior (600 kWh capacity, Socmin = 0.30).

Figure A1 .
Figure A1.Map of the MHC-V30W/D2RN8 Air-to-water heat pump's COP as function of the ambient temperature and the leaving water temperature.

Table 1 .
Different types of battery storage for building applications.

Table 2 .
System's storage parameters and their optimization limits.Then, the system's parameter values listed in Table2are optimally determined.The following constraints are set for the energy management system of the building.Electricity may be exported to the grid according to the seasons of the year as follows:

Table 3 .
Comparison of performance indices of the initial and optimized energy system (annually).

Table A2 .
MHC-V30W/D2RN8 Air-to-water heat pump: Heating capacity as function of the outdoor temperature (ODT) and the leaving water temperature (LWT) for heating-only mode.

Table A3 .
MHC-V30W/D2RN8 Air-to-water heat pumps: Power input as function of the outdoor temperature and the leaving water temperature for heating-only mode.