Ejemplo n.º 1
0
 def convert(self):
     model_energy_unit = cfg.calculation_energy_unit
     model_time_step = cfg.cfgfile.get('case', 'time_step')
     if self.time_unit is not None:
         # if sales has a time_unit, then the unit is energy and must be converted to capacity
         self.values = util.unit_convert(self.values, unit_from_num=self.capacity_or_energy_unit,
                                         unit_from_den=self.time_unit, unit_to_num=model_energy_unit,
                                         unit_to_den=model_time_step)
     else:
         # if sales is a capacity unit, the model must convert the unit type to an energy unit for conversion ()
         self.values = util.unit_convert(self.values, unit_from_num=cfg.ureg.Quantity(self.capacity_or_energy_unit)
                                                                        * cfg.ureg.Quantity(model_time_step),
                                         unit_from_den=model_time_step,
                                         unit_to_num=model_energy_unit,
                                         unit_to_den=model_time_step)
 def convert_and_remap(self, unit_type, stock_unit):
     """convert service demand to stock unit for stocks defined as service demand"""
     if unit_type == 'service demand':
         self.remap(map_to='int_values',fill_timeseries=False)
         self.int_values = util.unit_convert(self.int_values, unit_from_num=self.unit, unit_to_num=stock_unit)
     else:
         raise ValueError("should not have called this function for this demand stock unit type")
Ejemplo n.º 3
0
 def convert(self):
     """
     return values from raw_values that are converted to units consistent with output units
     """
     if self.definition == 'absolute':
         if self.is_numerator_service == 1:
             # if the numerator is service, definition has to be flipped in order to make the numerator an energy unit
             self.values = 1 / self.raw_values
             numerator_unit = self.denominator_unit
             denominator_unit = self.numerator_unit
             self.flipped = True
         else:
             self.values = self.raw_values
             numerator_unit = self.numerator_unit
             denominator_unit = self.denominator_unit
             self.flipped = False
         
         self.values = util.unit_convert(self.values, unit_from_num=numerator_unit,
                                         unit_from_den=denominator_unit,
                                         unit_to_num=cfg.cfgfile.get('case', 'energy_unit'),
                                         unit_to_den=self.service_demand_unit)
         self.converted = True
     else:
         self.values = self.raw_values.copy()
         self.converted = False
Ejemplo n.º 4
0
    def convert_cost(self):
        """
        convert raw_values to model currency and energy
        """

        self.values = util.unit_convert(self.raw_values, unit_from_den=self.cost_denominator_unit,
                                        unit_to_den=self.unit_to)
        self.values = util.currency_convert(self.values, self.currency_id, self.currency_year_id)
Ejemplo n.º 5
0
 def convert(self):
     """
     convert values to model currency and capacity (energy_unit/time_step)
     """
     if self.values is not None:
         model_energy_unit = cfg.calculation_energy_unit
         model_time_step = cfg.cfgfile.get('case', 'time_step')
         if self.time_unit is not None:
             self.values = util.unit_convert(self.values, unit_from_num=self.capacity_or_energy_unit,
                                         unit_from_den=self.time_unit, unit_to_num=model_energy_unit,
                                         unit_to_den=model_time_step)
         else:
            self.values = util.unit_convert(self.values, unit_from_num=cfg.ureg.Quantity(self.capacity_or_energy_unit)
                                                                        * cfg.ureg.Quantity(model_time_step),
                                         unit_from_den = model_time_step,
                                         unit_to_num=model_energy_unit,
                                         unit_to_den=model_time_step)
                                         
Ejemplo n.º 6
0
 def convert(self):
     """
     convert raw_values to model currency and capacity (energy_unit/time_step)
     """
     model_energy_unit = cfg.cfgfile.get('case', 'energy_unit')
     model_time_step = cfg.cfgfile.get('case', 'time_step')
     if self.time_unit is not None:
         # if a cost has a time_unit, then the unit is energy and must be converted to capacity
         self.values = util.unit_convert(self.raw_values, unit_from_num=self.capacity_or_energy_unit,
                                         unit_from_den=self.time_unit, unit_to_num=model_energy_unit,
                                         unit_to_den=model_time_step)
     else:
         # if a cost is a capacity unit, the model must convert the unit type to an energy unit for conversion ()
         self.values = util.unit_convert(self.raw_values, unit_from_den=cfg.ureg.Quantity(self.capacity_or_energy_unit)
                                                                        * cfg.ureg.Quantity(model_time_step),
                                         unit_from_num=model_time_step,
                                         unit_to_den=model_energy_unit,
                                         unit_to_num=model_time_step)
