This application helps users calculate the optimal combination of Photovoltaic (PV) system size (number of panels) and external battery capacity to maximize financial savings over a specified period. It utilizes the differential_evolution algorithm from scipy.optimize to find the best configuration within a user-defined budget.
- Optimization: Automatically finds the optimal number of PV panels and battery size (kWh).
- Financial Analysis: Calculates investment costs, potential savings, and payback period.
- Customizable Inputs: Allows configuration of budget, energy prices (fixed, variable, or percentage increase), panel efficiency, battery costs, and more.
- Visualization: Interactive plots showing:
- Daily consumption and production (rolling averages).
- Battery charge levels.
- Energy bought/sold grid interaction.
- Cumulative savings over time.
- Interactive UI: Built with Streamlit for an easy-to-use web interface.
-
Clone the repository:
git clone <repository_url> cd PV-Battery-Sizing-Optimizer-Visualizer
-
Install the required dependencies:
pip install -r requirements.txt
Run the application using Streamlit:
streamlit run PV_battery_optimizer_EUR.pyOnce running, your web browser should open automatically to the application URL (usually http://localhost:8501).
- Upload Data: You can upload your own
consumption.csvandirradiance.csvfiles or use the default sample data provided. - Set Parameters: Adjust the slider and input fields for:
- Budget: Maximum amount you are willing to invest.
- Projection Years: Number of years to calculate savings for.
- Energy Prices: Current buy/sell prices and pricing model.
- System Specs: Panel size, efficiency, battery costs, etc.
- Run Optimization: The app will process the inputs and display the optimal configuration and financial projections.
If you provide your own data, ensure the CSV files follow these formats:
Should contain daily energy consumption data.
- Columns:
date,energy - Units:
energyin kWh per day. - Format:
date,energy 2023-01-01,15.5 2023-01-02,14.2 ...
Should contain daily horizontal irradiation data.
- Columns:
date,irradiance - Units:
irradiancein J/cm² per day. - Format:
date,irradiance 2023-01-01,538 2023-01-02,285 ...
PV_battery_optimizer_EUR.py: The main application script containing the Streamlit UI and optimization logic.classes.py: Defines the data structures (UserInputs,OptimizationResults,PVSystem,Battery) used across the application.requirements.txt: List of Python libraries required to run the project.consumption.csv&irradiance.csv: Default sample data files.sample_consumption/: Directory containing additional sample consumption data files.
- Streamlit: For the web interface.
- Pandas: For data manipulation.
- NumPy: For numerical operations.
- Matplotlib: For plotting graphs.
- SciPy: For the optimization algorithm (
differential_evolution).