Implementing a Readily Deployed Solar Plant Sizing Tool in 400 Lines of Code

In the era of sustainable energy, harnessing the power of the sun through solar plants is a topic of great interest and importance. The design and optimization of these systems is a complex task, involving numerous variables and constraints. The problem involves determining the optimal number and type of various components in a solar plant system, including solar panels, solar inverters, inverter chargers, and batteries, given a set of constraints and objectives.

The problem is set specifying day and night hours, and energy production requirements and the goal is to design a system that minimizing the total cost. This problem is a perfect example of the kind of complex, real-world optimization problems that SOLVER-AI is designed to tackle. However, it’s important to note that this is a simplified problem that does not take into account factors such as geographic location and the amount of sunlight received at different times of the year.

Don't forget to also have a look at Implementing a Readily Deployed Autonomous Thermostat in 200 Lines of Code.


github

Problem Detailed Description

The solar plant system consists of four main components: solar panels, solar inverters, inverter chargers, and batteries. Each component has a set of parameters that describe its characteristics and performance, and a set of equations that describe how these parameters interact to produce the overall performance of the solar plant system.

For each of these components, we have a CSV file containing data for different alternative models and their specifications. These files provide a range of options for each component, allowing for a more flexible and tailored system design. The specifications in these files include various parameters such as power output, efficiency, and price, which are crucial for determining the optimal configuration of the solar plant system.

Solar Plant Component Diagram.

The solar panels are characterized by their total number, area, power output, efficiency, and price. The solar inverters are characterized by their total number, power rating, efficiency, and price. The inverter chargers are characterized by their total number, number of phases, power output, and efficiency. The batteries are characterized by their number in parallel, voltage, energy capacity, and efficiency loss.

An important aspect of this problem is the power flow, which varies between day and night. During the day, power is produced by the solar panels. This power is used by the home and also for charging the batteries. During the night, the power comes from the batteries. This dynamic nature of power flow adds another layer of complexity to the problem and needs to be taken into account when designing the solar plant system.

Solar plant power flow during the day.

Solar plant power flow during the night.

Objectives and Constraints

The constraints of the problem include limits on the total area covered by the solar panels, the difference between the power produced by the solar panels during the day and the total power rating of the solar inverters, and others.

The objectives is to minimize the total cost of the solar system.


Implementation

In order to define the problem for SOLVER-AI we consider positive power flow as in the figure.

Solar plant power positive flow definition.

Following is a description of the implemntation found in the code.

We are considering 4 files (SP.csv, SI.csv, IC.csv and B.csv) which are inventories of different models available for solar panels, solar inverters, inverter chargers and batteries, as shown in the image. These are setup as HardData so that the system can select the best one to satisfy constraints and objectives.

Solar plant with HardData for the components of the system.

Problem Setup

In the code you will find that the Equation modules are added first, followed by the HardData modules for the csv files. Not that no information on the relation of the different equations is specified. Below is a description of the equations implemented and the meaning of the parameters used.

Solar Panels

The SP.csv file contains the inventory of the different solar panel models available, with columns:

  • sp_area_m2: The area of a single solar panel in square meters.
  • sp_w: The power produced by a single solar panel in watts (this is an approximation not considering geographic location and exposure).
  • sp_eff_perc: The efficiency of the solar panels as a percentage.
  • sp_prc: Price of a single solar panel.

For an a number of solar panels sp_n_tot we can determine:

sp_area_m2_tot = sp_area_m2 * sp_n_tot
sp_w_tot = sp_n_tot * sp_w
sp_w_tot_wloss = sp_w_tot * (1 - sp_eff_perc / 100)
sp_w_day = sp_w_tot_wloss
sp_prc_tot = sp_prc * sp_n_tot

where:

  • sp_area_m2_tot: The total area covered by the solar panels, calculated as the area of a single panel multiplied by the total number of panels.
  • sp_w_tot: The total power produced by the solar panels, calculated as the power produced by a single panel multiplied by the total number of panels.
  • sp_w_tot_wloss: The total power produced by the solar panels after accounting for losses due to inefficiency.
  • sp_w_day: The power produced during the day, which would be the same as the total power with losses if we assume the panels only produce power during daylight hours.
  • sp_prc_tot: The total price of the solar panels, calculated as the price of a single panel multiplied by the total number of panels.

Solar Inverters

An SI.csv file contains the inventory of the different solar inverter models available, with columns:

  • si_kw: The power rating of a single solar inverter in kilowatts.
  • si_eff_perc: The efficiency of the solar inverter as a percentage.
  • si_prc: The price of a single solar inverter.

For an a number of solar panels si_n_tot we can determine:

si_w_tot = 1000 * si_kw * si_n_tot
si_w_wloss = sp_w_day * (si_eff_perc /100)
si_w_day = si_w_wloss
si_prc_tot = si_prc * si_n_tot

