Esempio n. 1
0
def test__infer_temperature_model_params():
    system = pvsystem.PVSystem(module_parameters={},
                               racking_model='open_rack',
                               module_type='glass_polymer')
    expected = temperature.TEMPERATURE_MODEL_PARAMETERS['sapm'][
        'open_rack_glass_polymer']
    assert expected == system._infer_temperature_model_params()
    system = pvsystem.PVSystem(module_parameters={},
                               racking_model='freestanding',
                               module_type='glass_polymer')
    expected = temperature.TEMPERATURE_MODEL_PARAMETERS['pvsyst'][
        'freestanding']
    assert expected == system._infer_temperature_model_params()
Esempio n. 2
0
def test_PVSystem_i_from_v():
    module = 'Example_Module'
    module_parameters = sam_data['cecmod'][module]
    system = pvsystem.PVSystem(module=module,
                               module_parameters=module_parameters)
    output = system.i_from_v(20, .1, .5, 40, 6e-7, 7)
    assert_almost_equals(-299.746389916, output, 5)
Esempio n. 3
0
def test_PVSystem_calcparams_pvsyst(pvsyst_module_params, mocker):
    mocker.spy(pvsystem, 'calcparams_pvsyst')
    module_parameters = pvsyst_module_params.copy()
    system = pvsystem.PVSystem(module_parameters=module_parameters)
    effective_irradiance = np.array([0, 800])
    temp_cell = np.array([25, 50])
    IL, I0, Rs, Rsh, nNsVth = system.calcparams_pvsyst(effective_irradiance,
                                                       temp_cell)
    pvsystem.calcparams_pvsyst.assert_called_once_with(
        effective_irradiance,
        temp_cell,
        alpha_sc=pvsyst_module_params['alpha_sc'],
        gamma_ref=pvsyst_module_params['gamma_ref'],
        mu_gamma=pvsyst_module_params['mu_gamma'],
        I_L_ref=pvsyst_module_params['I_L_ref'],
        I_o_ref=pvsyst_module_params['I_o_ref'],
        R_sh_ref=pvsyst_module_params['R_sh_ref'],
        R_sh_0=pvsyst_module_params['R_sh_0'],
        R_s=pvsyst_module_params['R_s'],
        cells_in_series=pvsyst_module_params['cells_in_series'],
        EgRef=pvsyst_module_params['EgRef'],
        R_sh_exp=pvsyst_module_params['R_sh_exp'])

    assert_allclose(IL, np.array([0.0, 4.8200]), atol=1)
    assert_allclose(I0, np.array([0.0, 1.47e-7]), atol=1.0e-5)
    assert_allclose(Rs, 0.5, atol=0.1)
    assert_allclose(Rsh, np.array([1000, 305.757]), atol=50)
    assert_allclose(nNsVth, np.array([1.6186, 1.7961]), atol=0.1)
Esempio n. 4
0
def test_PVSystem_first_solar_spectral_loss(sapm_module_params, expected):
    system = pvsystem.PVSystem(module_parameters=sapm_module_params)
    pw = 3
    airmass_absolute = 3
    out = system.first_solar_spectral_loss(pw, airmass_absolute)

    assert_allclose(out, expected, atol=1e-4)
Esempio n. 5
0
    def __init__(self, method="pypvsim", surface_tilt=0, surface_azimuth=180, \
        pmax=0, albedo=.25, surface_type=None, module=None, module_parameters=None, \
        modules_per_string=1, strings_per_inverter=1, inverter=None, inverter_parameters=None, \
        racking_model='open_rack_cell_glassback', **kwargs):

        self.tilt = surface_tilt
        self.azimuth = surface_azimuth
        self.albedo = albedo
        self.pmax = pmax
        self.racking_model = 'open_rack_cell_glassback'
        self.method = method

        if "lat" in kwargs:
            self.lat = kwargs['lat']
        if "lon" in kwargs:
            self.lon = kwargs['lon']
        if "dates" in kwargs:
            self.dates = kwargs['dates']

        if self.method == "pvlib":

            self.params = {}
            self.params['pdc0'] = pmax  # DC nameplate rating
            self.params[
                'gamma_pdc'] = 0.0044  # temperature coefficient. Typically in units of 1/C.
            self.params['eta_inv'] = 0.97  # inverter efficiency
            self.params['eta_inv_ref'] = 0.90  # reference inverter efficiency

            self.syst = pvsystem.PVSystem(surface_tilt=self.tilt, surface_azimuth=self.azimuth, \
                albedo=self.albedo, surface_type=surface_type, module=module, module_parameters=self.params, \
                modules_per_string=1, strings_per_inverter=1, inverter=None, inverter_parameters=None, \
                racking_model=self.racking_model)
Esempio n. 6
0
def test_PVSystem_get_irradiance():
    system = pvsystem.PVSystem(surface_tilt=32, surface_azimuth=135)
    times = pd.DatetimeIndex(start='20160101 1200-0700',
                             end='20160101 1800-0700', freq='6H')
    location = Location(latitude=32, longitude=-111)
    solar_position = location.get_solarposition(times)
    irrads = pd.DataFrame({'dni':[900,0], 'ghi':[600,0], 'dhi':[100,0]},
                          index=times)

    irradiance = system.get_irradiance(solar_position['apparent_zenith'],
                                       solar_position['azimuth'],
                                       irrads['dni'],
                                       irrads['ghi'],
                                       irrads['dhi'])

    expected = pd.DataFrame(data=np.array(
        [[ 883.65494055,  745.86141676,  137.79352379,  126.397131  ,
              11.39639279],
           [   0.        ,   -0.        ,    0.        ,    0.        ,    0.        ]]),
                            columns=['poa_global', 'poa_direct',
                                     'poa_diffuse', 'poa_sky_diffuse',
                                     'poa_ground_diffuse'],
                            index=times)

    assert_frame_equal(irradiance, expected, check_less_precise=2)
Esempio n. 7
0
def test_PVSystem_sapm_aoi_loss(sapm_module_params, mocker):
    system = pvsystem.PVSystem(module_parameters=sapm_module_params)
    mocker.spy(pvsystem, 'sapm_aoi_loss')
    aoi = 0
    out = system.sapm_aoi_loss(aoi)
    pvsystem.sapm_aoi_loss.assert_called_once_with(aoi, sapm_module_params)
    assert_allclose(out, 1.0, atol=0.01)
Esempio n. 8
0
def test_PVSystem_sapm():
    modules = sam_data['sandiamod']
    module = 'Canadian_Solar_CS5P_220M___2009_'
    module_parameters = modules[module]
    system = pvsystem.PVSystem(module=module,
                               module_parameters=module_parameters)
    times = pd.DatetimeIndex(start='2015-01-01', periods=2, freq='12H')
    irrad_data = pd.DataFrame(
        {
            'dni': [0, 1000],
            'ghi': [0, 600],
            'dhi': [0, 100]
        }, index=times)
    am = pd.Series([0, 2.25], index=times)
    aoi = pd.Series([180, 30], index=times)

    sapm = system.sapm(irrad_data['dni'], irrad_data['dhi'], 25, am, aoi)

    expected = pd.DataFrame(np.array([[0., 0., 0., 0., 0., 0., 0., 0.],
                                      [
                                          5.74526799, 5.12194115, 59.67914031,
                                          48.41924255, 248.00051089,
                                          5.61787615, 3.52581308, 1.12848138
                                      ]]),
                            columns=[
                                'i_sc', 'i_mp', 'v_oc', 'v_mp', 'p_mp', 'i_x',
                                'i_xx', 'effective_irradiance'
                            ],
                            index=times)

    assert_frame_equal(sapm, expected)
Esempio n. 9
0
def test_PVSystem_scale_voltage_current_power(mocker):
    data = None
    system = pvsystem.PVSystem(modules_per_string=2, strings_per_inverter=3)
    m = mocker.patch('pvlib.pvsystem.scale_voltage_current_power',
                     autospec=True)
    system.scale_voltage_current_power(data)
    m.assert_called_once_with(data, voltage=2, current=3)
