def test_sizing_minimize_npv_direct(databases): """ Goes through following functions: sizing.subset_respecting_llp_direct() sizing.sizing_minimize_npv() Note that the OptimizeWarning ignored through pytest.mark above is a warning that comes from the relatively small amount of data on shurflo pump. It warns that scipy and pvpumpingsystem could not provide statistical figures on the quality of the model fitting for this pump. """ pump_database = databases['pumps'] pv_database = databases['pv_modules'] mppt1 = databases['mppt'] reservoir1 = res.Reservoir(size=5000) # weather data weather_path = os.path.join( test_dir, '../data/weather_files/CAN_PQ_Montreal.Intl.AP.716270_CWEC.epw') weather_data, weather_metadata = pvlib.iotools.epw.read_epw( weather_path, coerce_year=2005) weather_shrunk = siz.shrink_weather_representative(weather_data) # rest of pumping system pipes = pn.PipeNetwork(h_stat=20, l_tot=100, diam=0.08, material='plastic', optimism=True) consum = cs.Consumption(constant_flow=1) pvps_fixture = pvps.PVPumpSystem(None, None, coupling='direct', mppt=mppt1, consumption=consum, reservoir=reservoir1, pipes=pipes) with pytest.warns(UserWarning) as record: selection, _ = siz.sizing_minimize_npv(pv_database, pump_database, weather_shrunk, weather_metadata, pvps_fixture, llp_accepted=0.01, M_s_guess=1) # Check that the warning is the one expected assert "do not match" in record[0].message.args[0] assert ('shurflo_9325' in selection.pump.values and 'Canadian_Solar_Inc__CS5C_80M' in selection.pv_module.values)
def __init__(self, pvgeneration, motorpump, coupling='mppt', motorpump_model=None, mppt=None, pipes=None, reservoir=None, consumption=None, idname=None): self.pvgeneration = pvgeneration # instance of PVArray self.motorpump = motorpump # instance of Pump self.coupling = coupling self.mppt = mppt if motorpump_model is None and motorpump is not None: self.motorpump_model = self.motorpump.modeling_method elif motorpump is not None: self.motorpump_model = motorpump_model self.motorpump.modeling_method = motorpump_model else: # motorpump is None (can happen in initialization of a sizing) pass if pipes is None: self.pipes = pn.PipeNetwork(0, 0, 0.1) # system with null length else: self.pipes = pipes # instance of PipeNetwork if reservoir is None: self.reservoir = rv.Reservoir() # instance of Reservoir else: self.reservoir = reservoir # instance of Reservoir if consumption is None: self.consumption = cs.Consumption() # instance of Consumption else: self.consumption = consumption # instance of Consumption self.idname = idname # instance of String # To be calculated later self.flow = None self.efficiency = None self.water_stored = None
solar_position_method='nrel_numpy', airmass_model='kastenyoung1989', dc_model='desoto', # 'desoto' or 'cec'. ac_model='pvwatts', aoi_model='physical', spectral_model='no_loss', temperature_model='sapm', losses_model='no_loss') # MPPT mppt1 = mppt.MPPT(efficiency=0.96, price=1000) # Pipes set-up pipes1 = pn.PipeNetwork( h_stat=20, # vertical static head [m] l_tot=100, # length of pipes [m] diam=0.05, # diameter of pipes [m] material='plastic') # Reservoir reservoir1 = rv.Reservoir( size=5000, # [L] water_volume=0, # [L] at beginning price=(1010 + 210)) # 210 is pipes price # Consumption input # represents 7200L/day consumption_data = cs.Consumption(constant_flow=5) # in L/min # Definition of the system. PVGeneration object must be given even # if it will be changed afterward by the sizing function. Pump attribute can
def pvps_set_up(): pvgen1 = pvgen.PVGeneration( # Weather data weather_data_and_metadata=( os.path.join(test_dir, '../data/weather_files/CAN_PQ_Montreal' '.Intl.AP.716270_CWEC_truncated.epw')), # PV array parameters pv_module_name='kyocera solar KU270 6MCA', price_per_watt=1, # in US dollars surface_tilt=45, # 0 = horizontal, 90 = vertical surface_azimuth=180, # 180 = South, 90 = East albedo=0, # between 0 and 1 modules_per_string=2, strings_in_parallel=2, # PV module glazing parameters (not always given in specs) glass_params={'K': 4, # extinction coefficient [1/m] 'L': 0.002, # thickness [m] 'n': 1.526}, # refractive index racking_model='open_rack', # or'close_mount' or 'insulated_back' # Models used (check pvlib.modelchain for all available models) orientation_strategy=None, # or 'flat' or 'south_at_latitude_tilt' clearsky_model='ineichen', transposition_model='haydavies', solar_position_method='nrel_numpy', airmass_model='kastenyoung1989', dc_model='desoto', # 'desoto' or 'cec' only ac_model='pvwatts', aoi_model='physical', spectral_model='no_loss', temperature_model='sapm', losses_model='pvwatts' ) pvgen1.run_model() mppt1 = mppt.MPPT(efficiency=1, price=200) pump_testfile = os.path.join(test_dir, '../data/pump_files/SCB_10_150_120_BL.txt') pump1 = pp.Pump(path=pump_testfile, modeling_method='arab') pipes1 = pn.PipeNetwork(h_stat=10, l_tot=100, diam=0.08, material='plastic', optimism=True) reserv1 = rv.Reservoir() consum1 = cs.Consumption(constant_flow=1) pvps1 = pvps.PVPumpSystem(pvgen1, pump1, coupling='mppt', mppt=mppt1, pipes=pipes1, consumption=consum1, reservoir=reserv1) return pvps1