Skip to content
Snippets Groups Projects
Commit 9b039e11 authored by Christoph von Oy's avatar Christoph von Oy
Browse files

Removed comp_ from identifiers

parent eb1047e0
No related branches found
No related tags found
No related merge requests found
Showing
with 52 additions and 51 deletions
Subproject commit 3519ec06eade34bf29da5f46877a3c7057e56edc
Subproject commit 18fddbcb6b99b9af1559c918f403c75e8b71801e
......@@ -11,19 +11,19 @@ def read_matrix(df):
for i in df.index:
matrix_row = []
for j in df.index:
matrix_row.append(df[df["comp_name"][j]][i])
matrix_row.append(df[df["name"][j]][i])
matrix.append(matrix_row)
return matrix
def read_components(df):
components = {}
for i in df.index:
components[df["comp_name"][i]] = i
components[df["name"][i]] = i
return components
def compare_components(comp_1, comp_2):
different = False
for column in ['comp_name', 'comp_type', 'model', 'min_size', 'max_size', 'current_size']:
for column in ['name', 'type', 'model', 'min_size', 'max_size', 'current_size']:
if comp_1[column] != comp_2[column]:
if not math.isnan(comp_1[column]) and not math.isnan(comp_2[column]):
different = True
......@@ -79,26 +79,27 @@ for dirpath, dirnames, filenames in os.walk(".\\input_files"):
file_contents = []
for matrix_file, sector in matrix_files:
df = pd.read_csv(os.path.join(dirpath, matrix_file))
df.rename(columns = {'comp_name': 'name', 'comp_type': 'type'}, inplace = True)
for i in df.index:
if df['comp_type'][i] in renamed_components:
df.loc[i, 'comp_type'] = renamed_components[df['comp_type'][i]]
if df['comp_type'][i] in consumption_components:
if df['type'][i] in renamed_components:
df.loc[i, 'type'] = renamed_components[df['type'][i]]
if df['type'][i] in consumption_components:
df.loc[i, 'model'] = ''
df.loc[i, 'min_size'] = ''
df.loc[i, 'max_size'] = ''
df.loc[i, 'current_size'] = ''
file_contents.append((df, read_matrix(df), read_components(df), sector))
all_components = pd.DataFrame(columns = ['comp_name', 'comp_type', 'model', 'min_size', 'max_size', 'current_size'])
all_connections = pd.DataFrame(columns = ['sector', 'comp_from', 'comp_to'])
all_components = pd.DataFrame(columns = ['name', 'type', 'model', 'min_size', 'max_size', 'current_size'])
all_connections = pd.DataFrame(columns = ['sector', 'from', 'to'])
for df, matrix, components, sector in file_contents:
for component in components:
if component not in all_components.loc[:]['comp_name']:
all_components.loc[component] = df.loc[components[component]][['comp_name', 'comp_type', 'model', 'min_size', 'max_size', 'current_size']]
if component not in all_components.loc[:]['name']:
all_components.loc[component] = df.loc[components[component]][['name', 'type', 'model', 'min_size', 'max_size', 'current_size']]
else:
if compare_components(all_components.loc[component], df.loc[components[component]][['comp_name', 'comp_type', 'model', 'min_size', 'max_size', 'current_size']]):
if compare_components(all_components.loc[component], df.loc[components[component]][['name', 'type', 'model', 'min_size', 'max_size', 'current_size']]):
raise KeyError
for connected_component in get_connected_components(matrix, components, component):
all_connections = pd.concat([all_connections, pd.Series({'sector': sector, 'comp_from': component, 'comp_to': connected_component}).to_frame().T], ignore_index = True)
all_connections = pd.concat([all_connections, pd.Series({'sector': sector, 'from': component, 'to': connected_component}).to_frame().T], ignore_index = True)
config = read_config(os.path.join(dirpath, "config.csv"))
changed_topologies.append(dirpath)
new_config = dict()
......@@ -117,65 +118,65 @@ for dirpath, dirnames, filenames in os.walk(".\\input_files"):
print(f"Config of topology {dirpath} has a variable electricity price, so be sure to add a price profile!")
else:
for i in all_components.index:
if all_components['comp_type'][i] == 'ElectricalGrid':
new_config[all_components['comp_name'][i] + '_price'] = value
if all_components['type'][i] == 'ElectricalGrid':
new_config[all_components['name'][i] + '_price'] = value
elif name == 'injection_price':
if config['injection_price_variable'] == 1:
print(f"Config of topology {dirpath} has a variable electricity injection price, so be sure to add a price profile!")
else:
for i in all_components.index:
if all_components['comp_type'][i] == 'ElectricalGrid':
new_config[all_components['comp_name'][i] + '_injection_price'] = value
if all_components['type'][i] == 'ElectricalGrid':
new_config[all_components['name'][i] + '_injection_price'] = value
elif name == 'gas_price':
if config['gas_price_variable'] == 1:
print(f"Config of topology {dirpath} has a variable gas price, so be sure to add a price profile!")
else:
for i in all_components.index:
if all_components['comp_type'][i] == 'GasGrid':
new_config[all_components['comp_name'][i] + '_price'] = value
if all_components['type'][i] == 'GasGrid':
new_config[all_components['name'][i] + '_price'] = value
elif name == 'injection_price_gas':
if config['injection_price_gas_variable'] == 1:
print(f"Config of topology {dirpath} has a variable gas injection price, so be sure to add a price profile!")
else:
for i in all_components.index:
if all_components['comp_type'][i] == 'GasGrid':
new_config[all_components['comp_name'][i] + '_injection_price'] = value
if all_components['type'][i] == 'GasGrid':
new_config[all_components['name'][i] + '_injection_price'] = value
elif name == 'heat_price':
if config['heat_price_variable'] == 1:
print(f"Config of topology {dirpath} has a variable heat price, so be sure to add a price profile!")
else:
for i in all_components.index:
if all_components['comp_type'][i] == 'HeatGrid':
new_config[all_components['comp_name'][i] + '_price'] = value
if all_components['type'][i] == 'HeatGrid':
new_config[all_components['name'][i] + '_price'] = value
elif name == 'injection_price_heat':
if config['injection_price_heat_variable'] == 1:
print(f"Config of topology {dirpath} has a variable heat injection price, so be sure to add a price profile!")
else:
for i in all_components.index:
if all_components['comp_type'][i] == 'HeatGrid':
new_config[all_components['comp_name'][i] + '_injection_price'] = value
if all_components['type'][i] == 'HeatGrid':
new_config[all_components['name'][i] + '_injection_price'] = value
elif name == 'cooling_price':
if config['cooling_price_variable'] == 1:
print(f"Config of topology {dirpath} has a variable cooling price, so be sure to add a price profile!")
else:
for i in all_components.index:
if all_components['comp_type'][i] == 'CoolingGrid':
new_config[all_components['comp_name'][i] + '_price'] = value
if all_components['type'][i] == 'CoolingGrid':
new_config[all_components['name'][i] + '_price'] = value
elif name == 'injection_price_cooling':
if config['injection_price_cooling_variable'] == 1:
print(f"Config of topology {dirpath} has a variable cooling injection price, so be sure to add a price profile!")
else:
for i in all_components.index:
if all_components['comp_type'][i] == 'CoolingGrid':
new_config[all_components['comp_name'][i] + '_injection_price'] = value
if all_components['type'][i] == 'CoolingGrid':
new_config[all_components['name'][i] + '_injection_price'] = value
elif name == 'elec_emission':
for i in all_components.index:
if all_components['comp_type'][i] == 'ElectricalGrid':
new_config[all_components['comp_name'][i] + '_emission'] = value
if all_components['type'][i] == 'ElectricalGrid':
new_config[all_components['name'][i] + '_emission'] = value
elif name == 'gas_emission':
for i in all_components.index:
if all_components['comp_type'][i] == 'GasGrid':
new_config[all_components['comp_name'][i] + '_emission'] = value
if all_components['type'][i] == 'GasGrid':
new_config[all_components['name'][i] + '_emission'] = value
else:
new_config[name] = value
all_components.to_csv(os.path.join(dirpath, "temp.csv"), index = False)
......
comp_name,comp_type,model,min_size,max_size,current_size
name,type,model,min_size,max_size,current_size
inv_pv_bat,Inverter,STP-7000TL-20,0,20,0
battery,LiionBattery,BAT1,0,6,6
grd,ElectricalGrid,GRD1,1000,1000,1000
......
sector,comp_from,comp_to
sector,from,to
electricity,inv_pv_bat,battery
electricity,inv_pv_bat,grd
electricity,inv_pv_bat,elec_cns
......
comp_name,comp_type,model,min_size,max_size,current_size
name,type,model,min_size,max_size,current_size
pv_roof,PVGenerator,PV2,6,6,6
inv_pv_bat,Inverter,STP-7000TL-20,0,20,0
battery,LiionBattery,BAT1,6,6,6
......
sector,comp_from,comp_to
sector,from,to
electricity,pv_roof,inv_pv_bat
electricity,inv_pv_bat,battery
electricity,inv_pv_bat,grd
......
comp_name,comp_type,model,min_size,max_size,current_size
name,type,model,min_size,max_size,current_size
pv_roof,PVGenerator,PV2,6,6,6
inv_pv_bat,Inverter,STP-7000TL-20,0,20,0
battery,LiionBattery,BAT1,6,6,6
......
sector,comp_from,comp_to
sector,from,to
electricity,pv_roof,inv_pv_bat
electricity,inv_pv_bat,battery
electricity,inv_pv_bat,grd
......
comp_name,comp_type,model,min_size,max_size,current_size
name,type,model,min_size,max_size,current_size
pv_roof,PVGenerator,PV2,6,6,6
inv_pv_bat,Inverter,STP-7000TL-20,0,20,0
battery,LiionBattery,BAT1,6,6,6
......
sector,comp_from,comp_to
sector,from,to
electricity,pv_roof,inv_pv_bat
electricity,inv_pv_bat,battery
electricity,inv_pv_bat,grd
......
comp_name,comp_type,model,min_size,max_size,current_size
name,type,model,min_size,max_size,current_size
grd,ElectricalGrid,GRD1,100000,100000,0
elec_cns,ElectricalConsumption,,,,
gas_boi,GasBoiler,BOI1,10,10,0
......
sector,comp_from,comp_to
sector,from,to
electricity,grd,elec_cns
gas,gas_grd,gas_boi
heat,water_tes,therm_cns
......
comp_name,comp_type,model,min_size,max_size,current_size
name,type,model,min_size,max_size,current_size
pv_roof,PVGenerator,PV2,10,10,0
inv_pv,BasicInverter,INVPV,10,10,0
grd,ElectricalGrid,GRD1,10000,10000,0
......
sector,comp_from,comp_to
sector,from,to
electricity,pv_roof,inv_pv
electricity,inv_pv,grd
electricity,inv_pv,elec_cns
......
comp_name,comp_type,model,min_size,max_size,current_size
name,type,model,min_size,max_size,current_size
pv_roof,PVGenerator,PV2,10,10,0
inv_pv,BasicInverter,INVPV,10,10,0
battery,LiionBattery,BAT1,10,10,0
......
sector,comp_from,comp_to
sector,from,to
electricity,pv_roof,inv_pv
electricity,inv_pv,grd
electricity,inv_pv,elec_cns
......
comp_name,comp_type,model,min_size,max_size,current_size
name,type,model,min_size,max_size,current_size
pv_roof,PVGenerator,PV2,10,10,0
inv_pv,BasicInverter,INVPV,10,10,0
battery,LiionBattery,BAT1,10,10,0
......
sector,comp_from,comp_to
sector,from,to
electricity,pv_roof,inv_pv
electricity,inv_pv,heat_pump
electricity,inv_pv,grd
......
comp_name,comp_type,model,min_size,max_size,current_size
name,type,model,min_size,max_size,current_size
pv_roof,PVGenerator,PV2,10,10,0
inv_pv,BasicInverter,INVPV,10,10,0
heat_pump,HeatPump,EHP1,10,10,0
......
sector,comp_from,comp_to
sector,from,to
electricity,pv_roof,inv_pv
electricity,inv_pv,heat_pump
electricity,inv_pv,grd
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment