Skip to main content

Python library for reservoir water balance calculations.

Project description

tjwb

PyPI - Version

tjwb is a Python library designed for water balance management in reservoirs. The library provides methods to calculate inflow and outflow speeds of various components, such as pumps, box culverts, and valve overflows, based on water level and configuration...

Overview

Subsequent Capacity = Previous Capacity + (Inflow Speed * ΔT) - (Outflow Speed * ΔT)

Where:

  • Subsequent Capacity: The capacity of the reservoir after the current time step.
  • Previous Capacity: The capacity of the reservoir before the current time step.
  • Inflow Speed: The rate at which water is entering the reservoir.
  • Outflow Speed: The rate at which water is leaving the reservoir.
  • ΔT: The time step or interval over which the inflow and outflow are measured.

If the difference between the subsequent capacity and the previous capacity is zero, then the inflow speed and outflow speed are equal:

Subsequent Capacity - Previous Capacity = 0

In this case:

Inflow Speed = Outflow Speed

If the difference between the subsequent capacity and the previous capacity is negative, then the outflow speed is greater than the inflow speed:

Subsequent Capacity - Previous Capacity < 0

In this case:

Outflow Speed > Inflow Speed

Conversely, if the difference between the subsequent capacity and the previous capacity is positive, then the inflow speed is greater than the outflow speed:

Subsequent Capacity - Previous Capacity > 0

In this case:

Inflow Speed > Outflow Speed

Installation

To install the library, use pip:

pip install tjwb

Usage

Basic Example

from datetime import datetime
from tjwb.dataset import Dataset, ComponentConfig
from tjwb.tjwb import calculate

dataset = (
    Dataset()
    .time_series([datetime(2023, 1, 1), datetime(2023, 1, 2)])
    .water_level([2.0, 3.0])
    .pump("pump1", [0.5, 0.6])
    .pump("pump2", [0.4, 0.4])
    .box_culvert("culvert1", ComponentConfig(elevation=1.0, height=2.0), [0.7, 0.8])
    .valve_overflow(
        "overflow1", ComponentConfig(elevation=1.0, height=2.0), [
            [0.4, 0.3],  # port 0
            [0.4, 0.3],  # port 1
            [0.4, 0.3],  # port 2
        ]
    )
)

result_df = calculate(
    dataset=dataset,
    water_level_capacity_map={2.0: 100, 3.0: 200},
    round_to=None,
    nearest_mapping=False
)

License

This library is released under the MIT License.

Contact

If you have any questions or issues, please open an issue on GitHub or email us at duynguyen02.dev@gmail.com.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tjwb-3.0.0.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

tjwb-3.0.0-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

Details for the file tjwb-3.0.0.tar.gz.

File metadata

  • Download URL: tjwb-3.0.0.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.3 Linux/6.8.0-41-generic

File hashes

Hashes for tjwb-3.0.0.tar.gz
Algorithm Hash digest
SHA256 141b102ac9d61be11cdb12059b19f3bf2bb602a4d6593ce6be846993cd81eeee
MD5 2c5bab70ddebc3b64442dd566e530b2e
BLAKE2b-256 d4363197b0c8ceb92c622a638d48b4e95d7d9f8330faba45605fe841c3f550ca

See more details on using hashes here.

File details

Details for the file tjwb-3.0.0-py3-none-any.whl.

File metadata

  • Download URL: tjwb-3.0.0-py3-none-any.whl
  • Upload date:
  • Size: 5.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.3 Linux/6.8.0-41-generic

File hashes

Hashes for tjwb-3.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 baa0aa086a893ddb579276684a450e1db7fce59acff10b27c21e472aa528de94
MD5 c8e8adbb1e6818c902696bd93750f5a9
BLAKE2b-256 1bd3a6e0f9d7f984a272ce2710fcc1ae81c5e88652ff889b401b58cd3250e0aa

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page