예제 #1
0
 def document_built_assets(self, cnxn, modelrun_id):
     ''' document the installation of all assets, that were scheduled and built during a modelrun in the "ISL_O_...." tables '''
     start_year = self.start_year
     sqote = "'"
     for gen_asset in self.generation_asset_itter:
         if gen_asset.scheduled_in > 0 and gen_asset.installation_date < 100000000:
             theSQL = 'INSERT INTO "ISL_O_BuiltAssets_Generation"(modelrun_id, installed_by_year, submodel, network, region, asset_index, capacity, asset_name, scheduled_in, asset_type) VALUES ( \
             ' + str(modelrun_id) + ', ' + str(
                 gen_asset.installation_date) + ', ' + sqote + str(
                     gen_asset.submodel) + sqote + ', ' + sqote + str(
                         gen_asset.dn) + sqote + ', \
             ' + str(gen_asset.region) + ', ' + sqote + str(
                             gen_asset.id) + sqote + ', ' + str(
                                 gen_asset.maxcap) + ', ' + sqote + str(
                                     gen_asset.asset_name) + sqote + ', \
             ' + sqote + str(gen_asset.scheduled_in
                             ) + sqote + ', ' + sqote + str(
                                 gen_asset.asset_type) + sqote + ')'
             ESQL.execute_SQL(theSQL, [], [], cnxn)
     for arc_obj in self.arc_itter:
         if arc_obj.scheduled_in > 0 and arc_obj.installation_date < 100000000:
             theSQL = 'INSERT INTO "ISL_O_BuiltAssets_Transmission"(modelrun_id, installed_by_year, submodel, network, origin, destination, capacity, asset_id, asset_name, scheduled_in) VALUES ( \
             ' + str(modelrun_id) + ', ' + str(
                 arc_obj.installation_date) + ', ' + sqote + str(
                     arc_obj.submodel) + sqote + ', ' + sqote + str(
                         arc_obj.dn) + sqote + ', \
             ' + sqote + str(arc_obj.origin) + sqote + ', ' + sqote + str(
                             arc_obj.destination) + sqote + ', ' + str(
                                 arc_obj.maxcap) + ', ' + sqote + str(
                                     arc_obj.id) + sqote + ', \
             ' + sqote + str(arc_obj.asset_name
                             ) + sqote + ', ' + sqote + str(
                                 arc_obj.scheduled_in) + sqote + ')'
             ESQL.execute_SQL(theSQL, [], [], cnxn)
예제 #2
0
def transport_demand(submodel, regions, year, global_scenario,
                     local_strategies, cnxn):
    # demand for transport is estimated by summing rail and road usage
    (origin, destination) = regions
    #modelrun_id = local_strategies['Transport'].input_submodelrun_id
    theSQL = 'SELECT "demand_trips" FROM "TR_LU_RoadDemandsByGOR" WHERE scenario_id = ' + str(
        global_scenario.id) + ' AND year = ' + str(year) + '\
             AND gor_1 = ' + str(origin) + 'AND gor_2 = ' + str(destination)
    try:
        [(road_demand, )] = ESQL.execute_SQL(theSQL, [], [], cnxn)
    except:
        #print 'error? - no road demand found:' + str(origin) + ', ' + str(destination)
        pass
    theSQL = 'SELECT "demand_trips" FROM "TR_LU_RailDemandByGOR" WHERE scenario_id = ' + str(
        global_scenario.id) + ' AND year = ' + str(year) + '\
             AND gor_1 = ' + str(origin) + 'AND gor_2 = ' + str(destination)
    try:
        [(rail_demand, )] = ESQL.execute_SQL(theSQL, [], [], cnxn)
    except:
        #print 'error? - no rail demand found:' + str(origin) + ', ' + str(destination)
        pass
    try:
        #print str(origin) + '->' + str(destination) + ': rail demand - ' + str(rail_demand) + ': road demand - ' + str(road_demand)
        return int(road_demand) + int(rail_demand)  #
    except:
        return None
