Skip to content

Commit

Permalink
Merge branch 'main' into combine_flow_and_control_graphs
Browse files Browse the repository at this point in the history
  • Loading branch information
SouthEndMusic committed Nov 17, 2023
2 parents 50af899 + 0b7b72d commit 8989586
Show file tree
Hide file tree
Showing 81 changed files with 4,133 additions and 3,189 deletions.
4 changes: 2 additions & 2 deletions .docker/compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ version: '2'

services:
qgis:
image: qgis/qgis:release-3_30
image: qgis/qgis:release-3_28
container_name: qgis
volumes:
- ../qgis/:/tests_directory/${PLUGIN_NAME}
- ../ribasim_qgis/:/tests_directory/${PLUGIN_NAME}
environment:
- CI=true
- DISPLAY=:99
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<build-runners>
<runner id="RUNNER_2193" name="" type="simpleRunner">
<parameters>
<param name="script.content"><![CDATA[rsync --verbose --recursive --delete qgis/ ribasim_qgis
<param name="script.content"><![CDATA[rsync --verbose --recursive --delete ribasim_qgis/ ribasim_qgis
rm --force ribasim_qgis.zip
zip -r ribasim_qgis.zip ribasim_qgis]]></param>
<param name="teamcity.step.mode" value="default" />
Expand Down
6 changes: 3 additions & 3 deletions build/create_binaries/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ TOML = "fa267f1f-6049-4f14-aa54-33bafae1ed76"
TimeZones = "f269a46b-ccf7-5d73-abea-4c690281aa53"

[compat]
Artifacts = "1"
LibGit2 = "1"
Artifacts = "<0.0.1,1"
LibGit2 = "<0.0.1,1"
PackageCompiler = "2"
TOML = "1"
TOML = "<0.0.1,1"
TimeZones = "=1.13.0"
julia = "1.10"
4 changes: 2 additions & 2 deletions build/libribasim/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ TOML = "fa267f1f-6049-4f14-aa54-33bafae1ed76"

[compat]
BasicModelInterface = "0.1"
Dates = "1"
TOML = "1"
Dates = "<0.0.1,1"
TOML = "<0.0.1,1"
julia = "1.10"
6 changes: 3 additions & 3 deletions build/ribasim_cli/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ TOML = "fa267f1f-6049-4f14-aa54-33bafae1ed76"
TerminalLoggers = "5d786b92-1e48-4d6f-9151-6b4477ca9bed"

[compat]
Dates = "1"
Logging = "1"
Dates = "<0.0.1,1"
Logging = "<0.0.1,1"
SciMLBase = "1.60, 2"
TOML = "1"
TOML = "<0.0.1,1"
TerminalLoggers = "0.1.7"
julia = "1.10"
18 changes: 13 additions & 5 deletions core/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,41 +41,49 @@ TimerOutputs = "a759f4b9-e2f1-59dc-863e-4aeb61b1ea8f"
TranscodingStreams = "3bb67fe8-82b1-5028-8e26-92a6c54297fa"

[compat]
Aqua = "0.8"
Arrow = "2.3"
BasicModelInterface = "0.1"
CSV = "0.10"
CodecLz4 = "0.4"
CodecZstd = "0.7,0.8"
ComponentArrays = "0.13.14, 0.14, 0.15"
ComponentArrays = "0.13,0.14,0.15"
Configurations = "0.17"
DBInterface = "2.4"
DataFrames = "1.4"
DataInterpolations = "4.4"
DataStructures = "0.18"
Dates = "1"
Dates = "<0.0.1,1"
Dictionaries = "0.3.25"
DiffEqCallbacks = "2.29.1"
Documenter = "0.27,1"
EnumX = "1.0"
FiniteDiff = "2.21"
ForwardDiff = "0.10"
Graphs = "1.9"
HiGHS = "1.7"
IOCapture = "0.2"
IterTools = "1.4"
JuMP = "1.15"
Legolas = "0.5"
Logging = "1"
Logging = "<0.0.1,1"
LoggingExtras = "1"
MetaGraphsNext = "0.6"
OrdinaryDiffEq = "6.7"
PreallocationTools = "0.4"
SQLite = "1.5.1"
SafeTestsets = "0.1"
SciMLBase = "1.60, 2"
SparseArrays = "1"
SparseArrays = "<0.0.1,1"
StructArrays = "0.6.13"
TOML = "<0.0.1,1"
Tables = "1"
TerminalLoggers = "0.1.7"
Test = "<0.0.1,1"
TestReports = "0.7"
TimeZones = "=1.13.0"
TimerOutputs = "0.5"
TranscodingStreams = "0.9, 0.10"
TranscodingStreams = "0.9,0.10"
julia = "1.10"

[extras]
Expand Down
2 changes: 1 addition & 1 deletion core/test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ using SafeTestsets: @safetestset
@safetestset "Docs" include("docs.jl")
@safetestset "Command Line Interface" include("cli.jl")
@safetestset "libribasim" include("libribasim.jl")
Aqua.test_all(Ribasim; ambiguities = false)
Aqua.test_all(Ribasim; ambiguities = false, persistent_tasks = false)
end
8 changes: 4 additions & 4 deletions docs/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ Ribasim = "aac5e3d9-0b8f-4d4f-8241-b1a7a9632635"

[compat]
Configurations = "0.17"
Dates = "1"
Documenter = "0.27, 1"
Dates = "<0.0.1,1"
Documenter = "0.27,1"
DocumenterMarkdown = "0.2"
InteractiveUtils = "1"
InteractiveUtils = "<0.0.1,1"
JSON3 = "1.12"
Legolas = "0.5"
Logging = "1"
Logging = "<0.0.1,1"
OrderedCollections = "1.6"
julia = "1.10"
5 changes: 0 additions & 5 deletions docs/_quarto.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,3 @@ quartodoc:
- Terminal
- DiscreteControl
- PidControl
- title: Utility functions
desc: Collection of utility functions.
contents:
- utils.geometry_from_connectivity
- utils.connectivity_from_geometry
8 changes: 4 additions & 4 deletions docs/contribute/addnode.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ from typing import Optional
import pandera as pa
from pandera.engines.pandas_engine import PydanticModel
from pandera.typing import DataFrame
from pydantic import ConfigDict

from ribasim import models
from ribasim.input_base import TableModel
Expand Down Expand Up @@ -142,11 +143,10 @@ class NewNodeType(TableModel):
possible other schemas
"""

static: Optional[DataFrame[StaticSchema]] = None
static: DataFrame[StaticSchema] | None
# possible other schemas

class Config:
validate_assignment = True
model_config = ConfigDict(validate_assignment=True)

def sort(self):
self.static.sort_values("node_id", ignore_index=True, inplace=True)
Expand All @@ -168,7 +168,7 @@ In `python/ribasim/ribasim/geometry/node.py` add a color and shape description i

# QGIS plugin

The script `qgis/core/nodes.py` has to be updated to specify how the new node type is displayed by the QGIS plugin. Specifically:
The script `ribasim_qgis/core/nodes.py` has to be updated to specify how the new node type is displayed by the QGIS plugin. Specifically:

- Add a color and shape description in the `MARKERS` dictionary in `Node.renderer`,
consistent with the entries added above;
Expand Down
65 changes: 65 additions & 0 deletions docs/core/index.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,68 @@ can be found in the [Ribasim repository](https://github.com/Deltares/Ribasim) un
%%| file: ../assets/c4_component_ribasim.mmd
%%| fig-cap: "Component overview of Ribasim"
```

# The simulation loop

`Ribasim.jl` in the above figure can be divided into 3 parts:

- Model initialization
- Running the simulation loop
- Writing the output files

The figure below gives a more detailed description of the simulation loop in the form of a [sequence diagram](https://en.wikipedia.org/wiki/Sequence_diagram). From top to bottom, it contains the following blocks:

- Allocation optimization; activated when the allocation timestep has been passed;
- Control actions; activated when some discrete control callback is triggered;
- Water balance; computing the flows over flow edges happens each timestep;
- Time integration step; Done by the selected integrator from `OrdinaryDiffEq.jl`.

```{mermaid}
sequenceDiagram
autonumber
participant Int as Process: Integrator
participant Optim as Process: Allocation optimization
participant Param as Data: Parameters
participant State as Data: State
participant Sim as Process: Water balance
loop Simulation loop (OrdinaryDiffEq.jl)
activate Int
%% Allocation
rect rgb(200, 200, 200)
opt Allocation optimization, per allocation network (JuMP.jl, HiGHS)
activate Optim
Int->>Optim: Callback: allocation timestep has passed
Param-->>Optim: Input
State-->>Optim: Input
Optim->>Optim: Optimize Basin allocations if below target level
Optim->>Optim: Optimize User allocation, per priority
Optim-->>Param: Set allocated flow rates
deactivate Optim
end
end
%% Control
rect rgb(200, 200, 200)
opt Control actions
Int->>Int: DiscreteControl callback
Int-->>Param: Parameter updates by control
end
end
%% water_balance!
rect rgb(200, 200, 200)
activate Sim
State-->>Sim: Input
Param-->>Sim: Input
Sim->>Sim: Compute flows over edges per node type
Sim-->>Param: Set flows
deactivate Sim
end
%% Time integration
rect rgb(200, 200, 200)
State-->>Int: Input
Param-->>Int: Input
Int->>Int: Time integration step
Int-->>State: Update state
end
deactivate Int
end
```
2 changes: 1 addition & 1 deletion docs/gen_schema.jl
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ function gen_root_schema(TT::Vector, prefix = prefix, name = "root")
"type" => "object",
)
for T in TT
tname = strip_prefix(T)
tname = lowercase(strip_prefix(T))
schema["properties"][tname] = OrderedDict("\$ref" => "$tname.schema.json")
end
open(normpath(@__DIR__, "schema", "$(name).schema.json"), "w") do io
Expand Down
Loading

0 comments on commit 8989586

Please sign in to comment.