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]) # (m3/s)
    .pump("pump2", [0.4, 0.4]) # (m3/s)
    .box_culvert("culvert1", ComponentConfig(elevation=1.0, height=2.0), [0.7, 0.8]) # (m)
    .valve_overflow(
        "overflow1", ComponentConfig(elevation=1.0, height=2.0), [
            [0.4, 0.3],  # port 0 (m)
            [0.4, 0.3],  # port 1 (m)
            [0.4, 0.3],  # port 2 (m)
        ]
    )
    .custom_outflows('custom1', [0.4, 0.7]) # v3.1.0 (m3/s)
    .capacity([2.0, 3.0]) # v3.1.0
)

result_df = calculate(
    dataset=dataset,
    water_level_capacity_map={2.0: 100, 3.0: 200},
    round_to=None,
    nearest_mapping=False,
    capacity_from_dataset_first=True  # v3.1.0 set True if you want to use the capacity in dataset instead of water_level_capacity_map
)

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.1.0.tar.gz (5.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tjwb-3.1.0-py3-none-any.whl (6.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: tjwb-3.1.0.tar.gz
  • Upload date:
  • Size: 5.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.12.3 Linux/6.8.0-49-generic

File hashes

Hashes for tjwb-3.1.0.tar.gz
Algorithm Hash digest
SHA256 df5aa9c2aa3e20fbf92f8a1125bdd901dc1e77789b06f52a1d84575e378f00e2
MD5 e4d667ae676cb4258513f5cce0551290
BLAKE2b-256 b6c8e6e9ea03efb7f450f1045dcbc070625635b4b415af63b7ca098237b5e71d

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for tjwb-3.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 47855c4f1a42e5091ab2d59af83102190d209e4365cb175da03b0f5735bb8e2a
MD5 fd18a9fb7ceb2081421e8c92bbde8fe5
BLAKE2b-256 31553b6a280c7f5f8cc1fe3482c0ae02a7d29af65d15e11a24b69fcbb6469784

See more details on using hashes here.

Supported by

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