Ejemplo n.º 7
0
 def convert(self):
     """
     return values from raw_values that are converted to units consistent with output units
     """
     if self.definition == 'absolute':
         self.values = util.unit_convert(self.raw_values,
                                         unit_from_num=self.input_unit, unit_to_num=self.output_unit)
         self.absolute = True
     else:
         self.values = self.raw_values.copy()
         self.absolute = False
    def convert(self):
        """
        return values from raw_values that are converted to units consistent with output units - energy and annual
        """
        if self.definition == 'absolute':
            if self.time_unit is None:
                self.time_unit = 'year'
            self.values = util.unit_convert(self.raw_values, unit_from_num=self.energy_unit,
                                            unit_from_den=self.time_unit,
                                            unit_to_num=cfg.calculation_energy_unit,
                                            unit_to_den='year')
            if self.demand_tech_unit_type == 'service demand':
                self.values = util.unit_convert(self.values, unit_from_num=self.unit,
                                                unit_to_num=self.service_demand_unit)
            self.absolute = True


        else:
            self.values = self.raw_values.copy()
            self.absolute = False
Ejemplo n.º 9
0
    def convert_cost(self):
        """
        convert raw_values to model currency and energy
        """

        self.values = util.unit_convert(
            self.raw_values,
            unit_from_den=self.cost_denominator_unit,
            unit_to_den=self.unit_to)
        self.values = util.currency_convert(self.values, self.currency_id,
                                            self.currency_year_id)
Ejemplo n.º 10
0
    def convert(self):
        """
        return values from raw_values that are converted to units consistent with output units - energy and annual
        """
        if self.definition == 'absolute':
            if self.time_unit is None:
                self.time_unit = 'year'
            self.values = util.unit_convert(self.raw_values, unit_from_num=self.energy_unit,
                                            unit_from_den=self.time_unit,
                                            unit_to_num=cfg.calculation_energy_unit,
                                            unit_to_den='year')
            if self.demand_tech_unit_type == 'service demand':
                self.values = util.unit_convert(self.values, unit_from_num=self.unit,
                                                unit_to_num=self.service_demand_unit)
            self.absolute = True


        else:
            self.values = self.raw_values.copy()
            self.absolute = False
 def convert_and_remap(self, unit_type, stock_unit):
     """convert service demand to stock unit for stocks defined as service demand"""
     if unit_type == 'service demand':
         self.remap(map_to='int_values', fill_timeseries=False)
         self.int_values = util.unit_convert(self.int_values,
                                             unit_from_num=self.unit,
                                             unit_to_num=stock_unit)
     else:
         raise ValueError(
             "should not have called this function for this demand stock unit type"
         )
Ejemplo n.º 12
0
 def convert(self):
     model_energy_unit = cfg.calculation_energy_unit
     model_time_step = cfg.cfgfile.get('case', 'time_step')
     if self.time_unit is not None:
         # if sales has a time_unit, then the unit is energy and must be converted to capacity
         self.values = util.unit_convert(
             self.values,
             unit_from_num=self.capacity_or_energy_unit,
             unit_from_den=self.time_unit,
             unit_to_num=model_energy_unit,
             unit_to_den=model_time_step)
     else:
         # if sales is a capacity unit, the model must convert the unit type to an energy unit for conversion ()
         self.values = util.unit_convert(
             self.values,
             unit_from_num=cfg.ureg.Quantity(self.capacity_or_energy_unit) *
             cfg.ureg.Quantity(model_time_step),
             unit_from_den=model_time_step,
             unit_to_num=model_energy_unit,
             unit_to_den=model_time_step)
Ejemplo n.º 13
0
 def convert(self):
     """
     return values from raw_values that are converted to units consistent with output units
     """
     if self.definition == 'absolute':
         self.values = util.unit_convert(self.raw_values,
                                         unit_from_num=self.input_unit, unit_to_num=self.output_unit)
         self.absolute = True
     else:
         self.values = self.raw_values.copy()
         self.absolute = False
