Deltares / Ribasim-NL

Ribasim water resources modeling in the Netherlands
https://ribasim.nl/
MIT License
4 stars 0 forks source link

Control: add Driel and Haringvlietsluizen #57

Closed d2hydro closed 8 months ago

d2hydro commented 9 months ago

Driel

Haringvlietsluizen

d2hydro commented 9 months ago

@visr, following our discussion December, "fractional flow as to receive a flow_rate" I assume such flow-rate comes best from a Q(h) and not from a "gravitation node" (manning or linear resistance) as these nodes need a downstream level. Taken from HydroLogic example:

Image

d2hydro commented 9 months ago

@visr, something is wrong with the control-state. Can you help me further? The model is here: https://we.tl/t-JMNBV65NWq

image

visr commented 9 months ago

I ran this script to update the model, which is the upgrade code from https://github.com/Deltares/Ribasim/pull/992, followed by a read-then-write using the latest version of Ribasim Python. After that it works.

import sqlite3

import pandas as pd

# Connect to the SQLite database
database_path = "database.gpkg"
conn = sqlite3.connect(database_path)

tables = ["TabulatedRatingCurve / static", "TabulatedRatingCurve / time"]

for table in tables:
    # Read the table into a pandas DataFrame
    try:
        df = pd.read_sql_query(f"SELECT * FROM '{table}'", conn)
    except:
        continue

    # Rename the column in the DataFrame
    df_renamed = df.rename(columns={"discharge": "flow_rate"})

    # Write the DataFrame back to the SQLite table
    df_renamed.to_sql(table, conn, if_exists="replace", index=False)

# Close the connection
conn.close()

# write
import ribasim

m = ribasim.Model(filepath="hws.toml")
m.write("hws.toml")

I suspect that the fix was the ordering of the tables: https://github.com/Deltares/Ribasim/pull/903. Now the tables are sorted in ascending greater_than: image

d2hydro commented 9 months ago

Check, for a full fix:

  1. run the code above using ribasim from the main-branch
  2. download and use Ribasim 2024.01.1 CLI: https://github.com/Deltares/Ribasim/releases/tag/v2024.01.1

Model with Driel-control is uploaded to: https://deltares.thegood.cloud/f/62081

d2hydro commented 8 months ago

Issue closed with model-release: 2024.2.1: https://deltares.thegood.cloud/f/62174