This PR resolves mass balance issues, and fixes a bug with the channel plotting in the debug figure. A few minor speed improvements.
mass balance
Resolved the mass balance issue (closes #62). There were two bugs in water and sediment routing.
One was that the connection in the flowsToFrac graph was being set incorrectly; the flow fraction was being set for the receiving cell, rather than the contributing cell, so that the whole graph was just shifted for the whole run. Honestly, I'm surprised the model worked at all with this bug :shrug:.
The second was probably more so the mass balance issue. This was that in sediment Qs_in calculations when there was only one contributor to a cell, the total sediment from that cell was being taken, even though that contributor could a branching cell. Now, all sediment calculation follows the same checks, regardless of the number of contributing cells; this is slightly slower, but it's safer and easier to read/maintain. In the process of figuring the mass balance issue out, I have added a mass balance check, which is now included in this PR. This mass balance takes 0.8% of the computation time of the updateTopography function (0.2% of the total run time), so I think it's worth leaving in as a sanity check.
display of channels
I also realized that the channel display function was limited in the number of branches it would iterate over (see the ==2 here). The result of this check for number of connecting cells was that if the number was > 2, then no links beyond this point would be drawn. After fixing that issue, it seems that there are many many more channels present for the no-water simulations, but there still does not appear to be any effect for the fan-delta case. I guess this is because the water causes aggradation and more frequent avulsions than in the no water case (where sediment is spread over a longer channel area across the whole domain.
This PR resolves mass balance issues, and fixes a bug with the channel plotting in the debug figure. A few minor speed improvements.
mass balance
Resolved the mass balance issue (closes #62). There were two bugs in water and sediment routing.
flowsToFrac
graph was being set incorrectly; the flow fraction was being set for the receiving cell, rather than the contributing cell, so that the whole graph was just shifted for the whole run. Honestly, I'm surprised the model worked at all with this bug :shrug:.Qs_in
calculations when there was only one contributor to a cell, the total sediment from that cell was being taken, even though that contributor could a branching cell. Now, all sediment calculation follows the same checks, regardless of the number of contributing cells; this is slightly slower, but it's safer and easier to read/maintain. In the process of figuring the mass balance issue out, I have added a mass balance check, which is now included in this PR. This mass balance takes 0.8% of the computation time of theupdateTopography
function (0.2% of the total run time), so I think it's worth leaving in as a sanity check.display of channels
I also realized that the channel display function was limited in the number of branches it would iterate over (see the
==2
here). The result of this check for number of connecting cells was that if the number was> 2
, then no links beyond this point would be drawn. After fixing that issue, it seems that there are many many more channels present for the no-water simulations, but there still does not appear to be any effect for the fan-delta case. I guess this is because the water causes aggradation and more frequent avulsions than in the no water case (where sediment is spread over a longer channel area across the whole domain.