Analysis of Prosumer Behavior in the Electrical Network

: This article deals with the prosumer behavior, speciﬁcally on an on-grid electrical network that is connected to a larger synchronous electrical network, as well as an off-grid system. In the Simulink (Matlab) application, two models were constructed for this purpose. The modeling of the operation of the electrical network’s on-grid system takes place in one of the models. The simulation of the operation of the electrical network’s off-grid system takes place in the other. We examined the model’s behavior in the provided simulated period from the standpoint of transient states and qualitative indicators of electrical energy under various connection conﬁgurations in both systems. The simulations resulted in the possibility of incorporating new sources of energy accumulation, such as pumped storage hydropower plants based on energy storage systems (ESSs), and modifying the model to the user’s needs. M.P.; methodology, M.K. L’.B.; formal D.M. and M.M.; simulation validation, D.M. and M.P., experimental validation, M.M. and D.M.; writing—original draft preparation, D.M. and M.M.; writing—review and editing, M.K. and L’.B., supervision, M.K.; project administration, D.M.; funding acquisition, M.K. All authors have


Introduction
The behavior of prosumers and an electrical grid connected to a larger synchronous grid, as well as an off-grid grid system, is examined in this article. The power system is becoming more complex than in previous periods, due to the integration of multiple Distributed Generation Resources (DGRs) and the rapid growth of power electronic devices (PEDs) [1,2]. A majority of power generators in a common power system are of the synchronous type, which increases the rotational inertia in an electric power system. The share of synchronous generators is decreasing in power networks where DGRs are widely used [3]. Of course, integrating PEDs (for example, a solar PV system or a doubly fed induction generator wind turbine system), overhead DC lines (for example, HVDC), utilization systems (for example, controller equipment) or various distribution systems (for example, various PED controllers) reduces system inertia, which can significantly alter the power system dynamics [4][5][6]. The DGRs' integration into the power system is also strongly dependent on the overall power system's transient stability. As a result, determining the intensity of transients and qualitative parameters in the range of the observed period is challenging [7,8]. In many cases, DGRs are installed at low voltage levels in the distribution system, which might increase the amount of fault current [9]. As a result, using DGRs in a small-scale power network might cause issues with transient stability, frequency responsiveness, fault elimination, voltage response, load capability and system control [10].

Problem Statement
As a result, this paper investigates the analyses of transients and qualitative indicators for different configurations of photovoltaic power plant, wind power plant, load, diesel generator and ESS (energy storage system), which can represent several possible methods of

Prosumer in Power System
A prosumer is someone who both generates and consumes energy (a transition enabled by the rise of new connected technology and the continual influx of renewable energy sources, such as solar and wind, onto the electric grid). Households are frequently referred to as loads or, in economic words, consumers on the technological grid. With the rise of the smart grid, the increased relevance of flexibility and the potential for widespread adoption of prosumer technologies, efforts to understand the role of active, rather than passive, end users have taken on new significance. The concept of the prosumer has been around for a long time, but recent developments in the energy system have given it new life. Moser et al. described the solar prosumers in the German energy transition system [22], and Jasiński et al. [23] showed the prosumer cooperatives development in rural areas. They described the differences for discount rates for individual prosumers (according to installation capacity).

Paper Contribution
The authors of this paper want to show the most significant monitored characteristics, such as active power flow and other quantities, including currents, voltage and frequency. We used Matlab source code to streamline the job with the measured partial findings in the form of graphs and electrical quantity values. The major goal of this paper, and the novelty contribution, is to analyze prosumer behavior in the electrical network, using previously published research. Section 2 contains a description of the individual blocks used in the simulation model, as well as the basic expressions. Section 3 presents the assumed circumstances for simulation of off-grid and on-grid system models, as well as the acquired results, on which Section 4 presents and discusses the conclusions.

Description of Individual Blocks of the Simulation Model
In the case of an on-grid system, the model includes the connection of the distribution system (DS), which includes a 110 kV voltage source, a 110 kV/22 kV reduction transformer, a 20 km long power line and a prosumer. The prosumer's connection to the DS is formed via the node labeled M1. A photovoltaic power plant (PVP) with a measurement point at node M5, a wind power plant (WPP) with a measurement point at node M6, an electricity storage system (ESS) with a measurement point at node M4 and a load with a measurement point at node M2 comprise the prosumer.
The model is distinguished by its thorough real-time provision of measured amplitude data for essential parameters. These data include, for example, current and active power flow, voltage monitoring in individual nodes, frequency monitoring and SOC ESS state monitoring [24]. The model also allows for the comparison of active powers of individual production and non-production units, as well as the monitoring of wind power plant parameters, such as turbine blade rotation, rotor speed in relative units and wind speed depending on wind characteristics. In the case of an off-grid system, the system was formed by the same elements as the prosumer in Figure 1.

