Ejemplo n.º 1
0
def test_liion_dc_connected_dc_sizing():
    model = batt.default("GenericBatteryCommercial")
    model.BatteryCell.batt_chem = 1
    model.Inverter.inverter_model = 0
    model.Inverter.inv_snl_eff_cec = 50
    model.BatterySystem.batt_ac_or_dc = 0
    BatteryTools.battery_model_sizing(model, 100, 400, 500)
    assert (model.BatterySystem.batt_computed_bank_capacity == pytest.approx(
        400, 1))
    assert (model.BatterySystem.batt_power_discharge_max_kwdc == pytest.approx(
        100, 1))
    assert (model.BatterySystem.batt_power_charge_max_kwdc == pytest.approx(
        100, 1))
    assert (model.BatterySystem.batt_power_discharge_max_kwac == pytest.approx(
        49, 1))
    assert (model.BatterySystem.batt_power_charge_max_kwac == pytest.approx(
        204, 1))
    assert (model.BatterySystem.batt_current_discharge_max == pytest.approx(
        200, 1))
    assert (model.BatterySystem.batt_current_charge_max == pytest.approx(
        200, 1))

    model.Inverter.inv_snl_eff_cec = 100
    model.BatterySystem.batt_ac_or_dc = 0
    BatteryTools.battery_model_sizing(model, 100, 400, 500)
    assert (model.BatterySystem.batt_computed_bank_capacity == pytest.approx(
        400, 1))
    assert (model.BatterySystem.batt_power_discharge_max_kwdc == pytest.approx(
        100, 1))
    assert (model.BatterySystem.batt_power_charge_max_kwdc == pytest.approx(
        100, 1))
    assert (model.BatterySystem.batt_power_discharge_max_kwac == pytest.approx(
        98, 1))
    assert (model.BatterySystem.batt_power_charge_max_kwac == pytest.approx(
        102, 1))
Ejemplo n.º 2
0
def test_leadacid():
    model = batt.default("GenericBatteryCommercial")
    model.BatteryCell.batt_chem = 0
    assert (model.BatterySystem.batt_computed_bank_capacity != pytest.approx(
        100, .5))
    assert (model.BatterySystem.batt_power_charge_max_kwdc != pytest.approx(
        50, 0.5))

    BatteryTools.battery_model_sizing(model, 100, 400, 500)
    assert (model.BatterySystem.batt_computed_strings == 261)
    assert (model.BatterySystem.batt_computed_series == 139)
    assert (model.BatterySystem.batt_computed_bank_capacity == pytest.approx(
        417, 1))
    assert (model.BatterySystem.batt_power_charge_max_kwdc == pytest.approx(
        96.29, 1))
Ejemplo n.º 3
0
def test_liion_ac_connected_ac_sizing():
    model = batt.default("GenericBatteryCommercial")
    model.BatteryCell.batt_chem = 1
    model.BatterySystem.batt_ac_or_dc = 1  # ac
    BatteryTools.battery_model_sizing(model, 100, 400, 500)
    assert (model.BatterySystem.batt_computed_bank_capacity == pytest.approx(
        417, 1))
    assert (model.BatterySystem.batt_power_discharge_max_kwdc == pytest.approx(
        104, 1))
    assert (model.BatterySystem.batt_power_charge_max_kwdc == pytest.approx(
        96, 1))
    assert (model.BatterySystem.batt_power_discharge_max_kwac == pytest.approx(
        100, 1))
    assert (model.BatterySystem.batt_power_charge_max_kwac == pytest.approx(
        100, 1))
    assert (model.BatterySystem.batt_current_discharge_max == pytest.approx(
        208, 1))
    assert (model.BatterySystem.batt_current_charge_max == pytest.approx(
        192, 1))
Ejemplo n.º 4
0
def test_battery_model_change_chemistry():
    model = batt.default("GenericBatterySingleOwner")
    original_capacity = model.value('batt_computed_bank_capacity')
    original_power = model.BatterySystem.batt_power_discharge_max_kwac

    BatteryTools.battery_model_change_chemistry(model, 'leadacid')

    params_new = battstfl.default('leadacid').export()
    cell_params = params_new['ParamsCell']
    pack_params = params_new['ParamsPack']

    assert (model.value('batt_computed_bank_capacity') == pytest.approx(
        original_capacity, 0.1))
    assert (model.value('batt_power_discharge_max_kwac') == pytest.approx(
        original_power, 0.1))
    assert (model.BatteryCell.batt_chem == cell_params['chem'])
    assert (model.BatteryCell.batt_calendar_choice ==
            cell_params['calendar_choice'])
    assert (model.BatteryCell.batt_Vnom_default == cell_params['Vnom_default'])
    assert (
        model.BatteryCell.LeadAcid_q10_computed == cell_params['leadacid_q10'])
    assert (model.BatteryCell.batt_Cp == pack_params['Cp'])

    BatteryTools.battery_model_change_chemistry(model, 'nmcgraphite')

    params_new = battstfl.default('nmcgraphite').export()
    cell_params = params_new['ParamsCell']
    pack_params = params_new['ParamsPack']

    assert (model.value('batt_computed_bank_capacity') == pytest.approx(
        original_capacity, 0.1))
    assert (model.value('batt_power_discharge_max_kwac') == pytest.approx(
        original_power, 0.1))
    assert (model.BatteryCell.batt_C_rate == cell_params['C_rate'])
    assert (model.BatteryCell.batt_calendar_choice ==
            cell_params['calendar_choice'])
    assert (model.BatteryCell.batt_Vexp == cell_params['Vexp'])
    assert (model.BatteryCell.batt_Cp == pack_params['Cp'])
Ejemplo n.º 5
0
Additional financial models, inputs, and outputs can be found at https://nrel-pysam.readthedocs.io/en/master/modules/Battery.html

Most recently tested against PySAM 2.2.3

@author: brtietz
"""

import PySAM.Battery as battery_model

analysis_period = 1  # years
steps_in_year = 8760  # currently hours in year, multiply this for subhourly tests (example * 12 for 5 minute tests)
days_in_year = 365

# Create the model using PySAM's defaults
battery = battery_model.default("GenericBatterySingleOwner")

# Set up inputs needed by the model.
battery.BatteryCell.batt_room_temperature_celsius = [20] * (steps_in_year * analysis_period)  # degrees C, room temperature. Would normally come from weather file

# 24 hours of data to duplicate for the test. Would need to add data here for subhourly
lifetime_generation = []
lifetime_dispatch = []
daily_generation = [0, 0, 0, 0, 0, 0, 0, 200, 400, 600, 800, 1000, 1000, 1000, 1000, 800, 600, 400, 200, 0, 0, 0, 0, 0]  # kW
daily_dispatch = [0, 0, 0, 0, 0, 0, 0, -200, -400, -600, -800, -1000, -1000, 0, 0, 200, 400, 600, 800, 1000, 1000, 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_generation.extend(daily_generation)
    lifetime_dispatch.extend(daily_dispatch)