private static double GetNodeValue(NodeVariableType type, FieldsMap fmap, AwareStep step, Node node, int index) { switch (type) { case NodeVariableType.BASEDEMAND: { double dsum = node.Demands.Sum(demand => demand.Base); return(fmap.RevertUnit((FieldType)type, dsum)); } case NodeVariableType.ELEVATION: return(fmap.RevertUnit((FieldType)type, node.Elevation)); case NodeVariableType.DEMAND: return(step != null?step.GetNodeDemand(index, node, fmap) : 0); case NodeVariableType.HEAD: return(step != null?step.GetNodeHead(index, node, fmap) : 0); case NodeVariableType.INITQUALITY: return(fmap.RevertUnit((FieldType)type, node.C0)); case NodeVariableType.PRESSURE: return(step != null?step.GetNodePressure(index, node, fmap) : 0); case NodeVariableType.QUALITY: return(step != null?step.GetNodeQuality(index) : 0); default: return(0.0); } }
///<summary>Load hydraulic simulation data to the water quality structures.</summary> private void LoadHydValues(AwareStep step) { int count = 0; foreach (QualityNode qN in _nodes) { qN.Demand = step.GetNodeDemand(count++, qN.Node, null); } count = 0; foreach (QualityLink qL in _links) { qL.Flow = step.GetLinkFlow(count++, qL.Link, null); } }
/// <summary> /// Retrieves hydraulic solution and time step for next hydraulic event from a hydraulics file. /// </summary> private ErrorCodeType GetHydVars() { AwareStep step = _tk2.GetStep((int)_msx.Htime); int n = _msx.Nobjects[(int)ObjectTypes.NODE]; for (int i = 0; i < n; i++) { _msx.D[i + 1] = (float)step.GetNodeDemand(i, null, null); } for (int i = 0; i < n; i++) { _msx.H[i + 1] = (float)step.GetNodeHead(i, null, null); } n = _msx.Nobjects[(int)ObjectTypes.LINK]; for (int i = 0; i < n; i++) { _msx.Q[i + 1] = (float)step.GetLinkFlow(i, null, null); } // update elapsed time until next hydraulic event _msx.Htime = step.Time + step.Step; // Initialize pipe segments (at time 0) or else re-orient segments to accommodate any flow reversals if (_msx.Qtime < _msx.Dur) { if (_msx.Qtime == 0) { InitSegs(); } else { ReorientSegs(); } } return(0); }