Esempio n. 10
0
def test_PVSystem_localize___repr__():
    system = pvsystem.PVSystem(module='blah', inverter='blarg', name='pv ftw')
    localized_system = system.localize(latitude=32, longitude=-111)

    expected = 'LocalizedPVSystem: \n  name: None\n  latitude: 32\n  longitude: -111\n  altitude: 0\n  tz: UTC\n  surface_tilt: 0\n  surface_azimuth: 180\n  module: blah\n  inverter: blarg\n  albedo: 0.25\n  racking_model: open_rack_cell_glassback'

    assert localized_system.__repr__() == expected
Esempio n. 11
0
def test_PVSystem_calcparams_desoto(cec_module_params, mocker):
    mocker.spy(pvsystem, 'calcparams_desoto')
    module_parameters = cec_module_params.copy()
    module_parameters['EgRef'] = 1.121
    module_parameters['dEgdT'] = -0.0002677
    system = pvsystem.PVSystem(module_parameters=module_parameters)
    effective_irradiance = np.array([0, 800])
    temp_cell = 25
    IL, I0, Rs, Rsh, nNsVth = system.calcparams_desoto(effective_irradiance,
                                                       temp_cell)
    pvsystem.calcparams_desoto.assert_called_once_with(
        effective_irradiance,
        temp_cell,
        alpha_sc=cec_module_params['alpha_sc'],
        a_ref=cec_module_params['a_ref'],
        I_L_ref=cec_module_params['I_L_ref'],
        I_o_ref=cec_module_params['I_o_ref'],
        R_sh_ref=cec_module_params['R_sh_ref'],
        R_s=cec_module_params['R_s'],
        EgRef=module_parameters['EgRef'],
        dEgdT=module_parameters['dEgdT'])
    assert_allclose(IL, np.array([0.0, 6.036]), atol=1)
    assert_allclose(I0, 2.0e-9, atol=1.0e-9)
    assert_allclose(Rs, 0.1, atol=0.1)
    assert_allclose(Rsh, np.array([np.inf, 20]), atol=1)
    assert_allclose(nNsVth, 0.5, atol=0.1)
Esempio n. 12
0
def test_PVSystem_sapm_aoi_loss(sapm_module_params):
    system = pvsystem.PVSystem(module_parameters=sapm_module_params)

    times = pd.DatetimeIndex(start='2015-01-01', periods=2, freq='12H')
    aoi = pd.Series([45, 10], index=times)

    out = system.sapm_aoi_loss(aoi)
Esempio n. 13
0
def test_PVSystem_get_iam_sapm(sapm_module_params, mocker):
    system = pvsystem.PVSystem(module_parameters=sapm_module_params)
    mocker.spy(_iam, 'sapm')
    aoi = 0
    out = system.get_iam(aoi, 'sapm')
    _iam.sapm.assert_called_once_with(aoi, sapm_module_params)
    assert_allclose(out, 1.0, atol=0.01)
Esempio n. 14
0
def test_PVSystem_get_iam(mocker, iam_model, model_params):
    m = mocker.spy(_iam, iam_model)
    system = pvsystem.PVSystem(module_parameters=model_params)
    thetas = 1
    iam = system.get_iam(thetas, iam_model=iam_model)
    m.assert_called_with(thetas, **model_params)
    assert iam < 1.
Esempio n. 15
0
def test_PVSystem_ashraeiam(mocker):
    mocker.spy(pvsystem, 'ashraeiam')
    module_parameters = pd.Series({'b': 0.05})
    system = pvsystem.PVSystem(module_parameters=module_parameters)
    thetas = 1
    iam = system.ashraeiam(thetas)
    pvsystem.ashraeiam.assert_called_once_with(thetas, b=0.05)
    assert iam < 1.
