Example #1
0
        private void ComposeSource()
        {
            if (_net.Nodes.Count == 0)
            {
                return;
            }

            _writer.WriteStartElement(SectType.SOURCES.ToString().ToLower());

            foreach (Node node in _net.Nodes)
            {
                QualSource source = node.QualSource;
                if (source == null)
                {
                    continue;
                }

                _writer.WriteStartElement("node");
                _writer.WriteAttributeString("name", node.Name);
                _writer.WriteAttributeString("type", source.Type.ToString());
                _writer.WriteAttributeString("quality", XmlConvert.ToString(source.C0));


                if (source.Pattern != null)
                {
                    _writer.WriteAttributeString("pattern", source.Pattern.Name);
                }

                _writer.WriteEndElement();
            }

            _writer.WriteEndElement();
        }
Example #2
0
        ///<summary>Determines source concentration in current time period.</summary>
        private double Sourcequal(QualSource source)
        {
            double c = source.C0;

            if (source.Type == SourceType.MASS)
            {
                c /= 60.0;
            }
            else
            {
                c /= _net.FieldsMap.GetUnits(FieldType.QUALITY);
            }


            Pattern pat = source.Pattern;

            if (pat == null)
            {
                return(c);
            }

            long k = (_qtime + _net.PStart) / _net.PStep % pat.Count;

            return(c * pat[(int)k]);
        }
Example #3
0
        private void ComposeSource(Network net)
        {
            if (net.Nodes.Count == 0)
            {
                return;
            }

            buffer.WriteLine(SectType.SOURCES.ParseStr());
            buffer.WriteLine(SOURCE_SUBTITLE);


            foreach (Node node in net.Nodes)
            {
                QualSource source = node.QualSource;
                if (source == null)
                {
                    continue;
                }

                buffer.Write(
                    " {0}\t{1}\t{2}",
                    node.Name,
                    source.Type,
                    source.C0);

                if (source.Pattern != null)
                {
                    buffer.Write(" " + source.Pattern.Name);
                }

                buffer.WriteLine();
            }
            buffer.WriteLine();
        }
Example #4
0
        ///<summary>Computes contribution (if any) of mass additions from WQ sources at each node.</summary>
        /// <param name="dt">Step duration in seconds.</param>
        private void Sourceinput(long dt)
        {
            double qcutoff = 10.0 * Constants.TINY;

            foreach (QualityNode qN  in  _nodes)
            {
                qN.SourceContribution = 0;
            }


            if (_qualflag != QualType.CHEM)
            {
                return;
            }

            foreach (QualityNode qN  in  _nodes)
            {
                QualSource source = qN.Node.QualSource;

                // Skip node if no WQ source
                if (source == null)
                {
                    continue;
                }

                if (source.C0 == 0.0)
                {
                    continue;
                }

                // Find total flow volume leaving node
                double volout = qN.Node.Type == NodeType.JUNC ? qN.VolumeIn : qN.VolumeIn - qN.Demand * dt;

                double qout = volout / dt;

                double massadded = 0;

                // Evaluate source input only if node outflow > cutoff flow
                if (qout > qcutoff)
                {
                    // Mass added depends on type of source
                    double s = Sourcequal(source);

                    switch (source.Type)
                    {
                    case SourceType.CONCEN:
                        // Only add source mass if demand is negative
                        if (qN.Demand < 0.0)
                        {
                            massadded = -s * qN.Demand * dt;
                            if (qN.Node.Type > NodeType.JUNC)
                            {
                                qN.Quality = 0.0;
                            }
                        }
                        else
                        {
                            massadded = 0.0;
                        }
                        break;

                    // Mass Inflow Booster Source:
                    case SourceType.MASS:
                        massadded = s * dt;
                        break;

                    // Setpoint Booster Source:
                    // Mass added is difference between source
                    // & node concen. times outflow volume
                    case SourceType.SETPOINT:
                        if (s > qN.Quality)
                        {
                            massadded = (s - qN.Quality) * volout;
                        }
                        else
                        {
                            massadded = 0.0;
                        }
                        break;

                    // Flow-Paced Booster Source:
                    // Mass added = source concen. times outflow volume
                    case SourceType.FLOWPACED:
                        massadded = s * volout;
                        break;
                    }

                    // Source concen. contribution = (mass added / outflow volume)
                    qN.SourceContribution = massadded / volout;

                    // Update total mass added for time period & simulation
                    qN.MassRate = qN.MassRate + massadded;
                    if (_htime >= _net.RStart)
                    {
                        _wsource += massadded;
                    }
                }
            }

            // Add mass inflows from reservoirs to Wsource
            if (_htime >= _net.RStart)
            {
                foreach (QualityTank qT  in  _tanks)
                {
                    if (((Tank)qT.Node).Type == NodeType.RESERV)
                    {
                        double volout = qT.VolumeIn - qT.Demand * dt;
                        if (volout > 0.0)
                        {
                            _wsource += volout * qT.Concentration;
                        }
                    }
                }
            }
        }