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")
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
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)
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)
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)
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
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)
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" )
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(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
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
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
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}
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
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
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)
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
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}
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
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
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())
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)