예제 #3
0
 def add_distribution_networks(self, tablename, modelrun_id, cnxn,
                               modelrun_params):
     arc_id = 1  # arc_id is a unique id issued in IS
     # load all the arcs from the database for this modelrun
     arcs = ESQL.execute_SQL(
         'SELECT * FROM ' + tablename + ' WHERE modelrun_id = ' +
         str(modelrun_id) + 'order by id', [], [], cnxn)
     # loop through the list of arcs and add them to the distribution_network for each submodel
     for new_arc in arcs:
         [
             tableid, cORt, submodel, dn, origin, destination, asset_name,
             maxcap, cap_ceiling, instdate, instd, maxlt, capex, rc, epi,
             com_type, modelrun_id
         ] = new_arc
         # if submodel doesn't exist yet then add it to the distribution_networks (e.g. Energy, Trasport)
         if submodel not in self.distribution_networks:
             self.distribution_networks[submodel] = {}
         # if a distribution network doesn't exist yet then add it to the distribution_networks (e.g. Electricity, Gas, Road, Rail)
         if dn not in self.distribution_networks[
                 submodel]:  # if this network does not yet exist: create network
             self.distribution_networks[submodel][dn] = DistributionNetwork(
                 cORt, submodel, dn)
             #self.distributionnetworks[submodel].append(dn)
         # create and add arc to respective network
         # now add the arc to IS, unless, it is an optional asset in a no-build modelrun
         if modelrun_params.no_build == 1 and instdate == 100000000:  # checking whether we are in a no-build modelrun and whether it is an optional asset
             pass
         else:  # in all other cases add the asset to IS
             arc = Arc(arc_id, cORt, submodel, dn, origin, destination,
                       asset_name, maxcap, cap_ceiling, instdate, instd,
                       maxlt, capex, rc, epi, com_type)
             self.distribution_networks[submodel][dn].transmission_arcs[
                 arc.id] = arc
             self.arc_itter.append(arc)
             arc_id += 1
예제 #4
0
def heat_demand(submodel, region, year, global_scenario, local_strategies,
                cnxn):
    #modelrun_id = local_strategies['Energy'].input_submodelrun_id
    theSQL = 'SELECT SUM(Peak_Gas) FROM "EE_LU_GasDemandByGOR" WHERE year = ' + str(
        year) + ' AND "GOR" = ' + str(region) + ' AND scenario_id=' + str(
            global_scenario.id)
    [(gas_demand, )
     ] = ESQL.execute_SQL(theSQL, [], [],
                          cnxn)  # gas demand is measured in GWhrs/day
    demand = 365 * gas_demand  # in GWhrs/year
    return int(demand)
