Technical and Economic Assessment of Battery Storage and Vehicle-to-Grid Systems in Building Microgrids

: In an electrical microgrid, distributed renewable generation is one of the main tools used to achieve energy sustainability, cost efﬁciency and autonomy from the grid. However, reliance on intermittent power sources will lead to a mismatch between generation and demand, causing problems for microgrid management. Flexibility is key to reducing the mismatch and providing a stable operation. In such a context, demand response and energy storage systems are the main factors that contribute to ﬂexibility in a microgrid. This paper provides an assessment of the technical and economic impacts of a microgrid at the building level, considering photovoltaic generation, battery energy storage and the use of electric vehicles in a vehicle-to-building system. The main novel contributions of this work are the quantiﬁcation of system efﬁciencies and the provision of insights into the design and implementation of microgrids using real on-site data. Several tests were conducted using real on-site data to calculate the overall efﬁciencies of the different assets during their operation. An economic assessment was carried out to evaluate the potential beneﬁts of coordinating battery storage with a vehicle-to-building system regarding the ﬂexibility and cost-efﬁcient operation of the microgrid. The results show that these two systems effectively increase the levels of self-consumption and available ﬂexibility, but the usefulness of private electric vehicles in public buildings is constrained by the schedules and parking times of the users. Furthermore, economic beneﬁts are highly dependent on the variability of tariffs and the costs of energy storage systems and their degradation, as well as the efﬁciency of the equipment used in the conversion chain.


Motivation
Following the recent challenges related to climate change mitigation and reducing dependency on fossil fuels, new technologies have been developed to increase end-use energy efficiency and improve the harvest of renewable energies cost-effectively. The increased penetration of distributed energy resources, such as wind, solar photovoltaic (PV) and biomass sources, and energy storage systems has rekindled interest in the development of electric microgrids. According to the Microgrid Exchange Group, "A microgrid is a group of interconnected loads and distributed energy resources within clearly defined electrical boundaries that acts as a single controllable entity with respect to the grid" [1]. Electric microgrids have the ability to work independently of the main utility grid and can be used to promote the installation of distributed energy generation, reduce the costs of energy transportation, improve local power quality, increase renewable source selfconsumption levels and provide auxiliary services to the main grid. Microgrids are also highly desirable in situations in which the high reliability of an energy supply service is required for critical facilities, such as hospitals, airports and military centers [2]. Microgrids can also be used to maintain energy supply in remote locations and to supply areas isolated during catastrophic events. This work aims to contribute a technical and economic assessment of the usage of battery energy storage systems and vehicle-to-building systems integrated into a campus microgrid to quantify system efficiencies and provide insights into the design and implementation of microgrids. All the assets were already installed inside the building, and data were collected during real operations, providing more realistic data than simulated results. The operational efficiencies were assessed and used to evaluate round-trip efficiency and cycle economies, which information is to be used as a reference by the energy management system. Furthermore, an economic assessment with different scenarios was made to highlight the impacts that flexibility can have in terms of increasing a building's selfconsumption and reducing overall electricity needs. In summary, the novel contributions to the field of study are: a.
An analysis of round-trip efficiencies of the most commonly used distributed energy systems in a microgrid using real on-site data; b.
A technical comparison of conventional bidirectional EV chargers and novel silicon carbide (SiC) bidirectional EV chargers; c.
Insights regarding the economic aspects of using BESSs and vehicle-to-building for load shifting and peak shaving in buildings.

