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
def ramp_constraints(scenario, epsilon=1e-3):
    """Identify time periods in which generators have binding ramp constraints.

    :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.

    .. note:: The first time period will always return ``False`` for each column.
    """
    _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
 def test_bad_value(self):
     with self.assertRaises(ValueError):
         _check_epsilon(-0.001)
 def test_zero(self):
     _check_epsilon(0)
 def test_bad_type(self):
     with self.assertRaises(TypeError):
         _check_epsilon("0.001")
 def test_good_int_value(self):
     _check_epsilon(1)
 def test_good_float_value(self):
     _check_epsilon(5e-4)
Beispiel #8
0
def test_check_epsilon():
    _check_epsilon(1e-2)
    _check_epsilon(0.001)
Beispiel #9
0
def test_check_epsilon_argument_value():
    with pytest.raises(ValueError):
        _check_epsilon(-0.00001)
Beispiel #10
0
def test_check_epsilon_argument_type():
    arg = ("1e-3", [0.0001])
    for a in arg:
        with pytest.raises(TypeError):
            _check_epsilon()