예제 #5
0
 def generate_ExtNet_edge(self, year, global_strategy, global_scenario,
                          modelrun_id, cnxn):
     planned_capacity, planned_and_possible_capacity = self.get_future_capacities(
         year, global_strategy)
     (fc, rc, epi, com_fac) = self.metric(global_scenario)
     # distribution network edge
     dn_edge_values = [('origin_val',self.ExtNet_origin), ('destination_val',self.ExtNet_destination), ('curr_capacity_val',self.current_capacity),\
                            ('planned_capacity_val',planned_capacity), ('planned_and_possible_capacity_val',planned_and_possible_capacity),\
                            ('fixcost_val',fc), ('runcost_val',rc), ('epi_val',epi),\
                            ('comfort_factor_val',com_fac), ('cap_ceiling_val',self.cap_ceiling), ('edge_name_val', self.id), ('modelrun_id_val', modelrun_id), ('year_val', year), ('asset_type_val', "") ]
     ESQL.execute_SQL_script('SQLscripts\ESQL_INSERT_ISL_I_ExtNet_Edge.sql',
                             [], dn_edge_values, cnxn)
     # interdependencies
     causing_arc_source = self.ExtNet_origin
     causing_arc_sink = self.ExtNet_destination
     for interdep in self.interdependencies:
         (intdp_type, aff_asset_type, aff_subm, aff_netw_or_keys, aff_reg1,
          aff_reg2, aff_ass_name, conversion_factor, max_cap,
          affCorT) = interdep
         if intdp_type == 'dir':  # direct interdependency:= affects a ks-demand
             if affCorT == 'C':
                 affected_arc_source = 'C_D_' + aff_subm + '_' + aff_netw_or_keys + '_' + aff_reg1
             elif affCorT == 'T':
                 affected_arc_source = 'T_D_' + aff_subm + '_' + aff_netw_or_keys + '_' + aff_reg1 + '_' + aff_reg2
             affected_arc_sink = 'T'
         elif intdp_type == 'syn' or intdp_type == 'mult':  # synergy or multiuse
             if aff_asset_type == 'gen':
                 affected_arc_source = 'C_G_' + aff_subm + '_' + aff_netw_or_keys + '_' + aff_reg1 + '_' + aff_ass_name
                 affected_arc_sink = 'C_N_' + aff_subm + '_' + aff_netw_or_keys + '_' + aff_reg1
             elif aff_asset_type == 'dist':
                 affected_arc_source = affCorT + '_N_' + aff_subm + '_' + aff_netw_or_keys + '_' + aff_reg1 + '_' + aff_ass_name
                 affected_arc_sink = affCorT + '_N_' + aff_subm + '_' + aff_netw_or_keys + '_' + aff_reg2
             max_cap = int(max_cap)
         # add interdependency caused by generation asset
         interdependency_values = (intdp_type, causing_arc_source,
                                   causing_arc_sink, affected_arc_source,
                                   affected_arc_sink, conversion_factor,
                                   max_cap, modelrun_id, year)
         ESQL.execute_SQL_script(
             'SQLscripts\ESQL_INSERT_ISL_I_ExtNet_Interdependency.sql', [],
             [('interdependency_values', interdependency_values)], cnxn)
예제 #6
0
def localtransport_demand(submodel, region, year, global_scenario,
                          local_strategies, cnxn):
    # demand for transport is estimated by summing rail and road usage
    #modelrun_id = local_strategies['Transport'].input_submodelrun_id
    theSQL = 'SELECT "demand_trips" FROM "TR_LU_RoadDemandsByGOR" WHERE scenario_id = ' + str(
        global_scenario.id) + ' AND year = ' + str(year) + '\
             AND gor_1 = ' + str(region) + 'AND gor_2 = ' + str(region)
    try:
        [(road_demand, ), (x, )] = ESQL.execute_SQL(theSQL, [], [], cnxn)
    except:
        print 'error? - no local road demand found:' + str(region)
    theSQL = 'SELECT "demand_trips" FROM "TR_LU_RailDemandByGOR" WHERE scenario_id = ' + str(
        global_scenario.id) + ' AND year = ' + str(year) + '\
             AND gor_1 = ' + str(region) + 'AND gor_2 = ' + str(region)
    try:
        [(rail_demand, ), (x, )] = ESQL.execute_SQL(theSQL, [], [], cnxn)
    except:
        print 'error? - no local rail demand found:' + str(region)
    try:
        return int(road_demand) + int(rail_demand)  #
    except:
        return 0
예제 #7
0
 def add_regions(self, tablename, modelrun_id, cnxn):
     regions = ESQL.execute_SQL(
         'SELECT submodel, regionname FROM "ISL_I_NetworkRegions" WHERE modelrun_id = '
         + str(modelrun_id) + 'order by id', [], [], cnxn)
     for new_region in regions:
         [submodel, name] = new_region
         if submodel not in self.spatial_network:
             self.spatial_network[submodel] = {}
         self.spatial_network[submodel][str(name)] = SpatialNode(name)
     for submodel in self.spatial_network:
         self.region_itter[submodel] = [
             self.spatial_network[submodel][region]
             for region in self.spatial_network[submodel]
         ]