Ejemplo n.º 14
0
 def convert(self):
     """
     convert raw_values to model currency and capacity (energy_unit/time_step)
     """
     model_energy_unit = cfg.calculation_energy_unit
     self.values = util.unit_convert(self.raw_values, unit_from_den=self.energy_unit,unit_to_den=model_energy_unit)
     if self.definition == 'absolute':
         self.values = util.currency_convert(self.values, self.currency_id, self.currency_year_id)
         self.absolute = True
     else:
         self.absolute = False
Ejemplo n.º 15
0
 def convert(self):
     """
     convert raw_values to model currency and capacity (energy_unit/time_step)
     """
     model_energy_unit = cfg.cfgfile.get('case', 'energy_unit')
     self.values = util.unit_convert(self.raw_values, unit_from_den=self.energy_unit,unit_to_den=model_energy_unit)
     if self.definition == 'absolute':
         self.values = util.currency_convert(self.values, self.currency_id, self.currency_year_id)
         self.absolute = True
     else:
         self.absolute = False
Ejemplo n.º 16
0
 def convert(self):
     """
     convert raw_values to model currency and capacity (energy_unit/time_step)
     """
     model_energy_unit = cfg.cfgfile.get('case', 'energy_unit')
     self.values = util.unit_convert(self.raw_values, unit_from_num=self.energy_unit,unit_to_num=model_energy_unit)
     if self.definition == 'absolute':
         self.values = util.currency_convert(self.values, self.currency_id, self.currency_year_id)
         self.absolute = True
     else:
         self.absolute = False
Ejemplo n.º 17
0
 def __init__(self, dispatch_feeders, dispatch_geography, dispatch_geographies, scenario):
     #TODO replace 1 with a config parameter
     for col, att in util.object_att_from_table('DispatchConfig', 1):
         setattr(self, col, att)
     self.node_config_dict = dict()
     for supply_node in util.sql_read_table('DispatchNodeConfig','supply_node_id',return_iterable=True):
         self.node_config_dict[supply_node] = DispatchNodeConfig(supply_node)
     self.set_dispatch_orders()
     self.dispatch_window_dict = dict(util.sql_read_table('DispatchWindows'))  
     self.curtailment_cost = util.unit_convert(0, unit_from_den='megawatt_hour',unit_to_den=cfg.calculation_energy_unit)
     self.unserved_capacity_cost = util.unit_convert(10000.0, unit_from_den='megawatt_hour',unit_to_den=cfg.calculation_energy_unit)
     self.dist_net_load_penalty = util.unit_convert(15000.0, unit_from_den='megawatt_hour',unit_to_den=cfg.calculation_energy_unit)
     # this bulk penalty is mostly for transmission
     self.bulk_net_load_penalty = util.unit_convert(5000.0, unit_from_den='megawatt_hour',unit_to_den=cfg.calculation_energy_unit)
     self.ld_upward_imbalance_penalty = util.unit_convert(150.0, unit_from_den='megawatt_hour',unit_to_den=cfg.calculation_energy_unit)
     self.ld_downward_imbalance_penalty = util.unit_convert(50.0, unit_from_den='megawatt_hour',unit_to_den=cfg.calculation_energy_unit)
     self.dispatch_feeders = dispatch_feeders
     self.feeders = [0] + dispatch_feeders
     self.dispatch_geography = dispatch_geography
     self.dispatch_geographies = dispatch_geographies
     self.stdout_detail = cfg.cfgfile.get('opt','stdout_detail')
     self.transmission = dispatch_transmission.DispatchTransmission(cfg.transmission_constraint_id, scenario)
     if self.stdout_detail == 'False':
         self.stdout_detail = False
     else:
         self.stdout_detail = True
     self.solve_kwargs = {"keepfiles": False, "tee": False}
Ejemplo n.º 18
0
 def convert(self):
     """
     convert raw_values to model currency and capacity (energy_unit/time_step)
     """
     model_energy_unit = cfg.calculation_energy_unit
     model_time_step = cfg.cfgfile.get('case', 'time_step')
     if hasattr(self,'time_unit') and self.time_unit is not None:
         # if a cost has a time_unit, then the unit is energy and must be converted to capacity
         self.values = util.unit_convert(self.raw_values, unit_from_den=self.capacity_or_energy_unit,
                                         unit_from_num=self.time_unit, unit_to_den=model_energy_unit,
                                         unit_to_num=model_time_step)
     else:
         # if a cost is a capacity unit, the model must convert the unit type to an energy unit for conversion ()
         self.values = util.unit_convert(self.raw_values, unit_from_den =cfg.ureg.Quantity(self.capacity_or_energy_unit)* cfg.ureg.Quantity(model_time_step),
                                     unit_from_num=model_time_step,
                                     unit_to_den=model_energy_unit,
                                     unit_to_num=model_time_step)
     if self.definition == 'absolute':
         self.values = util.currency_convert(self.values, self.currency_id, self.currency_year_id)
         self.absolute = True
     else:
         self.absolute = False
