EcohydrologyTeam / ClearWater-modules

A collection of water quality and vegetation process simulation modules designed to couple with water transport models.
MIT License
5 stars 0 forks source link

Pre-Initialize model xarray with timesteps #77

Closed sjordan29 closed 6 months ago

sjordan29 commented 6 months ago

Closes #68

This PR adds a new required time_steps parameter for instantiation of the base model class. Writing to a pre-initialized array rather than continuously concatenating arrays has speed advantages, particularly for large model grids and a large number of model timesteps -- as shown in #68, for models with > 100 iterations and >10 model cells, we see performance gains which become substantial as the number of iterations/grid sizes grows (>14x improvement at best). Additional memory management improvements will help address minor slowdowns for single-cell models.

sjordan29 commented 6 months ago

@imscw95, @kewalak - FYI - merging this to main. Changes require models to have a time_steps input parameter during instantiation to initialize the xarray dataset we're running and improve performance.