예제 #8
0
 def add_interdependencies(self, tablename, modelrun_id, cnxn):
     new_interdependencies = ESQL.execute_SQL(
         "select * from " + tablename + ' WHERE modelrun_id = ' +
         str(modelrun_id) + 'order by id', [], [], cnxn)
     for new_interdependency in new_interdependencies:
         [
             id, intdp_type, caus_subm, caus_netw, caus_ass_type,
             caus_ass_reg1, caus_ass_reg2, caus_ass_name, aff_asset_type,
             aff_subm, aff_netw_or_keys, conversion_factor, aff_reg1,
             aff_reg2, aff_ass_name, max_cap, modelrun_id
         ] = new_interdependency
         #TODO - Use a more permanent solution. This try/except is for the no_build strategy
         # it is necessary to catch errors from interdependencies that don't have an option to meet demand
         try:
             if intdp_type == 'dir':  # find type of keyservice: Commodity or Transport
                 affCorT = self.key_services[aff_netw_or_keys].kstype
             else:  # find type of submodel: Commodity or Transport
                 affCorT = self.distribution_networks[aff_subm][
                     aff_netw_or_keys].dntype
             if aff_asset_type == 'gen':
                 aff_ass_name_in_IS = [
                     gen_asset.id
                     for gen_asset in self.generation_asset_itter
                     if gen_asset.asset_name == aff_ass_name
                 ][0]
             elif aff_asset_type == 'dist':
                 aff_ass_name_in_IS = [
                     arc.id for arc in self.arc_itter
                     if arc.asset_name == aff_ass_name
                 ][0]
             else:
                 aff_ass_name_in_IS = None
             interdependency = (intdp_type, aff_asset_type, aff_subm,
                                aff_netw_or_keys, aff_reg1, aff_reg2,
                                aff_ass_name_in_IS, conversion_factor,
                                max_cap, affCorT)
             if caus_ass_type == 'gen':  # commodity generation asset causes the interdependency
                 gen_asset = [
                     gen_asset for gen_asset in self.generation_asset_itter
                     if gen_asset.asset_name == caus_ass_name
                 ][0]
                 gen_asset.interdependencies.append(interdependency)
             elif caus_ass_type == 'dist':  # transmission arc interdependency
                 arc = [
                     arc for arc in self.arc_itter
                     if arc.asset_name == caus_ass_name
                 ][0]
                 arc.interdependencies.append(interdependency)
         except:
             pass
