Ejemplo n.º 1
0
        ///<summary>Computes new quality in a pipe segment after reaction occurs.</summary>
        private double Pipereact(QualityLink ql, double c, double v, long dt)
        {
            double cnew, dc, dcbulk, dcwall, rbulk, rwall;


            if (_qualflag == QualType.AGE)
            {
                return(c + dt / 3600.0);
            }


            rbulk = Bulkrate(c, ql.Link.Kb, _net.BulkOrder) * _bucf;
            rwall = Wallrate(c, ql.Link.Diameter, ql.Link.Kw, ql.FlowResistance);


            dcbulk = rbulk * dt;
            dcwall = rwall * dt;


            if (_htime >= _net.RStart)
            {
                _wbulk += Math.Abs(dcbulk) * v;
                _wwall += Math.Abs(dcwall) * v;
            }


            dc   = dcbulk + dcwall;
            cnew = c + dc;
            cnew = Math.Max(0.0, cnew);
            return(cnew);
        }
Ejemplo n.º 2
0
        ///<summary>Computes average quality in link.</summary>
        double Avgqual(QualityLink ql)
        {
            double vsum = 0.0,
                   msum = 0.0;

            if (_qualflag == QualType.NONE)
            {
                return(0.0);
            }

            foreach (QualitySegment seg  in  ql.Segments)
            {
                vsum += seg.V;
                msum += seg.C * seg.V;
            }

            if (vsum > 0.0)
            {
                return(msum / vsum);
            }
            else
            {
                return((ql.FirstNode.Quality + ql.SecondNode.Quality) / 2.0);
            }
        }
Ejemplo n.º 3
0
        ///<summary>Finds wall reaction rate coeffs.</summary>
        private double Piperate(QualityLink ql)
        {
            double a, d, u, kf, kw, y, re, sh;

            d = ql.Link.Diameter;

            if (_sc == 0.0)
            {
                if (_net.WallOrder == 0.0)
                {
                    return(Constants.BIG);
                }
                else
                {
                    return(ql.Link.Kw * (4.0 / d) / _elevUnits);
                }
            }

            a  = Math.PI * d * d / 4.0;
            u  = Math.Abs(ql.Flow) / a;
            re = u * d / _net.Viscos;

            if (re < 1.0)
            {
                sh = 2.0;
            }

            else if (re >= 2300.0)
            {
                sh = 0.0149 * Math.Pow(re, 0.88) * Math.Pow(_sc, 0.333);
            }
            else
            {
                y  = d / ql.Link.Lenght * re * _sc;
                sh = 3.65 + 0.0668 * y / (1.0 + 0.04 * Math.Pow(y, 0.667));
            }


            kf = sh * _net.Diffus / d;


            if (_net.WallOrder == 0.0)
            {
                return(kf);
            }


            kw = ql.Link.Kw / _elevUnits;
            kw = 4.0 / d * kw * kf / (kf + Math.Abs(kw));
            return(kw);
        }