where:

  • si_w_tot: The total power rating of the solar inverters in the system, calculated as the power rating of a single inverter (in watts) multiplied by the total number of inverters.
  • si_w_wloss: The total power output of the solar inverters after accounting for losses due to inefficiency, calculated as the power produced by the solar panels during the day multiplied by the efficiency of the inverters.
  • si_w_day: The power output of the solar inverters during the day, which would be the same as the total power output with losses if we assume the inverters only operate during daylight hours.
  • si_prc_tot: The total price of the solar inverters, calculated as the price of a single inverter multiplied by the total number of inverters.

Batteries

A B.csv file contains the inventory of the different battery models available, with columns:

  • b_v: Voltage of a single battery.
  • b_kwh: Energy capacity of a single battery in kilowatt-hours.
  • b_eff_perc_loss: Efficiency loss of the battery as a percentage.

For an a number of batteriess b_par_n mounted in parallel given:

  • ic_battery_input_v: The inverter charger input voltage.
  • ic_w2_day_wloss: The inverter charger power input during the day after accounting for losses due to inefficiency.

we can determine:

b_v_tot = ic_battery_input_v
b_ser_n  = b_v_tot / b_v
b_n_tot = b_par_n * b_ser_n
b_wh_tot = 1000 * b_kwh * b_n_tot
b_wh_tot_wlos = b_wh_tot * (b_eff_perc_loss / 100)
b_w_day = -b_wh_tot / day_h
b_w_ngt = b_wh_tot_wlos / ngt_h
b_prc_tot = b_prc * b_n_tot

Where:

  • b_v_tot: The total voltage of the battery system, which is equal to the inverter charger input voltage.
  • b_ser_n: The number of batteries in series, calculated as the total voltage divided by the voltage of a single battery.
  • b_n_tot: The total number of batteries, calculated as the number of batteries in parallel multiplied by the number of batteries in series.
  • b_wh_tot: The total energy capacity of the battery system in watt-hours, calculated as the energy capacity of a single battery (in watt-hours) multiplied by the total number of batteries.
  • b_wh_tot_wlos: The total energy capacity of the battery system after accounting for losses due to inefficiency.
  • b_w_day: The power output of the battery system during the day, which is equal to the total energy capacity of the battery system divided by the number of day hours.
  • b_w_ngt: The power output of the battery system during the night, calculated as the total energy capacity of the battery system after losses divided by the number of night hours.
  • b_prc_tot: The total price of the battery system, calculated as the price of a single battery multiplied by the total number of batteries.

Inverter Chargers

An IC.csv file contains the inventory of the different inverter charger models available, with columns:

  • ic_n_phss: The number of phases of the inverter charger.
  • ic_w: The power output of the inverter charger.
  • ic_eff_perc_loss: The efficiency of the solar panels as a percentage, accounting for losses due to inefficiency.

For an a number of inverter chargers ic_n_tot_0 we can determine:

ic_n_tot = ic_n_tot_0 * ic_n_phss
ic_w_tot = ic_w * ic_n_tot
ic_w1_day  = -ic_w2_day
ic_w2_day = ic_w2_day_wloss / (ic_eff_perc_loss/100)
ic_w1_ngt = -ic_w2_ngt_wloss
ic_w2_ngt_wloss = ic_w2_ngt * (ic_eff_perc_loss/100)
ic_prc_tot = ic_prc * ic_n_tot_0 

Where:

  • ic_n_tot: The total number of inverter charger phases, calculated as the total number of inverter chargers multiplied by the number of phases.
  • ic_w_tot: The total power output of the inverter chargers, calculated as the power output of a single inverter charger multiplied by the total number of inverter charger phases.
  • ic_w1_day: The power output of the inverter charger during the day, calculated as the opposite of the power output of the inverter charger.
  • ic_w2_day: The power output of the inverter chargger during the day.
  • ic_w2_day_wloss: The power output of the inverter charger during the day after accounting for losses due to inefficiency.
  • ic_w1_ngt: The power output of the inverter charger during the night, calculated as the opposite of the power output of the inverter charger after losses.
  • ic_w2_ngt_wloss: The power output of the inverter charger during the night after accounting for losses due to inefficiency.
  • ic_prc_tot: The total price of the inverter chargers, calculated as the price of a single inverter charger multiplied by the total number of inverter chargers.

Home

Finally, we can calculate the energy delivered to the home as:

h_wh_day = (si_w_day + ic_w1_day) * day_h
h_wh_ngt = ic_w1_ngt * ngt_h

where:

  • h_wh_day : This is the total energy in watt-hours consumed by the household during the day.
  • h_wh_day : This is the total energy in watt-hours consumed by the household during the night.

Additional system equations

To constrain the system so that it makes sense we need to add the following:

ic_w2_day_wloss = -b_w_day
ic_w2_ngt = -b_w_ngt
delta_w_sp_si = sp_w_day - si_w_tot
delta_w_sp_si_max_perc = 100 * (sp_w_day - si_w_tot) / si_w_tot
delta_w_ic_max_day = np.abs(ic_w1_day) - ic_w_tot
delta_w_ic_max_ngt = np.abs(ic_w1_ngt) - ic_w_tot
delta_wh_max_expansion = 1000 * b_max_expansion_kwh - b_wh_tot
tot_prc = sp_prc_tot + si_prc_tot + ic_prc_tot + b_prc_tot

