コード例 #1
0
 public MainWindow()
 {
     InitializeComponent();
     Loaded += MainWindow_Loaded;
     XPlatHelper.DeterminePlatform();
     GlobalInputs = new SystemInputStream();
 }
コード例 #2
0
 public void AssemblyProjectList(RunParameters runParameters)
 {
     foreach (var path in runParameters.PathList)
     {
         string workingPath = XPlatHelper.FullyNormalizePath(Directory.GetCurrentDirectory(), path);
         if (workingPath.EndsWith(".sln", StringComparison.OrdinalIgnoreCase))
         {
             this.SolutionFileParsers.Add(new SolutionFileParser(workingPath));
         }
         else
         {
             this.ProjectFiles.Add(new ProjectFileReference(workingPath));
         }
     }
 }
コード例 #3
0
        public void ParseAndResolve(Dictionary <string, ProjectFile> masterProjectList)
        {
            XDocument xDocument               = XDocument.Load(this.FilePath);
            string    sdk                     = ((xDocument.XPathEvaluate("/Project/@Sdk") as IEnumerable <object>)?.FirstOrDefault() as XAttribute)?.Value;
            string    outputType              = (xDocument.XPathSelectElement("/Project/PropertyGroup[not(@Condition) or @Condition='']/OutputType"))?.Value;
            var       packageReferences       = (xDocument.XPathEvaluate("/Project/ItemGroup/PackageReference/@Include") as IEnumerable <object>)?.Cast <XAttribute>();
            var       projectReferences       = (xDocument.XPathEvaluate("/Project/ItemGroup/ProjectReference/@Include") as IEnumerable <object>)?.Cast <XAttribute>();
            var       canPackageReference     = (xDocument.XPathSelectElement("/Project/PropertyGroup[not(@Condition) or @Condition='']/IsPackable"))?.Value;
            var       packageIdReference      = (xDocument.XPathSelectElement("/Project/PropertyGroup[not(@Condition) or @Condition='']/PackageId"))?.Value;
            var       packageOnBuildReference = (xDocument.XPathSelectElement("/Project/PropertyGroup[not(@Condition) or @Condition='']/GeneratePackageOnBuild"))?.Value;

            if (string.Equals(sdk, WebSdk, StringComparison.OrdinalIgnoreCase))
            {
                this.ProjectType = TypeOfProject.Web;
            }
            else if (packageReferences.Any(a => string.Equals(a.Value, TestSdk, StringComparison.OrdinalIgnoreCase)))
            {
                this.ProjectType = TypeOfProject.Test;
            }
            else if (string.Equals(outputType, Exe, StringComparison.OrdinalIgnoreCase))
            {
                this.ProjectType = TypeOfProject.Application;
            }
            else
            {
                this.ProjectType = TypeOfProject.Library;
            }

            foreach (var include in projectReferences)
            {
                var includePath = XPlatHelper.FullyNormalizePath(this.Directory, include.Value);
                this.DependentOn.Add(masterProjectList[includePath]);
            }

            if (bool.TryParse(canPackageReference, out var canPackage) && canPackage &&
                !string.IsNullOrWhiteSpace(packageIdReference))
            {
                if (bool.TryParse(packageOnBuildReference, out var packageOnBuild) && packageOnBuild)
                {
                    this.Package = PackageType.PackageOnBuild;
                }
                else
                {
                    this.Package = PackageType.PackageStepNeeded;
                }
            }
        }
コード例 #4
0
        void ProcStartProject(string line)
        {
            var match = ProjectLineRegex.Match(line);

            if (match.Groups.Count == 5)
            {
                if (match.Groups[1].Value.ToUpperInvariant() == SolutionFolderId)
                {
                    this.SolutionFileState = State.InSolutionFolder;
                    return;
                }
                this.currentProject = new ProjectFileReference()
                {
                    Id       = match.Groups[4].Value.ToUpperInvariant(),
                    Name     = match.Groups[2].Value,
                    FilePath = XPlatHelper.FullyNormalizePath(this.SolutionFile.Directory, match.Groups[3].Value)
                };
                this.SolutionFile.ProjectFiles.Add(this.currentProject);
            }

            this.SolutionFileState = State.InProject;
        }
