diff --git a/example/calculate_hydraulic_reg.py b/examples/one-producer/calculate_hydraulic_reg.py similarity index 100% rename from example/calculate_hydraulic_reg.py rename to examples/one-producer/calculate_hydraulic_reg.py diff --git a/example/data/A_c.parquet b/examples/one-producer/data/A_c.parquet similarity index 100% rename from example/data/A_c.parquet rename to examples/one-producer/data/A_c.parquet diff --git a/example/data/A_i.parquet b/examples/one-producer/data/A_i.parquet similarity index 100% rename from example/data/A_i.parquet rename to examples/one-producer/data/A_i.parquet diff --git a/example/data/A_p.parquet b/examples/one-producer/data/A_p.parquet similarity index 100% rename from example/data/A_p.parquet rename to examples/one-producer/data/A_p.parquet diff --git a/example/data/L_i.parquet b/examples/one-producer/data/L_i.parquet similarity index 100% rename from example/data/L_i.parquet rename to examples/one-producer/data/L_i.parquet diff --git a/example/data/Q_c.parquet b/examples/one-producer/data/Q_c.parquet similarity index 100% rename from example/data/Q_c.parquet rename to examples/one-producer/data/Q_c.parquet diff --git a/bm/data/config.yaml b/examples/one-producer/data/config.yaml similarity index 100% rename from bm/data/config.yaml rename to examples/one-producer/data/config.yaml diff --git a/bm/data/regression.csv b/examples/one-producer/data/regression.csv similarity index 100% rename from bm/data/regression.csv rename to examples/one-producer/data/regression.csv diff --git a/example/data/rel_positions.parquet b/examples/one-producer/data/rel_positions.parquet similarity index 100% rename from example/data/rel_positions.parquet rename to examples/one-producer/data/rel_positions.parquet diff --git a/example/data/timeseries.csv b/examples/one-producer/data/timeseries.csv similarity index 100% rename from example/data/timeseries.csv rename to examples/one-producer/data/timeseries.csv diff --git a/example/run_mts.py b/examples/one-producer/run_mts.py similarity index 100% rename from example/run_mts.py rename to examples/one-producer/run_mts.py diff --git a/example/run_mts_easy.py b/examples/one-producer/run_mts_easy.py similarity index 100% rename from example/run_mts_easy.py rename to examples/one-producer/run_mts_easy.py diff --git a/example/run_sts.py b/examples/one-producer/run_sts.py similarity index 100% rename from example/run_sts.py rename to examples/one-producer/run_sts.py diff --git a/bm/convert_npy_to_parquet.py b/examples/synthetic-network/convert_npy_to_parquet.py similarity index 100% rename from bm/convert_npy_to_parquet.py rename to examples/synthetic-network/convert_npy_to_parquet.py diff --git a/bm/data/A_c.npy b/examples/synthetic-network/data/A_c.npy similarity index 100% rename from bm/data/A_c.npy rename to examples/synthetic-network/data/A_c.npy diff --git a/bm/data/A_c.parquet b/examples/synthetic-network/data/A_c.parquet similarity index 100% rename from bm/data/A_c.parquet rename to examples/synthetic-network/data/A_c.parquet diff --git a/bm/data/A_i.npy b/examples/synthetic-network/data/A_i.npy similarity index 100% rename from bm/data/A_i.npy rename to examples/synthetic-network/data/A_i.npy diff --git a/bm/data/A_i.parquet b/examples/synthetic-network/data/A_i.parquet similarity index 100% rename from bm/data/A_i.parquet rename to examples/synthetic-network/data/A_i.parquet diff --git a/bm/data/A_p.npy b/examples/synthetic-network/data/A_p.npy similarity index 100% rename from bm/data/A_p.npy rename to examples/synthetic-network/data/A_p.npy diff --git a/bm/data/A_p.parquet b/examples/synthetic-network/data/A_p.parquet similarity index 100% rename from bm/data/A_p.parquet rename to examples/synthetic-network/data/A_p.parquet diff --git a/bm/data/L_i.parquet b/examples/synthetic-network/data/L_i.parquet similarity index 100% rename from bm/data/L_i.parquet rename to examples/synthetic-network/data/L_i.parquet diff --git a/bm/data/Q_c.npy b/examples/synthetic-network/data/Q_c.npy similarity index 100% rename from bm/data/Q_c.npy rename to examples/synthetic-network/data/Q_c.npy diff --git a/bm/data/Q_c.parquet b/examples/synthetic-network/data/Q_c.parquet similarity index 100% rename from bm/data/Q_c.parquet rename to examples/synthetic-network/data/Q_c.parquet diff --git a/example/data/config.yaml b/examples/synthetic-network/data/config.yaml similarity index 100% rename from example/data/config.yaml rename to examples/synthetic-network/data/config.yaml diff --git a/bm/data/l_i.npy b/examples/synthetic-network/data/l_i.npy similarity index 100% rename from bm/data/l_i.npy rename to examples/synthetic-network/data/l_i.npy diff --git a/example/data/regression.csv b/examples/synthetic-network/data/regression.csv similarity index 100% rename from example/data/regression.csv rename to examples/synthetic-network/data/regression.csv diff --git a/bm/data/rel_positions.npy b/examples/synthetic-network/data/rel_positions.npy similarity index 100% rename from bm/data/rel_positions.npy rename to examples/synthetic-network/data/rel_positions.npy diff --git a/bm/data/rel_positions.parquet b/examples/synthetic-network/data/rel_positions.parquet similarity index 100% rename from bm/data/rel_positions.parquet rename to examples/synthetic-network/data/rel_positions.parquet diff --git a/bm/run_sts.py b/examples/synthetic-network/run_sts.py similarity index 100% rename from bm/run_sts.py rename to examples/synthetic-network/run_sts.py diff --git a/example_2_prod/data/A_c.parquet b/examples/two-producers/data/A_c.parquet similarity index 100% rename from example_2_prod/data/A_c.parquet rename to examples/two-producers/data/A_c.parquet diff --git a/example_2_prod/data/A_i.parquet b/examples/two-producers/data/A_i.parquet similarity index 100% rename from example_2_prod/data/A_i.parquet rename to examples/two-producers/data/A_i.parquet diff --git a/example_2_prod/data/A_p.parquet b/examples/two-producers/data/A_p.parquet similarity index 100% rename from example_2_prod/data/A_p.parquet rename to examples/two-producers/data/A_p.parquet diff --git a/example_2_prod/data/L_i.parquet b/examples/two-producers/data/L_i.parquet similarity index 100% rename from example_2_prod/data/L_i.parquet rename to examples/two-producers/data/L_i.parquet diff --git a/example_2_prod/data/Q_c.parquet b/examples/two-producers/data/Q_c.parquet similarity index 100% rename from example_2_prod/data/Q_c.parquet rename to examples/two-producers/data/Q_c.parquet diff --git a/example_2_prod/data/config.yaml b/examples/two-producers/data/config.yaml similarity index 100% rename from example_2_prod/data/config.yaml rename to examples/two-producers/data/config.yaml diff --git a/example_2_prod/data/regression.csv b/examples/two-producers/data/regression.csv similarity index 100% rename from example_2_prod/data/regression.csv rename to examples/two-producers/data/regression.csv diff --git a/example_2_prod/data/rel_positions.parquet b/examples/two-producers/data/rel_positions.parquet similarity index 100% rename from example_2_prod/data/rel_positions.parquet rename to examples/two-producers/data/rel_positions.parquet diff --git a/example_2_prod/run_sts_two_producers.py b/examples/two-producers/run_sts_two_producers.py similarity index 100% rename from example_2_prod/run_sts_two_producers.py rename to examples/two-producers/run_sts_two_producers.py diff --git a/setup.py b/setup.py index ca206d6..c1a8014 100644 --- a/setup.py +++ b/setup.py @@ -1,21 +1,24 @@ -"""Set up the package from requirments.""" -import os +"""Set up topotherm from requirements.""" +import os from setuptools import setup, find_packages + # The directory containing this file here = os.path.dirname(os.path.realpath(__file__)) + # The text of the README file -with open(os.path.join(here, "README.md")) as fid: +with open(os.path.join(here, "README.md"), encoding='utf-8') as fid: readme = fid.read() -with open(os.path.join(here, "requirements.txt")) as fid: + +with open(os.path.join(here, "requirements.txt"), encoding='utf-8') as fid: reqs = fid.read().splitlines() # This call to setup() does all the work setup( name="topotherm", version="0.1.0", - description="A package to optimize district heating systems", + description="A package to design district heating networks", long_description=readme, long_description_content_type="text/markdown", url="https://github.com/jylambert/topotherm", diff --git a/tests/hydraulics.py b/tests/hydraulics.py index fa55bf5..f13887c 100644 --- a/tests/hydraulics.py +++ b/tests/hydraulics.py @@ -9,6 +9,7 @@ def test_feed_line_temp(): + """Test feed line temperature calculation""" # Optionally: calculate the supply temperatures for a given max supply t and # return temperature according to ambient temperature variable_feed_temp = precalc.determine_feed_line_temp( @@ -22,14 +23,14 @@ def test_feed_line_temp(): def test_regression(): - """Test regression""" + """Test thermal capacity and thermal losses regression""" r_thermal_cap = precalc.regression_thermal_capacity(settings) assert abs(r_thermal_cap['a'] - 0.018377) < 0.01 * 0.018377 assert abs(r_thermal_cap['b'] - 567.335) < 0.01 * 567.335 assert abs(r_thermal_cap['r2'] - 0.869778) < 0.01 * 0.869778 # heat loss regression - r_heat_loss = precalc.regression_heat_losses(settings, - thermal_capacity=r_thermal_cap) + r_heat_loss = precalc.regression_heat_losses( + settings, thermal_capacity=r_thermal_cap) # assert that each params item is within 1% of the expected value assert abs(r_heat_loss['a'] - 4.348000e-07) < 0.01 * 4.348000e-07 assert abs(r_heat_loss['b'] - 0.02189) < 0.01 * 0.02189 diff --git a/topotherm/postprocessing.py b/topotherm/postprocessing.py index 7f385ae..b29ba63 100644 --- a/topotherm/postprocessing.py +++ b/topotherm/postprocessing.py @@ -1,8 +1,14 @@ -"""Postprocessing of the results from the optimization. This includes the calculation of the -diameter and mass flow of the pipes, the elimination of unused pipes and nodes. +"""Postprocessing of the results from the optimization. This includes the +calculation of the diameter and mass flow of the pipes, the elimination of +unused pipes and nodes. This module includes the following functions: - * sts: Postprocessing for the STS model + * calc_diam_and_velocity: Equations for the calculation of the diameter and + velocity of the pipes depending on the mass flow and the power of the pipes + * sts: Postprocessing for the single time step model + * to_networkx_graph: Export the postprocessed, optimal district as a + networkx graph + * mts: Postprocessing for the multiple time step model """ from typing import Tuple @@ -58,7 +64,7 @@ def sts(model: pyo.ConcreteModel, settings (tt.settings.Settings): settings for the optimization Returns: - _dict: containing the variables and postprocessed data + res: containing the variables and postprocessed data """ # Get the values from the model p_ij = np.array(pyo.value(model.P['ij', 'in', :, :])) @@ -296,7 +302,8 @@ def to_networkx_graph(matrices): - m_i_0 (mass flow of the optimal pipes) - p (Power of the optimal pipes) - Returns: Figure of the district + Returns: + G: networkx graph """ G = nx.DiGraph() s = np.array([0, 0, 0])