where:

  • delta_w_sp_si: This is the difference between the power produced by the solar panels during the day and the total power rating of the solar inverters in the system.
  • delta_w_sp_si_max_perc: This is the percentage difference between the power produced by the solar panels during the day and the total power rating of the solar inverters.
  • delta_w_ic_max_day: This is the difference between the absolute value of the power output of the inverter charger during the day and the total power output of the inverter chargers.
  • delta_w_ic_max_ngt: This is the difference between the absolute value of the power output of the inverter charger during the night and the total power output of the inverter chargers.
  • delta_wh_max_expansion: This is the difference between the maximum possible expansion of the battery system's energy capacity and the total energy capacity of the battery system.
  • tot_prc: This is the total price of the solar system, including the solar panels, solar inverters, inverter chargers, and batteries.

Problem execution

In order to run the problem the solver is set up as follows:

  • Constants:
    • day_h = 14
    • ngt_h = 10
    • n_y = 10
  • Ranges:
    • Solar Pannels
      • sp_n_tot int in range [1, 50]
    • Solar Inverter
      • si_n_tot int in range [1, 10]
    • Inverter Charger
      • ic_n_tot_0 int in range [1, 10]
    • Battery
      • b_par_n int in range [1, 10]
  • Constraints
    • Availabele solar panel area requirements
      • sp_area_m2_tot < 100
    • System consistency parameters
      • delta_w_sp_si > 0
      • delta_w_sp_si_max_perc < 33
      • delta_w_ic_max_day < 0
      • delta_w_ic_max_ngt < 0
      • delta_wh_max_expansion > -.001
    • Minimum power requirements
      • h_wh_day > 5000
      • h_wh_ngt > 3000
  • Objectives
    • minimize tot_prc

In the code we:

  1. Create a SolverAiClientSetup object solverAiClientSetup.
  2. Use the solverAiClientSetup object for creating all required modules and Problem.
  3. Create a SolverAiComputeInput object input.
  4. Use the input object to set up the solverSetup, constants, inputs, objectives and constraints.
  5. Create a SolverAiClientCompute object solverAiClientCompute.
  6. Run the computation with the runSolver function of the solverAiClientCompute object.
  7. Write the results to csv file with SolverAiResultsWriter.

Extending the Code

The code provided in example_solar_plant_sizing keeps into account only a particular time of the day, but this could be easily by making use of VectorizationIndices, for example using 1-12 to specify that each of the Equation modules would be replicated for each of the 12 months of the year. Additionaly a Code module could be used for queriying an external database to retrieve solar irradiance data.


Website Calculator Integration

In this section, we will explore how the SOLVER-AI system can be seamlessly integrated into a website-based calculator. This integration allows customers to input their specific requirements for a solar plant system, and receive a range of optimal solutions tailored to their needs. We will discuss the process from initial setup to real-time operation, highlighting how SOLVER-AI can enhance customer experience, streamline business operations, and provide valuable insights for continuous improvement. Let’s delve into the practical application of SOLVER-AI in a business context.

  1. Initial Setup: The company that sells solar plants would initially set up the SOLVER-AI system with all the necessary modules and Problem configurations. This includes all relevant equations and data from CSV files related to different solar plant components. This setup would be performed only once or updated as new components are introduced to the market.
  2. Customer Interaction: Customers would interact with a calculator on the company’s website, inputting their specific requirements for the solar system. These requirements would include factors such as the desired power output, available space for solar panels, etc.
  3. Request Forwarding: Once the customer submits their requirements, the website would forward this request to the SOLVER-AI system. The system would then use these inputs to design a range of setups that satisfy the customer’s requirements.
  4. Solution Generation: SOLVER-AI would generate a set of optimal solutions based on the customer’s inputs and the pre-configured modules and Problem. These solutions would represent different configurations of the solar plant system that meet the customer’s requirements.
  5. Result Presentation: The solutions would then be sent back to the website and presented to the customer in an easy-to-understand format. This could include a comparison of the different setups, highlighting factors such as total cost, power output, component models used, etc.
  6. Data Security: An intermediary server should be interposed between the website and SOLVER-AI to ensure the token is kept safe. This server could also handle tasks such as data preprocessing and error checking before the data is sent to SOLVER-AI.
  7. Continuous Improvement: The company could continuously monitor the performance of the SOLVER-AI system and use this data to further refine the modules and Problem over time. This would allow the system to adapt to changing market conditions, customer preferences, and improvements in solar technology. No changes to the website would be required.

Remember, these are just suggestions and the actual implementation would depend on the specific requirements and constraints of your company and customers.


Privacy Policy Cookie Policy 
Website Terms and Conditions Platform Terms and Conditions 
X



//


SOLVER-AI ® is a registered trademark in the UK.
Copyright © 2022-2024 SOLVER-AI Ltd. All Rights Reserved.