Ejemplo n.º 19
0
 def convert(self):
     """
     convert raw_values to model currency and capacity (energy_unit/time_step)
     """
     model_energy_unit = cfg.cfgfile.get('case', 'energy_unit')
     model_time_step = cfg.cfgfile.get('case', 'time_step')
     if hasattr(self,'time_unit') and self.time_unit is not None:
         # if a cost has a time_unit, then the unit is energy and must be converted to capacity
         self.values = util.unit_convert(self.raw_values, unit_from_den=self.capacity_or_energy_unit,
                                         unit_from_num=self.time_unit, unit_to_den=model_energy_unit,
                                         unit_to_num=model_time_step)
     else:
         # if a cost is a capacity unit, the model must convert the unit type to an energy unit for conversion ()
         self.values = util.unit_convert(self.raw_values, unit_from_den =cfg.ureg.Quantity(self.capacity_or_energy_unit)* cfg.ureg.Quantity(model_time_step),
                                     unit_from_num=model_time_step,
                                     unit_to_den=model_energy_unit,
                                     unit_to_num=model_time_step)
     if self.definition == 'absolute':
         self.values = util.currency_convert(self.values, self.currency_id, self.currency_year_id)
         self.absolute = True
     else:
         self.absolute = False
Ejemplo n.º 20
0
 def convert(self):
     """
     convert values to model currency and capacity (energy_unit/time_step)
     """
     if self.values is not None:
         model_energy_unit = cfg.calculation_energy_unit
         model_time_step = cfg.cfgfile.get('case', 'time_step')
         if self.time_unit is not None:
             self.values = util.unit_convert(
                 self.values,
                 unit_from_num=self.capacity_or_energy_unit,
                 unit_from_den=self.time_unit,
                 unit_to_num=model_energy_unit,
                 unit_to_den=model_time_step)
         else:
             self.values = util.unit_convert(
                 self.values,
                 unit_from_num=cfg.ureg.Quantity(
                     self.capacity_or_energy_unit) *
                 cfg.ureg.Quantity(model_time_step),
                 unit_from_den=model_time_step,
                 unit_to_num=model_energy_unit,
                 unit_to_den=model_time_step)
Ejemplo n.º 21
0
 def convert_cost(self):
     """
     convert raw_values to model currency and capacity (energy_unit/time_step)
     """
     if self.demand_tech_unit_type == 'service demand':
         if self.tech_time_unit is None:
             self.time_unit = 'year'
         self.values = util.unit_convert(self.raw_values, unit_from_num=self.tech_time_unit,
                                         unit_from_den=self.unit,
                                         unit_to_num=self.stock_time_unit, unit_to_den=self.service_demand_unit)
     else:
         self.values = copy.deepcopy(self.raw_values)
     if self.definition == 'absolute':
         self.values = util.currency_convert(self.values, self.currency_id, self.currency_year_id)
         self.absolute = True
     else:
         self.absolute = False
Ejemplo n.º 22
0
 def convert_cost(self):
     """
     convert raw_values to model currency and capacity (energy_unit/time_step)
     """
     if self.demand_tech_unit_type == 'service demand':
         if self.tech_time_unit is None:
             self.time_unit = 'year'
         self.values = util.unit_convert(self.raw_values, unit_from_num=self.tech_time_unit,
                                         unit_from_den=self.unit,
                                         unit_to_num=self.stock_time_unit, unit_to_den=self.service_demand_unit)
     else:
         self.values = copy.deepcopy(self.raw_values)
     if self.definition == 'absolute':
         self.values = util.currency_convert(self.values, self.currency_id, self.currency_year_id)
         self.absolute = True
     else:
         self.absolute = False
