Skip to content

Commit

Permalink
Merge branch 'release/v0_0_1'
Browse files Browse the repository at this point in the history
  • Loading branch information
joroeder committed Oct 28, 2020
2 parents 16599a8 + c812f47 commit d8d0127
Show file tree
Hide file tree
Showing 186 changed files with 11,484 additions and 855 deletions.
4 changes: 3 additions & 1 deletion .flake8
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
[flake8]
exclude = meta/migrations/
ignore = E265
ignore = E265, W503
max-line-length = 100
per-file-ignores =
__init__.py : F401
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
*.pyc
*.png
*.egg-info
*.html
.idea
results/
_build
jupyter_notebooks
*/import_export_plot/data_csv_output/
*/import_osmnx/data/
4 changes: 3 additions & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,9 @@ disable=parameter-unpacking,
too-many-instance-attributes,
too-few-public-methods,
arguments-differ,
import-error
import-error,
self-cls-assignment,
duplicate-code,

# Enable the message, report, category or checker with the given id(s). You can
# either give multiple identifier separated by comma (,) or put this option
Expand Down
14 changes: 11 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ matrix:


# To install packages which are not on pip
#before_install:
# - sudo apt-get install ...
before_install:
- sudo apt-get install proj-bin
- sudo apt-get install libspatialindex-dev
#addons:
# apt:
# update: true
Expand All @@ -18,12 +19,16 @@ matrix:
install:
- pip install -r tests/test_requirements.txt
- pip install -e .
# install scipy explicitly conda because installing networkx with pip skips installing scipy.
- pip install scipy
- pip install pytest-cov
- pip install coveralls

