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