Skip to content

Commit

Permalink
Merge pull request #361 from PaulTalbot-INL/min_pcts
Browse files Browse the repository at this point in the history
minimums as percents
  • Loading branch information
dylanjm authored Jun 7, 2024
2 parents 4f08499 + b38b9f8 commit 9a40121
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 53 deletions.
30 changes: 14 additions & 16 deletions src/Components.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,11 +386,8 @@ def get_input_specs(cls):
capfactor = vp_factory.make_input_specs('capacity_factor', descr=descr, allowed=['ARMA', 'CSV'])
specs.addSub(capfactor)

descr = r"""provides the minimum value at which this component can act, in units of the indicated resource. """
descr = r"""provides the minimum value at which this component can act, as a percentage of the installed capacity. """
minn = vp_factory.make_input_specs('minimum', descr=descr)
minn.addParam('resource', param_type=InputTypes.StringType,
descr=r"""indicates the resource that defines the minimum activity level for this component,
as with the component's capacity.""")
specs.addSub(minn)

return specs
Expand All @@ -409,7 +406,6 @@ def __init__(self, **kwargs):
self._crossrefs = defaultdict(dict) # crossrefs objects needed (e.g. armas, etc), as {attr: {tag, name, obj})
self._dispatchable = None # independent, dependent, or fixed?
self._minimum = None # lowest interaction level, if dispatchable
self._minimum_var = None # limiting variable for minimum
self.ramp_limit = None # limiting change of production in a time step
self.ramp_freq = None # time steps required between production ramping events
self._function_method_map = {} # maps things that call functions to the method within the function that needs calling
Expand All @@ -435,8 +431,6 @@ def read_input(self, specs, mode, comp_name):
self._set_valued_param(name, comp_name, item, mode)
if name == '_capacity':
self._capacity_var = item.parameterValues.get('resource', None)
elif item.getName() == 'minimum':
self._minimum_var = item.parameterValues.get('resource', None)
# finalize some values
resources = set(list(self.get_inputs()) + list(self.get_outputs()))
## capacity: if "variable" is None and only one resource in interactions, then that must be it
Expand All @@ -445,12 +439,6 @@ def read_input(self, specs, mode, comp_name):
self._capacity_var = list(resources)[0]
else:
self.raiseAnError(IOError, f'Component "{comp_name}": If multiple resources are active, "capacity" requires a "resource" specified!')
## minimum: basically the same as capacity, functionally
if self._minimum and self._minimum_var is None:
if len(resources) == 1:
self._minimum_var = list(resources)[0]
else:
self.raiseAnError(IOError, f'Component "{comp_name}": If multiple resources are active, "minimum" requires a "resource" specified!')

def _set_valued_param(self, name, comp, spec, mode):
"""
Expand Down Expand Up @@ -523,11 +511,21 @@ def get_minimum(self, meta, raw=False):
"""
if raw:
return self._minimum
meta['request'] = {self._minimum_var: None}
cap_var = self.get_capacity_var()
if self._minimum is None:
evaluated = {self._capacity_var: 0.0}
evaluated = {cap_var: 0.0}
else:
evaluated, meta = self._minimum.evaluate(meta, target_var=self._minimum_var)
meta['request'] = {cap_var: None}
evaluated, meta = self._minimum.evaluate(meta, target_var=cap_var)
# check that min value is acceptable [0,1]
# TODO it would be better to be able to check this before run-time, but we don't have a method
# in place to check e.g. ARMA,
value = evaluated[cap_var]
if not (0 <= value <= 1):
self.raiseAnError(ValueError, f'While calculating minimum operating level for component "{self.tag}", ' +
f'an invalid percent was provided/calculated ({value}). Minimums should be between 0 and 1, inclusive.')
# convert percentage to real value
evaluated[cap_var] = self.get_capacity(meta)[0][cap_var] * value
return evaluated, meta