예제 #9
0
 def generate_edges_for_ExtNet(self, IS, year, global_strategy,
                               global_scenario, local_strategies,
                               modelrun_id, cnxn):
     # SOURCE EDGE : S -> GA
     source_edge_values = [('origin_val', 'S'), ('destination_val',self.ExtNet_identifier), ('curr_capacity_val',__INF__),\
                            ('planned_capacity_val',__INF__), ('planned_and_possible_capacity_val',__INF__),\
                            ('fixcost_val',0), ('runcost_val',0), ('epi_val',0),\
                            ('comfort_factor_val',0), ('cap_ceiling_val',1), ('edge_name_val', ''), ('modelrun_id_val', modelrun_id), ('year_val', year), ('asset_type_val', "")]
     ESQL.execute_SQL_script('SQLscripts\ESQL_INSERT_ISL_I_ExtNet_Edge.sql',
                             [], source_edge_values, cnxn)
     planned_capacity, planned_and_possible_capacity = self.get_future_capacities(
         year, global_strategy)
     (fc, rc, epi, com_fac) = self.metric(global_scenario)
     # GENERATION EDGE : GA -> spatial_node
     spatial_node = 'C_N_' + self.submodel + '_' + self.dn + '_' + self.region
     generation_edge_values = [('origin_val',self.ExtNet_identifier), ('destination_val',spatial_node), ('curr_capacity_val',self.current_capacity),\
                            ('planned_capacity_val',planned_capacity), ('planned_and_possible_capacity_val', planned_and_possible_capacity),\
                            ('fixcost_val',fc), ('runcost_val',rc), ('epi_val',epi),\
                            ('comfort_factor_val',com_fac), ('cap_ceiling_val',self.cap_ceiling), ('edge_name_val', self.id),\
                            ('modelrun_id_val', modelrun_id), ('year_val', year), ('asset_type_val', "'" + str(self.asset_type) + "'")]
     ESQL.execute_SQL_script('SQLscripts\ESQL_INSERT_ISL_I_ExtNet_Edge.sql',
                             [], generation_edge_values, cnxn)
     # INTERDEPENDENCIES
     causing_arc_source = self.ExtNet_identifier
     causing_arc_sink = spatial_node
     for interdep in self.interdependencies:
         (intdp_type, aff_type, aff_subm, aff_netw_or_keys, aff_reg1,
          aff_reg2, aff_ass_name, conversion_factor, max_cap,
          affCorT) = interdep
         if intdp_type == 'dir':  # direct interdependency:= affects a ks-demand
             if affCorT == 'C':
                 affected_arc_source = 'C_D_' + aff_subm + '_' + aff_netw_or_keys + '_' + aff_reg1
             elif affCorT == 'T':
                 affected_arc_source = 'T_D_' + aff_subm + '_' + aff_netw_or_keys + '_' + aff_reg1 + '_' + aff_reg2
             affected_arc_sink = 'T'
         elif intdp_type == 'syn' or intdp_type == 'mult':  # synergy or multiuse := affects a generation (C only) or a distribution (C or T) asset
             if aff_type == 'gen':
                 affected_arc_source = 'C_G_' + aff_subm + '_' + aff_netw_or_keys + '_' + aff_reg1 + '_' + aff_ass_name
                 affected_arc_sink = 'C_N_' + aff_subm + '_' + aff_netw_or_keys + '_' + aff_reg1
             elif aff_type == 'dist':
                 if affCorT == 'Transport':
                     CorT = 'T'
                 elif affCorT == 'Commodity':
                     CorT = 'C'
                 affected_arc_source = CorT + '_N_' + aff_subm + '_' + aff_netw_or_keys + '_' + aff_reg1 + '_' + aff_ass_name
                 affected_arc_sink = CorT + '_N_' + aff_subm + '_' + aff_netw_or_keys + '_' + aff_reg2
         # add interdependency caused by generation asset
         interdependency_values = (intdp_type, causing_arc_source,
                                   causing_arc_sink, affected_arc_source,
                                   affected_arc_sink, conversion_factor,
                                   max_cap, modelrun_id, year)
         ESQL.execute_SQL_script(
             'SQLscripts\ESQL_INSERT_ISL_I_ExtNet_Interdependency.sql', [],
             [('interdependency_values', interdependency_values)], cnxn)
예제 #10
0
 def add_keyservices(self, tablename, modelrun_id, cnxn):
     keyservices = ESQL.execute_SQL(
         "select * from " + tablename + ' WHERE modelrun_id = ' +
         str(modelrun_id) + 'order by id', [], [], cnxn)
     for new_keyservice in keyservices:
         [
             table_id, ks, kstype, supply_network, runcost, epi, comf_name,
             submodel, modelrun_id
         ] = new_keyservice
         if ks in self.key_services:
             self.key_services[ks].list_of_supply_networks[
                 supply_network] = (runcost, epi, comf_name)
         else:
             keyservice_object = KeyService(ks, kstype, submodel)
             self.key_services[ks] = keyservice_object
             self.key_services[ks].list_of_supply_networks[
                 supply_network] = (runcost, epi, comf_name)
예제 #11
0
def import_aq_database(opts, force=False):

    # try:

    exec_sql = ExecuteSQL.ExecuteSQL(opts.db_type, opts.db_host, opts.db_user,
                                     opts.db_pass, opts.db_name)

    create_db_directories(opts.aq_db_path, opts.aq_db_name, force)
    db_ini_filename = generate_ini(opts.aq_db_path, opts.aq_db_name,
                                   opts.aq_engine, opts.aq_loader)

    generate_base_desc(
        exec_sql, opts.aq_db_name,
        opts.aq_db_path + '/' + opts.aq_db_name + '/base_struct/base.aqb')
    export_data(exec_sql,
                opts.aq_db_path + '/' + opts.aq_db_name + '/data_orga/tables/')

    loader.load_data(opts.aq_tools, opts.aq_db_name)  # FIXME
