Table of Contents

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

The clients with its examples can be downloaded from https://github.com/SOLVER-AI-LTD/client. The code can be found in:

with the respective results in:


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:

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:

Solar Inverters

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

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:

Batteries

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

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

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:

Inverter Chargers

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

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:

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:

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:

Problem execution

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

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.