Esempio n. 1
0
def pmin_constraints(scenario, epsilon=1e-3):
    """Identify time periods in which generators are at minimum power.

    :param powersimdata.scenario.scenario.Scenario scenario: scenario instance.
    :param float epsilon: allowable 'fuzz' for whether constraint is binding.
    :return: (*pandas.DataFrame*) -- Boolean data frame of same shape as PG.
    """
    _check_scenario_is_in_analyze_state(scenario)
    _check_epsilon(epsilon)

    pg = scenario.state.get_pg()
    grid = scenario.state.get_grid()
    pmin = grid.plant["Pmin"]
    binding_pmin_constraints = (pg - pmin) <= epsilon

    return binding_pmin_constraints
Esempio n. 2
0
def ramp_constraints(scenario, epsilon=1e-3):
    """Identify time periods in which generators have binding ramp constraints.
    .. note:: The first time period will always return *False* for each column.

    :param powersimdata.scenario.scenario.Scenario scenario: scenario instance.
    :param float epsilon: allowable 'fuzz' for whether constraint is binding.
    :return: (*pandas.DataFrame*) -- Boolean dataframe of same shape as PG.
    """
    _check_scenario_is_in_analyze_state(scenario)
    _check_epsilon(epsilon)

    pg = scenario.state.get_pg()
    grid = scenario.state.get_grid()
    ramp = grid.plant["ramp_30"]
    diff = pg.diff(axis=0)
    binding_ramp_constraints = (ramp * 2 - abs(diff)) <= epsilon

    return binding_ramp_constraints
Esempio n. 3
0
def test_check_epsilon():
    _check_epsilon(1e-2)
    _check_epsilon(0.001)
Esempio n. 4
0
def test_check_epsilon_argument_value():
    with pytest.raises(ValueError):
        _check_epsilon(-0.00001)
Esempio n. 5
0
def test_check_epsilon_argument_type():
    arg = ("1e-3", [0.0001])
    for a in arg:
        with pytest.raises(TypeError):
            _check_epsilon()
Esempio n. 6
0
 def test_bad_value(self):
     with self.assertRaises(ValueError):
         _check_epsilon(-0.001)
Esempio n. 7
0
 def test_bad_type(self):
     with self.assertRaises(TypeError):
         _check_epsilon("0.001")
Esempio n. 8
0
 def test_zero(self):
     _check_epsilon(0)
Esempio n. 9
0
 def test_good_int_value(self):
     _check_epsilon(1)
Esempio n. 10
0
 def test_good_float_value(self):
     _check_epsilon(5e-4)