r-barnes / faster-unmixer

A faster implementation of the sediment inverse/unmixing scheme proposed in Lipp et al (2021).
5 stars 1 forks source link

Allow variable production rates #35

Closed AlexLipp closed 1 year ago

AlexLipp commented 1 year ago

NB This branch builds off #33 not main

Previously we have considered that each sub-basin in a network contributes an amount of material proportional only to its unique area. However, in reality, this is weighted according to the sediment generation rate (in the case of a sediment hosted tracer) or the run off rate (in the case of water hosted tracer). To modify this, this PR adds an export_rate to each node in the network. This can (optionally) be set by the user using a dictionary of values which map a sample name to export rate. If this is not provided, default values of 1 for each node are used (i.e., equal weighting across all sub-catchments).

As the network now tracks the total flux of material and the total flux of a particular tracer within that material, I have renamed some of the node attributes to prevent conclusion. e.g., total_flux and total_tracer_flux now track the total flux of all material (e.g., water/sediment) and the total_tracer_flux now tracks the total flux of the tracer within it.

It is desirable for problems to be DPP compliant as it allows for them to be resolved with differing parameter values efficiently. This, for example, would allow multiple different export_rates to be tried to explore the impact on the calculated upstream solutions. In keeping with the DPP ruleset I have added a number of intermediate dummy variables, and associated constraints to ensure the problem is DPP.

As we now have two further sets of parameters to set (the export_rate parameters and the new dummy parameter inverse_total_flux) I have abstracted the parameter setting codes in the solve() function to three new functions:_set_observation_parameters etc.

Finally, I have modified the synthetic test to consider a random set of export rates, which are provided in the input and for the solution. I also now use a simpler, synthetic, test dataset to better track inputs and outputs.