コード例 #5
0
        public static void ComputeAdditionalProperty(ref SystemInputStream _in, ref double AirX, ref double WaterX)
        {
            #region Variable declarations
            const double Epsilon = 0.75;

            //All properties are final state
            double DensityWaterInitial;
            double DensityAirInitial;

            double MassFlowWaterFinal;
            double MassFlowAirFinal;

            double TWaterFinal;
            double TAirFinal;
            double TWaterMeanFinal;
            double TAirMeanFinal;
            double ViscosityAir;
            double ViscosityWater;
            double CpAir;
            double CpWater;
            double PrandtlAir;
            double PrandtlWater;
            double G_Air;
            double G_Water;
            double Reynolds_Air;
            double Reynolds_Water;
            double J_Water;
            double F_Water;
            double J_Air;
            double F_Air;
            double H_Water;
            double H_Air;
            double c7;
            double c8;
            double c9;
            double VelocityAir;
            double FinEfficiency;
            double OverallEfficiency;
            double Rw;
            double UaInverse;
            double C_Water;
            double C_Air;
            double C_Min;
            double C_Star;
            double NTU;
            double epsilon;
            double ConductionAreaWater;
            double ConductionAreaAir;
            double lambdaAir;
            double lambdaWater;
            double M1;
            double M2;
            double EpsilonRatio;
            double deltaEpsilon;
            double ActualEpsilon;
            double HeatTransferRate;
            double prevvalWater;
            double prevvalAir;
            #endregion

            #region User Input acquisition
            double L1           = _in.NumericalReadings.First(x => x.Parameter == "L1").Value;
            double L2           = _in.NumericalReadings.First(x => x.Parameter == "L2").Value;
            double L3           = _in.NumericalReadings.First(x => x.Parameter == "L3").Value;
            double Xt           = _in.NumericalReadings.First(x => x.Parameter == "Xt").Value;
            double Xl           = _in.NumericalReadings.First(x => x.Parameter == "Xl").Value;
            double Do           = _in.NumericalReadings.First(x => x.Parameter == "Do").Value;
            double Di           = _in.NumericalReadings.First(x => x.Parameter == "Di").Value;
            double DelH         = _in.NumericalReadings.First(x => x.Parameter == "DelH").Value;
            double FinThickness = _in.NumericalReadings.First(x => x.Parameter == "FinThickness").Value;

            double QWaterInitial = _in.NumericalReadings.First(x => x.Parameter == "QWaterInitial").Value;
            double TWaterInitial = _in.NumericalReadings.First(x => x.Parameter == "TWaterInitial").Value;
            double PWaterInitial = _in.NumericalReadings.First(x => x.Parameter == "PWaterInitial").Value;

            double QAirInitial = _in.NumericalReadings.First(x => x.Parameter == "QAirInitial").Value;
            double TAirInitial = _in.NumericalReadings.First(x => x.Parameter == "TAirInitial").Value;
            double PAirInitial = _in.NumericalReadings.First(x => x.Parameter == "PAirInitial").Value;
            //double Nr = _in.NumericalReadings.First(x => x.Parameter == "Nr").Value;
            double FinPitch = _in.NumericalReadings.First(x => x.Parameter == "FinPitch").Value;

            double Nr = L3 / Xt;

            DensityWaterInitial = PWaterInitial / (287.04 * (TWaterInitial));
            DensityAirInitial   = PAirInitial / (287.04 * (TAirInitial));

            MassFlowWaterFinal = QWaterInitial * DensityWaterInitial;
            MassFlowAirFinal   = QAirInitial * DensityAirInitial;
            #endregion

            #region Iteration
            do
            {
                #region TMean calculation

                TWaterFinal     = TWaterInitial - Epsilon * (TWaterInitial - TAirInitial);
                TAirFinal       = TAirInitial + Epsilon * (MassFlowWaterFinal / MassFlowAirFinal) * (TWaterInitial - TAirInitial);
                TWaterMeanFinal = (TWaterFinal + TWaterInitial) / 2;
                TAirMeanFinal   = (TAirFinal + TAirInitial) / 2;

                #endregion

                prevvalAir   = TAirFinal;
                prevvalWater = TWaterFinal;

                #region CoolProp

                //Calculate additional properties
                ViscosityAir   = CoolProp.PropsSI("V", "T", TAirMeanFinal, "P", 101325, "Air");
                ViscosityWater = CoolProp.PropsSI("V", "T", TWaterMeanFinal, "P", 101325, "Water");
                CpAir          = CoolProp.PropsSI("CPMASS", "T", TWaterMeanFinal, "P", 101325, "Water");
                CpWater        = CoolProp.PropsSI("CPMASS", "T", TWaterMeanFinal, "P", 101325, "Water");
                PrandtlAir     = CoolProp.PropsSI("CPMASS", "T", TWaterMeanFinal, "P", 101325, "Water");
                PrandtlWater   = CoolProp.PropsSI("CPMASS", "T", TWaterMeanFinal, "P", 101325, "Water");

                #endregion

                #region Calculate G and Re

                G_Air = MassFlowAirFinal /
                        ((_in.SysType == SystemType.Inline)
                            ? _in.TubeOutsideInlineData.TotalMinFfArea
                            : _in.TubeOutsideStaggered.TotalMinFfArea);

                G_Water = MassFlowWaterFinal /
                          ((_in.SysType == SystemType.Inline)
                              ? _in.TubeOutsideInlineData.TotalMinFfArea
                              : _in.TubeOutsideStaggered.TotalMinFfArea);

                Reynolds_Air = G_Air * ((_in.SysType == SystemType.Inline)
                    ? _in.TubeOutsideInlineData.HydDiameter
                    : _in.TubeOutsideStaggered.HydDiameter) / ViscosityAir;

                Reynolds_Water = G_Water * ((_in.SysType == SystemType.Inline)
                    ? _in.TubeOutsideInlineData.HydDiameter
                    : _in.TubeOutsideStaggered.HydDiameter) / ViscosityWater;

                #endregion

                #region Calculation of J

                if (Nr <= 1)
                {
                    if (_in.SysType == SystemType.Inline)
                    {
                        double c1 = 1.9 - 0.23 * Math.Log(Reynolds_Water);
                        double c2 = -0.236 + 0.126 * Math.Log(Reynolds_Water);
                        J_Water = 0.108 * Math.Pow(Reynolds_Water, -0.29) * Math.Pow(Xt / Xl, c1) * Math.Pow(FinPitch / Do, 1.084) *
                                  Math.Pow(FinPitch / _in.TubeOutsideInlineData.HydDiameter, -0.786) *
                                  Math.Pow(FinPitch / Xt, c2);


                        c1    = 1.9 - 0.23 * Math.Log(Reynolds_Air);
                        c2    = -0.236 + 0.126 * Math.Log(Reynolds_Air);
                        J_Air = 0.108 * Math.Pow(Reynolds_Air, -0.29) * Math.Pow(Xt / Xl, c1) * Math.Pow(FinPitch / Do, 1.084) *
                                Math.Pow(FinPitch / _in.TubeOutsideInlineData.HydDiameter, -0.786) *
                                Math.Pow(FinPitch / Xt, c2);
                    }
                    else
                    {
                        double c1 = 1.9 - 0.23 * Math.Log(Reynolds_Water);
                        double c2 = -0.236 + 0.126 * Math.Log(Reynolds_Water);
                        J_Water = 0.108 * Math.Pow(Reynolds_Water, -0.29) * Math.Pow(Xt / Xl, c1) * Math.Pow(FinPitch / Do, 1.084) *
                                  Math.Pow(FinPitch / _in.TubeOutsideStaggered.HydDiameter, -0.786) *
                                  Math.Pow(FinPitch / Xt, c2);


                        c1    = 1.9 - 0.23 * Math.Log(Reynolds_Air);
                        c2    = -0.236 + 0.126 * Math.Log(Reynolds_Air);
                        J_Air = 0.108 * Math.Pow(Reynolds_Air, -0.29) * Math.Pow(Xt / Xl, c1) * Math.Pow(FinPitch / Do, 1.084) *
                                Math.Pow(FinPitch / _in.TubeOutsideStaggered.HydDiameter, -0.786) *
                                Math.Pow(FinPitch / Xt, c2);
                    }
                }
                else
                {
                    if (_in.SysType == SystemType.Inline)
                    {
                        //Water
                        double c3 = -0.361 - 0.042 * Nr / Math.Log(Reynolds_Water) +
                                    0.158 * Math.Log(Nr * Math.Pow(FinPitch / Do, 0.41));
                        double c4 = -1.224 -
                                    0.076 * Math.Pow(Xl / _in.TubeOutsideInlineData.HydDiameter, 1.42) /
                                    Math.Log(Reynolds_Water);
                        double c5 = -0.083 + 0.058 * Nr / Math.Log(Reynolds_Water);
                        double c6 = -5.735 + 1.21 * Math.Log(Reynolds_Water / Nr);
                        J_Water = 0.086 * Math.Pow(Reynolds_Water, c3) * Math.Pow(Nr, c4) * Math.Pow(FinPitch / Do, c5) *
                                  Math.Pow(FinPitch / _in.TubeOutsideInlineData.HydDiameter, c6) *
                                  Math.Pow(FinPitch / Xt, -0.93);
                        //Air
                        c3 = -0.361 - 0.042 * Nr / Math.Log(Reynolds_Air) + 0.158 * Math.Log(Nr * Math.Pow(FinPitch / Do, 0.41));
                        c4 = -1.224 -
                             0.076 * Math.Pow(Xl / _in.TubeOutsideInlineData.HydDiameter, 1.42) / Math.Log(Reynolds_Air);
                        c5    = -0.083 + 0.058 * Nr / Math.Log(Reynolds_Air);
                        c6    = -5.735 + 1.21 * Math.Log(Reynolds_Air / Nr);
                        J_Air = 0.086 * Math.Pow(Reynolds_Air, c3) * Math.Pow(Nr, c4) * Math.Pow(FinPitch / Do, c5) *
                                Math.Pow(FinPitch / _in.TubeOutsideInlineData.HydDiameter, c6) *
                                Math.Pow(FinPitch / Xt, -0.93);
                    }
                    else
                    {
                        //Water
                        double c3 = -0.361 - 0.042 * Nr / Math.Log(Reynolds_Water) +
                                    0.158 * Math.Log(Nr * Math.Pow(FinPitch / Do, 0.41));
                        double c4 = -1.224 -
                                    0.076 * Math.Pow(Xl / _in.TubeOutsideStaggered.HydDiameter, 1.42) /
                                    Math.Log(Reynolds_Water);
                        double c5 = -0.083 + 0.058 * Nr / Math.Log(Reynolds_Water);
                        double c6 = -5.735 + 1.21 * Math.Log(Reynolds_Water / Nr);
                        J_Water = 0.086 * Math.Pow(Reynolds_Water, c3) * Math.Pow(Nr, c4) * Math.Pow(FinPitch / Do, c5) *
                                  Math.Pow(FinPitch / _in.TubeOutsideStaggered.HydDiameter, c6) *
                                  Math.Pow(FinPitch / Xt, -0.93);
                        //Air
                        c3 = -0.361 - 0.042 * Nr / Math.Log(Reynolds_Air) + 0.158 * Math.Log(Nr * Math.Pow(FinPitch / Do, 0.41));
                        c4 = -1.224 -
                             0.076 * Math.Pow(Xl / _in.TubeOutsideStaggered.HydDiameter, 1.42) / Math.Log(Reynolds_Air);
                        c5    = -0.083 + 0.058 * Nr / Math.Log(Reynolds_Air);
                        c6    = -5.735 + 1.21 * Math.Log(Reynolds_Air / Nr);
                        J_Air = 0.086 * Math.Pow(Reynolds_Air, c3) * Math.Pow(Nr, c4) * Math.Pow(FinPitch / Do, c5) *
                                Math.Pow(FinPitch / _in.TubeOutsideStaggered.HydDiameter, c6) * Math.Pow(FinPitch / Xt, -0.93);
                    }
                }

                #endregion

                #region H Calculation

                H_Water = J_Water * G_Water * CpWater / Math.Pow(PrandtlWater, (double)2 / 3);
                H_Air   = J_Air * G_Air * CpAir / Math.Pow(PrandtlAir, (double)2 / 3);

                #endregion

                #region F Calculation

                c7      = -0.764 + 0.739 * Xt / Xl + 0.177 * FinPitch / Do - 0.00758 / Nr;
                c8      = -15.689 + 64.021 / Math.Log(Reynolds_Water);
                c9      = 1.696 - 15.695 / Math.Log(Reynolds_Water);
                F_Water = 0.0267 * Math.Pow(Reynolds_Water, c7) * Math.Pow(Xt / Xl, c8) * Math.Pow(FinPitch / Do, c9);

                c7    = -0.764 + 0.739 * Xt / Xl + 0.177 * FinPitch / Do - 0.00758 / Nr;
                c8    = -15.689 + 64.021 / Math.Log(Reynolds_Air);
                c9    = 1.696 - 15.695 / Math.Log(Reynolds_Air);
                F_Air = 0.0267 * Math.Pow(Reynolds_Air, c7) * Math.Pow(Xt / Xl, c8) * Math.Pow(FinPitch / Do, c9);

                #endregion

                #region Fin Efficiency

                VelocityAir = QAirInitial / (L1 * L3 - Nr * L1 * Do);
                if (VelocityAir <= 15 && VelocityAir >= 6)
                {
                    MessageBox.Show("Velocity should be between 6m/s and 15m/s", "Input out of limits");
                    return;
                }

                FinEfficiency = 7.41 * Math.Pow(VelocityAir, -0.12) *
                                Math.Pow(Xt / (2 * FinThickness), -2.32) * Math.Pow(Xl / (2 * FinThickness), -0.198);

                OverallEfficiency = 1 - ((1 - FinEfficiency) * (L2 * L3 - _in.Nt * Math.PI * Do * Do) /
                                         ((_in.SysType == SystemType.Inline)
                                             ? _in.TubeOutsideInlineData.TotalHeatArea
                                             : _in.TubeOutsideStaggered.TotalHeatArea));

                Rw = (Do - Di) / (_in.MaterialCoeff * (_in.Nt + 1) * 2 * L1 * L2);

                #endregion

                #region UA Calculation


                if (_in.SysType == SystemType.Inline)
                {
                    UaInverse = Rw + (1 / (OverallEfficiency * H_Water * _in.TubeOutsideInlineData.TotalHeatArea)) +
                                (1 / (OverallEfficiency * H_Air * _in.TubeOutsideInlineData.TotalHeatArea));
                }
                else
                {
                    UaInverse = Rw + (1 / (OverallEfficiency * H_Water * _in.TubeOutsideStaggered.TotalHeatArea)) +
                                (1 / (OverallEfficiency * H_Air * _in.TubeOutsideStaggered.TotalHeatArea));
                }

                C_Water = MassFlowWaterFinal * CpWater;
                C_Air   = MassFlowAirFinal * CpAir;
                C_Min   = Math.Min(C_Air, C_Water);
                C_Star  = (C_Water / C_Air);
                if (C_Star > 1)
                {
                    C_Star = 1 / C_Star;
                }

                NTU = 1 / (UaInverse * C_Min);

                #endregion

                epsilon             = FactorialCompute(25, NTU, C_Star);
                ConductionAreaWater = _in.Nt * Math.PI * Di * L1;
                ConductionAreaAir   = _in.Nt * Math.PI * Do * L1;

                lambdaAir   = _in.MaterialCoeff * ConductionAreaAir / (L1 * C_Air);
                lambdaWater = _in.MaterialCoeff * ConductionAreaWater / (L1 * C_Water);

                M1 = H_Air / H_Water;
                M2 = lambdaWater / lambdaAir;

                XPlatHelper.OpenImageTables();


                while (true)
                {
                    UserInputDialog userInput = new UserInputDialog("Enter Delta(Epsilon)/Epsilon");
                    userInput.ShowDialog();
                    if (!string.IsNullOrWhiteSpace(userInput.Answer))
                    {
                        double x;
                        if (double.TryParse(userInput.Answer, out x))
                        {
                            EpsilonRatio = x;
                            break;
                        }
                    }
                }

                deltaEpsilon  = EpsilonRatio * Epsilon;
                ActualEpsilon = Epsilon - deltaEpsilon;

                HeatTransferRate = ActualEpsilon * (TAirInitial - TWaterInitial) * C_Min;

                TWaterFinal = prevvalWater - HeatTransferRate / C_Water;
                TAirFinal   = prevvalAir - HeatTransferRate / C_Air;
            } while (!((Math.Abs((prevvalWater - TWaterFinal) / prevvalWater) < 0.05) &&
                       (Math.Abs((prevvalAir - TAirFinal) / prevvalAir) < 0.05)));
            #endregion

            {
                double TMeanAir     = (TAirInitial + TAirFinal) / 2;
                double TMeanWater   = (TWaterInitial + TWaterFinal) / 2;
                double RoFinalAir   = (PAirInitial / 287.04) / TAirFinal;
                double RoFinalWater = (PWaterInitial / 287.04) / TWaterFinal;
                double RoMeanAir    = 2 * RoFinalAir * DensityAirInitial / (RoFinalAir + DensityAirInitial);
                double RoMeanWater  = 2 * RoFinalWater * DensityWaterInitial / (RoFinalWater + DensityWaterInitial);
                double RhFinal      = (_in.SysType == SystemType.Inline)
                    ? _in.TubeOutsideInlineData.TotalMinFfArea
                    : _in.TubeOutsideStaggered.TotalMinFfArea;
                RhFinal /= 2;
                double GAirFinal = MassFlowAirFinal / ((_in.SysType == SystemType.Inline)
                    ? _in.TubeOutsideInlineData.TotalMinFfArea
                    : _in.TubeOutsideStaggered.TotalMinFfArea);
                double GWaterFinal = MassFlowWaterFinal / ((_in.SysType == SystemType.Inline)
                    ? _in.TubeOutsideInlineData.TotalMinFfArea
                    : _in.TubeOutsideStaggered.TotalMinFfArea);

                XPlatHelper.OpenFinalTable();
                double Kc, Ke;
                while (true)
                {
                    UserInputDialog userInput = new UserInputDialog("Enter Kc");
                    userInput.ShowDialog();
                    if (!string.IsNullOrWhiteSpace(userInput.Answer))
                    {
                        double x;
                        if (double.TryParse(userInput.Answer, out x))
                        {
                            Kc = x;
                            break;
                        }
                    }
                }
                while (true)
                {
                    UserInputDialog userInput = new UserInputDialog("Enter Ke");
                    userInput.ShowDialog();
                    if (!string.IsNullOrWhiteSpace(userInput.Answer))
                    {
                        double x;
                        if (double.TryParse(userInput.Answer, out x))
                        {
                            Ke = x;
                            break;
                        }
                    }
                }

                double Sigma = (_in.SysType == SystemType.Inline)
                    ? _in.TubeOutsideInlineData.RatioFfFrontalArea
                    : _in.TubeOutsideStaggered.RatioFfFrontalArea;

                double delPAir =
                    Math.Pow(GAirFinal, 2) / (2 * DensityAirInitial) * (
                        (1 - Sigma * Sigma + Kc) + 2 * (DensityAirInitial / RoFinalAir - 1) +
                        (F_Air * L1 / RhFinal * DensityAirInitial / RoMeanAir)
                        - (1 - Sigma * Sigma - Ke * DensityAirInitial / RoFinalAir));

                double delPWater =
                    Math.Pow(GWaterFinal, 2) / (2 * DensityWaterInitial) * (
                        (1 - Sigma * Sigma + Kc) + 2 * (DensityWaterInitial / RoFinalWater - 1) +
                        (F_Water * L1 / RhFinal * DensityWaterInitial / RoMeanWater)
                        - (1 - Sigma * Sigma - Ke * DensityWaterInitial / RoFinalWater));

                AirX   = delPAir;
                WaterX = delPWater;
            }
        }