riverine.solver#
Pure solver functions for mix volume/concentration computation.
These functions take numeric inputs and return numeric outputs, with no dependency on Mix/Action objects. They will be replaced by Rust in Phase 1.
Functions#
|
Determine total mix volume from action effects. |
FixedVolume: each component gets the same fixed volume. |
|
EqualConcentration: adjust volumes so all dest concentrations are equal. |
|
FixedConcentration: vol = mix_vol * (fixed_conc / src_conc). |
|
ToConcentration: dest = target - already contributed. |
|
|
FillToVolume: buffer volume = target - sum(others). |
General dest concentration: dest_conc = src_conc * (transfer_vol / mix_vol). |
|
|
All validation checks on a solved mix. |
Module Contents#
- riverine.solver.compute_total_volume(action_effects: Sequence[tuple]) riverine.units.DecimalQuantity[source]#
Determine total mix volume from action effects.
- Parameters:
action_effects – List of (MixVolumeDep, volume) tuples from each action. MixVolumeDep values: “determines”, “independent”, “depends”.
- Returns:
The total volume of the mix.
- Return type:
- riverine.solver.compute_fixed_volume_each(fixed_volume: riverine.units.DecimalQuantity, n: int) list[riverine.units.DecimalQuantity][source]#
FixedVolume: each component gets the same fixed volume.
- Parameters:
fixed_volume – Volume per component.
n – Number of components.
- riverine.solver.compute_equal_concentration_each(fixed_volume: riverine.units.DecimalQuantity, source_concs: list[riverine.units.DecimalQuantity], method: Literal['min_volume', 'max_volume', 'check'] | tuple[Literal['max_fill'], str]) list[riverine.units.DecimalQuantity][source]#
EqualConcentration: adjust volumes so all dest concentrations are equal.
- Parameters:
fixed_volume – The reference volume (min or max depending on method).
source_concs – Source concentration of each component.
method – “min_volume”, “max_volume”, “check”, or (“max_fill”, buffer_name).
- riverine.solver.compute_fixed_concentration_each(mix_vol: riverine.units.DecimalQuantity, fixed_conc: riverine.units.DecimalQuantity, source_concs: list[riverine.units.DecimalQuantity]) list[riverine.units.DecimalQuantity][source]#
FixedConcentration: vol = mix_vol * (fixed_conc / src_conc).
- Parameters:
mix_vol – Total mix volume.
fixed_conc – Target destination concentration.
source_concs – Source concentration of each component.
- riverine.solver.compute_toconcentration_dest_concs(target_conc: riverine.units.DecimalQuantity, other_concs: list[riverine.units.DecimalQuantity]) list[riverine.units.DecimalQuantity][source]#
ToConcentration: dest = target - already contributed.
- Parameters:
target_conc – Target total concentration for each component.
other_concs – Concentration already contributed by other actions, per component.
- riverine.solver.compute_fill_volume(target_vol: riverine.units.DecimalQuantity, other_vols_sum: riverine.units.DecimalQuantity) riverine.units.DecimalQuantity[source]#
FillToVolume: buffer volume = target - sum(others).
- Parameters:
target_vol – Target total volume.
other_vols_sum – Sum of volumes from all other actions.
- riverine.solver.compute_dest_concentrations(source_concs: list[riverine.units.DecimalQuantity], each_vols: list[riverine.units.DecimalQuantity], mix_vol: riverine.units.DecimalQuantity) list[riverine.units.DecimalQuantity][source]#
General dest concentration: dest_conc = src_conc * (transfer_vol / mix_vol).
- Parameters:
source_concs – Source concentration of each component.
each_vols – Transfer volume of each component.
mix_vol – Total mix volume.
- riverine.solver.validate_mix(mixline_names_vols: list[tuple[list[str], riverine.units.DecimalQuantity | None]], total_vol: riverine.units.DecimalQuantity, min_volume: riverine.units.DecimalQuantity, has_fixed_concentration_action: bool, has_fixed_total_volume: bool, buffer_name: str, intermediate_mixes: list[tuple[str, riverine.units.DecimalQuantity, riverine.units.DecimalQuantity]]) list[riverine.units.VolumeError][source]#
All validation checks on a solved mix.
- Parameters:
mixline_names_vols – List of (names, total_tx_vol) from each mixline.
total_vol – Total mix volume.
min_volume – Minimum acceptable transfer volume.
has_fixed_concentration_action – Whether any action is FixedConcentration.
has_fixed_total_volume – Whether the mix has a fixed total volume.
buffer_name – Name of the buffer component.
intermediate_mixes – List of (mix_name, mix_fixed_total_vol, needed_vol) for intermediate mix checks.