Esempio n. 16
0
def summer_power_fixed(summer_clearsky, albuquerque, system_parameters):
    """Simulated power from a FIXED PVSystem in Albuquerque, NM."""
    pv_system = pvsystem.PVSystem(**system_parameters)
    mc = modelchain.ModelChain(pv_system,
                               albuquerque,
                               orientation_strategy='south_at_latitude_tilt')
    mc.run_model(summer_clearsky)
    return mc.ac
Esempio n. 17
0
def test_PVSystem_physicaliam():
    module_parameters = pd.Series({'K': 4, 'L': 0.002, 'n': 1.526})
    system = pvsystem.PVSystem(module_parameters=module_parameters)
    thetas = np.linspace(-90, 90, 9)
    iam = system.physicaliam(thetas)
    expected = np.array([        nan,  0.8893998 ,  0.98797788,  0.99926198,         nan,
        0.99926198,  0.98797788,  0.8893998 ,         nan])
    assert_allclose(iam, expected, equal_nan=True)
Esempio n. 18
0
def test_PVSystem_sapm_spectral_loss(sapm_module_params, mocker):
    mocker.spy(pvsystem, 'sapm_spectral_loss')
    system = pvsystem.PVSystem(module_parameters=sapm_module_params)
    airmass = 2
    out = system.sapm_spectral_loss(airmass)
    pvsystem.sapm_spectral_loss.assert_called_once_with(
        airmass, sapm_module_params)
    assert_allclose(out, 1, atol=0.5)
Esempio n. 19
0
def test_PVSystem_physicaliam(mocker):
    module_parameters = pd.Series({'K': 4, 'L': 0.002, 'n': 1.526})
    system = pvsystem.PVSystem(module_parameters=module_parameters)
    mocker.spy(pvsystem, 'physicaliam')
    thetas = 1
    iam = system.physicaliam(thetas)
    pvsystem.physicaliam.assert_called_once_with(thetas, **module_parameters)
    assert iam < 1.
Esempio n. 20
0
def test_PVSystem_sapm(sapm_module_params):
    system = pvsystem.PVSystem(module_parameters=sapm_module_params)

    times = pd.DatetimeIndex(start='2015-01-01', periods=5, freq='12H')
    effective_irradiance = pd.Series([-1, 0.5, 1.1, np.nan, 1], index=times)
    temp_cell = pd.Series([10, 25, 50, 25, np.nan], index=times)

    out = system.sapm(effective_irradiance, temp_cell)
Esempio n. 21
0
def test_PVSystem_ashraeiam():
    module_parameters = pd.Series({'b': 0.05})
    system = pvsystem.PVSystem(module_parameters=module_parameters)
    thetas = np.array([-90. , -67.5, -45. , -22.5,   0. ,  22.5,  45. ,  67.5,  89., 90. , np.nan])
    iam = system.ashraeiam(thetas)
    expected = np.array([        0,  0.9193437 ,  0.97928932,  0.99588039,  1.        ,
        0.99588039,  0.97928932,  0.9193437 ,         0, 0,  np.nan])
    assert_allclose(iam, expected, equal_nan=True)
Esempio n. 22
0
def test_PVSystem_physicaliam():
    module_parameters = pd.Series({'K': 4, 'L': 0.002, 'n': 1.526})
    system = pvsystem.PVSystem(module_parameters=module_parameters)
    thetas = np.array([-90. , -67.5, -45. , -22.5,   0. ,  22.5,  45. ,  67.5,  90. , np.nan])
    iam = system.physicaliam(thetas)
    expected = np.array([        0,  0.8893998 ,  0.98797788,  0.99926198,         1,
        0.99926198,  0.98797788,  0.8893998 ,         0, np.nan])
    assert_allclose(iam, expected, equal_nan=True)
Esempio n. 23
0
def test_PVSystem_localize___repr__():
    system = pvsystem.PVSystem(module='blah', inverter='blarg')
    localized_system = system.localize(latitude=32, longitude=-111)

    assert localized_system.__repr__() == (
        'LocalizedPVSystem with tilt:0 and' +
        ' azimuth: 180 with Module: blah and Inverter: blarg at ' +
        'Latitude: 32 and Longitude: -111')