# commands to run tests
script:
- flake8
- pylint */*.py
- pytest
- pytest --cov=dhnx
#jobs:
# include:
# - stage: "Tests" # naming the Tests stage
Expand All @@ -48,3 +53,6 @@ script:
# only:
# - branch_name1
# - branch_name2

after_success:
- coveralls
10 changes: 10 additions & 0 deletions AUTHORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Authors
=======

--**alphabetic order**--

* Jann Launer
* Johannes Röder
* Joris Zimmermann
* Marie-Claire Gering
* oakca
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2020 oemof developing group

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
88 changes: 88 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
|badge_travis| |badge_coverage|

~~~~
DHNx
~~~~

This package provides an open toolbox for district heating and cooling network
optimization and simulation models.

.. contents::

About
=====

The aim of DHNx is to provide a toolbox for building models of
district heating/cooling systems.

Quickstart
==========

If you have a working Python3 environment, use pypi to install the latest DHNx version:

.. code:: bash
pip install dhnx
Install the developer version of DHNx by cloning DHNx to your computer and running

.. code:: bash
pip install -e DHNx
in your virtualenv.

Check out the
`examples <https://github.com/oemof-heat/DHNx/tree/dev/examples>`_ to get started.

Documentation
=============

The documentation (work in progress) can be found here
`<https://dhnx.readthedocs.io/en/latest/>`_.
To build the docs locally using sphinx-build run the following in a terminal.

.. code:: bash
sphinx-build docs <build-dir>
Contributing
============

Everybody is welcome to contribute to the development of DHNx. The `developer
guidelines of oemof <https://oemof.readthedocs.io/en/stable/developing_oemof.html>`_
are in most parts equally applicable to DHNx.

License
=======

MIT License

Copyright (c) 2020 oemof developing group

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.


.. |badge_coverage| image:: https://coveralls.io/repos/github/oemof-heat/DHNx/badge.svg?branch=dev&service=github
:target: https://coveralls.io/github/oemof-heat/DHNx?branch=dev
:alt: Test coverage

.. |badge_travis| image:: https://api.travis-ci.org/oemof/DHNx.svg?branch=dev
:target: https://travis-ci.org/oemof/DHNx
:alt: Build status
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = "0.0.1"
12 changes: 12 additions & 0 deletions dhnx/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
__version__ = "0.0.1"

from . import input_output
from . import network
from . import plotting
from . import model
from . import simulation
from . import dhn_from_osm
from . import optimization
from . import optimization_add_components
from . import optimization_dhs_nodes
from . import optimization_oemof_heatpipe
9 changes: 9 additions & 0 deletions dhnx/component_attrs/consumers.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
attribute,type,unit,default,description,status,requirement
id,int,n/a,n/a,Unique id,Input,required
component_type,str,--,Consumer,Component type,Input,optional
lat,float,n/a,n/a,Geographic latitude,Input,optional
lon,float,n/a,n/a,Geographic longitude,Input,optional
mass_flow,float/sequence,kg/s,n/a,Mass flow,Input,optional
delta_temp_drop,float/sequence,kg/s,n/a,Temperature drop from inlet to return,Input,optional
zeta_inlet,float,--,n/a,Localized pressure loss coefficient for inlet flow,Input,optional
zeta_return,float,--,n/a,Localized pressure loss coefficient for return flow,Input,optional
3 changes: 3 additions & 0 deletions dhnx/component_attrs/environment.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
attribute,type,unit,default,description,status,requirement
component_type,str,--,Environment,Component type,Input,optional
temp_env,float/sequence,deg C or K,n/a,Environment temperature,Input,optional
7 changes: 7 additions & 0 deletions dhnx/component_attrs/forks.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
attribute,type,unit,default,description,status,requirement
id,int,n/a,n/a,Unique id,Input,required
component_type,str,--,Fork,Component type,Input,optional
lat,float,n/a,n/a,Geographic latitude,Input,optional
lon,float,n/a,n/a,Geographic longitude,Input,optional
zeta_inlet,float,--,n/a,Localized pressure loss coefficient for inlet flow,Input,optional
zeta_return,float,--,n/a,Localized pressure loss coefficient for return flow,Input,optional
9 changes: 9 additions & 0 deletions dhnx/component_attrs/pipes.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
attribute,type,unit,default,description,status,requirement
id,int,n/a,n/a,Unique id,Input,required
component_type,str,--,Pipe,Component type,Input,optional
from_node,int,n/a,n/a,Node where Pipe begins,Input,required
to_node,int,n/a,n/a,Node where Pipe ends,Input,required
length,float,m,n/a,Length of the Pipe,Input,optional
diameter,float,mm,n/a,Inner diameter of the pipes,Input,optional
heat_transfer_coeff,float,W/(m*K),n/a,Heat transfer coefficient,Input,optional
roughness,float,mm,n/a,Roughness of pipes,Input,optional
8 changes: 8 additions & 0 deletions dhnx/component_attrs/producers.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
attribute,type,unit,default,description,status,requirement
id,int,n/a,n/a,Unique id,Input,required
component_type,str,--,Producer,Component type,Input,optional
lat,float,n/a,n/a,Geographic latitude,Input,optional
lon,float,n/a,n/a,Geographic longitude,Input,optional
temp_inlet,float/sequence,deg C or K,n/a,Inlet temperature at producer,Input,optional
zeta_inlet,float,--,n/a,Localized pressure loss coefficient for inlet flow,Input,optional
zeta_return,float,--,n/a,Localized pressure loss coefficient for return flow,Input,optional
6 changes: 6 additions & 0 deletions dhnx/components.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
component_class,list_name,description
Environment,environment,"Environment"
Producer,producers,"Heat producer"
Consumer,consumers,"Heat consumer"
Fork,forks,"Node where several pipes meet"
Pipe,pipes,"Pipes representing double pipes (feed and return) that connect nodes"
93 changes: 93 additions & 0 deletions dhnx/dhn_from_osm.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# -*- coding: utf-8

"""
This module is designed to hold functions for importing networks and building
footprints from openstreetmap.
This file is part of project dhnx (). It's copyrighted
by the contributors recorded in the version control history of the file,
available from its original location:
SPDX-License-Identifier: MIT
"""

try:
import geopandas as gpd

except ImportError:
print("Need to install geopandas to process osm data.")

import pandas as pd

try:
from shapely.ops import nearest_points
from shapely.geometry import LineString

except ImportError:
print("Need to install shapely to download from osm.")


def connect_points_to_network(points, nodes, edges):
r"""
Parameter
---------
points : geopandas.GeoDataFrame
Points to connect to the network
nodes : geopandas.GeoDataFrame
Nodes of the network
edges : geopandas.GeoDataFrame
Edges of the network
Returns
-------
points : geopandas.GeoDataFrame
Points connected to the network
nodes : geopandas.GeoDataFrame
Original nodes of the network and
nearest connecting points on the
network's edges.
edges : geopandas.GeoDataFrame
Edges of the network.
"""
edges_united = edges.unary_union

len_nodes = len(nodes)
len_points = len(points)

# assign ids to new points
n_points = []
n_nearest_points = []
n_edges = []

for i, point in enumerate(points.geometry):
id_nearest_point = len_nodes + i

id_point = len_nodes + len_points + i

nearest_point = nearest_points(edges_united, point)[0]

n_points.append([id_point, point])

n_nearest_points.append([id_nearest_point, nearest_point])

n_edges.append([id_point, id_nearest_point, LineString([point, nearest_point])])

n_points = gpd.GeoDataFrame(
n_points,
columns=['index', 'geometry']).set_index('index')

n_nearest_points = gpd.GeoDataFrame(
n_nearest_points,
columns=['index', 'geometry']).set_index('index')

n_edges = gpd.GeoDataFrame(n_edges, columns=['u', 'v', 'geometry'])

joined_nodes = pd.concat([nodes, n_nearest_points], sort=True)
joined_edges = pd.concat([edges, n_edges], sort=True)

return n_points, joined_nodes, joined_edges
Loading

0 comments on commit d8d0127

Please sign in to comment.