def get_sqrt_RTE(self):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
RAVEN_sample_ID,Time,_ROM_Cluster,Year,scaling,Dispatch__AR__production__electricity,Dispatch__Coal__production__electricity,Dispatch__e_grid__production__electricity,Dispatch__sink__production__electricity,Signal,ProbabilityWeight-Coal_capacity,prefix,ProbabilityWeight,PointProbability
0,0.0,0,10,1.0,1000.0,1908.60640151,-250.0,-2658.60640151,-2.51444698396e-10,1.0,1,1.0,0.004
0,0.1,0,10,1.0,1000.0,1908.60640151,-250.0,-2658.60640151,0.0627905192528,1.0,1,1.0,0.004
0,0.2,0,10,1.0,1000.0,1908.60640151,-250.0,-2658.60640151,0.125333233263,1.0,1,1.0,0.004
0,0.3,0,10,1.0,1000.0,1908.60640151,-250.0,-2658.60640151,0.187381314259,1.0,1,1.0,0.004
0,0.4,0,10,1.0,1000.0,1908.60640151,-250.0,-2658.60640151,0.248689886814,1.0,1,1.0,0.004
0,0.5,0,10,1.0,1000.0,1908.60640151,-250.0,-2658.60640151,0.309016994,1.0,1,1.0,0.004
0,0.6,0,10,1.0,1000.0,1908.60640151,-250.0,-2658.60640151,0.368124552286,1.0,1,1.0,0.004
0,0.7,0,10,1.0,1000.0,1908.60640151,-250.0,-2658.60640151,0.425779291144,1.0,1,1.0,0.004
0,0.8,0,10,1.0,1000.0,1908.60640151,-250.0,-2658.60640151,0.481753673658,1.0,1,1.0,0.004
0,0.9,0,10,1.0,1000.0,1908.60640151,-250.0,-2658.60640151,0.535826794514,1.0,1,1.0,0.004
0,1.0,0,10,1.0,1000.0,1908.60640151,-250.0,-2658.60640151,0.587785251806,1.0,1,1.0,0.004
0,1.1,0,10,1.0,1000.0,1908.60640151,-250.0,-2658.60640151,0.637423989243,1.0,1,1.0,0.004
0,1.2,0,10,1.0,1000.0,1908.60640151,-250.0,-2658.60640151,0.684547105404,1.0,1,1.0,0.004
0,1.3,0,10,1.0,1000.0,1908.60640151,-250.0,-2658.60640151,0.728968626879,1.0,1,1.0,0.004
0,1.4,0,10,1.0,1000.0,1908.60640151,-250.0,-2658.60640151,0.770513242217,1.0,1,1.0,0.004
0,1.5,0,10,1.0,1000.0,1908.60640151,-250.0,-2658.60640151,0.809016993801,1.0,1,1.0,0.004
0,1.6,0,10,1.0,1000.0,1908.60640151,-250.0,-2658.60640151,0.844327924914,1.0,1,1.0,0.004
0,1.7,0,10,1.0,1000.0,1908.60640151,-250.0,-2658.60640151,0.876306679443,1.0,1,1.0,0.004
0,1.8,0,10,1.0,1000.0,1908.60640151,-250.0,-2658.60640151,0.904827051854,1.0,1,1.0,0.004
0,1.9,0,10,1.0,1000.0,1908.60640151,-250.0,-2658.60640151,0.929776485266,1.0,1,1.0,0.004
0,2.0,0,10,1.0,1000.0,1908.60640151,-250.0,-2658.60640151,0.951056515665,1.0,1,1.0,0.004

This file was deleted.

24 changes: 10 additions & 14 deletions tests/integration_tests/mechanics/min_demand/heron_input.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,17 @@
<author>E. Worsham</author>
<created>2020-10-15</created>
<description>
Tests having a minimum level for a demand component.
Tests having a minimum level for a demand component. A couple generating components
with no economics have two sinks to send to. The grid sink has a minimum load, but
is less profitable, while the general sink is more profitable. The dispatch should
show the grid sink taking the minimum value and the general sink taking the rest.
</description>
<classesTested>HERON</classesTested>
</TestInfo>

<Case name="Sizing">
<mode>sweep</mode>
<debug/>
<num_arma_samples>3</num_arma_samples>
<time_discretization>
<time_variable>Time</time_variable>
Expand Down Expand Up @@ -58,25 +62,18 @@
<fixed_value>-2500</fixed_value>
</capacity>
<minimum>
<ARMA variable="Signal">flex</ARMA>
<multiplier>-100</multiplier>
<fixed_value>0.1</fixed_value>
</minimum>
</demands>
<economics>
<lifetime>1</lifetime>
<CashFlow name="e_sales" type="repeating" taxable="False" inflation="none">
<driver>
<Function method="electric_source">transfers</Function>
<activity>electricity</activity>
</driver>
<reference_price>
<fixed_value>1.0</fixed_value>
<fixed_value>-1.0</fixed_value>
</reference_price>
<reference_driver>
<fixed_value>1</fixed_value>
</reference_driver>
<scaling_factor_x>
<fixed_value>1</fixed_value>
</scaling_factor_x>
</CashFlow>
</economics>
</Component>
Expand All @@ -91,10 +88,10 @@
<lifetime>3</lifetime>
<CashFlow name="e_sales" type="repeating" taxable="False" inflation="none">
<driver>
<Function method="electric_source">transfers</Function>
<activity>electricity</activity>
</driver>
<reference_price>
<fixed_value>10.0</fixed_value>
<fixed_value>-10.0</fixed_value>
</reference_price>
</CashFlow>
</economics>
Expand All @@ -103,7 +100,6 @@

<DataGenerators>
<ARMA name='flex' variable="Signal">%HERON_DATA%/TSA/Sine/arma.pk</ARMA>
<Function name="transfers">transfers.py</Function>
</DataGenerators>
</HERON>

Expand Down
2 changes: 1 addition & 1 deletion tests/integration_tests/mechanics/min_demand/tests
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# prereq = SineArma
[./csv]
type = OrderedCSV
output = 'Sizing_o/sweep.csv'
output = 'Sizing_o/dispatch_print.csv'
zero_threshold = 1e-5
rel_err = 1e-6
[../]
Expand Down
19 changes: 0 additions & 19 deletions tests/integration_tests/mechanics/min_demand/transfers.py

This file was deleted.

0 comments on commit 9a40121

Please sign in to comment.