1 Solver

Solver(**data)

Defines the numerical solver options.

For more details see https://docs.sciml.ai/DiffEqDocs/stable/basics/common_solver_opts/#solver_options.

1.1 Attributes

Name Type Description
algorithm str The used numerical time integration algorithm (Optional, defaults to NordsieckBDF)
saveat float Time interval in seconds between saves of output data. 0 saves every timestep, inf only saves at start- and endtime. (Optional, defaults to 86400)
dt float Timestep of the solver. (Optional, defaults to None which implies adaptive timestepping)
dtmin float The minimum allowed timestep of the solver (Optional, defaults to 0.0)
dtmax float The maximum allowed timestep size (Optional, defaults to 0.0 which implies the total length of the simulation)
force_dtmin bool If a smaller dt than dtmin is needed to meet the set error tolerances, the simulation stops, unless force_dtmin = true (Optional, defaults to False)
abstol float The absolute tolerance for adaptive timestepping, applied to the change of each state over a time step, in m3 (Optional, defaults to 1e-4)
reltol float The relative tolerance for adaptive timestepping, applied to the change of each state over a time step (Optional, defaults to 1e-4)
maxiters int The total number of linear iterations over the whole simulation. (Defaults to 1e9, only needs to be increased for extremely long simulations)
reduced_implicit_solve bool Whether to use the implicit solve optimized for Ribasim. Setting this to false bypasses much of the custom numerical code, using a less optimized but potentially more robust algorithm. (Optional, defaults to true)
sparse bool Whether a sparse Jacobian matrix is used, which gives a significant speedup for models with >~10 basins.
autodiff bool Whether automatic differentiation instead of fine difference is used to compute the Jacobian. (Optional, defaults to true)
evaporate_mass bool Whether mass is lost due to evaporation in water quality calculations. (Optional, defaults to true)
depth_threshold float Universal depth at which the low storage factor kicks in
max_depth float Universal maximum Basin depth above which the Basin is flagged when the model becomes unstable
level_difference_threshold float Universal reduction factor threshold for the level difference of Pump/Outlet and TabulatedRatingCurve nodes
min_discrete_control_interval float The minimum time in seconds between control state updates of a DiscreteControl node, if the time is smaller a warning is given. Set to 0 to disable. (Optional, defaults to 1)
discrete_control_interval float The interval in seconds at which DiscreteControl logic is evaluated, or after every timestep if 0. (Optional, defaults to 0)
specialize bool Trades initialization speed for simulation speed, useful for long-running simulations. (Optional, defaults to false)

1.2 Methods

Name Description
check_parent
diff Compare two instances of a BaseModel.
model_dump

1.2.1 check_parent

Solver.check_parent()

1.2.2 diff

Solver.diff(other, ignore_meta=False)

Compare two instances of a BaseModel.

** Warning: This method is experimental and is likely to change. **

If they are equal, return None. Otherwise, return a nested dictionary with the differences. When the differences are not a DataFrame (like the toml config), the dict has self and other as key. For DataFrames we return a dict with diff as key, and a datacompy Comparison object.

When ignore_meta is set to True, the meta_* columns in the DataFrames are ignored. Note that in that case the key will still be returned and the value will be None.

1.2.2.1 Examples

>>> nbasic == basic
False
>>> x = nbasic.diff(basic)
{'basin': {'node': {'diff': <datacompy.pandas.PandasCompare object at 0x16e5a45c0>},
        'static': {'diff': <datacompy.pandas.PandasCompare object at 0x16eb90080>}},
'solver': {'saveat': {'other': 86400.0, 'self': 0.0}}}
>>> x["basin"]["static"]["diff"].report()
DataComPy Comparison
--------------------
...

1.2.3 model_dump

Solver.model_dump(**kwargs)