示例#1
0
        public override void Execute(bool propagate)
        {
            //if dew point is known
            HumidGasCalculator humidGasCalculator = GetHumidGasCalculator();

            if (dewPoint.HasValue)
            {
                if (relativeHumidity.HasValue && !temperature.IsSpecifiedAndHasValue)
                {
                    Calculate(temperature, humidGasCalculator.GetDryBulbFromDewPointAndRelativeHumidity(dewPoint.Value, relativeHumidity.Value));
                }
                else if (pressure.HasValue)
                {
                    if (dewPoint.Value <= 1.0e-10 && !moistureContentDryBase.IsSpecifiedAndHasValue)
                    {
                        Calculate(moistureContentDryBase, 0);
                    }
                    else if (!moistureContentDryBase.IsSpecifiedAndHasValue)
                    {
                        Calculate(moistureContentDryBase, humidGasCalculator.GetHumidityFromDewPointAndPressure(dewPoint.Value, pressure.Value));
                    }
                }
                //Pressure should always be known. So it should not be calculated
                else if (moistureContentDryBase.HasValue)
                {
                    //Calculate(pressure, humidGasCalculator.GetPressureFromDewPointAndHumidity(dewPoint.Value, humidity.Value));
                }
            }

            //if humidity is known
            if (moistureContentDryBase.HasValue)
            {
                if (pressure.HasValue && !dewPoint.IsSpecifiedAndHasValue)
                {
                    Calculate(dewPoint, humidGasCalculator.GetDewPointFromHumidityAndPressure(moistureContentDryBase.Value, pressure.Value));
                }

                //to prevent repeated calculation of the same variable
                //if (relativeHumidity.HasValue && dewPoint.HasValue && !temperature.IsSpecifiedAndHasValue) {
                if (relativeHumidity.HasValue && dewPoint.HasValue && !temperature.HasValue)
                {
                    Calculate(temperature, humidGasCalculator.GetDryBulbFromDewPointAndRelativeHumidity(dewPoint.Value, relativeHumidity.Value));
                }

                //to prevent repeated calculation of the same variable
                //if (wetBulbTemperature.HasValue && pressure.HasValue && !temperature.IsSpecifiedAndHasValue) {
                if (wetBulbTemperature.HasValue && pressure.HasValue && !temperature.HasValue)
                {
                    Calculate(temperature, humidGasCalculator.GetDryBulbFromWetBulbHumidityAndPressure(wetBulbTemperature.Value, moistureContentDryBase.Value, pressure.Value));
                }
            }

            //to prevent repeated calculation of the same variable
            //if (wetBulbTemperature.HasValue && relativeHumidity.HasValue && pressure.HasValue
            //   && !temperature.IsSpecifiedAndHasValue) {
            if (wetBulbTemperature.HasValue && relativeHumidity.HasValue && pressure.HasValue &&
                !temperature.HasValue)
            {
                Calculate(temperature, humidGasCalculator.GetDryBulbFromWetBulbRelativeHumidityAndPressure(wetBulbTemperature.Value, relativeHumidity.Value, pressure.Value));
            }

            double humidEnthalpyValue;
            double mcDryBase = moistureContentDryBase.Value;

            if (specificEnthalpy.HasValue && moistureContentDryBase.HasValue && !specificEnthalpyDryBase.HasValue)
            {
                Calculate(specificEnthalpyDryBase, specificEnthalpy.Value * (1.0 + mcDryBase));
            }

            //if (specificEnthalpyDryBase.HasValue && pressure.HasValue && !temperature.IsSpecifiedAndHasValue) {
            if (specificEnthalpyDryBase.HasValue && pressure.HasValue && !temperature.HasValue)
            {
                if (moistureContentDryBase.HasValue)
                {
                    Calculate(temperature, humidGasCalculator.GetDryBulbFromHumidEnthalpyHumidityAndPressure(specificEnthalpyDryBase.Value, moistureContentDryBase.Value, pressure.Value));
                }
                else if (relativeHumidity.HasValue)
                {
                    Calculate(temperature, humidGasCalculator.GetDryBulbFromHumidEnthalpyRelativeHumidityAndPressure(specificEnthalpyDryBase.Value, relativeHumidity.Value, pressure.Value));
                }
                else if (dewPoint.HasValue)
                {
                    Calculate(temperature, humidGasCalculator.GetDryBulbFromHumidEnthalpyDewPointAndPressure(specificEnthalpyDryBase.Value, relativeHumidity.Value, pressure.Value));
                }
                else if (wetBulbTemperature.HasValue)
                {
                    Calculate(temperature, humidGasCalculator.GetDryBulbFromHumidEnthalpyWetBulbAndPressure(specificEnthalpyDryBase.Value, wetBulbTemperature.Value, pressure.Value));
                }
            }

            //if temperature is first known
            if (temperature.HasValue)
            {
                if (dewPoint.HasValue || relativeHumidity.HasValue)
                {
                    if (dewPoint.HasValue && !relativeHumidity.IsSpecifiedAndHasValue)
                    {
                        Calculate(relativeHumidity, humidGasCalculator.GetRelativeHumidityFromDryBulbAndDewPoint(temperature.Value, dewPoint.Value));
                    }
                    else if (relativeHumidity.HasValue && !dewPoint.IsSpecifiedAndHasValue)
                    {
                        Calculate(dewPoint, humidGasCalculator.GetDewPointFromDryBulbAndRelativeHumidity(temperature.Value, relativeHumidity.Value));
                    }

                    if (pressure.HasValue)
                    {
                        if (!moistureContentDryBase.IsSpecifiedAndHasValue)
                        {
                            Calculate(moistureContentDryBase, humidGasCalculator.GetHumidityFromDewPointAndPressure(dewPoint.Value, pressure.Value));
                        }
                        if (!wetBulbTemperature.IsSpecifiedAndHasValue)
                        {
                            Calculate(wetBulbTemperature, humidGasCalculator.GetWetBulbFromDryBulbHumidityAndPressure(temperature.Value, moistureContentDryBase.Value, pressure.Value));
                            double satTemp = humidGasCalculator.GetSatTempFromDryBulbHumidityAndPressure(temperature.Value, moistureContentDryBase.Value, pressure.Value);
                        }
                    }
                    else if (moistureContentDryBase.HasValue)
                    {
                        if (!pressure.IsSpecifiedAndHasValue)
                        {
                            Calculate(pressure, humidGasCalculator.GetPressureFromDewPointAndHumidity(dewPoint.Value, moistureContentDryBase.Value));
                        }
                        if (!wetBulbTemperature.IsSpecifiedAndHasValue)
                        {
                            Calculate(wetBulbTemperature, humidGasCalculator.GetWetBulbFromDryBulbHumidityAndPressure(temperature.Value, moistureContentDryBase.Value, pressure.Value));
                            double satTemp = humidGasCalculator.GetSatTempFromDryBulbHumidityAndPressure(temperature.Value, moistureContentDryBase.Value, pressure.Value);
                        }
                    }
                }
                else if (wetBulbTemperature.HasValue && pressure.HasValue)
                {
                    if (!moistureContentDryBase.IsSpecifiedAndHasValue)
                    {
                        Calculate(moistureContentDryBase, humidGasCalculator.GetHumidityFromDryBulbWetBulbAndPressure(temperature.Value, wetBulbTemperature.Value, pressure.Value));
                    }
                    if (!relativeHumidity.IsSpecifiedAndHasValue)
                    {
                        Calculate(relativeHumidity, humidGasCalculator.GetRelativeHumidityFromDryBulbHumidityAndPressure(temperature.Value, moistureContentDryBase.Value, pressure.Value));
                    }
                    if (!dewPoint.IsSpecifiedAndHasValue)
                    {
                        Calculate(dewPoint, humidGasCalculator.GetDewPointFromDryBulbAndRelativeHumidity(temperature.Value, relativeHumidity.Value));
                    }
                }

                else if (moistureContentDryBase.HasValue && pressure.HasValue)
                {
                    if (!wetBulbTemperature.IsSpecifiedAndHasValue)
                    {
                        Calculate(wetBulbTemperature, humidGasCalculator.GetWetBulbFromDryBulbHumidityAndPressure(temperature.Value, moistureContentDryBase.Value, pressure.Value));
                        double satTemp = humidGasCalculator.GetSatTempFromDryBulbHumidityAndPressure(temperature.Value, moistureContentDryBase.Value, pressure.Value);
                    }

                    if (!relativeHumidity.IsSpecifiedAndHasValue)
                    {
                        Calculate(relativeHumidity, humidGasCalculator.GetRelativeHumidityFromDryBulbHumidityAndPressure(temperature.Value, moistureContentDryBase.Value, pressure.Value));
                    }
                    if (!dewPoint.IsSpecifiedAndHasValue)
                    {
                        Calculate(dewPoint, humidGasCalculator.GetDewPointFromDryBulbAndRelativeHumidity(temperature.Value, relativeHumidity.Value));
                    }
                }

                else if (wetBulbTemperature.HasValue && moistureContentDryBase.HasValue)
                {
                    //if (!pressure.IsSpecifiedAndHasValue) {
                    //   Calculate(pressure, humidGasCalculator.GetPressureFromDryBulbWetBulbAndHumidity(temperature.Value, wetBulbTemperature.Value, moistureContentDryBase.Value));
                    //}
                    if (!dewPoint.IsSpecifiedAndHasValue)
                    {
                        Calculate(dewPoint, humidGasCalculator.GetDewPointFromHumidityAndPressure(temperature.Value, pressure.Value));
                    }
                    if (!relativeHumidity.IsSpecifiedAndHasValue)
                    {
                        Calculate(relativeHumidity, humidGasCalculator.GetRelativeHumidityFromDryBulbAndDewPoint(temperature.Value, dewPoint.Value));
                    }
                }
            }

            mcDryBase = moistureContentDryBase.Value;
            if (moistureContentDryBase.HasValue && temperature.HasValue)
            {
                double cpDryBase = humidGasCalculator.GetHumidHeat(moistureContentDryBase.Value, temperature.Value);
                Calculate(specificHeatDryBase, cpDryBase);
                Calculate(specificHeat, cpDryBase / (1.0 + mcDryBase));
                if (pressure.HasValue)
                {
                    double humidVolumeValue = humidGasCalculator.GetHumidVolume(temperature.Value, moistureContentDryBase.Value, pressure.Value);
                    Calculate(humidVolume, humidVolumeValue);
                    humidEnthalpyValue = humidGasCalculator.GetHumidEnthalpyFromDryBulbHumidityAndPressure(temperature.Value, moistureContentDryBase.Value, pressure.Value);
                    Calculate(specificEnthalpyDryBase, humidEnthalpyValue);
                    Calculate(specificEnthalpy, humidEnthalpyValue / (1.0 + mcDryBase));
                    Calculate(density, (1.0 + mcDryBase) / humidVolumeValue);
                }
            }

            CalculateFlow();

            //if (temperature.HasValue && pressure.HasValue && massFlowRate.HasValue &&
            //   volumeFlowRate.HasValue && massFlowRateDryBase.HasValue && wetBulbTemperature.HasValue &&
            //   dewPoint.HasValue && moistureContentDryBase.HasValue && relativeHumidity.HasValue &&
            //   density.HasValue && specificEnthalpy.HasValue && specificHeatDryBase.HasValue) {
            //   solveState = SolveState.Solved;
            //}

            bool hasUnsolvedVar = false;

            foreach (ProcessVarDouble pv in varList)
            {
                if (!pv.HasValue)
                {
                    hasUnsolvedVar = true;
                    break;
                }
            }
            if (!hasUnsolvedVar)
            {
                solveState = SolveState.Solved;
            }
            //else
            //{
            //   foreach (ProcessVarDouble pv in varList)
            //   {
            //      if (!pv.IsSpecified && pv.HasValue)
            //      {
            //         solveState = SolveState.PartiallySolved;
            //         break;
            //      }
            //   }
            //}

            if (HasSolvedAlready)
            {
                DryingGasComponents dgc = (DryingGasComponents)materialComponents;
                //we cannot do a calculate operation since these variables are not in the
                //varList and they cannot be erased after they are initially calculated
                dgc.DryMedium.SetMassFractionValue(1.0 / (1.0 + Humidity.Value));
                dgc.Moisture.SetMassFractionValue(Humidity.Value / (1.0 + Humidity.Value));
                dgc.ComponentsFractionsChanged();
            }
            AdjustVarsStates();
            OnSolveComplete();
        }