Open Fati-Mon opened 2 months ago
Thanks for the report. Could you add the Python script you have for writing the model, and the error message that Ribasim gives?
EDIT: The Python script is here: https://github.com/Deltares/Ribasim/issues/1263#issuecomment-2213567653
The error itself comes from here, where area and level are both typed empty arrays Float64[]
and the resulting level_to_area
is an Any[]
which causes dispatch issues.
Not sure how many issues hide behind this one though. If it isn't easy to support, with correct results, we should error early with a clear message.
Even after adding a Basin I get the same problem:
import subprocess # for running the model
import shutil
from pathlib import Path
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
from ribasim import Allocation, Model, Node
from ribasim.nodes import (
flow_boundary,
basin,
terminal
)
from shapely.geometry import Point
base_dir = Path("c:/Ribasim9")
model_dir = base_dir / "Virgin"
flows_path = model_dir / "input/ACTINFLW.csv"
starttime = "2023-01-01"
endtime = "2024-01-01"
model = Model(
starttime=starttime,
endtime=endtime,
crs="EPSG:4326",
)
#%% FLOW BOUNDARY
# FLOW BOUNDARY
flows = pd.read_csv(flows_path, sep=";")
model.flow_boundary.add(
Node(1, Point(0.0, 0.0), name='Main'),
[flow_boundary.Time(time=flows.time, flow_rate=flows.main, #name="Main"
)]
)
model.flow_boundary.add(
Node(2, Point(-3.0, 0.0), name='Minor'),
[flow_boundary.Time(time=flows.time, flow_rate=flows.minor, #name="Main"
)]
)
# BASIN (confluence)
model.basin.add(
Node(3, Point(-1.5, -1), name='Conf'),
[
basin.Profile(area=[1000.0, 1000.0], level=[0.0, 1.0]),
basin.State(level=[20.0]),
basin.Time(time=[starttime, endtime], precipitation=[0.0, 3e-6]),
],
)
# TERMINAL
model.terminal.add(Node(4, Point(-1.5, -3.0), name="Terminal"))
# EDGES
model.edge.add(model.flow_boundary[1], model.basin[3])
model.edge.add(model.flow_boundary[2], model.basin[3])
model.edge.add(model.basin[3], model.terminal[4])
# SCHEMATIZATION
model.plot()
datadir = Path("data")
toml_path = datadir / "basic/ribasim.toml"
model.write(toml_path)
rib_path = base_dir / "ribasim_windows/ribasim.exe"
subprocess.run([rib_path, toml_path], check=True)
Is it the way the subprocess run is called?
Is it the way the subprocess run is called?
Indeed, this is improved in #1650.
For the error of https://github.com/Deltares/Ribasim/issues/1615#issuecomment-2228671453, I suggest we look again after #1649 is merged.
What If a user wants to model a simple system with no storage, the following error is shown:
Why
Not clear that a basin node is needed to be able to run the model. How Mention in the error that the user needs to add a basin for the model to run or describe that certain nodes cannot be directly linked (in this case flow boundaries directly linked with a terminal)