Calculate tracer concentrations internally #1849
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #1105
Very much a work in progress. Currently calculates the concentration of hardcoded tracers, using no user input from tables (although that stage has been set).Ever since the rework from Bart in #1819 I felt calculating tracers would be simple to implement.This uses the intermediate flows from
update_cumulative_flows
to update the mass balance in all basins using straightforward addition/subtraction for each solver timestep. As such it should be more accurate than Delwaq (which uses the mean flows at the saveat interval). I do see some notable differences from Delwaq which needs investigating. Continuity tracer looks good though, so I'm slightly optimistic.My initial attempt was to add this calculation to the
save_flow
callback, at the same time interval we export to Delwaq, but since this only does addition over large timesteps (whereas Delwaq does integration) the results were quite off (especially in the beginning, hitting negative concentrations). The end results looked similar to this approach. I also looked into adding this stuff instead to thewater_balance!
methods, but I'm out of my depth in how the RHS works (in terms of sciml, caches, etc.).Decide on either using interpolation for temporal input or update (discretely) via callback:update: Use discrete callback for updating concentrationsuse_evaporation
(and come up with a better name, evaporate_mass?)UserDemand should return mass, not swallow it.