Exemple #1
0
def test_run_model_from_effective_irradiance(sapm_dc_snl_ac_system, location,
                                             weather, total_irrad):
    data = weather.copy()
    data[['poa_global', 'poa_diffuse', 'poa_direct']] = total_irrad
    data['effective_irradiance'] = data['poa_global']
    mc = ModelChain(sapm_dc_snl_ac_system, location, aoi_model='no_loss',
                    spectral_model='no_loss')
    ac = mc.run_model_from_effective_irradiance(data).ac
    expected = pd.Series(np.array([149.280238, 96.678385]),
                         index=data.index)
    assert_series_equal(ac, expected)
Exemple #2
0
def PVlibwrapper(PV_instance, tmy, return_model_object=False):
    PV = PV_instance

    tmy.site = Location(tmy.lat, tmy.lon)

    cec_inverters = pvlib.pvsystem.retrieve_sam("cecinverter")
    cec_modules = pvlib.pvsystem.retrieve_sam("CECMod")

    # default: Jinko Solar Co Ltd JKM350M 72 V
    module = cec_modules[PV.module]

    # default: Huawei Technologies Co Ltd SUN2000 100KTL USH0 800V
    cec_inverter = cec_inverters[PV.inverter]

    temperature_model_parameters = TEMPERATURE_MODEL_PARAMETERS["sapm"][
        "open_rack_glass_glass"]

    if PV.tracking:
        system = SingleAxisTracker(
            axis_tilt=0,
            axis_azimuth=PV.azimuth,
            module_parameters=module,
            inverter_parameters=cec_inverter,
            temperature_model_parameters=temperature_model_parameters,
            strings_per_inverter=PV.strings_per_inverter,
            modules_per_string=PV.modules_per_string,
        )
        losses_model = "no_loss"
    else:
        system = PVSystem(
            surface_tilt=PV.tilt,
            surface_azimuth=PV.azimuth,
            module_parameters=module,
            inverter_parameters=cec_inverter,
            temperature_model_parameters=temperature_model_parameters,
            strings_per_inverter=PV.strings_per_inverter,
            modules_per_string=PV.modules_per_string,
        )
        losses_model = "pvwatts"

    total_module_power = PV.strings_per_inverter * PV.modules_per_string * module[
        "STC"]

    mc = ModelChain(
        system,
        tmy.site,
        aoi_model="ashrae",
        spectral_model="no_loss",
        losses_model=losses_model,
        transposition_model="perez",
    )

    if hasattr(PV, "bifacial_irradiance"):
        mc.run_model_from_effective_irradiance(PV.bifacial_irradiance)
        print()
        print()
        print(f"{PV.name} triggered run_from")
        print()
        print()
    else:
        mc.run_model(PVlibweather(tmy))
        print()
        print()
        print(f"{PV.name} triggered run_model")
        print()
        print()

    normalized_power = mc.ac / total_module_power
    scaled_power = normalized_power * PV.installed
    # reset index
    scaled_power.index = PV.state.index

    if return_model_object:
        return mc, scaled_power
    else:
        return scaled_power