GithubHelp home page GithubHelp logo

meghnathomas / magnets Goto Github PK

View Code? Open in Web Editor NEW
11.0 1.0 4.0 2.61 MB

A Python package to aggregate and reduce water distribution network models

License: MIT License

Makefile 0.38% Python 6.90% Jupyter Notebook 92.72%

magnets's Introduction

MAGNets

A Python package to aggregate and reduce water distribution network models

PyPI - Downloads

Overview

MAGNets (Model AGgregation and reduction of water distribution Networks) is a Python package designed to perform the reduction and aggregation of water distribution network models. The software is capable of reducing a network around an optional operating point and allows the user to customize which junctions they would like retained in the reduced model. MAGNets' reduction approach is based on the variable elimination method proposed by Ulanicki et al (1996).

Requirements

MAGNets has been tested on Python version 3.6, 3.7, and 3.8. A list of its dependencies can be found here.

Installation: Stable release

Python distributions, such as Anaconda, are recommended to manage the Python environment as they already contain (or easily support the installation of) many Python packages (such as SciPy and NumPy) that are used in the MAGNets package. Instructions to download and install the Anaconda distribution can be found at this link, and Anaconda for specific versions of Python can be found in the Anaconda distribution archive. This blog post demonstrates how to easily change the Anaconda Python version to a version compatible with MAGNets using the command prompt.

To install MAGNets, run this command in your terminal:

pip install magnets

This is the preferred method to install MAGNets, as it will always install the most recent stable release.

If you don’t have pip installed, this Python installation guide can guide you through the process.

Installation: From sources

The sources for MAGNets can be downloaded from the Github repo.

You can either clone the public repository:

git clone https://github.com/meghnathomas/MAGNets

Or download the tarball:

curl -OJL https://github.com/meghnathomas/magnets/tarball/master

Once you have a copy of the source, you can install it with:

python setup.py install

Getting Started

Use this jupyter notebook to run some useful examples of MAGNets. Additional example codes and 12 test networks can be found in the examples and publications folders.


Once MAGNets is installed on the system, it can be used in a projet through the means of a Python IDE. For example, to use MAGNets on Spyder, open Spyder either through the Anaconda GUI or by typing the following command in the command prompt:

spyder

Open a new script and import MAGNets using the following command:

import magnets as mg

The user can then call on the following function to reduce a hydraulic model of a water distribution network.

wn2 = mg.reduction.reduce_model(inp_file, op_pt, nodes_to_keep, max_nodal_degree)

The parameters of the reduce_model function are described as follows:

  1. inp_file: the EPANET-compatible .inp file of the water distribution network model.
  2. op_pt: (optional, default = 0) the operating point, or the reporting time step of the hydraulic simulation at which the non-linear headloss equations are linearized.
  3. nodes_to_keep: (optional, default = []) a list of nodes the user wishes to retain in the reduced model.
  4. max_nodal_degree: (optional, default = None) the maximum nodal degree of nodes being removed from the model. The nodal degree of a node is equal to the number of pipes incident to the node.

wn2 contains the water network model object of the reduced model. A .inp file of the reduced model is also written into the directory that contains the .inp file of the original network.

Cite Us

To cite MAGNets, please use the following publication: MAGNets: Model Reduction and Aggregation of Water Networks

@article{doi:10.1061/JWRMD5.WRENG-5486,
 author = {Meghna Thomas  and Lina Sela },
 title = {MAGNets: Model Reduction and Aggregation of Water Networks},
 journal = {Journal of Water Resources Planning and Management},
 volume = {149},
 number = {2},
 pages = {06022006},
 year = {2023},
 doi = {10.1061/JWRMD5.WRENG-5486},
 URL = {https://ascelibrary.org/doi/abs/10.1061/JWRMD5.WRENG-5486},
 }

Contact

Meghna Thomas - [email protected]

Lina Sela - [email protected]

Credits

This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.

magnets's People

Contributors

meghnathomas avatar maozdemir avatar

Stargazers

Jorge Cruz avatar  avatar Tomek Janus avatar Wenjin Hao avatar Katherine Klise avatar Matt Bartos avatar Gerardo Andrés Riaño Briceño avatar Abhiram  avatar Marios S. Kyriakou avatar Michael Tryby avatar  avatar

Watchers

 avatar

magnets's Issues

demand allocation

add a check -- if the removal node HAS a demand pattern associated it, and at least a part of its demand is allocated to a neighboring node WITHOUT an assigned demand pattern, make sure the demand pattern of the removal node is transferred to the neighboring node.

wntr get_graph

get_graph is deprecated- switch to to_graph

(only for recent wntr versions??)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.