예제 #12
0
 def add_generation_assets(self, tablename, modelrun_id, cnxn,
                           modelrun_params):
     asset_id = 1  # asset_id is a unique id issued in IS
     theSQL = "SELECT dn, capex, instduration, maxlifetime, maxcap, rampspeed, runcostperunit, instdate, asset_name, epi, comtype, submodel, cap_ceiling, region, asset_type FROM " + tablename + ' WHERE modelrun_id = ' + str(
         modelrun_id) + ' order by id'
     gen_assets = ESQL.execute_SQL(theSQL, [], [], cnxn)
     for new_ga in gen_assets:
         [
             dn, capex, instd, maxlt, maxcap, rs, rc, instdate, asset_name,
             epi, com_type, submodel, cap_ceiling, region, asset_type
         ] = new_ga
         if modelrun_params.no_build == 1 and instdate == 100000000:  # checking whether we are in a no-build modelrun and whether it is an optional asset
             pass
         else:  # in all other cases add the asset to IS
             asset_object = GenerationAsset(asset_id, submodel, dn, region,
                                            asset_name, instd, maxlt,
                                            instdate, maxcap, cap_ceiling,
                                            rs, capex, rc, epi, com_type,
                                            asset_type)
             self.spatial_network[submodel][str(region)].generation_assets[
                 asset_object.id] = asset_object
             self.generation_asset_itter.append(asset_object)
             asset_id += 1