Related Works
In Europe, there is a current policy trend to work towards near-zero energy buildings (nZEBs). One of the main research subjects is the implementation of better energy storage facilities in buildings. Battery systems and, more recently, vehicle-to-building systems have been subjects of increasing research in the past decade due to more accessible costs, more variety in the technology available on the market, the potential for flexibility and policies that encourage nZEB renovations.
The way in which EVs are used is also evolving. Increasing numbers of EV models are being built with an increased focus on the bidirectional transfer of power. This feature presents a viable solution for increasing flexibility by adding a new storage asset to microgrids. The functionality of EVs will not be limited to mobility only; they will provide various services to the user and the grid through the vehicles' unused battery capacities being taken advantage of. The work presented in [12] offers a comparison between vehicleto-grid, vehicle-to-building and vehicle-to-home (V2H). It is stated that V2G is the most complex and ambitious concept to apply, being heavily reliant on the penetration of EV technology to be successful. V2B and V2H are easier to implement, neither requiring large infrastructures or large numbers of EVs to be available. Another advantage is that these two methods prove to be more beneficial for the individual user. In [13], an economic evaluation of EV charging integrated into microgrids is presented. A campus microgrid is used as a test bench and several business models based on the self-consumption of electricity and smart charging are simulated. It concludes that using PV systems coupled with smart charging presents the highest profit for the operator. The installation of a battery storage system is less profitable, but increases flexibility and reduces dependency on the grid, particularly when PV is not being generated. In [14], the authors simulate a V2B system with six electric vehicles and evaluate the impact of battery degradation. The results prove that V2B has relatively significant profit potential, even considering the costs associated with battery degradation.
The work in [15] addresses energy sharing through a transactive energy market in community microgrids, using stationary vehicles and EVs as flexibility resources. The proposed method indicates that, with the management of energy storage resources, it is possible to reduce the mismatch between demand and local generation as well as operating costs. The method also highlights the benefits of aggregating stationary or mobile assets to increase impacts on the grid. Similarly, Ref. [16] simulates a method for energy communities in which EVs are used as flexibility resources between several buildings. The results show that the flexibility provided by EVs is more impactful in terms of providing reduced costs and increased self-consumption for buildings integrated into energy communities as compared with the individual management of buildings. In [17], a concept of collaborative charging for vehicle-to-building is proposed. The study demonstrates that it is economically viable for a building manager to provide free EV charging to users in exchange for control of the storage capacity during allotted time periods. The user benefits from the free energy and the building benefits from the increased storage reserve that can be used to reduce power peaks or increase self-consumption of intermittent renewable sources. In [18], a coordination scheme for EV charging in office buildings is proposed. The method is focused on taking advantage of integrated distributed resources, such as PV generation and battery storage systems, to achieve an energy cost reduction by coordinating with the known schedules of the building employees and loads. This method illustrates an energy cost reduction of 14% when compared with a first-come-first-served approach. In [19], the authors study the impacts that plug-in EVs can have regarding contributions to a nearly zero-energy building. The results show that, by sharing even a fraction of their battery capacities, plug-in EVs can reduce the amount of energy supplied by the grid by up to 40% in the considered scenarios. The authors also conclude that stationary storage systems have increased benefits when used to compensate for the intermittent presence of charging EVs. Similarly, the works [20,21] analyze vehicle-to-building-to-vehicle in different management schemes to reduce a building's energy signature and its electric consumption. On the topic of integration into microgrids, Ref. [22] focuses on the system and protocols needed for microgrids to integrate EVs. The authors suggest utilizing a blockchain-based method to provide adequate security and protection for users' data.
Most of the aforementioned works conclude upon the effectiveness, value or profitability of V2G as a resource to be integrated into buildings or cities. However, there are few works exploring the efficiencies and losses of energy transactions between assets, such as V2G or BESS, integrated into the same building/microgrid. The work in [23] is claimed to be the first to experiment on the round-trip efficiency of V2G systems. The results achieved for V2G efficiency are very close to those achieved for the experiments in this paper, but the scope of the research is narrow and does not include analysis of other common operations inside buildings, such as charging from PV or from/to BESS. In [24], the relationship between energy cost and efficiency is studied. The authors present data regarding V2G efficiency using EVs and plug-in hybrid EVs and make remarks about the economic impacts and benefits of V2G for system operators. In [25], a thorough study is presented regarding several aspects of V2G in order to propose regulations to maximize profit and determine optimal operating points. The work mentions the efficiency of V2G but does not present any experimental results that demonstrate or can be used by system operators to account for losses during energy transactions in microgrids or buildings. All these works approach V2G efficiencies in different ways but fail to provide a panoramic view of the expected efficiencies in a microgrid.
On the subject of operational stability, in a microgrid environment, the enclosed and limited resources mean that power fluctuations pose higher risks to operational stability [26]. The high reliance on intermittent resources heightens the probability of unwanted power fluctuations. Due to their ability to store energy and schedule charges, electric vehicles, as well as energy storage systems, present new opportunities for applying demand-side measures, such as demand response [27]. Demand response has been proven to dramatically increase microgrid reliability by minimizing peak demand, increasing the match between generation and demand, and improving cost efficiency [28][29][30][31][32]. Grid operators also rely on other demand-side measures, such as tariffs and monetary incentives, to smooth the demand curve and modify consumption habits to better match the existing energy availability [33]. All these works conclude that EVs will have a major role in achieving nZEB building status, whether from the perspective of supplying extra storage capacity to buildings, improving charging services for users or providing ancillary services, such as demand response. As such, this work focuses on analyzing the efficiency of several methods for integrating EVs in microgrids, the main one being vehicle-to-building. Battery energy storage systems have been subject to considerable advances in the past decade, and the battery pack price has fallen from over 1000 €/kWh in 2010 to 132 €/kWh in 2021 [34], and the forecasts point to a 100 €/kWh mark by the middle of this decade. Such a reduction in costs will lead to higher incentives for energy storage systems in stationary applications, as well as the electrification of the transportation sector. The main limitation of such battery systems has been their limited numbers of cycles, which cause the capacity to degrade both with time and usage. Daily charge-discharge cycles will gradually degrade a battery's health and reduce its efficiency and useful capacity. Therefore, it is important to address the issue of battery degradation and its impacts on the economic and technical operations of the microgrid.
The work in [35] presents two experiments designed to assess the battery degradation caused by V2G and calendar aging due to temperature and state of charge (SoC). For these experiments, batteries were discharged twice a day at the maximum power. With this usage profile, it was shown that the lifetime of the battery pack decreased to nearly half its predicted lifetime. These experiments also led to a new method to track the battery's state of health. In [36], a methodology is proposed to quantify EV battery degradation from driving only versus driving and vehicle-to-grid services. It was concluded that interactions, such as peak load shaving and frequency regulation, at a typical power rate, do not significantly accelerate battery degradation when compared with degradation due to driving or calendar aging. When correctly used, vehicle-to-grid/building impacts on battery degradation are insignificant. In [37], a thorough battery degradation model is suggested that considers calendar aging, capacity throughput, temperature, state of charge, depth of discharge and current rate. The results of such work indicate that this model can extend the life of the EV battery beyond the situation in which there is no V2G by optimizing state of charge and power transfer. In [38], measurements made to study the power losses during the charge and discharge of an EV are presented. One-way losses varied from 12% to 36%, with most losses occurring inside power electronics. Based on these results, the authors underline the importance of choosing adequate charging stations for increasing efficiency.
According to the European Environment Agency [39], reducing system losses and therefore being able to achieve more efficient distribution systems, whether they are centralized systems or microgrids, is crucial to achieving the targets for decarbonization and decentralization of the electric grid. The aforementioned works are all in agreement that vehicle-to-building is crucial to achieving reduced emissions in buildings and improving energy costs and efficiency, in which battery storage systems and electric vehicles have a natural synergy. Therefore, this work aims to complement such conclusions by contributing real-use data on vehicle-to-building system efficiency and strategies for the implementation of such systems in microgrid environments.

Paper Organization
The remainder of the paper is structured as follows: Section 2 presents the characteristics of the microgrid, as well as the specifications of the equipment used in the experimental work. Section 3 presents the results of the experimental tests, as well as an economic assessment of several different scenarios in which various levels of storage capacity are available to the building, which results are discussed in Section 4. Lastly, Section 5 summarizes the paper, highlighting its main conclusions.

Microgrid Characteristics
The experiments were conducted at the Department of Electrical Engineering of the University of Coimbra. The building has an area of about 10,000 m 2 and electricity consumption of 500 MWh/year. The building comprises several classrooms, laboratories, administrative services and three research institutes. The highest energy consumption of the building is in the periods from 10 am to noon and from 5:30 pm to 7 pm. This partially coincides with peak tariff hours: 9:30 am to noon and 6:30 pm to 9 pm. The distribution transformer that services the building has a maximum load of 630 kVA and operates with a load factor of around 30-40%. The building is equipped with 292 PV panels corresponding to about 70 kW with AC injection. A diagram of the microgrid installed in the building is presented in Figure 1.