R PEER REVIEW
3 of 20 state monitoring [24]. The model also allows for the comparison of active powers of individual production and non-production units, as well as the monitoring of wind power plant parameters, such as turbine blade rotation, rotor speed in relative units and wind speed depending on wind characteristics. In the case of an off-grid system, the system was formed by the same elements as the prosumer in Figure 1.

Wind Power Plant Block
The wind power plant subsystem (WPP) itself consists of three logical parts: the protective part, which is part of the block called "Wind Turbine Protections"; the power plant block, where the input signals (wind characteristics) are processed and the output signal is generated (standard WPP block offered by Simscape library); and the computational part, from which we receive the results of vectors with measured signals (data-acquisition block) [25].
The wind turbine protections are designed to automatically reset after a predetermined amount of time. The protection disconnects the wind turbine from the network if the limit values are exceeded (TripStatus output will be logic 1). The protection is then reset after a predetermined amount of time (5 s), with the possibility of reconnection of the wind turbine if the fault state is eliminated. The synchronization is then problematic and then should be ensured soft reconnection of wind turbine.
WPP is designed with an installed power of 400 kW. The power plant starts producing electricity from a speed of 5 m/s (the minimal speed for electricity producing) and reaches maximum power at a speed of 9 m/s. Above this speed, "Pitch" control is active, i.e., it uses the rotation of the entire rotor blade according to the instantaneous wind speed, so that the total current onset at a given moment is optimal [25].
The output voltage of the WPP generator is 575 V, which is further transformed to a voltage level of 22 kV. The WPP itself is located 2 km from the load site by an overhead line.
The output from the WPP is a measuring block labeled m_wt1 (see Figure 2), from which outputs are monitored characteristics, such as active and reactive power in relative units, blade rotation and turbine rotor speed. The values from these quantities are further processed in the data-acquisition block (Figure 3), where the conversion takes place from proportional units to SI system units. The power characteristics of a wind turbine was utilized to build the characteristics of specific Simulink WT model (see Figure 4).

Wind Power Plant Block
The wind power plant subsystem (WPP) itself consists of three logical parts: the protective part, which is part of the block called "Wind Turbine Protections"; the power plant block, where the input signals (wind characteristics) are processed and the output signal is generated (standard WPP block offered by Simscape library); and the computational part, from which we receive the results of vectors with measured signals (data-acquisition block) [25].
The wind turbine protections are designed to automatically reset after a predetermined amount of time. The protection disconnects the wind turbine from the network if the limit values are exceeded (TripStatus output will be logic 1). The protection is then reset after a predetermined amount of time (5 s), with the possibility of reconnection of the wind turbine if the fault state is eliminated. The synchronization is then problematic and then should be ensured soft reconnection of wind turbine.
WPP is designed with an installed power of 400 kW. The power plant starts producing electricity from a speed of 5 m/s (the minimal speed for electricity producing) and reaches maximum power at a speed of 9 m/s. Above this speed, "Pitch" control is active, i.e., it uses the rotation of the entire rotor blade according to the instantaneous wind speed, so that the total current onset at a given moment is optimal [25].
The output voltage of the WPP generator is 575 V, which is further transformed to a voltage level of 22 kV. The WPP itself is located 2 km from the load site by an overhead line.
The output from the WPP is a measuring block labeled m_wt1 (see Figure 2), from which outputs are monitored characteristics, such as active and reactive power in relative units, blade rotation and turbine rotor speed. The values from these quantities are further processed in the data-acquisition block (Figure 3), where the conversion takes place from proportional units to SI system units. The power characteristics of a wind turbine was utilized to build the characteristics of specific Simulink WT model (see Figure 4).  The wind turbine protection block itself protects the VE from the following:    The wind turbine protection block itself protects the VE from the following: • Short-circuit current, • Current and voltage asymmetry, Undervoltage and overvoltage, • Exceeding the specified rotor speed of the turbine, • Decrease in the specified rotor speed of the turbine.    The wind turbine protection block itself protects the VE from the following: • Short-circuit current, • Current and voltage asymmetry, Undervoltage and overvoltage, • Exceeding the specified rotor speed of the turbine, • Decrease in the specified rotor speed of the turbine.   The wind turbine protection block itself protects the VE from the following: • Short-circuit current, • Current and voltage asymmetry, • Overcurrent, • Undervoltage and overvoltage, • Exceeding the specified rotor speed of the turbine, • Decrease in the specified rotor speed of the turbine.

Photovoltaic Power Plant Block
The photovoltaic (PV) power plant model is not a part of the Simulink library. Therefore, we created a relatively simplified model ( Figure 5), where components in the form of a power converter were omitted. The PV plant consists of current sources, which represent the connection of solar panels; a 0.4 kV/22 kV transformer; logic blocks, where the size of the injected current is calculated by individual current sources; and output measuring blocks. The PV plant is 2 km long from the site of the load or the distribution network.

