Skip to content

Commit

Permalink
Improve Solvers (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
rileyhales authored Aug 20, 2023
1 parent 8012c32 commit a7913b2
Show file tree
Hide file tree
Showing 8 changed files with 383 additions and 166 deletions.
35 changes: 35 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# River Route

`river-route` is a Python package for routing runoff through a river network.
The routing calculations are vectorized and use numpy and scipy which keeps the array computation times on par with faster compiled languages.

The implemented routing methods are:
- Muskingum Cunge - Analytical solution
- Muskingum Cunge - Numerical solution

## Quick Start Guide
You will need to prepare a configuration file for the routing.

```python
import river_route as rr

rm = rr.RouteMuskingum('/path/to/config.yml')
rm.route()

river_id_to_inspect = 12345
rm.plot(river_id_to_inspect)
```

## Tips for efficient computations
Results will vary based on your system specifications, the size of the river network, and the length of the simulation.
These tips may help you achieve faster results.

1. **Use fewer inflow files**: File IO operations can be relatively slow and are a probable bottleneck on HPC systems
when I/O operations depend on networked drives. You may achieve faster results by doing a single computation
covering 2 weeks instead of 14 computations covering 1 day each.
2. **Cache routing Matrices**: The adjacency matrix and inverted I-C2@A matrix can be time consuming to compute. Provide
paths to store them in the config file to cache them between simulations
3. **Adjust the time step**: Using a longer time step will reduce the number of computations which takes less time to
compute. It also requires storing fewer intermediate results in memory yielding a modest reduction in memory usage. A
longer time step can increase performance if it does not induce numerical instability in the outflows.

18 changes: 18 additions & 0 deletions environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: rr
channels:
- conda-forge
- defaults
dependencies:
- dask
- fastparquet
- matplotlib
- netcdf4
- networkx
- numpy
- pandas
- petsc4py
- pyyaml
- scipy
- tqdm
- xarray
- zarr
4 changes: 4 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
dask
fastparquet
matplotlib
netcdf4
networkx
numpy
pandas
petsc4py
pyyaml
scipy
tqdm
Expand Down
8 changes: 8 additions & 0 deletions river_route/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
from river_route._route_muskingum import RouteMuskingum

__version__ = '0.1.0'
__author__ = 'Riley Hales PhD'
__url__ = 'https://github.com/rileyhales/river_route'

__all__ = [
'RouteMuskingum',

__version__,
__author__,
__url__
]
Loading

0 comments on commit a7913b2

Please sign in to comment.