Microgrid Characteristics
The experiments were conducted at the Department of Electrical Engineering of the University of Coimbra. The building has an area of about 10,000 m 2 and electricity consumption of 500 MWh/year. The building comprises several classrooms, laboratories, administrative services and three research institutes. The highest energy consumption of the building is in the periods from 10 am to noon and from 5:30 pm to 7 pm. This partially coincides with peak tariff hours: 9:30 am to noon and 6:30 pm to 9 pm. The distribution transformer that services the building has a maximum load of 630 kVA and operates with a load factor of around 30-40%. The building is equipped with 292 PV panels corresponding to about 70 kW with AC injection. A diagram of the microgrid installed in the building is presented in Figure 1. An energy storage system consisting of three LG Chem RESU10H 400V Li-ion [40] batteries is operational, with a total capacity of about 29.4 kWh (27.9 kWh of usable energy). The batteries are connected to three Sunny Boy Storage 5.0 [41] single-phase inverters, each with a rated power of 5 kW and a rated max efficiency of 97.5%.
The building is also equipped with the ability to ensure V2G/V2B electric vehicle charging with several conventional DC chargers and one prototype of a silicon carbide charger, all using the CHAdeMO protocol. The selected DC charger is a Magnum CAP three-phase bidirectional DC charger [42] with a maximum charging output of 10 kW and an efficiency of 93% at rated voltage and power. The power circuit of the chargers is composed of an AC/DC and a DC/DC converter and transformers to deliver the correct power either to the vehicle or to the residence outlet. Due to the high switching frequency of the semiconductors for power conversions and the conduction losses, large amounts of heat are produced during the operation of the charger, which requires the usage of a forced ventilation system. Along with the onboard CPU, all these components and power conversions accrue losses during the charging operation, further decreasing the efficiency. The segregation of these losses is beyond the scope of this paper, with the charger considered as a single entity. A prototype of a fully functional three-phase SiC technology DC charger is also available and was used for further testing in parallel with the conventional DC charger. Due to its novel technology, the SiC charger is smaller and produces less heat and noise, having higher efficiency when compared to the conventional DC charger [43,44]. An energy storage system consisting of three LG Chem RESU10H 400V Li-ion [40] batteries is operational, with a total capacity of about 29.4 kWh (27.9 kWh of usable energy). The batteries are connected to three Sunny Boy Storage 5.0 [41] single-phase inverters, each with a rated power of 5 kW and a rated max efficiency of 97.5%.
The building is also equipped with the ability to ensure V2G/V2B electric vehicle charging with several conventional DC chargers and one prototype of a silicon carbide charger, all using the CHAdeMO protocol. The selected DC charger is a Magnum CAP three-phase bidirectional DC charger [42] with a maximum charging output of 10 kW and an efficiency of 93% at rated voltage and power. The power circuit of the chargers is composed of an AC/DC and a DC/DC converter and transformers to deliver the correct power either to the vehicle or to the residence outlet. Due to the high switching frequency of the semiconductors for power conversions and the conduction losses, large amounts of heat are produced during the operation of the charger, which requires the usage of a forced ventilation system. Along with the onboard CPU, all these components and power conversions accrue losses during the charging operation, further decreasing the efficiency. The segregation of these losses is beyond the scope of this paper, with the charger considered as a single entity. A prototype of a fully functional three-phase SiC technology DC charger is also available and was used for further testing in parallel with the conventional DC charger. Due to its novel technology, the SiC charger is smaller and produces less heat and noise, having higher efficiency when compared to the conventional DC charger [43,44].
The building is also equipped with several heating, ventilation and air conditioning (HVAC) systems for temperature regulation in classrooms, offices and laboratories. During the summer and winter months, nearly 40% of the demand is due to the HVAC systems. These conditions are ideal to test and apply demand-control measures. For this, smart thermostats were developed and used to regulate the part of the HVAC load inside classrooms. The results of these tests are not within the scope of this paper, since they were previously studied in [45]. Lastly, monitoring software has been developed to display the data for and the status of all the microgrid's assets in real time. The monitoring system is used to make decisions based on the current and predicted parameters of the microgrid, considering electricity prices, predicted PV production, building occupancy, weekdays and seasonal changes. A screenshot of the display is presented in Figure 2.
The building is also equipped with several heating, ventilation and air conditioning (HVAC) systems for temperature regulation in classrooms, offices and laboratories. During the summer and winter months, nearly 40% of the demand is due to the HVAC systems. These conditions are ideal to test and apply demand-control measures. For this, smart thermostats were developed and used to regulate the part of the HVAC load inside classrooms. The results of these tests are not within the scope of this paper, since they were previously studied in [45]. Lastly, monitoring software has been developed to display the data for and the status of all the microgrid's assets in real time. The monitoring system is used to make decisions based on the current and predicted parameters of the microgrid, considering electricity prices, predicted PV production, building occupancy, weekdays and seasonal changes. A screenshot of the display is presented in Figure 2.  Figure 3 presents a daily net load diagram and PV production for two days in the Department of Electrical and Computer Engineering during the late summer (September 2020). The difference between the net load from the weekend (Sunday) to the weekday (Monday) is clearly visible, as well as the grid injection due to excess solar generation. As can be seen, there is clearly a mismatch between PV generation and demand. During weekends and summertime, the demand level is lower than the generation, leading to a generation surplus (negative net demand), and some energy needs to be injected into the grid, which is paid with a very low tariff. Similarly, during weekdays, the peak in PV generation coincides with the lunch break.   Figure 3 presents a daily net load diagram and PV production for two days in the Department of Electrical and Computer Engineering during the late summer (September 2020). The difference between the net load from the weekend (Sunday) to the weekday (Monday) is clearly visible, as well as the grid injection due to excess solar generation. As can be seen, there is clearly a mismatch between PV generation and demand. During weekends and summertime, the demand level is lower than the generation, leading to a generation surplus (negative net demand), and some energy needs to be injected into the grid, which is paid with a very low tariff. Similarly, during weekdays, the peak in PV generation coincides with the lunch break.
ing the summer and winter months, nearly 40% of the demand is due to the HVAC systems. These conditions are ideal to test and apply demand-control measures. For this, smart thermostats were developed and used to regulate the part of the HVAC load inside classrooms. The results of these tests are not within the scope of this paper, since they were previously studied in [45]. Lastly, monitoring software has been developed to display the data for and the status of all the microgrid's assets in real time. The monitoring system is used to make decisions based on the current and predicted parameters of the microgrid, considering electricity prices, predicted PV production, building occupancy, weekdays and seasonal changes. A screenshot of the display is presented in Figure 2.  Figure 3 presents a daily net load diagram and PV production for two days in the Department of Electrical and Computer Engineering during the late summer (September 2020). The difference between the net load from the weekend (Sunday) to the weekday (Monday) is clearly visible, as well as the grid injection due to excess solar generation. As can be seen, there is clearly a mismatch between PV generation and demand. During weekends and summertime, the demand level is lower than the generation, leading to a generation surplus (negative net demand), and some energy needs to be injected into the grid, which is paid with a very low tariff. Similarly, during weekdays, the peak in PV generation coincides with the lunch break.  It can be observed that there is a need for energy flexibility to improve the usage of the energy resources. By coordinating the PV production with the available storage capacity, it is possible to reduce the energy injected into the grid and use it later in the day when electricity tariffs are higher. This situation will ensure a double benefit to the microgrid by increasing self-consumption and reducing peak demand. EVs can be used to mitigate this issue. By leaving a vehicle connected to the building during lunch breaks and work hours, the building management system may opt to use the EV's available storage to supplement the building's BESS and artificially increase demand when there is a renewable generation surplus. This energy can either be paid for by the EV owner at a lower price or returned to the building later in the day during peak hours. Additionally, by increasing the levels of flexibility in the building, it will be possible to increase the autonomy of the microgrid from the utility grid and further increase the existing photovoltaic generation, thereby approaching the goal of a near-zero emissions building.

