Skip to content

Commit

Permalink
Merging
Browse files Browse the repository at this point in the history
  • Loading branch information
jylambert committed Sep 24, 2024
2 parents 60189df + aced3b0 commit 3d4669d
Show file tree
Hide file tree
Showing 41 changed files with 24 additions and 13 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
13 changes: 8 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
7 changes: 4 additions & 3 deletions tests/hydraulics.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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
Expand Down
17 changes: 12 additions & 5 deletions topotherm/postprocessing.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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', :, :]))
Expand Down Expand Up @@ -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])
Expand Down

0 comments on commit 3d4669d

Please sign in to comment.