Photovoltaic Power Plant Block
The photovoltaic (PV) power plant model is not a part of the Simulink library. Therefore, we created a relatively simplified model ( Figure 5), where components in the form of a power converter were omitted. The PV plant consists of current sources, which represent the connection of solar panels; a 0.4 kV/22 kV transformer; logic blocks, where the size of the injected current is calculated by individual current sources; and output measuring blocks. The PV plant is 2 km long from the site of the load or the distribution network.
The model itself works on the principle of a current source, which injects current depending on the input characteristic of solar radiation and on the set value of the efficiency of the PV plant and the useful area of solar panels [26]. Photovoltaic panels, which are represented by alternating current sources ( Figure 6), generate alternating currents depending on the input combined voltage, measured between phases L1 (marked A) and L2 (marked B) and between phases L2 and L3 (marked C).
As can be seen from Figure 6, four variables enter the calculation part of the PV subsystem, on the basis of which the current is calculated, and then it is injected into the circuit by alternating current sources. These are the phase-to-phase voltage values, the characteristics of the solar radiation, the total useful area of the solar panels and the efficiency of the solar panels. Based on the input values of the phase-to-phase voltage, it is converted to the value of the phase voltage according to the following formula: From the input constants of the total useful area and efficiency, together with the instantaneous value of the solar radiation characteristic, it is possible to calculate the real component of single-phase apparent power, S (reactive component of apparent power is constant). Thus, for apparent power, we have the following [27]: where P is the active power, Q is the reactive power, UL1 is the phase value of the voltage, and IL1 is the conjugate phase value of the current. We calculated the active power as follows: where SRi is the instantaneous value of solar radiation, AREA is the total usable area of solar panels, and EFF is the efficiency of solar panels. After expressing the phase value of the current from Equation (3), we can get the following: The model itself works on the principle of a current source, which injects current depending on the input characteristic of solar radiation and on the set value of the efficiency of the PV plant and the useful area of solar panels [26].
Photovoltaic panels, which are represented by alternating current sources ( Figure 6), generate alternating currents depending on the input combined voltage, measured between phases L1 (marked A) and L2 (marked B) and between phases L2 and L3 (marked C).
The values of the currents IL1 and IL2 are input variables in the control of alternating current sources, which represent the production of electricity by solar panels.

Energy Storage System Block (ESS)
The ESS (energy storage system) subsystem itself, analogous to BESS (battery energy storage system), consists of 4 blocks: control block (ESS Control), calculation of SOC status, current sources that simulate the operation of ESS (same principle of operation as in the case of a PV unit) and a 0.4 kV/22 kV transformer ( Figure 7). As can be seen from Figure 6, four variables enter the calculation part of the PV subsystem, on the basis of which the current is calculated, and then it is injected into the circuit by alternating current sources. These are the phase-to-phase voltage values, the characteristics of the solar radiation, the total useful area of the solar panels and the efficiency of the solar panels. Based on the input values of the phase-to-phase voltage, it is converted to the value of the phase voltage according to the following formula: From the input constants of the total useful area and efficiency, together with the instantaneous value of the solar radiation characteristic, it is possible to calculate the real component of single-phase apparent power, S (reactive component of apparent power is constant). Thus, for apparent power, we have the following [27]: (2) where P is the active power, Q is the reactive power, U L1 is the phase value of the voltage, and I L1 is the conjugate phase value of the current.
We calculated the active power as follows: where SR i is the instantaneous value of solar radiation, AREA is the total usable area of solar panels, and EFF is the efficiency of solar panels. After expressing the phase value of the current from Equation (3), we can get the following: From the calculated value of I L1 , it is enough to calculate the value of the I L2 current according to the expression (using the Fortescue method of symmetrical components for the analysis of the steady-state performance of rotating machines and utilizing of complex vector, called contemporary complex Fortescue's operator, a [28]): The values of the currents I L1 and I L2 are input variables in the control of alternating current sources, which represent the production of electricity by solar panels.

Energy Storage System Block (ESS)
The ESS (energy storage system) subsystem itself, analogous to BESS (battery energy storage system), consists of 4 blocks: control block (ESS Control), calculation of SOC status, current sources that simulate the operation of ESS (same principle of operation as in the case of a PV unit) and a 0.4 kV/22 kV transformer ( Figure 7).
ESS, analogous to BESS, is charged from the distribution system (DS) at the time of switching on the low tariff, which, in the given simulation model, represents the set time from 24 to 6 o'clock. Charging itself is allowed if the ESS capacity is less than the nominal ESS capacity [29].
Several variables enter the control part of the ESS block (ESS Control): combined voltages and currents in node M1, calculation of active power, maximal allowed active power taken from DS (constant) and maximum charging power (constant).

Energy Storage System Block (ESS)
The ESS (energy storage system) subsystem itself, analogous to BESS (battery energy storage system), consists of 4 blocks: control block (ESS Control), calculation of SOC status, current sources that simulate the operation of ESS (same principle of operation as in the case of a PV unit) and a 0.4 kV/22 kV transformer (Figure 7). ESS, analogous to BESS, is charged from the distribution system (DS) at the time of switching on the low tariff, which, in the given simulation model, represents the set time In the control part, the parameters of the instantaneous measured value of active power are compared with the maximal permitted active power consumption. If the maximum permitted active power consumption from the DS is exceeded by the prosumer, then the output from the controller block is the difference of values between the instantaneous value of the active power and the maximal permissible value of the consumed active power, i.e., the ESS is discharged. This action of the control unit is valid only in the interval between regular charging cycles, i.e., in the time from 6 to 24 o'clock. A block labeled "Charging Logic" is used to control the charging behavior. The output of this block is a logical 1 in the regular dedicated charging time, which is compared with the SOC state.
If the SOC level is lower than the set parameter, the ESS will be charged at a predefined interval.
Of course, in order to be able to flawlessly simulate the behavior of the ESS, it is necessary to record the state of the SOC in real time, for which we used the Stored Energy Calculation block. The ESS itself serves to cover the load in case the maximum power consumption from the DS is exceeded.

Load Block
The load block ( Figure 8) consists of two parts: a dynamic load, which involves the connection of several hundred households [30] and the adjacent industrial part; a static load, which represents the connection of technological equipment (e.g., several electric boilers for domestic hot water (DHW) production) in three stages (3 × 50 kW), in the case of surplus active power on the prosumer and asynchronous motor side.
With a dynamic load, we can set the nominal power in MW, the power factor depending on which we change the size of the reactive power taken by the load and the load characteristics. The measurement of electrical quantities takes place in the M2 node (22 kV), i.e., taking into account the transformer losses.
In the case of a dynamic load, similar to the PV unit or ESS unit, it is the connection of current sources that work on the same principle (identical connection), but the control of current sources is conditioned by the load characteristic, and they supply negative alternating current to the circuit.

Load Block
The load block ( Figure 8) consists of two parts: a dynamic load, which involves the connection of several hundred households [30] and the adjacent industrial part; a static load, which represents the connection of technological equipment (e.g., several electric boilers for domestic hot water (DHW) production) in three stages (3 × 50 kW), in the case of surplus active power on the prosumer and asynchronous motor side. With a dynamic load, we can set the nominal power in MW, the power factor depending on which we change the size of the reactive power taken by the load and the load characteristics. The measurement of electrical quantities takes place in the M2 node (22 kV), i.e., taking into account the transformer losses.
In the case of a dynamic load, similar to the PV unit or ESS unit, it is the connection of current sources that work on the same principle (identical connection), but the control of current sources is conditioned by the load characteristic, and they supply negative alternating current to the circuit.

Measurement Block
One of the most important components of the model is the measurement block in Figure 9, labeled as "Measuring". A number of electrical and non-electrical quantities in the form of their amplitudes enter the measurement block [31]. The measurement of electrical quantities takes place in three phases, but due to the connection of symmetrical three-phase voltage sources, respectively current and symmetrical three-phase load, we see in the individual graphs only the amplitude of one phase, as they overlap each other. The course of measured quantities can be monitored in real time during the simulation via the Scope block. Selected important quantities are automatically saved in .mat format files, which we use when plotting graphical waveforms, using Matlab source code.

Measurement Block
One of the most important components of the model is the measurement block in Figure 9, labeled as "Measuring". A number of electrical and non-electrical quantities in the form of their amplitudes enter the measurement block [31]. The measurement of electrical quantities takes place in three phases, but due to the connection of symmetrical three-phase voltage sources, respectively current and symmetrical three-phase load, we see in the individual graphs only the amplitude of one phase, as they overlap each other. The course of measured quantities can be monitored in real time during the simulation via the Scope block. Selected important quantities are automatically saved in .mat format files, which we use when plotting graphical waveforms, using Matlab source code.

Diesel Generator Block
The model of the diesel generator block ( Figure 10) consists of standard blocks that are part of the Simulink library, namely a synchronous generator with expressed poles, an excitation system, a block that controls the synchronous speed (PID controller) and a transformer. Using the rotor speed of the diesel generator, we can record the frequency in the network throughout the model [32].
The inputs of the synchronous generator block are a mechanical input, namely the mechanical power, Pm, and an input for the excitation voltage marked, Vf. The diesel generator unit itself can operate in two operating modes, namely generator and engine operation. In the case of a negative value of mechanical power from the PID controller (Diesel Engine Governor), it works in motor operation, and, conversely, in the case of a positive

Diesel Generator Block
The model of the diesel generator block ( Figure 10) consists of standard blocks that are part of the Simulink library, namely a synchronous generator with expressed poles, an excitation system, a block that controls the synchronous speed (PID controller) and a transformer. Using the rotor speed of the diesel generator, we can record the frequency in the network throughout the model [32].

On-Grid System
In the given simulation, the aim was to show the operation of the on-grid system of the electrical network [33], which is connected in the node M1, according to Figure 1, with DS. In the case of excess power on the prosumer side, the power is supplied to the DS for the purpose of delivery, distribution of electricity and vice versa; in case of lack of power to cover the load, the power taken from the DS is needed.
The initial conditions of the present configuration are as follows: connected solar power plant with a total installed capacity of Pi = 1800 kWp; usable area of solar panels 12,000 m 2 , with an efficiency of 15%; solar radiation characteristics according to Figure 11; load with a peak power of 1 MW (in case of excess power from RES, the possibility to connect other technological equipment as a load with a total power of 3 × 50 kW); the load characteristics according to Figure 12; connected ESS (energy storage system), as it can represent several possible methods of energy storage, such as flywheels, compressed air, supercapacitors, etc.; and set ESS parameters of Pn = 500 kW, nominal capacity = 2000 kWh, charging power = 500 kW and initial level SOC = 95%. The inputs of the synchronous generator block are a mechanical input, namely the mechanical power, P m , and an input for the excitation voltage marked, V f . The diesel generator unit itself can operate in two operating modes, namely generator and engine operation. In the case of a negative value of mechanical power from the PID controller (Diesel Engine Governor), it works in motor operation, and, conversely, in the case of a positive value at the mechanical input, it works in generator mode.
The output of the synchronous generator is a three-phase voltage, which is fed to the transformer block and a measuring output by which we record the magnitude of the stator voltage as feedback for the excitation system block and rotor speed for the PID controller that maintains synchronous rotational speed.

On-Grid System
In the given simulation, the aim was to show the operation of the on-grid system of the electrical network [33], which is connected in the node M1, according to Figure 1, with DS. In the case of excess power on the prosumer side, the power is supplied to the DS for the purpose of delivery, distribution of electricity and vice versa; in case of lack of power to cover the load, the power taken from the DS is needed.
The initial conditions of the present configuration are as follows: connected solar power plant with a total installed capacity of P i = 1800 kWp; usable area of solar panels 12,000 m 2 , with an efficiency of 15%; solar radiation characteristics according to Figure 11; load with a peak power of 1 MW (in case of excess power from RES, the possibility to connect other technological equipment as a load with a total power of 3 × 50 kW); the load characteristics according to Figure 12; connected ESS (energy storage system), as it can represent several possible methods of energy storage, such as flywheels, compressed air, supercapacitors, etc.; and set ESS parameters of P n = 500 kW, nominal capacity = 2000 kWh, charging power = 500 kW and initial level SOC = 95%. 12,000 m , with an efficiency of 15%; solar radiation characteristics according to Figure 11; load with a peak power of 1 MW (in case of excess power from RES, the possibility to connect other technological equipment as a load with a total power of 3 × 50 kW); the load characteristics according to Figure 12; connected ESS (energy storage system), as it can represent several possible methods of energy storage, such as flywheels, compressed air, supercapacitors, etc.; and set ESS parameters of Pn = 500 kW, nominal capacity = 2000 kWh, charging power = 500 kW and initial level SOC = 95%.  14, x FOR PEER REVIEW 10 of 20 The simulation itself takes place within 48 h, where, as can be seen from Figure 12, the peak load is lower during the first day than on the following day. The level of the basic load is 0.3 pu from the nominal load-in our case, 1 MW.
When describing the transient states of the simulation, we issued the initial conditions of the model configuration, with the observed period (48 h) divided into certain intervals, where we described the course of power, voltage, frequency and other important characteristics.

A Description of the Characteristics of Active Powers from
In the first interval of Figure 13, in the time from 0 to 6 o'clock, the power from WPP and from DS is used to cover the load. ESS is fully charged. At the beginning of the second interval, it starts to supply the PV plant power to the network, which causes a decrease in the power taken from the DS. In the third interval, the excess power from the RES is supplied to the DS for the purpose of its sale. If the power supplied to the DS from the RES exceeds the value of 50 kW, the technological equipment is connected as a load in three stages (50, 100 and 150 kW), with a total power of 3 × 50 kW, with the shutdown of technological equipment tied not only to the value of power supplied to the DS from the RES, but also for a certain measured time, when they take power from the network. This means The simulation itself takes place within 48 h, where, as can be seen from Figure 12, the peak load is lower during the first day than on the following day. The level of the basic load is 0.3 pu from the nominal load-in our case, 1 MW.
When describing the transient states of the simulation, we issued the initial conditions of the model configuration, with the observed period (48 h) divided into certain intervals, where we described the course of power, voltage, frequency and other important characteristics.

A Description of the Characteristics of Active Powers from
In the first interval of Figure 13, in the time from 0 to 6 o'clock, the power from WPP and from DS is used to cover the load. ESS is fully charged. At the beginning of the second interval, it starts to supply the PV plant power to the network, which causes a decrease in the power taken from the DS. In the third interval, the excess power from the RES is supplied to the DS for the purpose of its sale. If the power supplied to the DS from the RES exceeds the value of 50 kW, the technological equipment is connected as a load in three stages (50, 100 and 150 kW), with a total power of 3 × 50 kW, with the shutdown of technological equipment tied not only to the value of power supplied to the DS from the RES, but also for a certain measured time, when they take power from the network. This means that these technological devices can take power from the network even if the power from the RES is not supplied to the DS. The fourth interval is characterized by the disconnection of technological equipment, because the conditions for their further operation are not met. At the beginning of the fifth interval, it will start supplying ESS power to the network, because the condition of the maximum allowed power taken from the DS, namely 250 kW, has been met. In the sixth interval, from 24 to 30 h, the time is reserved for charging the ESS by switching on at a low tariff. In this time zone, even if the ESS is charged to the built-in rated capacity, the ESS does not supply any power to the network. The seventh interval is characterized by a reduced supply of power from the PV plant compared to the third interval; that is, the WPP from approximately 34 h delivers a rated power of 400 kW almost until the end of the simulation (compare to Figures 14 and 15). Moreover, similar to the third interval, in the case of excess power from RES, the connection of technological equipment occurs as a load. In the last interval, i.e., the eighth interval, at a time when radiation from the sun is getting lower and the power supplied by the PV plant is rapidly decreasing, it is again activated by the ESS, which stabilizes the power taken from the DS at 250 kW.       The capacity of the ESS stabilized at 60% of SOC, as shown in the course of the SOC of ESS in Figure 16. Table 1 shows that the WPP delivered the most electricity to the network during the observed time, 16.17 MWh, followed by the PV plant (9.85 MWh). The power absorbed from the DS by the prosumer accounted for 19.93% of the total power volume required to cover the load.
For Figure 13, i.e., for the course of active powers, the balance of active powers applies at each time point: where ∑P G is total active power of power plants (also DS), P is total active load and ∆P is total active losses (we neglected them) [2].

4, x FOR PEER REVIEW 12 of 20
The capacity of the ESS stabilized at 60% of SOC, as shown in the course of the SOC of ESS in Figure 16. Table 1 shows that the WPP delivered the most electricity to the network during the observed time, 16.17 MWh, followed by the PV plant (9.85 MWh). The power absorbed from the DS by the prosumer accounted for 19.93% of the total power volume required to cover the load.    After modification of Expression (7), we get the following: where ∑P TOTAL = ∑P G and ∑P LOAD = ∆P; ∑P ESS is the total active power of the ESS, including BESS (where losses are already included); ∑P PV_FARM is the total active power of the solar power plant (where losses are included); ∑P WIND_FARM is the total active power of the wind power plant (where losses are included); ∑P GRID is the total active power of DS; and ∑P LOAD is the total active load power. The balance of reactive power at each time point also applies to the given simulation: where ∑Q G is the total reactive power of power plants (also DS), ∑Q B is the summary charging power of the lines (we neglected them), ∑Q kz is the total reactive power of compensating devices (we neglected them), ∑Q is the total reactive load power and ∆Q is the total reactive power losses in electrical networks (we neglected them) [2]. After modifying Expression (10), we get the following: where ∑Q TOTAL = ∑Q G and ∑Q LOAD = ∆Q; ∑Q ESS is the total reactive power of the ESS, including BESS (losses are already included); ∑Q PV_FARM is the total reactive power of the solar power plant (losses are included); ∑Q WIND_FARM is the total reactive power of the wind power plant (losses are included); ∑Q GRID is the total reactive power of DS; ∑Q LOAD is the total reactive load power. Description of the frequency characteristic in the network ( Figure 17):

I.
A decrease of the frequency below the nominal value f n is caused by the gradual connection of the load, respectively technological equipment in three stages 3 × 50 kW. II. An increase of the frequency above the nominal value f n is caused by the gradual disconnection of the load, respectively technological equipment. III. A decrease of the frequency below the nominal value f n is caused by the charging of the ESS and the increase of the frequency by disconnection of the ESS (end of charging, SOC = 95%). IV. An increase of the frequency above the nominal value f n is caused by the connection of the ESS due to the exceeding of the maximum allowed power consumption from the DS by the prosumer, i.e., 250 kW. V.
A decrease, respectively frequency increase (V. and VI.) below, respectively above the nominal value f n is again due to connection, and by disconnecting the load, where the regulation occurred by reduction, and by increasing the supply of power from DS. of the ESS due to the exceeding of the maximum allowed power consumption from the DS by the prosumer, i.e., 250 kW.
V. A decrease, respectively frequency increase (V. and VI.) below, respectively above the nominal value fn is again due to connection, and by disconnecting the load, where the regulation occurred by reduction, and by increasing the supply of power from DS. Within the given simulation, 29.94 MWh of electricity was consumed in the given time period. Electricity from RES, which was used directly to cover the load, accounted for 80.07% (23.97 MWh). In addition, there was a total volume of 1.54 MWh within the excess power from RES supplied to the DS.
In the given simulation, the aim was to show the operation of the off-grid system, where, at 22 h, there was a failure on the diesel generator. The missing network power was ensured by connecting the off-grid system to the DS [34].
The initial conditions of the mentioned configuration are as follows: • Connected PV power plant with a total installed capacity of 900 kWp, usable area of solar panels 6000 m 2 with an efficiency of 15%, and solar radiation characteristics according to Figure 11; • A load with a peak power of 1.1 MW (an asynchronous motor with a power of 100 kW is connected in the 3 h of the simulation) and the load characteristic according to Figure 12; Within the given simulation, 29.94 MWh of electricity was consumed in the given time period. Electricity from RES, which was used directly to cover the load, accounted for 80.07% (23.97 MWh). In addition, there was a total volume of 1.54 MWh within the excess power from RES supplied to the DS.
In the given simulation, the aim was to show the operation of the off-grid system, where, at 22 h, there was a failure on the diesel generator. The missing network power was ensured by connecting the off-grid system to the DS [34].
The initial conditions of the mentioned configuration are as follows: • Connected PV power plant with a total installed capacity of 900 kWp, usable area of solar panels 6000 m 2 with an efficiency of 15%, and solar radiation characteristics according to Figure 11; • A load with a peak power of 1.1 MW (an asynchronous motor with a power of 100 kW is connected in the 3 h of the simulation) and the load characteristic according to • At the beginning of the first interval, the ESS is charged (initial SOC level = 40%) at the time of the low tariff. The load is mainly covered by a diesel generator together with a wind turbine.

•
In the second interval, at 3 o'clock, a load in the form of an asynchronous motor with a power of 100 kW was connected, and at 5 o'clock, the charging of the ESS was terminated (SOC = 95%).

•
In the third interval, the ESS starts its operation, thus reducing the share of the delivered power of the diesel generator until 11 o'clock. At a given interval, the PV plant also starts to supply power to the network.

•
In the fourth interval, the ESS was disconnected due to the exhaustion of the nominal capacity (SOC level = 10%); the regulation of the active power in the network is ensured by means of a diesel generator.

•
In the fifth interval, the PV plant also terminated its activity; only the power from the WPP and the diesel generator serves to cover the load. At 10:00 p.m., there was a fault in the diesel generator, and so it had to be disconnected. The lack of power in the off-grid network could not be replaced by any available resource that is part of this system. Therefore, the off-grid network was connected to the DS, which ensured the supply of power without interruption. In the off-grid nodes, this caused an increase in voltage from 21.7 to 23.5 kV (Figure 19).

•
The sixth interval is characterized by charging the ESS in the time from midnight to 6 o'clock on the 2nd day, where it was disconnected.

•
In the seventh interval, the power begins to be supplied from the PV power plant. Peak power will reach approximately 0.3 MW at 34 h, but compared to the 1st day, it is a decrease in production, which is given by the input characteristics of solar radiation.

•
In eighth, and final, interval, the PV power plant ceases to supply to the network power, and the load supplied from the DS mainly contributes to covering the load. For the entire monitored section, most electricity was supplied from DS in the total amount of 14.32 MWh, followed by a diesel generator, 11.6 MWh. In total, electricity was consumed in the volume of 33.36 MWh (Table 2). sured by means of a diesel generator.

•
In the fifth interval, the PV plant also terminated its activity; only the power from the WPP and the diesel generator serves to cover the load. At 10:00 p.m., there was a fault in the diesel generator, and so it had to be disconnected. The lack of power in the offgrid network could not be replaced by any available resource that is part of this system. Therefore, the off-grid network was connected to the DS, which ensured the supply of power without interruption. In the off-grid nodes, this caused an increase in voltage from 21.7 to 23.5 kV (Figure 19).

•
The sixth interval is characterized by charging the ESS in the time from midnight to 6 o'clock on the 2nd day, where it was disconnected.

•
In the seventh interval, the power begins to be supplied from the PV power plant. Peak power will reach approximately 0.3 MW at 34 h, but compared to the 1st day, it is a decrease in production, which is given by the input characteristics of solar radiation.

•
In eighth, and final, interval, the PV power plant ceases to supply to the network power, and the load supplied from the DS mainly contributes to covering the load. For the entire monitored section, most electricity was supplied from DS in the total amount of 14.32 MWh, followed by a diesel generator, 11.6 MWh. In total, electricity was consumed in the volume of 33.36 MWh ( Table 2).   For Figure 18, i.e., for the characteristics of active powers, the balance of active powers applies at each time point: (13) where ∑P G is total active power of power plants (also DS), P is total active load and ∆P is total active losses (we neglected them) [2].
After modification of Expression (13), we get the following: ∑ P PV_FARM + ∑ P GRID + ∑ P W I ND_FARM + ∑ P ESS + ∑ P DIESEL = ∑ P LOAD [W] (15) where ∑P TOTAL = ∑P G and ∑P LOAD = ∆P; ∑P PV_FARM is the total active power of the solar power plant (losses are included); ∑P WIND_FARM is the total active power of the wind power plant (losses are included); ∑P GRID is the total active power of DS; ∑P ESS is the total active power of the ESS, including BESS (losses are included); ∑P DIESEL is the total active power of the diesel generator; ∑P LOAD is the total active load power. The balance of reactive power at each time point also applies to the given simulation: where ∑Q G is the total reactive power of power plants (also DS), ∑Q B is the summary charging power of the lines (we neglected them), ∑Q kz is the total reactive power of compensating devices (we neglected them), ∑Q is the total reactive load power and ∆Q is the total reactive power losses in electrical networks (we neglected them) [2]. After modifying Expression (16), we obtain the following: where ∑Q TOTAL = ∑Q G , ∑Q LOAD = ∆Q, ∑Q PV_FARM is the total reactive power of the solar power plant (losses are included), ∑Q WIND_FARM is the total reactive power of the wind power plant (losses are included), ∑Q GRID is the total reactive power of DS, ∑Q ESS is the total reactive power of the ESS (losses are included), ∑Q DIESEL is the total reactive power of the diesel generator and ∑Q LOAD is the total reactive load power. In Figures 19 and 20, we can see at 22 h how a failure occurred on the diesel generator, with the necessary power being replaced by phasing the off-grid system to the distribution system.
Description of the frequency characteristic in the network ( Figure 21): VI. A decrease of the frequency below the nominal value, f n , to the level of 47.75 Hz is caused by the connection of an asynchronous motor with nominal power, P n = 100 kW; the network was regulated by increasing the supply of power from the diesel generator. VII. An increase of the frequency above the nominal value, f n , to the level of 53 Hz is caused by the disconnection of the load prior to the end of ESS charging. VIII. An increase of the frequency above the nominal value, f n , to the value of 52.8 Hz was again caused by the operation of the ESS, no longer as an appliance, but by the supply of active power. IX. A frequency dropped to 47.65 Hz by disconnecting the ESS, as the SOC level of the ESS reached its minimum (SOC = 10%). X. A decrease of frequency to the value of 45.15 Hz was caused by the failure of the diesel generator (disconnection in 22 h); the network regulation is ensured by the connection of the off-grid system to the distribution system.    Within the simulation period, 27.85% of electricity was produced from RES, and the majority of electricity was supplied from DS and diesel generators.

Conclusions
This paper describes the operation of the off-grid model and on-grid system created in the Simulink program (Matlab). A model was created to analyze the behavior of prosumers and consisted of the connection of a wind power plant, a photovoltaic power plant, an electricity storage system (ESS), a load (dynamic and static) and a distribution system.
A separate model was created for the off-grid system, which consisted of the same components as the connection of the on-grid system supplemented by a diesel generator as the main regulating component of the active power and frequency in the system. Within the given simulation, we also tested the response of the system to a fault on the diesel generator with the subsequent phasing of the off-grid system of the electrical network to the distribution system, so that it was possible to compare the systems within one simulation.
Within the models, it is possible to analyze off-grid and on-grid electricity networks Within the simulation period, 27.85% of electricity was produced from RES, and the majority of electricity was supplied from DS and diesel generators.

Conclusions
This paper describes the operation of the off-grid model and on-grid system created in the Simulink program (Matlab). A model was created to analyze the behavior of prosumers and consisted of the connection of a wind power plant, a photovoltaic power plant, an electricity storage system (ESS), a load (dynamic and static) and a distribution system.
A separate model was created for the off-grid system, which consisted of the same components as the connection of the on-grid system supplemented by a diesel generator as the main regulating component of the active power and frequency in the system. Within the given simulation, we also tested the response of the system to a fault on the diesel generator with the subsequent phasing of the off-grid system of the electrical network to the distribution system, so that it was possible to compare the systems within one simulation.
Within the models, it is possible to analyze off-grid and on-grid electricity networks over a longer period of time; they also have the ability to add new sources of accumulation, e.g., pumped storage hydropower plant based on ESS, and can be adapted to the user's own needs.
From the point of view of the evaluation of the quality of electrical energy according to STN EN 50160: 2011 (33 0121) for LV and HV, we can deduce that, in the entire interconnected electrical network when connecting, respectively disconnecting of the load or production unit did not cause any dangerous phenomena; and from the point of view of the most important qualitative indicators, voltages and frequencies have been kept within the permissible limits. From the frequency characteristics, we can see that, in the case of the off-grid network system, when switching the load in the form of an asynchronous motor or ESS during charging, respectively discharging, there have been much more pronounced frequency deviations, and this is not exceptional in the case of such a system. Within the on-grid system, in all case simulations, the frequency deviations in the power control were of the order of tenths and did not exceed ±0.5 Hz in any of the simulated cases.
When modeling individual case simulations, we encountered a number of problems, e.g., in the case of a wind farm model, and such problems significantly slow down the simulation and also prolong the time it takes to perform calculations in Matlab. For this reason, it was necessary to use idealized input characteristics of solar radiation, wind speed and load characteristics. In the case of simulation without the wind power plant, the simulation time is of the order of seconds, using up to 1 h. The given model can be applied in real model situations, but it is necessary to take into account a significantly longer simulation time.
This paper fills the literature gap in the research area on modeling of case simulations using of prosumers. This paper also contributes to the energy communities that want to be green and create opportunities to utilize energy in a way that is more efficient.