Exemple #1
0
def test_reopt_sizing_pvsam(solar_resource):
    import PySAM.Utilityrate5 as ur
    sys = pvsam.default("FlatPlatePVCommercial")
    fin = ur.from_existing(sys, "FlatPlatePVCommercial")
    bt = stbt.from_existing(sys, "GenericBatteryCommercial")

    sys.SolarResource.solar_resource_file = solar_resource
    bt.Load.crit_load = [0] * 8760
    post = sys.Reopt_size_battery_post()

    assert('Scenario' in post['reopt_post'])
    assert(post['reopt_post']['Scenario']['Site']['latitude'] == pytest.approx(33.6, 0.1))
Exemple #2
0
@author: brtietz
"""

import PySAM.Battery as battery_model
import PySAM.Pvsamv1 as pvsam
from PySAM.PySSC import *

weather_file = sys.argv[1]  # .csv weather file with tmy format

analysis_period = 1  # years
days_in_year = 365

# Create the detailed residential pv model using PySAM's defaults
system_model = pvsam.default("FlatPlatePVResidential")
# Create the battery model based on the PV defaults
battery = battery_model.from_existing(system_model,
                                      "GenericBatteryResidential")

# Default model does not include a weather file, so set that based on the command line path
system_model.SolarResource.solar_resource_file = weather_file

# 24 hours of dispatch data, duplicated for each day. Would need to extend daily_dispatch for subhourly
lifetime_dispatch = []
daily_dispatch = [
    0, 0, 0, 0, 0, 0, 0, -2, -2, -2, -2, -2, -1, 0, 0, 0, 0, 2, 4, 2, 2, 0, 0,
    0
]  # kW, negative is charging
# Extend daily lists for entire analysis period
for i in range(0, days_in_year * analysis_period):
    lifetime_dispatch.extend(daily_dispatch)

# Change from default dispatch to custom dispatch