Ejemplo n.º 23
0
 def __init__(self, dispatch_feeders, dispatch_geography,
              dispatch_geographies, scenario):
     #TODO replace 1 with a config parameter
     for col, att in util.object_att_from_table('DispatchConfig', 1):
         setattr(self, col, att)
     self.node_config_dict = dict()
     for supply_node in util.sql_read_table('DispatchNodeConfig',
                                            'supply_node_id',
                                            return_iterable=True):
         self.node_config_dict[supply_node] = DispatchNodeConfig(
             supply_node)
     self.set_dispatch_orders()
     self.dispatch_window_dict = dict(
         util.sql_read_table('DispatchWindows'))
     self.curtailment_cost = util.unit_convert(
         0,
         unit_from_den='megawatt_hour',
         unit_to_den=cfg.calculation_energy_unit)
     self.unserved_capacity_cost = util.unit_convert(
         10000.0,
         unit_from_den='megawatt_hour',
         unit_to_den=cfg.calculation_energy_unit)
     self.dist_net_load_penalty = util.unit_convert(
         15000.0,
         unit_from_den='megawatt_hour',
         unit_to_den=cfg.calculation_energy_unit)
     # this bulk penalty is mostly for transmission
     self.bulk_net_load_penalty = util.unit_convert(
         5000.0,
         unit_from_den='megawatt_hour',
         unit_to_den=cfg.calculation_energy_unit)
     self.ld_upward_imbalance_penalty = util.unit_convert(
         150.0,
         unit_from_den='megawatt_hour',
         unit_to_den=cfg.calculation_energy_unit)
     self.ld_downward_imbalance_penalty = util.unit_convert(
         50.0,
         unit_from_den='megawatt_hour',
         unit_to_den=cfg.calculation_energy_unit)
     self.dispatch_feeders = dispatch_feeders
     self.feeders = [0] + dispatch_feeders
     self.dispatch_geography = dispatch_geography
     self.dispatch_geographies = dispatch_geographies
     self.stdout_detail = cfg.cfgfile.get('opt', 'stdout_detail')
     self.transmission = dispatch_transmission.DispatchTransmission(
         cfg.transmission_constraint_id, scenario)
     if self.stdout_detail == 'False':
         self.stdout_detail = False
     else:
         self.stdout_detail = True
     self.solve_kwargs = {"keepfiles": False, "tee": False}
Ejemplo n.º 24
0
 def convert(self):
     """
     return values from raw_values that are converted to units consistent with output units
     """
     if self.definition == 'absolute':
         if self.is_numerator_service == 1:
             # if the numerator is service, definition has to be flipped in order to make the numerator an energy unit
             self.values = 1 / self.raw_values
             numerator_unit = self.denominator_unit
             denominator_unit = self.numerator_unit
             self.flipped = True
         else:
             self.values = self.raw_values
             numerator_unit = self.numerator_unit
             denominator_unit = self.denominator_unit
             self.flipped = False
         self.values = util.unit_convert(self.values, unit_from_num=numerator_unit,
                                         unit_from_den=denominator_unit,
                                         unit_to_num=cfg.calculation_energy_unit,
                                         unit_to_den=self.service_demand_unit)
         self.absolute = True
     else:
         self.values = self.raw_values.copy()
         self.absolute = False
Ejemplo n.º 25
0
 def convert(self):
     if self.input_type == 'total':
         self.values = util.unit_convert(self.raw_values, unit_from_num=self.unit,
                                         unit_to_num=self.unit_to)
     else:
         self.values = self.raw_values
Ejemplo n.º 26
0
 def set_max_min_flex_loads(self, distribution_load):
     self.flex_load_penalty = util.unit_convert(0.1, unit_from_den='megawatt_hour',unit_to_den=cfg.calculation_energy_unit)
     native_slice = distribution_load.xs(2, level='timeshift_type')
     groups = native_slice.groupby(level=['period', self.dispatch_geography, 'dispatch_feeder'])
     self.max_flex_load = self._timeseries_to_dict(groups.max())
     self.min_flex_load = self._timeseries_to_dict(groups.min())
Ejemplo n.º 27
0
 def convert_units(self):
     if hasattr(self,'energy_unit'):
         unit_factor = util.unit_convert(1, unit_from_den=self.energy_unit, unit_to_den=cfg.calculation_energy_unit)
         self.values /= unit_factor
 def convert(self):
     """converts energy units to model energy units and service units to subsector service demand units"""
     self.values = util.unit_convert(self.raw_values, unit_from_num=self.energy_unit,
                                     unit_from_den=self.denominator_unit,
                                     unit_to_num=cfg.calculation_energy_unit,
                                     unit_to_den=self.service_demand_unit)