double massbal_getFlowError() // // Input: none // Output: none // Purpose: computes flow routing mass balance error. // { double totalInflow; double totalOutflow; // --- get final volume of nodes and links FlowTotals.finalStorage = massbal_getStorage(TRUE); // --- add contributions to total inflow and outflow that are always positive totalInflow = FlowTotals.initStorage + FlowTotals.wwInflow + FlowTotals.iiInflow; totalOutflow = FlowTotals.finalStorage + FlowTotals.flooding + FlowTotals.evapLoss + FlowTotals.seepLoss + FlowTotals.reacted; // --- add on contributions that might be either positive or negative if ( FlowTotals.dwInflow >= 0.0 ) totalInflow += FlowTotals.dwInflow; else totalOutflow -= FlowTotals.dwInflow; if ( FlowTotals.gwInflow >= 0.0 ) totalInflow += FlowTotals.gwInflow; else totalOutflow -= FlowTotals.gwInflow; if ( FlowTotals.exInflow >= 0.0 ) totalInflow += FlowTotals.exInflow; else totalOutflow -= FlowTotals.exInflow; if ( FlowTotals.outflow >= 0.0 ) totalOutflow += FlowTotals.outflow; else totalInflow -= FlowTotals.outflow; // --- find percent difference between total inflow and outflow FlowTotals.pctError = 0.0; if ( fabs(totalInflow - totalOutflow) < 1.0 ) { FlowTotals.pctError = TINY; } else if ( fabs(totalInflow) > 0.0 ) { FlowTotals.pctError = 100.0 * (1.0 - totalOutflow / totalInflow); } else if ( fabs(totalOutflow) > 0.0 ) { FlowTotals.pctError = 100.0 * (totalInflow / totalOutflow - 1.0); } FlowError = FlowTotals.pctError; return FlowTotals.pctError; }
double massbal_getFlowError() // // Input: none // Output: none // Purpose: computes flow routing mass balance error. // { double totalInflow; double totalOutflow; double internalOutflow; // --- get final volume of nodes and links FlowTotals.finalStorage = massbal_getStorage(TRUE); // --- compute % difference between total inflow and outflow totalInflow = FlowTotals.dwInflow + FlowTotals.wwInflow + FlowTotals.gwInflow + FlowTotals.iiInflow + FlowTotals.exInflow + FlowTotals.initStorage; totalOutflow = FlowTotals.outflow + FlowTotals.pumpedVol + FlowTotals.finalStorage; FlowTotals.internalOutflow = 0.0; if ( fabs(totalInflow - totalOutflow) < 1.0 ) { FlowTotals.internalOutflow = TINY; } else { FlowTotals.internalOutflow = totalInflow - totalOutflow; } FlowError = FlowTotals.internalOutflow; return FlowTotals.internalOutflow; }