Mass balance equations are the foundation of WEAP's monthly water accounting: total inflows equal total outflows, net of any change in storage (in reservoirs and aquifers). Every node and link in WEAP has a mass balance equation, and some have additional equations which constrain their flows (e.g., inflow to a demand site cannot exceed its supply requirement, outflows from an aquifer cannot exceed its maximum withdrawal, link losses are a fraction of flow, etc.).
Each mass balance equation becomes a constraint in the LP.
Inflow = Outflow + AdditionToStorage
which can be rewritten as
Inflow - Outflow - AdditionToStorage = 0
AdditionToStorage only applies to reservoirs and aquifers. AdditionToStorage is positive for an increase in storage and negative for a decrease in storage. Outflow includes consumption and losses.
Every flow from one point to another is represented by a variable in the LP.
For example, assume Demand Site A draws from Supplies B and C, and returns water to those same supplies, as well as consuming some of the water. The mass balance equation would be
InflowB,A + InflowC,A - OutflowA,B - OutflowA,C - ConsumptionA = 0
Where InflowB,A is the inflow from supply B to demand site A. The LP constraint would be a row in the LP matrix, with coefficients of 1 for the inflow variables and -1 for the outflow variables. The entire row would be set equal to 0.
As another example, if there were losses in transmission link D, which transmits supply from supply B to demand site A, the mass balance equation for the transmission link would be:
InflowB,D - OutflowD,A - LossesD = 0
And the first example would be rewritten as
InflowD,A + InflowC,A - OutflowA,B - OutflowA,C - ConsumptionA = 0