예제 #13
0
 def generate_edges_for_ExtNet(self, IS, year, global_strategy,
                               global_scenario, local_strategies,
                               modelrun_id, cnxn):
     if self.kstype == 'C':
         for region in IS.region_itter[self.submodel]:
             demand = self.derive_demand(self.submodel, region.name, year,
                                         global_scenario, local_strategies,
                                         cnxn)
             forecast_demand = self.derive_demand(
                 self.submodel, region.name,
                 year + global_strategy.planning_horizon, global_scenario,
                 local_strategies, cnxn)
             if (demand != None) and (forecast_demand != None):
                 dem_ident = str(self.kstype + '_D_' + self.submodel + '_' +
                                 self.name + '_' + region.name)
                 demand_edge_values = [('origin_val',dem_ident), ('destination_val','T'), ('curr_capacity_val',demand),\
                                ('planned_capacity_val',forecast_demand), ('planned_and_possible_capacity_val',forecast_demand),\
                                ('fixcost_val',0), ('runcost_val',0), ('epi_val',0),\
                                ('comfort_factor_val',0), ('cap_ceiling_val',1), ('edge_name_val', ''), ('modelrun_id_val', modelrun_id), ('year_val', year), ('asset_type_val', "")]
                 ESQL.execute_SQL_script(
                     'SQLscripts\ESQL_INSERT_ISL_I_ExtNet_Edge.sql', [],
                     demand_edge_values, cnxn)
                 for dn in self.list_of_supply_networks:  # for every supplying network add edge to demand
                     sup_node = str('C_N_' + self.submodel + '_' + dn +
                                    '_' + region.name + '_0')
                     (rc, epi, name) = self.list_of_supply_networks[dn]
                     fc = 0
                     exec 'com_fac = global_scenario.' + name + '_comfactor'
                     supply_edge_values = [('origin_val',sup_node), ('destination_val',dem_ident), ('curr_capacity_val',__INF__),\
                                ('planned_capacity_val',__INF__), ('planned_and_possible_capacity_val',__INF__),\
                                ('fixcost_val',fc), ('runcost_val',rc), ('epi_val',epi),\
                                ('comfort_factor_val',com_fac), ('cap_ceiling_val',1), ('edge_name_val', ''), ('modelrun_id_val', modelrun_id), ('year_val', year), ('asset_type_val', "")]
                     ESQL.execute_SQL_script(
                         'SQLscripts\ESQL_INSERT_ISL_I_ExtNet_Edge.sql', [],
                         supply_edge_values, cnxn)
     elif self.kstype == 'T':
         for origin in IS.region_itter[self.submodel]:
             for destination in IS.region_itter[self.submodel]:
                 if origin == destination:
                     continue
                 demand = self.derive_demand(
                     self.submodel, (origin.name, destination.name), year,
                     global_scenario, local_strategies, cnxn)
                 forecast_demand = self.derive_demand(
                     self.submodel, (origin.name, destination.name),
                     year + global_strategy.planning_horizon,
                     global_scenario, local_strategies, cnxn)
                 if (demand != None) and (forecast_demand != None):
                     dem_node = str(self.kstype) + '_D_' + str(
                         self.submodel) + '_' + (self.name) + '_' + str(
                             origin.name) + '_' + str(destination.name)
                     demand_edge_values = [('origin_val',dem_node), ('destination_val','T'), ('curr_capacity_val',demand),\
                            ('planned_capacity_val',forecast_demand), ('planned_and_possible_capacity_val',forecast_demand),\
                            ('fixcost_val',0), ('runcost_val',0), ('epi_val',0),\
                            ('comfort_factor_val',0), ('cap_ceiling_val',1), ('edge_name_val', ''), ('modelrun_id_val', modelrun_id), ('year_val', year), ('asset_type_val', "")]
                     ESQL.execute_SQL_script(
                         'SQLscripts\ESQL_INSERT_ISL_I_ExtNet_Edge.sql', [],
                         demand_edge_values, cnxn)
                     sup_node = 'T_G_' + dem_node[4:]
                     source_edge_values = [('origin_val','S'), ('destination_val',sup_node), ('curr_capacity_val',__INF__),\
                            ('planned_capacity_val',__INF__), ('planned_and_possible_capacity_val',__INF__),\
                            ('fixcost_val',0), ('runcost_val',0), ('epi_val',0),\
                            ('comfort_factor_val',0), ('cap_ceiling_val',1), ('edge_name_val', ''), ('modelrun_id_val', modelrun_id), ('year_val', year), ('asset_type_val', "")]
                     ESQL.execute_SQL_script(
                         'SQLscripts\ESQL_INSERT_ISL_I_ExtNet_Edge.sql', [],
                         source_edge_values, cnxn)
                     for dn in self.list_of_supply_networks:  # for every supplying network add edge to demand
                         (rc, epi, name) = self.list_of_supply_networks[dn]
                         fc = 0
                         exec 'com_fac = global_scenario.' + name + '_comfactor'
                         edge_destination = str('T_N_' +
                                                str(self.submodel) + '_' +
                                                dn + '_' + origin.name)
                         generation_edge_values = [('origin_val',sup_node), ('destination_val',edge_destination), ('curr_capacity_val',__INF__),\
                            ('planned_capacity_val',__INF__), ('planned_and_possible_capacity_val',__INF__),\
                            ('fixcost_val',0), ('runcost_val',0), ('epi_val',0),\
                            ('comfort_factor_val',0), ('cap_ceiling_val',1), ('edge_name_val', ''), ('modelrun_id_val', modelrun_id), ('year_val', year), ('asset_type_val', "")]
                         ESQL.execute_SQL_script(
                             'SQLscripts\ESQL_INSERT_ISL_I_ExtNet_Edge.sql',
                             [], generation_edge_values, cnxn)
                         edge_origin = str('T_N_' + self.submodel + '_' +
                                           dn + '_' + destination.name +
                                           '_0')
                         supply_edge_values = [('origin_val',edge_origin), ('destination_val',dem_node), ('curr_capacity_val',__INF__),\
                            ('planned_capacity_val',__INF__), ('planned_and_possible_capacity_val',__INF__),\
                            ('fixcost_val',fc), ('runcost_val',rc), ('epi_val',epi),\
                            ('comfort_factor_val',com_fac), ('cap_ceiling_val',1), ('edge_name_val', ''), ('modelrun_id_val', modelrun_id), ('year_val', year), ('asset_type_val', "")]
                         ESQL.execute_SQL_script(
                             'SQLscripts\ESQL_INSERT_ISL_I_ExtNet_Edge.sql',
                             [], supply_edge_values, cnxn)