optimiser for pitch
This commit is contained in:
		
							parent
							
								
									25b7f5b0d4
								
							
						
					
					
						commit
						ebae0aecfe
					
				
							
								
								
									
										33
									
								
								Utilities/Optimisation.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										33
									
								
								Utilities/Optimisation.py
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,33 @@ | |||||||
|  | from Utilities.Shading import calculate_energy_production_vertical | ||||||
|  | from scipy.optimize import minimize | ||||||
|  | import logging | ||||||
|  | 
 | ||||||
|  | logger = logging.getLogger(__name__) | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | def optimise_vertical_panel_pitch(c): | ||||||
|  |     def objective(pitch): | ||||||
|  |         """ | ||||||
|  |         Objective function to minimize the energy production from vertical panels. | ||||||
|  | 
 | ||||||
|  |         Args: | ||||||
|  |             pitch (float): The pitch of the vertical panels in degrees. | ||||||
|  | 
 | ||||||
|  |         Returns: | ||||||
|  |             float: The negative of the energy production from vertical panels. | ||||||
|  |         """ | ||||||
|  |         c["array"]["spacing"] = pitch | ||||||
|  |         logging.info(f"Optimizing with pitch: {pitch}m") | ||||||
|  |         vertical_energy = calculate_energy_production_vertical(c) | ||||||
|  |         total_energy_yield = vertical_energy.sum() | ||||||
|  |         logger.info(f"Total energy yield for pitch {pitch}m: {total_energy_yield}kWh") | ||||||
|  |         return -total_energy_yield | ||||||
|  | 
 | ||||||
|  |     # perform minimization | ||||||
|  |     initial_pitch = c["array"]["spacing"] | ||||||
|  |     result = minimize(objective, initial_pitch, bounds=[(0, 90)]) | ||||||
|  |     optimal_pitch = result.x[0] | ||||||
|  |     c["array"]["spacing"] = optimal_pitch | ||||||
|  |     logger.info(f"Optimal pitch found: {optimal_pitch}m") | ||||||
|  |     vetical_energy = calculate_energy_production_vertical(c) | ||||||
|  |     return (optimal_pitch, vetical_energy) | ||||||
| @ -1,5 +1,4 @@ | |||||||
| import numpy as np | import numpy as np | ||||||
| from ladybug_geometry.geometry3d import Point3D, Vector3D |  | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| def calculate_no_of_panels(system_size, panel_peak_power): | def calculate_no_of_panels(system_size, panel_peak_power): | ||||||
|  | |||||||
| @ -177,9 +177,8 @@ def calculate_energy_production_vertical(c): | |||||||
|     afternoon_shaded_fraction = ( |     afternoon_shaded_fraction = ( | ||||||
|         afternoon_shaded_fraction * no_of_shaded_rows / no_of_rows |         afternoon_shaded_fraction * no_of_shaded_rows / no_of_rows | ||||||
|     ) |     ) | ||||||
|     logger.info( | 
 | ||||||
|         f"Shaded fraction calculated for morning and afternoon solar positions." |     logger.info("Shaded fraction calculated for solar positions") | ||||||
|     ) |  | ||||||
| 
 | 
 | ||||||
|     # calculate irradiance on plane of array |     # calculate irradiance on plane of array | ||||||
|     poa_front = pvlib.irradiance.get_total_irradiance( |     poa_front = pvlib.irradiance.get_total_irradiance( | ||||||
| @ -264,7 +263,7 @@ def calculate_energy_production_horizontal(c): | |||||||
|         axis_tilt=axis_tilt, |         axis_tilt=axis_tilt, | ||||||
|     ) |     ) | ||||||
|     shaded_fraction = shaded_fraction * no_of_shaded_rows / no_of_rows |     shaded_fraction = shaded_fraction * no_of_shaded_rows / no_of_rows | ||||||
|     logger.info(f"Shaded fraction calculated for solar positions.") |     logger.info(f"Shaded fraction calculated for solar positions: {shaded_fraction}") | ||||||
| 
 | 
 | ||||||
|     poa = pvlib.irradiance.get_total_irradiance( |     poa = pvlib.irradiance.get_total_irradiance( | ||||||
|         surface_tilt=0, |         surface_tilt=0, | ||||||
|  | |||||||
| @ -1,5 +1,5 @@ | |||||||
| array: | array: | ||||||
|   system_size: 400 # in kWp |   system_size: 900 # in kWp | ||||||
|   spacing: 1 # spacing between adjacent panel rows in m |   spacing: 1 # spacing between adjacent panel rows in m | ||||||
|   edge_setback: 1.8 # distance from the edge of the roof to the array |   edge_setback: 1.8 # distance from the edge of the roof to the array | ||||||
|   roof_slope: 0 |   roof_slope: 0 | ||||||
|  | |||||||
							
								
								
									
										8
									
								
								main.py
									
									
									
									
									
								
							
							
						
						
									
										8
									
								
								main.py
									
									
									
									
									
								
							| @ -3,10 +3,8 @@ import yaml | |||||||
| import logging | import logging | ||||||
| import numpy as np | import numpy as np | ||||||
| import matplotlib.pyplot as pl | import matplotlib.pyplot as pl | ||||||
| from Utilities.Shading import ( | from Utilities.Shading import calculate_energy_production_horizontal | ||||||
|     calculate_energy_production_horizontal, | from Utilities.Optimisation import optimise_vertical_panel_pitch | ||||||
|     calculate_energy_production_vertical, |  | ||||||
| ) |  | ||||||
| 
 | 
 | ||||||
| logging.basicConfig( | logging.basicConfig( | ||||||
|     level=logging.INFO, |     level=logging.INFO, | ||||||
| @ -30,7 +28,7 @@ logger.info("Configuration loaded successfully.") | |||||||
| logger.debug(f"Configuration: {c}") | logger.debug(f"Configuration: {c}") | ||||||
| 
 | 
 | ||||||
| # calculate energy production for horizontal and vertical panels | # calculate energy production for horizontal and vertical panels | ||||||
| vertical_energy = calculate_energy_production_vertical(c) | optimal_pitch, vertical_energy = optimise_vertical_panel_pitch(c) | ||||||
| logger.info("Energy production for vertical panels calculated successfully.") | logger.info("Energy production for vertical panels calculated successfully.") | ||||||
| logger.debug(f"Vertical Energy Production: {vertical_energy.sum()}") | logger.debug(f"Vertical Energy Production: {vertical_energy.sum()}") | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user