2.2.3. V2B Algorithm at Work
The V2B algorithm’s integration into the work infrastructure is designed for the optimal management of energy flow in the worksite microgrid. Similarly, in the house configuration, the work energy system is characterized by renewable energy production, e.g., a PV system, loads, a dedicated storage system, and, of course, an EV charging station, as shown in
Figure 4.
The proposed V2B algorithm aims to balance the energy needs of the company with those of the EV owner while encouraging the self-consumption of locally generated PV energy and reducing the dependence on the external electrical grid.
The V2B algorithm relies on power measurements from the various circuits within the workplace energy system while imposing key parameters, such as the expected worker departure time (and the expected vehicle SoC (.) required at the end of the user’s work period.
When the EV connects to the charging station, the algorithm initializes by reading key system parameters, including the EV′S state of charge , the state of health of the EV battery , the state of charge of the storage system in the workplace microgrid , and the EV′S connection time instant . Additionally, it requests from the EV owner the input paraments and .
The algorithm continuously monitors the
to ensure that the desired charge level,
, is achieved by the specified departure time. Specifically, the
during the time interval in which the EV is connected to the microgrid charging station at the workplace is defined as
As described in the flowchart in
Figure 5, the algorithm proposes different battery operation modes depending on the value of
and the power exchanged between the microgrid and the main grid,
. These include optimal charging at the optimal power (
), fast charging at the maximum power (
), charging at the minimum between the optimal power (
) and the power
, and discharging at the minimum between
and
to V2B services. Specifically,
is the optimal charging and discharging power, chosen to prevent overstressing the battery, whose numerical value corresponds to a defined fraction
β of the EV′S battery capacity. Similarly, the value of
corresponds precisely to the maximum battery capacity of the EV.
The power exchanged by the microgrid
is determined as
where
is the power delivered by the PV system,
represent the power delivered by the fixed storage, and
is the power consumed by the loads within the lab/office microgrid.
Focusing on the algorithm, once the parameters are initialized and the input values are received, it first checks the stop condition. Specifically, the algorithm verifies whether the emergency stop button has been activated or if the current time has reached the departure time
. In either case, the algorithm must be stopped. Subsequently, the algorithm enables the EV′S optimal charging if the time required to charge the vehicle at
from the current
to
is greater than zero and equal or greater than the remaining dwell time. Therefore, the conditions for optimal charging are expressed as
If Conditions (8) and (9) are not satisfied, it either means that the value of has already been reached, or that there is still a lot of time left, and the EV does not need to be recharged immediately. In this case, the algorithm compares the value of with and with a specified threshold value, .
If
, the fast charging at maximum power,
, is activated, provided the dwell time is less than or equal to the time required to charge the vehicle at
and reach
from the current
, which is needed to ensure vehicle mobility. This condition is described as
where
and
are simplified since they are numerically equal.
Meanwhile, if Condition (10) is not met, and the microgrid generates surplus power ( the EV is charged to the minimum value between and , and the algorithm cycle is completed. The same operating mode is required for the EV battery in the case where Conditions (8) and (9) are not satisfied and .
Moreover, if >, , and the microgrid generates and injects power into the network, the EV is charged using the same operating mode, unless its is 100%. However, if the microgrid imports power, the vehicle is allowed to be discharged to the grid and offers V2B service at a power equal to the minimum value between and . According to the algorithm logic, the V2B mode can be maintained if the microgrid import condition remains and if the is greater than the .
The algorithm operates based on the balance of power in the microgrid . In surplus microgrid conditions, the EV is recharged up to the minimum ofand , while in deficit conditions, the EV can discharge and offer V2B service, supplying power equal to the minimum of ∣∣ and . Discharging is allowed if and theexceeds a predefined threshold, ensuring the EV retains sufficient energy for mobility and its battery does not degrade. When , the algorithm prioritizes recharging the EV to maintain its minimum mobility requirements. In critical situations, fast charging is enabled to ensure that the vehicle can satisfy its mobility needs within the available time before departure.
The main aim of the proposed algorithm is to minimize grid dependency by optimizing the use of locally generated PV energy and efficiently managing the storage systems while considering the needs of the vehicle owner. Specifically, the goal is to maximize the difference between the energy that would be drawn from the grid without the V2B functionality (
) and the energy required with the algorithm active (
):
where
,
, and
represent, respectively, the energy consumed by the loads, the energy generated by the PV system, the energy exchanged with the storage system within the microgrid located at the workplace, and the energies of the vehicle connected to the microgrid charging station, calculated over the connection time interval
.
when the battery is discharging, when the battery is charging, when the EV is charging, and when the EV is discharging in V2B mode.
At the same time, it must always be ensured that
In order to maintain optimal performance, the algorithm operates in real time, updating all system parameters and decisions every second to ensure adaptive and dynamic energy management, therefore balancing the microgrid’s and EV owner’s needs. This demonstrates the possibility of making use of EV′S as flexible energy assets in microgrid environments for better efficiency and sustainability within a system.
2.2.4. Algorithm Integration
In particular, the V2H and V2B algorithms interact thanks to the VPA in an attempt to optimize the management of the energy flow between the home microgrid and those of the office/laboratory by sharing critical operational data, namely,
The SoC of the fixed storage systems at home and the office/laboratory, which enables both algorithms to consider available local energy reserves;
The SoC of the EV battery, so that mobility requirements and energy-sharing services are consistently met;
Historical data related to the consumption of load and PV generation in a home microgrid, which helps the VPA predict surplus energy and refine charging strategies for the EV.
The integration of the VPA and V2B algorithms ensures that the partition of the battery dedicated to mobility at time
will always be 100% charged and gives the user the flexibility to choose the final charge of the part dedicated to V2X services according to his needs (e.g., to perform the load balancing of his home at night). For this reason, the VPA communicates the
value to the lab microgrid, which is appropriately processed by the V2B algorithm to calculate the following:
where
is expressed as
and
represents the energy required by the user for V2H services.
This ensures the EV leaves the office/laboratory with sufficient energy for transportation and to support the home microgrid by leveraging surplus PV energy.
The coordination of the algorithms ensures a significant enhancement of PV self-consumption in both microgrids, offering the EV as a dynamic energy reservoir. This EV can offer its flexible services, first, to the office/laboratory microgrid during the power deficit period and, later on, to the home through V2H. Real-time updates and historical analyses, together, optimize the energy allocation, minimizing the dependence on the grid, while balancing the sustainability–user need equation and, hence, ensuring efficient and flexible energy management across the interconnected systems.