EcohydrologyTeam / ClearWater-riverine

A 2D water quality transporter model to calculate conservative advection and diffusion of constituents from an unstructured grid of flows
MIT License
6 stars 0 forks source link

Improve timestep performance #52

Open sjordan29 opened 7 months ago

sjordan29 commented 7 months ago

cProfile results (profile.prof), explored in SnakeViz identify bottlenecks in the code. For clearwater-riverine, the main bottleneck is in

clearwater_riverine\transport.py:159(update), and specifically within the code that updates the left hand side matrix to solve the transport equation. Within that function, time is primarily sent in xarray.

This issue can be closed when some low-hanging performance gains are made.

Hypothesis Variables are read from RAS HDF output to an xarray, but then those values must be put into a numpy format for compatibility with the sparse matrix solver. I think these data could be stored outside of an xarray and only saved to the xarray if requested by the user, which would reduce conversion in and out of xarray format.