Microgrid Efficiency
The interconnection between different sources of energy generation, energy storage systems and a variety of loads implies many stages of power conversion for voltage level compatibility in the power exchange. PV systems generate DC power, but most building loads are in AC. Even when storing solar energy in a battery, a DC-to-DC converter has to be used to make the voltages and currents compatible with a BESS. The need for all these energy conversions adds up to infrastructural costs and reduces the overall efficiency of the microgrid. Hence, it is desirable to look for opportunities to reduce the number of power conversions needed and to increase the efficiency of the power conversion equipment. An example of a solution is the direct charging of EVs or BESSs using PV energy [46]. Currently, the solar energy produced is converted to AC to enter the grid and then it is converted back to DC to charge the electric vehicle. By having a direct DC link from the PV generation to the EV charger, it is possible to avoid one stage of power conversion and reduce the cycle losses by about 10% while still maintaining the AC connection and the possibility of V2B, as was assessed in the experimental trials.
EV chargers are another source of cycle inefficiency. Since most of the charging is carried out directly from the grid, conversion from AC to DC is needed. This power conversion is performed using high-speed semiconductors (MOSFETs) with high switching frequencies which generate switching and conduction losses, leading to large amounts of heat that must be managed. A new semiconductor technology, silicon carbide (SiC), is being introduced in electronics, with considerable benefits [47]. SiC semiconductors have much lower drain-source resistance and are much faster, which translates into lower conduction and lower switching losses. These characteristics allow the construction of lighter and smaller charging stations with higher efficiency, fewer ventilation needs and even potentially lower costs with mass production [48].
Regarding the efficiency of vehicle-to-building systems, there is a trade-off, since, compared with traditional unidirectional charging, it leads to an increased number of charging and discharging cycles and hence to increased battery degradation and operational losses. There are several factors and variables that affect battery degradation, ranging from chemistry to driving habits to charging conditions, among others. As such, studies regarding the impact of vehicle-to-grid/building on battery degradation have reached different conclusions, from neglectable to relevant impacts [36,[49][50][51][52]. Battery degradation reduces the usability of the vehicle, and operational losses diminish economical returns and overall system efficiency. These two constraints limit the profitability of V2B and are a barrier to convincing the user to commit their vehicle to the building. In order to be attractive to the user, V2B must have relevant economic benefits and a proper assessment of the costs and benefits must be provided.
Regarding BESSs, they are composed of a power conversion system connected to the grid and a battery management system (BMS) to ensure even charge distribution in the battery cells and reliable battery operation. Energy losses present in a BESS are due to conversion losses, ohmic resistance losses and battery losses, with the battery accounting for the majority of these losses. Battery losses occur due to internal resistance, heat produced during the electrochemical reactions, cell voltage imbalance, charging profile, BMS selfconsumption, aging and temperature. For example, frequently using fast and ultra-fast charging (>1 C) will rapidly decrease battery capacity, whereas freezing temperatures slow the electrochemical reactions, reducing performance, and high temperatures accelerate aging due to stress. Each one of these components will contribute a small amount to the overall losses of the system, and careless operation will accelerate the natural capacity degradation of the battery, reducing the number of working cycles. Since BESSs are still Energies 2022, 15, 8905 9 of 23 relatively expensive, it is desirable to take maximum advantage of available capacities to ensure cost-effectiveness.

Results
In this section, the experimental trials for the BESS and V2G systems are presented. The results are for several tests with different working conditions. For the BESS, full chargedischarge cycles were made, and, for V2G, different power levels were used to charge the battery for a given time period and SoC. The conducted experiments also intended to ensure an overview of the overall power losses and efficiencies present in the BESS during a full charge-discharge cycle. The round-trip efficiency (RTE) could then be calculated and used to evaluate the operating efficiencies of the overall system. The round-trip efficiency of an energy storage system is a term used to describe how much useful energy the system can provide versus the amount of energy inputted into the system.

Solar PV Monitoring
The PV system has been monitored daily since the start of its operation. It was identified that there was a surplus of generation during weekends from 10 am to 4 pm and on clear sunny days on workdays during lunch hours. About 70 kWh need to be injected into the grid each day of the weekend and about 40 kWh during weekdays in the summer. During winter, there is very little injection of generation into the grid. Over the last 4 years, the system has ensured an average generation of about 75 MWh/year, of which around 3 to 4 MWh/year are estimated to be generation surplus to be injected into the grid. The inverters have a calculated average efficiency of around 95%, which means that only 71. 25 MWh/year are used in the building.

Li-on Batteries
The objective of the experiments with the Li-on batteries was to collect data from different locations of the power circuit to assess the efficiencies of the charging and discharging processes. Figure 4 presents a diagram of the circuit along with the different powers measured, P1 to P4. The points that were chosen to take measurements from were: Point A-between the main grid and the converter; Point B-between the converter and the terminals of the batteries before the BMS. Each battery has a total energy capacity of 9.8 kWh and 9.3 kWh of usable energy. Therefore, in the charging-discharging tests, only 9.3 kWh of energy was cycled. The values for the SoC use as a reference the usable energy capacity, e.g., 0% SoC in the results corresponds to 5% real SoC (500 Wh) of the battery. The tests consisted of ensuring a full charge-discharge cycle, from 0% to 100% to 0% of the usable SoC, and measuring the currents and voltages at Points A and B. The energy was then calculated in each stage, as well as the respective efficiencies. The efficiencies were calculated using Equations (1) to (4). Equation (1) presents the round-trip efficiency (η RTE ), Equation (2) the converter charging efficiency (η char ), Equation (3) the converter discharging efficiency (η dischar ) and Equation (4) the battery efficiency (η bat ).  A full charge and discharge cycle was tested for each of the three batteries with the maximum charging power allowed by the inverter, which is 4.8 kW, corresponding to around 0.5 C. The second round of tests was then performed with one of the batteries, where the same measurements were repeated for 0.1 C and 0.3 C. At the time of these tests, the BESS had around one year of lifetime and had been working at around a chargedischarge cycle every two days. The state of health of all the batteries was around 95%. The results of the first round of tests are presented in Tables 1 and 2. From these results, it can be seen that the efficiency of the converters is around the rated value of 97%. Most of the system losses occur inside the battery due to its electrochemical reactions, internal resistance and temperature. Part of the energy lost inside the battery is used for the operation of the battery management system, which is integrated directly inside the battery. In sum, the round-trip efficiency for this BESS is around 85%, A full charge and discharge cycle was tested for each of the three batteries with the maximum charging power allowed by the inverter, which is 4.8 kW, corresponding to around 0.5 C. The second round of tests was then performed with one of the batteries, where the same measurements were repeated for 0.1 C and 0.3 C. At the time of these tests, the BESS had around one year of lifetime and had been working at around a chargedischarge cycle every two days. The state of health of all the batteries was around 95%. The results of the first round of tests are presented in Tables 1 and 2. From these results, it can be seen that the efficiency of the converters is around the rated value of 97%. Most of the system losses occur inside the battery due to its electrochemical reactions, internal resistance and temperature. Part of the energy lost inside the battery is used for the operation of the battery management system, which is integrated directly inside the battery. In sum, the round-trip efficiency for this BESS is around 85%, with 5% of the energy lost in conversion and nearly 10% of it lost while being stored inside the battery. Ohmic losses due to cabling are also present, but since they are highly dependent on the system's physical architecture and the value is too small to have a real economic impact, they were not considered. Nevertheless, in this system, ohmic losses account for 0.5% of the total losses, this percentage being diluted inside the losses throughout the various cycle stages.
The third round of tests was made to ascertain the differences in efficiency caused by a different charging power level. One battery was chosen, and the full charge-discharge tests were repeated. Table 3 presents the achieved results. As expected, the charging power affected the efficiencies. With lower currents, the inverters will work farther from the nominal operating point, thus reducing efficiency. Oppositely, less current will benefit the battery by producing less heat and reducing electrochemical stress. Even though at lower Cs the battery efficiency increases, the overall round-trip efficiency will be higher when working with lower values of power and at the inverter's rated power. Higher C values were not possible to test due to the inverter power ratings.
A brief analysis was also made regarding battery degradation by measuring the state of health (SoH), which is the metric used to measure the condition of a battery, this being the ratio between the battery's current capacity and the specified rated capacity. Li-ion batteries will lose capacity and gain internal resistance over time due to the wear and tear of the cathodes and anodes. Common factors that affect battery aging are calendar time, cell chemistry, temperature, average SoC, C rate, cycle number and depth of discharge (DoD). In this case, the batteries are installed in an underground garage, where the temperature is mostly constant all year round. At the time of these measurements, they had an estimated age of 3 years and had been operating with 5 full charge-discharge cycles per week (on weekdays), counting around 625 cycles since the start of operation. In normal conditions, the C rate was kept at 0.5 C, and the DoD was from 100% to 5%, which is larger than what is normally advised. The SoH was then measured with external equipment. The measured values and also the SoHs calculated by each of the integrated battery management systems are shown in Table 4. Two of the batteries indicated a decrease in storage capacity of around 4-5% and the other a decrease of 3%. The lifetime expectancy stated by the manufacturer is 10 years or 6000 cycles for the maintenance of at least 60% of their initial rated energy storage capacities. This means that, in all cases, capacity degradation is within or below the expected levels of −4%, with around 300 cycles per annum. Further analysis of battery degradation and its costs was beyond the scope of this paper but is planned for future research.

V2G Chargers
For the V2G assessment, two three-phase bidirectional DC chargers were tested. One charger used conventional silicon MOSFETs, and another charger was built using highefficiency silicon carbide technology. The purpose of these experiments was to evaluate the efficiencies and to identify the different types of losses occurring in the electric circuit comprising the grid, the charger and the EV. A Nissan Leaf with a 40 kWh battery and V2G capacity was used for the tests. An approach similar to the one applied in the battery tests was taken. Strategic points in the power circuit were identified, and at each of these points the voltage and current were measured to calculate the power and energy. The measuring points were as follows: Point A-AC measurement between the grid and the charger; Point B-DC measurement at the output of the charger; Point C-DC measurement at the terminal ends of the vehicle's battery. The considered circuit and the points are illustrated in Figure 5.
For the V2G assessment, two three-phase bidirectional DC chargers were tested. One charger used conventional silicon MOSFETs, and another charger was built using highefficiency silicon carbide technology. The purpose of these experiments was to evaluate the efficiencies and to identify the different types of losses occurring in the electric circuit comprising the grid, the charger and the EV. A Nissan Leaf with a 40 kWh battery and V2G capacity was used for the tests.
An approach similar to the one applied in the battery tests was taken. Strategic points in the power circuit were identified, and at each of these points the voltage and current were measured to calculate the power and energy. The measuring points were as follows: Point A-AC measurement between the grid and the charger; Point B-DC measurement at the output of the charger; Point C-DC measurement at the terminal ends of the vehicle's battery. The considered circuit and the points are illustrated in Figure 5. Several tests were performed for each charger with power levels of 2.5 kW, 5 kW, 7.5 kW and 10 kW, during both charging and discharging. All tests were conducted with a battery SoC of about 50%, as at this level the losses due to battery energy storage are reduced. For each power level, the vehicle was put on charge for the time necessary time for a change of 2% in the SoC, following a discharge, at the same power level, for a similar amount of time. The SoC of the battery was monitored using the onboard software. A test was also performed in which an order to charge the vehicle at 0 kW of power was placed on the charger to study its standalone consumption (only Point A was monitored), as well as to evaluate the standby consumption. The efficiencies were calculated using Equations (5) to (6). Equation (5) presents the charger charging efficiency ( char), Equation (6) the discharging efficiency ( dischar) and Equation (7) the round-trip efficiency of the charger ( cyc).

char =
The values of the calculated efficiencies for the charger are presented in Table 5, with negative values of power for discharge. One of the main conclusions that can be derived from these tests is that for higher power values there will be an increase in charger efficiency (leading to higher cycle efficiency). This was expected, mainly due to the operation being near the rated conditions of the chargers. Another reason is that by increasing power, the constant losses present in the chargers become less impactful than the delivered power.  Several tests were performed for each charger with power levels of 2.5 kW, 5 kW, 7.5 kW and 10 kW, during both charging and discharging. All tests were conducted with a battery SoC of about 50%, as at this level the losses due to battery energy storage are reduced. For each power level, the vehicle was put on charge for the time necessary time for a change of 2% in the SoC, following a discharge, at the same power level, for a similar amount of time. The SoC of the battery was monitored using the onboard software. A test was also performed in which an order to charge the vehicle at 0 kW of power was placed on the charger to study its standalone consumption (only Point A was monitored), as well as to evaluate the standby consumption. The efficiencies were calculated using Equations (5) to (6). Equation (5) presents the charger charging efficiency (η char ), Equation (6) the discharging efficiency (η dischar ) and Equation (7) the round-trip efficiency of the charger (η cyc ).
The values of the calculated efficiencies for the charger are presented in Table 5, with negative values of power for discharge. One of the main conclusions that can be derived from these tests is that for higher power values there will be an increase in charger efficiency (leading to higher cycle efficiency). This was expected, mainly due to the operation being near the rated conditions of the chargers. Another reason is that by increasing power, the constant losses present in the chargers become less impactful than the delivered power.
Besides the losses caused by the Joule effect in the copper wirings and charger cable and the semiconductors losses (switching and conduction), there are other electronic components, such as transformers, relays and other passive elements, that contribute to the overall losses during operation (leakage currents, hysteresis losses, etc.). These losses remain mostly constant during the operation and are independent of the charging power. Thus, when working with higher power levels, their impact on the overall efficiency is less noticeable.
The results also indicate a relevant disparity between charging and discharging efficiencies. This can be explained by the asymmetrical path that is needed for power conversion. Whereas in AC to DC a rectifier is used, the reverse operation is performed by an inverter, which will have different levels of loss, and the current flows through a different circuit. Figure 6 presents a comparison of the charger efficiencies.  The charging of EVs not only results in changes to the electricity demands of buildings but can also have a significant impact on power quality. An EV charger is a nonlinear load that can produce large current harmonics that will flow through an electric grid, distorting voltage. Residential EV owners could face problems with power quality and, in larger buildings, when considering a high number of chargers and several EVs charging simultaneously, the harmonics could have a relevant impact on the voltage levels. Previous works [53,54] regarding the harmonic impact of multiple electric vehicle charging have concluded that harmonic limitations may be a greater barrier than power limitations regarding EV charging. The IEEE 519-2022 [55] is the current active standard that dictates the maximum distortion allowed for electric power systems in the USA.
During the charging and discharging tests, the harmonic current components were monitored. The main purpose was to assess the level of harmonics produced by the used chargers. As can be observed in Figure 7, the total current harmonic distortion is situated at around 3.6%, and the following harmonics are all under the requirements of the IEEE 519-2022 standard. Specifically, in the tested case, the building has three EV chargers installed, but since the transformer is underutilized (with a load factor of around 30%-40%) the current harmonics created by the EV charging were not expected to have a significant impact on the voltage levels of the building. Temperature is also an impactful factor regarding overall efficiency, and, during the developed tests, both chargers were situated inside a cool and dry place, where the air temperature was mostly constant. The SiC charger was noticeably cooler during operation than the conventional IGBT charger. The first charger was also noticeably quieter due to its requiring less ventilation, and therefore less power was needed for temperature control. This is one of the main reasons for the increased efficiency levels of the SiC charger. By using SiC semiconductors, the overall losses in power conversion are reduced. There will be smaller switching and conduction losses, less heat produced and therefore less power used for ventilation. The increased bandgap in the SiC charger also allows the semiconductors to work at higher voltages and with higher frequencies, with higher efficiency.
Regarding charging, it can be concluded that higher levels of power will lead, in most cases, to higher efficiencies. Nevertheless, the impact of charging with high levels of current on the efficiency and health of the batteries must also be taken into account. For the conducted experiments, charging and discharging powers were kept at about 0.5 C, which was considered safe and not high enough to hinder the batteries' health. These results also show the advantages of SiC technology in terms of achieving a boost of more than 10% of the cycle efficiency. The SiC charger was also much less affected by the different charging powers.
The charging of EVs not only results in changes to the electricity demands of buildings but can also have a significant impact on power quality. An EV charger is a nonlinear load that can produce large current harmonics that will flow through an electric grid, distorting voltage. Residential EV owners could face problems with power quality and, in larger buildings, when considering a high number of chargers and several EVs charging simultaneously, the harmonics could have a relevant impact on the voltage levels. Previous works [53,54] regarding the harmonic impact of multiple electric vehicle charging have concluded that harmonic limitations may be a greater barrier than power limitations regarding EV charging. The IEEE 519-2022 [55] is the current active standard that dictates the maximum distortion allowed for electric power systems in the USA.
During the charging and discharging tests, the harmonic current components were monitored. The main purpose was to assess the level of harmonics produced by the used chargers. As can be observed in Figure 7, the total current harmonic distortion is situated at around 3.6%, and the following harmonics are all under the requirements of the IEEE 519-2022 standard. Specifically, in the tested case, the building has three EV chargers installed, but since the transformer is underutilized (with a load factor of around 30-40%) the current harmonics created by the EV charging were not expected to have a significant impact on the voltage levels of the building. The charging of EVs not only results in changes to the electricity demands of buildings but can also have a significant impact on power quality. An EV charger is a nonlinear load that can produce large current harmonics that will flow through an electric grid, distorting voltage. Residential EV owners could face problems with power quality and, in larger buildings, when considering a high number of chargers and several EVs charging simultaneously, the harmonics could have a relevant impact on the voltage levels. Previous works [53,54] regarding the harmonic impact of multiple electric vehicle charging have concluded that harmonic limitations may be a greater barrier than power limitations regarding EV charging. The IEEE 519-2022 [55] is the current active standard that dictates the maximum distortion allowed for electric power systems in the USA.
During the charging and discharging tests, the harmonic current components were monitored. The main purpose was to assess the level of harmonics produced by the used chargers. As can be observed in Figure 7, the total current harmonic distortion is situated at around 3.6%, and the following harmonics are all under the requirements of the IEEE 519-2022 standard. Specifically, in the tested case, the building has three EV chargers installed, but since the transformer is underutilized (with a load factor of around 30%-40%) the current harmonics created by the EV charging were not expected to have a significant impact on the voltage levels of the building.

Economic Assessment
Using the aforementioned results, an economic assessment was carried out, considering several different scenarios for the DEEC building. Net load diagrams for a weekday and a weekend day are presented in Figure 8a,b. In these load diagrams, the impact of PV

Economic Assessment
Using the aforementioned results, an economic assessment was carried out, considering several different scenarios for the DEEC building. Net load diagrams for a weekday and a weekend day are presented in Figure 8a,b. In these load diagrams, the impact of PV generation is visible. The steep peaks are explained by the sample rate, of 10 min, which means that the load diagram shows drastic changes in consumption, particularly during the late afternoon (19:30 h). The building is also prone to heavy loads due to the use of electric motors in laboratories, which originate the various peaks during the workday. Since the peak load of the building is low when compared to the installed power (292 kW), there is little advantage in aiming for a peak shaving strategy, although the use of such a method is feasible in other buildings. Instead, the main purpose of the BESS and V2B systems with respect to cost efficiency is to absorb the surplus generation and take advantage of the tariff variation.
For the economic analysis of the scenarios, it was first considered to group the available storage capacities for both the BESS and V2B and take into account the sum of the storage capacities as a whole. However, this was not possible due to: (1) the difference in the efficiencies of the charging cycles when using the BESS or V2B and (2) the fact that the periods of availability for the BESS and V2B are different, since, whereas BESS storage capacity is available 24/7, the availability of V2B is constrained by user habits. If the EV is privately owned, then the only hours when it is available for the building microgrid are during work hours. Inversely, if the EV is owned by the company using the building, the period in which it is guaranteed to be available for V2B is during off-work hours. Since only private EV users currently utilize the building chargers, the first case for V2B availability was considered, that is, storage capacity from V2B being only available during work hours (9 am to 6 pm). For these reasons, the storage capacities for the BESS and V2B were treated as separate, and several scenarios were studied with different amounts of storage. generation is visible. The steep peaks are explained by the sample rate, of 10 min, which means that the load diagram shows drastic changes in consumption, particularly during the late afternoon (19:30 h). The building is also prone to heavy loads due to the use of electric motors in laboratories, which originate the various peaks during the workday.
Since the peak load of the building is low when compared to the installed power (292 kW), there is little advantage in aiming for a peak shaving strategy, although the use of such a method is feasible in other buildings. Instead, the main purpose of the BESS and V2B systems with respect to cost efficiency is to absorb the surplus generation and take advantage of the tariff variation.
(a) (b) For the economic analysis of the scenarios, it was first considered to group the available storage capacities for both the BESS and V2B and take into account the sum of the storage capacities as a whole. However, this was not possible due to: (1) the difference in the efficiencies of the charging cycles when using the BESS or V2B and (2) the fact that the periods of availability for the BESS and V2B are different, since, whereas BESS storage capacity is available 24/7, the availability of V2B is constrained by user habits. If the EV is privately owned, then the only hours when it is available for the building microgrid are during work hours. Inversely, if the EV is owned by the company using the building, the period in which it is guaranteed to be available for V2B is during off-work hours. Since only private EV users currently utilize the building chargers, the first case for V2B availability was considered, that is, storage capacity from V2B being only available during work hours (9 am to 6 pm). For these reasons, the storage capacities for the BESS and V2B were treated as separate, and several scenarios were studied with different amounts of storage.
The base scenario is one in which where there is no energy storage capacity whatsoever to be used by the building. This scenario will be used for comparison and for calculating economic and technical benefits. In Scenario A, the existing and operational BESS, with a total of 27.9 kWh of battery storage, was considered. For the analysis of the scenarios with V2B, some considerations have to be made: for Scenario B, 30 kWh of V2B storage capacity was added. This value was chosen based on the existing two V2G chargers, and the assumption was made that each user allotted 15 kWh of the EV battery for V2B operations and that the capacity injected into the grid had to be recovered by the end of the day. This is a limitation and, in some cases, may lead to an increase in demand during peak hours and a reduction in the overall usable storage capacity. The considered available time, for a standard Portuguese working schedule, is from 09:00 to 18:00; given this, V2B capacities are only available during that time. Due to these limitations, the economic benefits from the building's point of view are limited. There is almost no generation surplus to be considered during weekdays, and during weekends the users are not typically present in the building. Instead, the plausible benefit for the building is related to using smart charging to avoid charging EVs during peak hours. The base scenario is one in which where there is no energy storage capacity whatsoever to be used by the building. This scenario will be used for comparison and for calculating economic and technical benefits. In Scenario A, the existing and operational BESS, with a total of 27.9 kWh of battery storage, was considered. For the analysis of the scenarios with V2B, some considerations have to be made: for Scenario B, 30 kWh of V2B storage capacity was added. This value was chosen based on the existing two V2G chargers, and the assumption was made that each user allotted 15 kWh of the EV battery for V2B operations and that the capacity injected into the grid had to be recovered by the end of the day. This is a limitation and, in some cases, may lead to an increase in demand during peak hours and a reduction in the overall usable storage capacity. The considered available time, for a standard Portuguese working schedule, is from 09:00 to 18:00; given this, V2B capacities are only available during that time. Due to these limitations, the economic benefits from the building's point of view are limited. There is almost no generation surplus to be considered during weekdays, and during weekends the users are not typically present in the building. Instead, the plausible benefit for the building is related to using smart charging to avoid charging EVs during peak hours.
By calculating the energy consumed during peak hours on weekdays and the generation surplus during the peak periods, it was concluded that there is a margin to upgrade the building storage capacity by 70 kWh, which is under consideration. Since there is a need for more storage capacity and the DEEC building has plans for increasing the storage capacity of the DEEC building, scenarios C and D were considered, in which the storage capacities for the BESS and V2B were increased to double their existing values to assess the economic impacts. The different scenarios are summarized in Table 6. When assessing the scenarios, it is important to take into account the weekly tariff cycle currently in use by the DEEC building: during weekdays, the peak periods are from 09:30 h to 12 h and from 18:30 h to 21 h, and there is no peak tariff during weekends. The rest of the weekly tariffs and their prices are presented in Appendix A. During injection, the value paid for by the grid was calculated to be EUR 0.18 per injected kWh. The cost for the base scenario was calculated to be 76.6 €/day during weekdays and 27.64 €/day for the weekends. These were the reference costs to be used to calculate savings. Other assumptions were made. For the BESS, it was considered that the SoC at the start of the day was always zero, and for V2B it was assumed that the vehicles all had at least 15 kWh available for the grid at the start of the day and that each vehicle was charged with equal amounts of power and energy. The results for the economic scenarios are presented in When assessing the scenarios, it is important to take into account the weekly tariff cycle currently in use by the DEEC building: during weekdays, the peak periods are from 09:30 h to 12 h and from 18:30 h to 21 h, and there is no peak tariff during weekends. The rest of the weekly tariffs and their prices are presented in Appendix A. During injection, the value paid for by the grid was calculated to be EUR 0.18 per injected kWh. The cost for the base scenario was calculated to be 76.6 €/day during weekdays and 27.64 €/day for the weekends. These were the reference costs to be used to calculate savings. Other assumptions were made. For the BESS, it was considered that the SoC at the start of the day was always zero, and for V2B it was assumed that the vehicles all had at least 15 kWh available for the grid at the start of the day and that each vehicle was charged with equal amounts of power and energy. The results for the economic scenarios are presented in

Microgrid Efficiency Analysis
Following the experimental results, the obtained data were gathered and Table 7 was created to summarize the efficiencies of all the tested assets as well as to evaluate the final

Microgrid Efficiency Analysis
Following the experimental results, the obtained data were gathered and Table 7 was created to summarize the efficiencies of all the tested assets as well as to evaluate the final

Microgrid Efficiency Analysis
Following the experimental results, the obtained data were gathered and Table 7 was created to summarize the efficiencies of all the tested assets as well as to evaluate the final operational efficiency. All the values for efficiencies presented in the table are the values achieved through the developed experiments, except those for the grid transformer and the efficiency of the EV battery (marked with an asterisk (*) in Table 7), for which the datasheet value for the asset was used.
In the 'Operation' column, several possible energy-transfer actions are presented. For example, the 'PV-Grid' line is the efficiency related to transferring photovoltaic energy directly to the grid, whereas 'G2V' refers to a grid-to-vehicle operation. When SiC is mentioned, this means that the electric vehicle charging was made using the SiC charger. For the efficiencies of the EV chargers, the values at maximum power were used. The efficiency of the operation was then calculated by multiplying the different efficiencies at each stage for each operation. For instance, for the ESS to EV operation, power must be converted from DC to AC, then AC to DC in the charger; lastly, both the storage efficiencies of the ESS battery and the EV battery have to be considered as well for calculating the round-trip efficiency. The real values of round-trip efficiencies have small variations of +−1% due to differences in the battery storage systems, the EV batteries and the operating conditions. Nevertheless, the stated values provide a distinct overview of the efficiencies present for each operation. The purpose of the table is to provide an overview of the expected efficiencies in the assessed microgrid. The table can then be integrated into a decision-making algorithm that takes into account the efficiencies of each microgrid asset, allowing the prediction of energy generation, available capacity and user limitations relevant to choosing when and how to store energy or maximize economic benefit. By analyzing the table, it can be concluded that opting for SiC technology chargers will significantly improve the overall efficiency of operation. Grid operators or building management systems should give priority to charging-discharging using this type of equipment, when available, over conventional chargers. With SiC chargers, storing energy in EVs is more efficient than storing it in BESSs. This decision is also heavily dependent on the number of available SiC charges, user limitations and EV available capacities. The least efficient operations for the microgrid are charging or discharging an electric vehicle directly to or from another BESS. In these types of operations, a significant amount of energy is lost during power conversion. Since there is no direct DC-to-DC charging in this system, power has to be converted twice: once when going into the grid and again when injected either into a BESS or EV. Therefore, charging an EV directly from a BESS should be avoided when taking into account efficiency factors. These results indicate that the installation of a DC bus connecting solar, battery and DC charger systems could be an interesting solution to increase the efficiency of the system even more. This would allow the charging of EVs directly from PV generation (a direct solar charging solution), avoiding the conversion of this energy to AC and back to DC. In the following section, these efficiencies will be used for an assessment of the economic impacts.

Economic Analysis
Following the economic analysis, the main results are summarized in Table 8. In scenario A, only the operating BESS is used (27.9 kWh). During the weekday, the batteries store energy during super off-peak hours and discharge during peak hours at lunch and late afternoon. Since there is no PV generation surplus and the peak power is not troublesome to the building, the benefit of operating the BESS during weekdays is restricted to the profit achieved due to the reduction in consumption during peak hours. The calculated daily cost was EUR 72.33 for weekdays, which represents a saving of EUR 426 in electricity consumption per day or 1114 €/annum (for the calculations of yearly savings, 261 weekdays and 104 weekend days were considered). At the weekends, due to the PV generation surplus, the batteries charge during lunch hours. In this case, the battery capacity is not sufficient to absorb all the generation surplus, and about 40 kWh of PV generation is still injected into the grid. The stored energy is then used by the building during the normal tariff period at night (since there is no peak period during weekend days). Without the BESS, the weekend daily electricity cost is EUR 38.06, whereas with the BESS the daily cost decreases to EUR 35.9. Scenario B takes advantage of both the BESS and V2B storage capacity. During the weekday, the BESS charges at night and discharges during daily peak hours. At the weekend, the BESS waits until noon to start charging and until the late afternoon for the discharge. The cost on weekdays is reduced to EUR 71.45 per day and on weekends to EUR 34.68 per day. For V2B, during weekend days, the same schedule of availability was used as that on weekdays (9 am to 6 pm). Therefore, the V2B system starts discharging the battery of an EV as soon as the client enters the workplace. (Note: V2B power is capped at 10 kW.) Since it was considered a restriction that the energy used by the building be returned to the EV by the end of the day to the V2B client, it was only possible to utilize 18.8 kWh of the storage capacity during weekends. This value is the sum of the energy discharged from the vehicle in the morning period (5.3 kWh) and the predicted late-afternoon discharged energy (11.5 kWh) before 6 pm. Even though there is still leftover capacity in the EVs, if the building overcharges the vehicles during the period in which there is an excess of solar generation it will not be able to recover that charge due to the time limit imposed by the EV clients, for whom the day ends at 6 pm. If a client leaves earlier, before 5 pm, then their vehicle would have charged more energy than the amount supplied to the building. This is not necessarily a problem, and benefits/consequences will vary depending on the economic model adopted by the building operator for V2B, but for this work the aim was to ensure flexibility and the maintenance of an energy equilibrium; if the building operator wishes to prevent this issue, V2B charging would have to be halted in the afternoon, as soon as the charged value was equal to the discharged value in the morning. In both cases, the usable storage capacity for V2B will be lower than the initially allotted capacity of 30 kWh. If there were no schedule limitations, then it would be possible to recoup all the charged energy in the EVs later in the afternoon. This is a barrier to the efficacy of V2B and highlights the advantage of 24/7 BESS availability. Due to the constraint of energy equilibrium, there will be an increase in demand late in the afternoon on workdays. The system operator must therefore plan accordingly, so that neither the client is left lacking energy nor is the electricity bill increased due to charging during peak hours.
Due to the generation surplus during weekends, a scenario in which the BESS is upgraded to a larger capacity was considered. In scenario C, the scheduling for charging/discharging is the same as in scenario A: during weekdays, the BESS charges during super off-peak hours (2 am to 6 am) and discharges during peak hours. At weekends, it waits for the PV generation surplus to charge and discharges during the evening. Using this method, the energy injected into the grid decreases from 74.83 kWh to 5.33 kWh-a reduction of more than 90%. With a BESS with 70 kWh capacity, the daily costs are reduced to EUR 60.78 per weekday and the energy injected into the grid decreases from around 7 MWh/year to only 0.5 MWh/year. The cost for weekends is reduced to EUR 30.56-a reduction of 19.6% from the base cost. Finally, in the last scenario, 60 kWh of V2B storage capacity was added to the BESS. The schedules are similar to those in scenario C, and during weekdays the batteries charge at night, during the super off-peak period, and discharge at peak hours. As soon as the EV clients enter the workplace, the system starts discharging the batteries using the V2B system. According to the defined constraints, the system must try to maintain a zero sum between the charged and discharged energy in the EVs. Therefore, during the afternoon, the amount of energy charged to the parked vehicles is limited by the amount of energy discharged into the grid during the morning period and the predicted late-afternoon energy discharge. When the maximum usable storage from V2B is reached, the system initiates the BESS charging cycle. As soon as the energy surplus from PV generation is over, the V2B system starts discharging until 6 pm or when the maximum energy limit is reached. The gap between V2B and battery discharge is due to clients leaving at 6 pm, but batteries only start discharging at 6:30 pm, when the peak tariff period starts. Once again, due to the constraints of the V2B schedule and energy equilibrium, the usable storage capacity is reduced. From the available 70 kWh allocated to the EV users, only a maximum of 25.83 kWh was used at once. In comparison, for the BESS, 49 kWh of storage capacity was used. In this scenario, the morning peak period consumption is eliminated and all the excess surplus energy is used by the system. This scenario leads to savings of EUR 61.23 per weekday and EUR 31.06 at weekends.
As can be seen from the comparisons presented in Table 8, it was possible to significantly reduce the energy injected into the grid and the energy consumed during peak hours. Expanding the existing BESS to 70 kWh (Scenario C) is more cost-effective than trying to complement the existing battery storage capacity with V2B (Scenario B). However, if the building has available EV users, it may be faster and easier to create additional storage using V2B than to invest in upgrading the existing system.
The usability of V2B is heavily limited by its availability. The small difference in the reduction in energy consumed in peak periods between scenarios C and D is caused by the schedule limitation for V2B, since it is not possible to use that storage capacity to cover the late-afternoon peak. During peak periods, priority is given to the BESS, due to the system being more efficient ( Table 7). As such, if the BESS is capable of soaking up all the energy consumed during peak, it is not economically viable to rely on V2B, because it will not be possible to take advantage of a difference in price from the tariff, leading to reduced savings. This was demonstrated in scenario C during weekdays, in the time periods where V2B charges and discharges had the same cost, having no direct economic benefit. Building operators may still opt to use V2B in similar scenarios to reap other technical benefits.

Conclusions
This work has presented a technical and economic analysis of a battery energy storage system and a vehicle-to-building system integrated into a campus microgrid. The results were gathered using the distribution systems already operating in a campus microgrid. For the technical analysis, full charge-discharge cycles were considered to calculate the round-trip efficiencies of several common interactions in the microgrid. A prototype SiC bidirectional charger was analyzed and compared with a conventional V2G charger, and a power quality analysis of vehicle chargers was also conducted. The results showed that the SiC technology is superior to conventional IGBT bidirectional chargers, with operating efficiency increases ranging from 10 to 26% depending on the power used. The results also showed that, in most cases, using energy stored in batteries is more efficient than using the same amount of energy stored in vehicles. The more stages and transitions of power there are in a microgrid, the less efficient the overall performance will be. The installation of a DC bus connecting PV generation, batteries and DC charging systems could significantly increase the round-trip efficiency of all energy transfers.
For the economic analysis, the impacts of the BESS and V2B regarding the reduction of excess grid injection and peak-hour energy consumption were explored. Four different scenarios with different levels of storage capacity were simulated. It can be concluded that, by using both a BESS and V2B, it is possible to significantly reduce the peak energy consumption and the grid energy injection. However, a BESS is more effective in reducing peak energy consumption and more cost-effective than V2B. The usability of V2B is hindered by the availability of EV clients and tariff periods. If it is not possible to take advantage of different tariff prices when V2B is available, it will not be possible to obtain a cost advantage. The benefits of V2B are also limited by the conditions agreed upon between the microgrid operator and the EV users. In this analysis, it was decided that the quantity of energy charged into the vehicle by the microgrid must be recovered by the end of the same day. This led to situations in which consumption shifted but without originating any economic benefit. In comparison, the BESS was more efficient, and the 24/7 availability provided the most flexibility for the microgrid. As for V2B, due to the volatility and relative unpredictability of the users' schedules, it should be seen as a way to complement existing storage when available and not as the main means of achieving flexibility.
Electric vehicles and energy storage systems have been shown to be primary agents with respect to achieving the objective of nZEB status. The results of this work provide insights and a technical table to be used by building and microgrid designers or operators for the development of better system architectures and better planning for existing resources.

Conflicts of Interest:
The authors declare no conflict of interest. The funders had no role in the design of the study; in the collection, analyses, or interpretation of data; in the writing of the manuscript; or in the decision to publish the results.

Appendix A
The electricity tariffs and prices per kWh paid by the DEEC building are presented in Table A1. A decision was made to use the prices for 2021 so as to avoid the high volatility of prices due to the socio-economic situation in Europe in 2022. The price paid per kWh injected into the grid is the median value of the daily OMIE-the Iberian Electricity Market Operator-for March 2021.