Esempio n. 24
0
def test_PVSystem_ashraeiam():
    module_parameters = pd.Series({'b': 0.05})
    system = pvsystem.PVSystem(module_parameters=module_parameters)
    thetas = np.linspace(-90, 90, 9)
    iam = system.ashraeiam(thetas)
    expected = np.array([        nan,  0.9193437 ,  0.97928932,  0.99588039,  1.        ,
        0.99588039,  0.97928932,  0.9193437 ,         nan])
    assert_allclose(iam, expected, equal_nan=True)
Esempio n. 25
0
def test_PVSystem_localize_with_latlon():
    system = pvsystem.PVSystem(module='blah', inverter='blarg')
    localized_system = system.localize(latitude=32, longitude=-111)

    assert localized_system.module == 'blah'
    assert localized_system.inverter == 'blarg'
    assert localized_system.latitude == 32
    assert localized_system.longitude == -111
Esempio n. 26
0
def summer_power_tracking(summer_clearsky, albuquerque, array_parameters,
                          system_parameters):
    """Simulated power for a TRACKING PVSystem in Albuquerque"""
    array = pvsystem.Array(pvsystem.SingleAxisTrackerMount(),
                           **array_parameters)
    system = pvsystem.PVSystem(arrays=[array], **system_parameters)
    mc = modelchain.ModelChain(system, albuquerque)
    mc.run_model(summer_clearsky)
    return mc.results.ac
Esempio n. 27
0
def test_PVSystem_sapm(sapm_module_params, mocker):
    mocker.spy(pvsystem, 'sapm')
    system = pvsystem.PVSystem(module_parameters=sapm_module_params)
    effective_irradiance = 500
    temp_cell = 25
    out = system.sapm(effective_irradiance, temp_cell)
    pvsystem.sapm.assert_called_once_with(effective_irradiance, temp_cell,
                                          sapm_module_params)
    assert_allclose(out['p_mp'], 100, atol=100)
Esempio n. 28
0
def test_PVSystem_first_solar_spectral_loss(module_parameters, module_type,
                                            coefficients, mocker):
    mocker.spy(atmosphere, 'first_solar_spectral_correction')
    system = pvsystem.PVSystem(module_parameters=module_parameters)
    pw = 3
    airmass_absolute = 3
    out = system.first_solar_spectral_loss(pw, airmass_absolute)
    atmosphere.first_solar_spectral_correction.assert_called_once_with(
        pw, airmass_absolute, module_type, coefficients)
    assert_allclose(out, 1, atol=0.5)
Esempio n. 29
0
def test_PVSystem_snlinverter(sam_data):
    inverters = sam_data['cecinverter']
    testinv = 'ABB__MICRO_0_25_I_OUTD_US_208_208V__CEC_2014_'
    system = pvsystem.PVSystem(inverter=testinv,
                               inverter_parameters=inverters[testinv])
    vdcs = pd.Series(np.linspace(0,50,3))
    idcs = pd.Series(np.linspace(0,11,3))
    pdcs = idcs * vdcs

    pacs = system.snlinverter(vdcs, pdcs)
    assert_series_equal(pacs, pd.Series([-0.020000, 132.004308, 250.000000]))
Esempio n. 30
0
def test_PVSystem_scale_voltage_current_power():
    data = pd.DataFrame(
        np.array([[2, 1.5, 10, 8, 12, 0.5, 1.5]]),
        columns=['i_sc', 'i_mp', 'v_oc', 'v_mp', 'p_mp', 'i_x', 'i_xx'],
        index=[0])
    expected = pd.DataFrame(
        np.array([[6, 4.5, 20, 16, 72, 1.5, 4.5]]),
        columns=['i_sc', 'i_mp', 'v_oc', 'v_mp', 'p_mp', 'i_x', 'i_xx'],
        index=[0])
    system = pvsystem.PVSystem(modules_per_string=2, strings_per_inverter=3)
    out = system.scale_voltage_current_power(data)