diff --git a/examples/one-producer/run_sts.py b/examples/one-producer/run_sts.py index e5b8acd..14d1e8c 100644 --- a/examples/one-producer/run_sts.py +++ b/examples/one-producer/run_sts.py @@ -67,7 +67,6 @@ def main(filepath, outputpath, plots=True, solver='gurobi', mode='economic'): # modify either in code or in the config file settings.economics.source_c_inv = [0.] # no investment costs for sources - settings.temperatures.supply = 90 model_sets = tt.sets.create(mat) model = tt.single_timestep.model( @@ -110,7 +109,6 @@ def main(filepath, outputpath, plots=True, solver='gurobi', mode='economic'): f.savefig(os.path.join(outputpath, 'district_optimal.svg'), bbox_inches='tight') - if __name__ == '__main__': main(filepath=os.path.join(DATAPATH), outputpath=os.path.join(OUTPUTPATH), plots=PLOTS, solver=SOLVER, mode='economic') diff --git a/examples/synthetic-network/convert_npy_to_parquet.py b/examples/synthetic-network/convert_npy_to_parquet.py deleted file mode 100644 index ffc3ac9..0000000 --- a/examples/synthetic-network/convert_npy_to_parquet.py +++ /dev/null @@ -1,19 +0,0 @@ -import numpy - -# read in all .npy files in the subdirectory data -a_i = numpy.load('data/A_i.npy', allow_pickle=True) -a_p = numpy.load('data/A_p.npy', allow_pickle=True) -a_c = numpy.load('data/A_c.npy', allow_pickle=True) -l_i = numpy.load('data/L_i.npy', allow_pickle=True) -q_c = numpy.load('data/Q_c.npy', allow_pickle=True) -position = numpy.load('data/rel_positions.npy', allow_pickle=True) - -# save as parquet files -import pandas as pd - -pd.DataFrame(a_i).to_parquet('data/A_i.parquet') -pd.DataFrame(a_p).to_parquet('data/A_p.parquet') -pd.DataFrame(a_c).to_parquet('data/A_c.parquet') -pd.DataFrame(l_i).to_parquet('data/L_i.parquet') -pd.DataFrame(q_c).T.to_parquet('data/Q_c.parquet') -pd.DataFrame(position).to_parquet('data/rel_positions.parquet') diff --git a/examples/synthetic-network/data/A_c.npy b/examples/synthetic-network/data/A_c.npy deleted file mode 100644 index 5f3b1df..0000000 Binary files a/examples/synthetic-network/data/A_c.npy and /dev/null differ diff --git a/examples/synthetic-network/data/A_i.npy b/examples/synthetic-network/data/A_i.npy deleted file mode 100644 index 4d06ee3..0000000 Binary files a/examples/synthetic-network/data/A_i.npy and /dev/null differ diff --git a/examples/synthetic-network/data/A_p.npy b/examples/synthetic-network/data/A_p.npy deleted file mode 100644 index 67ff8bd..0000000 Binary files a/examples/synthetic-network/data/A_p.npy and /dev/null differ diff --git a/examples/synthetic-network/data/Q_c.npy b/examples/synthetic-network/data/Q_c.npy deleted file mode 100644 index 372cea8..0000000 Binary files a/examples/synthetic-network/data/Q_c.npy and /dev/null differ diff --git a/examples/synthetic-network/data/config.yaml b/examples/synthetic-network/data/config.yaml index 763409b..aeb60f9 100644 --- a/examples/synthetic-network/data/config.yaml +++ b/examples/synthetic-network/data/config.yaml @@ -25,12 +25,10 @@ solver: time_limit: 10000 economics: - source_flh: [2500] # h/y source_c_inv: [0] # Investment costs for each source source_c_irr: [0.08] # Interest rate for each source source_lifetime: [40.] # years for source investments source_price: [80e-3] # Price for heat production at supply in €/kW - consumer_flh: 2500 # h/y heat_price: 120e-3 # Selling Price for heat in €/kW pipes_c_irr: 0.08 # Interest rate pipes_lifetime: 40. # years for piping investments diff --git a/examples/synthetic-network/data/flh_consumer.parquet b/examples/synthetic-network/data/flh_consumer.parquet new file mode 100644 index 0000000..ddda28a Binary files /dev/null and b/examples/synthetic-network/data/flh_consumer.parquet differ diff --git a/examples/synthetic-network/data/flh_source.parquet b/examples/synthetic-network/data/flh_source.parquet new file mode 100644 index 0000000..c76684f Binary files /dev/null and b/examples/synthetic-network/data/flh_source.parquet differ diff --git a/examples/synthetic-network/data/l_i.npy b/examples/synthetic-network/data/l_i.npy deleted file mode 100644 index e061513..0000000 Binary files a/examples/synthetic-network/data/l_i.npy and /dev/null differ diff --git a/examples/synthetic-network/data/rel_positions.npy b/examples/synthetic-network/data/rel_positions.npy deleted file mode 100644 index 32d2493..0000000 Binary files a/examples/synthetic-network/data/rel_positions.npy and /dev/null differ diff --git a/examples/synthetic-network/run_sts.py b/examples/synthetic-network/run_sts.py index 821b264..f58268f 100644 --- a/examples/synthetic-network/run_sts.py +++ b/examples/synthetic-network/run_sts.py @@ -67,8 +67,6 @@ def main(filepath, outputpath, plots=True, solver='gurobi', mode='forced'): settings = tt.settings.load(os.path.join(filepath, 'config.yaml')) print(settings) settings.economics.source_c_inv = [0.] # no investment costs for sources - settings.economics.source_flh = [2500.] # full load hours - settings.economics.consumers_flh = [2500.] # full load hours model_sets = tt.sets.create(mat) model = tt.single_timestep.model( @@ -118,11 +116,6 @@ def main(filepath, outputpath, plots=True, solver='gurobi', mode='forced'): network = tt.postprocessing.to_networkx_graph(opt_mats) - print(len(network.edges)) - print(mat['a_i'].shape[1]) - print(len(network.nodes)) - print(mat['a_i'].shape[0]) - fig, ax = plt.subplots(figsize=(20, 20), layout='constrained') node_colors = [] node_label = [] @@ -133,7 +126,7 @@ def main(filepath, outputpath, plots=True, solver='gurobi', mode='forced'): for node in network.nodes(data=True): node_colors.append(node[1]['color']) - node_label.append(node[1]['type']) + node_label.append(node[1]['type_']) node_id[node[0]] = str(node[0]) node_pos.append([node[1]['x'], node[1]['y']]) @@ -145,13 +138,14 @@ def main(filepath, outputpath, plots=True, solver='gurobi', mode='forced'): edgelist=network.edges, width=edges_p, ax=ax, label=edges_label, alpha=0.3, edge_color='grey') nx.draw_networkx_nodes(network, pos=node_pos, node_color=node_colors, - ax=ax, label=node) + ax=ax, label=node_label) nx.draw_networkx_labels(network, pos=node_pos, labels=node_id, ax=ax)# nx.draw_networkx_edge_labels(network, pos=node_pos, edge_labels=edges_label, ax=ax) + adjancency = nx.to_numpy_array(network, weight=None) + print(adjancency) fig.show() - plt.pause(120) fig.savefig(os.path.join(outputpath, 'networkx.svg'), bbox_inches='tight') # close all figures plt.close('all') diff --git a/topotherm/postprocessing.py b/topotherm/postprocessing.py index a88b5e1..9e6c291 100644 --- a/topotherm/postprocessing.py +++ b/topotherm/postprocessing.py @@ -358,11 +358,11 @@ def to_networkx_graph(matrices): for q in range(matrices['a_c'].shape[0]): x, y = matrices['position'][q, 0], matrices['position'][q, 1] if ges[q] == 1: - G.add_node(q, color='Red', type='consumer', x=x, y=y) + G.add_node(q, color='Red', type_='consumer', x=x, y=y) elif ges[q] == 0: - G.add_node(q, color='Green', type='internal', x=x, y=y) + G.add_node(q, color='Green', type_='internal', x=x, y=y) if ges[q] <= -1: - G.add_node(q, color='Orange', type='source', x=x, y=y) + G.add_node(q, color='Orange', type_='source', x=x, y=y) # edge_labels = dict() # Add the edges to the graph @@ -370,7 +370,7 @@ def to_networkx_graph(matrices): s = (np.where(matrices['a_i'][:, k] == 1)[0][0], np.where(matrices['a_i'][:, k] == -1)[0][0]) G.add_edge(s[0], s[1], - weight=matrices['l_i'][k], + weight=matrices['l_i'][k].item(), d=matrices['d_i_0'][k], p=matrices['p'][k])