Package: pv-sizing
PV-sizingPlease read the instructions carefully for the correct operation of the library. It is in an early stage of development and needs some improvements. However, its correct use gives very good results. Any help for the improvement and maintenance of the library is welcome!IntroductionPhotovoltaic sizingThis library allows the sizing of photovoltaic panels for any building and load curve provided. The photovoltaic producition was calculated using the "IDAE: Pliego de Condiciones Técnicas de Instalaciones Conectadas a Red" with the following equation:$$
E_{\mathrm{p}}=\frac{G_{\mathrm{dm}}(\alpha, \beta) P_{\mathrm{mp}} P R}{G_{\mathrm{CEM}}}
$$By simply entering the number of panels (and their parameters from the datasheet provided by the manufacturer), the hourly irradiance (fromhttps://re.jrc.ec.europa.eu/pvg_tools/en/), and the hourly load over a year it is possible to obtain the accumulated cahsflow taking into account the inflation over a period of 25 years (typical duration of a photovoltaic project). It is also necessary to provide the electricity purchase tariff, and also the price for compensation in case of grid feed-in.It also allows the sizing of the battery bank for N days of autonomy based on the daily energy consumed.The calculations for the initial investment have been calculated with typical market values. They can also be varied depending on the actual initial investment.In the image you can see a representation of the final result obtained. Also in the table below the accumulated cashflow over the liftime of the project is shown.YearInitial inversionOperation and maintenenceSavingsCashflowAccumulated cashflow03565.172571.303450527.383444-3109.092506-3109.09250610.000072.729519548.478782475.749263-2633.34324320.000074.184109570.417933496.233824-2137.10941930.000075.667792593.234651517.566859-1619.54256040.000077.181147616.964037539.782889-1079.75967150.000078.724770641.642598562.917828-516.84184360.000080.299266667.308302587.00903670.16719370.000081.905251694.000634612.095383682.26257680.000083.543356721.760659638.2173031320.47987990.000085.214223750.631086665.4168631985.896742100.000086.918508780.656329693.7378222679.634563110.000088.656878811.882582723.2257053402.860268120.000090.430015844.357886753.9278704156.788138130.000092.238616878.132201785.8935854942.681724140.000094.083388913.257489819.1741015761.855825150.000095.965056949.787789853.8227336615.678558160.000097.884357987.779300889.8949437505.573501170.000099.8420441027.290472927.4484288433.021929180.0000101.8388851068.382091966.5432069399.565136190.0000103.8756631111.1173751007.24171210406.806848200.0000105.9531761155.5620701049.60889411456.415742210.0000108.0722391201.7845531093.71231312550.128055220.0000110.2336841249.8559351139.62225113689.750306230.0000112.4383581299.8501721187.41181414877.162120240.0000114.6871251351.8441791237.15705416114.319174Data structureIrradiance and load must be hourly and must contain a minimum ofone full year of data. If the data contains more than one year, the library automatically averages the available data over the year.Load datatimeLoad (kWh)2020-07-01 01:00:000.2062020-07-01 02:00:000.2042020-07-01 03:00:000.1972020-07-01 04:00:000.2052020-07-01 05:00:000.1962020-07-01 06:00:000.1982020-07-01 07:00:000.1962020-07-01 08:00:000.4182020-07-01 09:00:000.1872020-07-01 10:00:000.1892020-07-01 11:00:000.192020-07-01 12:00:000.2032020-07-01 13:00:000.192020-07-01 14:00:000.1932020-07-01 15:00:000.1912020-07-01 16:00:000.2352020-07-01 17:00:000.1972020-07-01 18:00:000.1942020-07-01 19:00:000.1892020-07-01 20:00:000.1892020-07-01 21:00:000.2072020-07-01 22:00:000.2922020-07-01 23:00:000.298Irradiation datatimeGb(i)Gd(i)Gr(i)H_sunT2mWS10mInt2005-01-01 00:09:000.00.00.00.07.971.660.02005-01-01 01:09:000.00.00.00.06.421.790.02005-01-01 02:09:000.00.00.00.06.371.930.02005-01-01 03:09:000.00.00.00.06.352.00.02005-01-01 04:09:000.00.00.00.06.312.00.02005-01-01 05:09:000.00.00.00.06.121.860.02005-01-01 06:09:000.00.00.00.05.791.720.02005-01-01 07:09:000.00.00.00.05.751.930.02005-01-01 08:09:000.00.00.00.05.571.860.02005-01-01 09:09:00181.3357.091.7112.556.391.860.02005-01-01 10:09:00400.78113.834.322.668.112.070.02005-01-01 11:09:00611.53135.726.630.969.22.280.02005-01-01 12:09:00660.96192.727.8936.579.852.280.02005-01-01 13:09:00710.3211.028.5938.6110.182.140.02005-01-01 14:09:00650.11235.038.2536.6510.252.070.02005-01-01 15:09:00670.37184.767.5731.110.122.070.02005-01-01 16:09:00485.18184.655.622.859.752.140.02005-01-01 17:09:000.072.221.0912.769.082.210.02005-01-01 18:09:000.024.970.381.487.982.210.02005-01-01 19:09:000.00.00.00.07.192.410.02005-01-01 20:09:000.00.00.00.06.672.620.02005-01-01 21:09:000.00.00.00.06.292.760.02005-01-01 22:09:000.00.00.00.06.032.970.02005-01-01 23:09:000.00.00.00.05.823.170.0Gb(i): Beam (direct) irradiance on the inclined plane (plane of the array) (W/m2)
Gd(i): Diffuse irradiance on the inclined plane (plane of the array) (W/m2)
Gr(i): Reflected irradiance on the inclined plane (plane of the array) (W/m2)
H_sun: Sun height (degree)
T2m: 2-m air temperature (degree Celsius)
WS10m: 10-m total wind speed (m/s)
Int: 1 means solar radiation values are reconstructedThis CSV file can be obtained with the PVGIS class explained below.Electricity priceFor electricity price data you can provide a fixed price, or a format as shown in the table below.It needs to be a DataFrame with the index of type DatetimeIndex in order to automatically match the first hour of the load DataFrame and the electricity price DataFrame.  Only the prices for 24 hours must be provided.Hour€/kWh2022-04-09 00:00:000.334192022-04-09 01:00:000.331432022-04-09 02:00:000.331932022-04-09 03:00:000.349652022-04-09 04:00:000.352132022-04-09 05:00:000.349602022-04-09 06:00:000.369442022-04-09 07:00:000.372122022-04-09 08:00:000.361552022-04-09 09:00:000.291252022-04-09 10:00:000.178532022-04-09 11:00:000.148032022-04-09 12:00:000.134112022-04-09 13:00:000.134342022-04-09 14:00:000.115472022-04-09 15:00:000.079602022-04-09 16:00:000.064712022-04-09 17:00:000.054582022-04-09 18:00:000.131632022-04-09 19:00:000.198262022-04-09 20:00:000.294122022-04-09 21:00:000.349782022-04-09 22:00:000.359152022-04-09 23:00:000.35213InstallPV-sizing depends on the following libraries:pandasnumpynumpy-financialOptional libraries:pvlibseleniumplotlydashTo install the library you can simply use the pip command as follows:pip install pv-sizingExample photovoltaic productionfrom pv_sizing.dimension.pv import PVProduction

from pv_sizing.utils.load_example import example_irr, example_load

from pv_sizing.utils.constants import fresnel_fixed
from pv_sizing.utils.pv_utils import init_inv

from pv_sizing.web_scrapping.electricity_price import ElectricityPrice

import pandas as pd


pv_costs = {"num_panel": 5,
            "price_panel": 260,
            "price_inverter" : 1300,
            "additional_cost" : 500,
            "installation_cost_perc" : 0.15}

initial_investment = init_inv(**pv_costs)

electricity_price = ElectricityPrice().extract_data()

pv = PVProduction(irr_data=example_irr, load=example_load, tnoct=42, gamma=-0.36, 
                    panel_power=450, num_panel=num_panel, fresnel_eff=fresnel_fixed)

cashflow, van, tir = pv.economic_analysis(initial_investment, sell_price=0.06, buy_price=electricity_price)

pv.plot(cashflow['Accumulated cashflow'])Example battery sizingfrom pv_sizing.dimension.battery import BatterySizing
from pv_sizing.utils.load_example import example_irr, example_load

days_auto = 0.5

bat = BatterySizing(irr_data=example_irr, load=example_load, tnoct=42, gamma=-0.36, 
                    panel_power=450, num_panel=num_panel,fresnel_eff=fresnel_fixed,
                    amb_temp_multiplier=1.163, days_auto=days_auto, dod=0.95,
                    amp_hour_rating= 2400 / 48, batt_volt=48, inversor_eff=0.85)

total_battery_capacity, n_bat_paralell, n_bat_series = bat.battery_sizing()Example PVGIS scrappingfrom pv_sizing.web_scrapping.irradiance import PVGIS
import os

pvgis = PVGIS(lat = 28.242, lon = -16.647, azimuth = 0, elevation = 30, absolute_path = os.getcwd())
pvgis.interact_with_page()*Some other files may be necessary for the correct functioning of this class. Currently it is necessary to use Chrome with ChromeDriver 103.0.5060.134. The location in the machine is no relevant since the webdriver_manager is used in the script.Example of electricity price scrappingThis class allows the extraction of hourly energy prices. The prices have been obtained from the Spanish Electricity Grid (REE) for the day of execution of the script.from pv_sizing.web_scrapping.electricity_price import ElectricityPrice

electricity_price = ElectricityPrice().extract_data()*Some other files may be necessary for the correct functioning of this class. Currently it is necessary to use Chrome with ChromeDriver 103.0.5060.134. The location in the machine is no relevant since the webdriver_manager is used in the script.Example interactive plotfrom pv_sizing.app_layout.dashboard import interactive_plot
from pv_sizing.app_layout.applayout import app

interactive_plot()

if __name__ == "__main__":
    app.run_server(debug=True)When this code has been run, the following message will appear in the terminal:Dash is running onhttp://127.0.0.1:8050/Serving Flask app 'pv_sizing.app_layout.applayout'Debug mode: onOpenhttp://127.0.0.1:8050/on your terminal and try the interactive sizing mode.In this version, only the example data can be used for the interactive plot. In future versions it will be possible to drag the load and irradiance .CSV files directly into the browser.