A stochastic water demand end-use model in Python
Project description
PYSIMDEUM
pysimdeum
is a Python package for modelling and simulating residential stochastic water demand at the end-use level.
Main functionalities:
- Build and populate houses with users and water end-use devices according to country specific statistics
- Simulate water usage stochastically based on the statistics
- The results are stored as
xarray.DataArray
, so all the simulation information can be accessed and aggregated afterwards (e.g., specific end-uses, sums over water usage of users, rolling means over time, ...) - Serialization:
pysimdeum
supports different output formats (e.g., csv, excel, netcdf, ...) - Plotting results using matplotlib
A detailed documentation will be soon available under https://pysimdeum.readthedocs.io.
Output is based on statistics about household sizes and water use of the Netherlands. These can be changed either within the code or by creating the correct toml files. An overview of worldwide differences is available in:
Mazzoni, F., Alvisi, S., Blokker, E. J. M., Buchberger, S. G., Castelletti, A., Cominola, A., Gross, M. P., Jacobs, H. E., Mayer, P., Steffelbauer, D. B., Stewart, R. A., Stillwell, A. S., Tzatchkov, V., Yamanaka, V. H. A. and Franchini, M. (2022). "Investigating the characteristics of residential end uses of water: a worldwide review." Water Research, art. no. 119500, doi:https://doi.org/10.1016/j.watres.2022.119500.https://www.sciencedirect.com/science/article/pii/S0043135422014452 https://livelink.kwrwater.nl/livelink/livelink.exe/Open/69638292
Warning!
Be warned, that pysimdeum
is still changing a lot. Until it's marked as 1.0.0, you should assume that it is unstable and act accordingly. We are trying to avoid breaking changes but they can and will occur!
Installation
pysimdeum
uses features only available in a newer Python version, which is why Python >= 3.8 is needed along with several Python package dependencies.
pysimdeum
is available on PyPI and can be easily installed together with its dependencies using pip
:
pip install pysimdeum
Alternatively, you can install pysimdeum
from its repository:
pip install git+https://github.com/KWR-Water/pysimdeum.git
Dependencies
pysimdeum
requires the following Python packages:
- matplotlib
- numpy
- pandas
- toml
- xarray
- scipy
Basic Usage
To use pysimdeum
, you first have to import it in your script:
import pysimdeum
In pysimdeum
, everything is about the House
. If you want to start with a new, empty House, type the following:
house = pySIMDEUM.built_house(house_type='one_person')
If you want to build a specific House, e.g., a one-person household, you can use the house_type
keyword:
# Built a house (one-person household)
house = pySIMDEUM.built_house(house_type='one_person')
The house is automatically populated by people, which follow certain statistics, and "furnished" with water end-use devices or appliances (e.g., toilet, bathtub, ...). You can check, which appliances are available by using the appliances
or users
property of the House:
# Show users and water end-use devices present in the house
print(house.users)
print(house.appliances)
To simulate the water consumption of a house, you can use the House`s simulate
method:
# Simulate water consumption for house (xarray.DataArray)
consumption = house.simulate(num_patterns=100)
The simulation result is an xarray.DataArray
--- basically a labelled numpy.ndarray
with four dimensions / axes (i.e., time, user, enduse, patterns).
You can easily create statistics over the consumption object, for example, to compute the average total consumption (sum of consumption of all users and enduses as an average over the patterns), you can build the sum over the user
and enduse
axes (the total consumption), and then build the mean over the patterns
axes. There are two flowtypes
defined. totalflow
and hotflow
. totalflow
reflects the total water use while hotflow
reflects the water that has been heated up.
# Build statistics from consumption
tot_cons = consumption.sum(['enduse', 'user']).sel(flowtypes='totalflow').mean([ 'patterns'])
If you want to plot the results pand additionally depict some rolling averages (e.g., hourly means = 3600 seconds), you can this in the following way
# Plot total consumption
tot_cons.plot()
tot_cons.rolling(time=3600, center=True).mean().plot()
plt.show()
License
pysimdeum
is available under a EUPL-1.2 license.
Contributing
If you want to contribute, please check out our Code of Conduct and our Contribution Guide. Looking forward to your pull request or issue!
Citing
If you publish work based on pysimdeum
, we appreciate a citation of the following reference:
- Steffelbauer, D.B., Hillebrand B., Blokker, E.J.M., 2022. pySIMDEUM: An open-source stochastic water demand end-use model in Python. Proceedings of the 2nd joint Water Distribution System Analysis and Computing and Control in the Water Industry (WDSA/CCWI2022) conference, Valencia (Spain), 18-22 July 2022.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file pysimdeum-1.0.1.tar.gz
.
File metadata
- Download URL: pysimdeum-1.0.1.tar.gz
- Upload date:
- Size: 33.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.19
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d555dec382295c1d20062ba87f08596ad5a2cacd46e552d5f46c61465d8f5cbc |
|
MD5 | 28fc0bd55e47269d8badd5ab5fd8b7a6 |
|
BLAKE2b-256 | 38b3a7afdd897e7afc4e757b96ebd9544be5b7c23a14ac858343f48c85bf4bc1 |
File details
Details for the file pysimdeum-1.0.1-py3-none-any.whl
.
File metadata
- Download URL: pysimdeum-1.0.1-py3-none-any.whl
- Upload date:
- Size: 39.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.19
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5f634430af519dcf6dec6b25cbbfeeb47081fcc1ea108111abc082a39bdd9277 |
|
MD5 | 0f2fe5b98b14ca9a1621d7ee1df4d70e |
|
BLAKE2b-256 | d4aeb1c46f9d02ae521452c921daf764767b1d3136487554b2bc08d51c8a8d2b |