예제 #1
0
 /// <summary>
 /// Вычисляет температуру кипения жидкости.
 /// </summary>
 /// <param name="liq">Объект, описывающий жидкость.</param>
 /// <returns>Возвращает значение температуры кипения жидкости при ее давлении в градусах Цельсия.</returns>
 public static double BoilingPoint(LiquidPure liq)
 {
     var table =
         Database.Query(
             String.Format("SELECT pressure,boiling_point FROM boiling_points_from_pressure WHERE id='{0}'",
                           liq.Id));
     var data = table.Select(list => list.ConvertAll(Convert.ToDouble)).ToList();
     return LinearInterpolation(data, liq.Pressure);
 }
예제 #2
0
 /// <summary>
 /// Вычисляет плотность жидкости методом линейной интерполяции по узловым точкам,
 /// содержащимся в базе данных.
 /// </summary>
 /// <param name="liq">Объект, описывающий жидкость.</param>
 /// <returns>Возвращает значение плотности жидкости при ее температуре в килограммах на кубометр.</returns>
 public static double Density(LiquidPure liq)
 {
     if (liq.ModularCondition == 1)
     {
         var table = Database.Query(String.Format("SELECT temperature,density FROM IV WHERE id='{0}'", liq.Id));
         var data = table.Select(list => list.ConvertAll(Convert.ToDouble)).ToList();
         return LinearInterpolation(data, liq.Temperature);
     }
     if (liq.Id == "10")
     {
         var table =
             Database.Query(String.Format("SELECT temperature,density FROM LVI"));
         var data = table.Select(list => list.ConvertAll(Convert.ToDouble)).ToList();
         return LinearInterpolation(data, liq.Temperature);
     }
     return 10; // УБРАТЬ ПОТОМ
 }
예제 #3
0
 /// <summary>
 /// Данный класс описывает жидкие смеси.
 /// </summary>
 /// <param name="id">Идентификационный номер смеси.</param>
 /// <param name="molarFraction">Молярная доля низкокипящего компонента.</param>
 /// <param name="t">Температура жидкости, в градусах Цельсия.</param>
 /// <param name="p">Давление, оказываемое на жидкость, в мм рт. ст.</param>
 public LiquidMix(string id, double molarFraction, double t, double p)
     : base(id, t, p)
 {
     var liq1 = new LiquidPure(id.Split(',')[0], t, p);
     var liq2 = new LiquidPure(id.Split(',')[1], t, p);
     if (liq1.BoilingPoint <= liq2.BoilingPoint)
     {
         this._Components[0] = liq1;
         this._Components[1] = liq2;
     }
     else
     {
         this._Components[0] = liq2;
         this._Components[1] = liq1;
     }
     this._MolarFraction = molarFraction;
     this.SetMolarMass();
     this.MolarFraction = molarFraction;
     this.SetPressure(p);
     this.SetTemperature(t);
 }
예제 #4
0
 /// <summary>
 /// Вычисляет динамический коэффициент вязкости жидкости методом линейной интерполяции по узловым точкам,
 /// содержащимся в базе данных.
 /// </summary>
 /// <param name="liq">Объект, описывающий жидкость.</param>
 /// <returns>Возвращает значение динамического коэффициента вязкости жидкости при ее температуре в мПа*с.</returns>
 public static double ViscosityDynamic(LiquidPure liq)
 {
     var table = Database.Query(String.Format("SELECT temperature,viscosity FROM IX WHERE id='{0}'", liq.Id));
     var data = table.Select(list => list.ConvertAll(Convert.ToDouble)).ToList();
     return LinearInterpolation(data, liq.Temperature);
 }
예제 #5
0
 public static double ThermalCapacity(LiquidPure liq)
 {
     var table = Database.Query(String.Format("SELECT temperature,thermal_capacity FROM thermal_capacity WHERE id='{0}'", liq.Id));
     var data = table.Select(list => list.ConvertAll(Convert.ToDouble)).ToList();
     return LinearInterpolation(data, liq.Temperature);
 }
예제 #6
0
 /// <summary>
 /// Вычисляет молярную массу жидкости.
 /// </summary>
 /// <param name="liq">Объект, описывающий жидкость.</param>
 /// <returns>Возвращает значение молярной массы жидкости в кг/кмоль.</returns>
 public static double MolarMass(LiquidPure liq)
 {
     var table =
         Database.Query(
             String.Format(
                 "SELECT molar_mass FROM liquid_list WHERE id='{0}'", liq.Id));
     var data = table.Select(list => list.ConvertAll(Convert.ToDouble)).ToList();
     return data[0][0];
 }
예제 #7
0
        static void Main(string[] args)
        {
            // Разделитель - точка
            var inf = new CultureInfo(System.Threading.Thread.CurrentThread.CurrentCulture.Name);
            System.Threading.Thread.CurrentThread.CurrentCulture = inf;
            inf.NumberFormat.NumberDecimalSeparator = ".";
            // Вывод курсовой
            //var ans = Database.Query("insert into liquid_list(name,formula,molar_mass) values('Бутан','C4H10',58.1)");
            //var ans = Database.Query("select * from liquid_list");
            /*string ConnectionString = "Data Source=|DataDirectory|\\EasyPACT.sdf";
            SqlCeConnection Connect = new SqlCeConnection(ConnectionString);
            Connect.Open();
            var command = Connect.CreateCommand();
            command.CommandTimeout = Connect.ConnectionTimeout;
            command.Connection = Connect;
            command.CommandType = CommandType.Text;
            command.CommandText = "select * from liquid_list";
            var table = new DataTable();
            var adapter = new SqlCeDataAdapter(command);
            adapter.Fill(table);
            command.CommandText = "insert into liquid_list ([name],[formula],molar_mass) values('Бутан','C4H10',58.01)";
            adapter.UpdateCommand = command;
            var row = table.NewRow();
            row.BeginEdit();
            row.SetField("name", "Бутан");
            row.SetField("formula", "C4H10");
            row.SetField("molar_mass", Convert.ToSingle(58.01));
            row.EndEdit();
            table.Rows.Add(row);
            table.AcceptChanges();
            adapter.Update(table);
            table.AcceptChanges();
            //table.AcceptChanges();

            Connect.Close();*/
            //var ht = new HeatExchangerPipe(14);
            var liq = new LiquidMix("11,12", 0.28, 20, 760);
            var pip = new PipelineRound(33, 1, 0.069, 0.0025, 52);
            pip.AddLocalResistance(1);
            pip.AddLocalResistance(12);
            pip.AddLocalResistance(65.5);
            pip.AddLocalResistance(2.1);
            pip.AddLocalResistance(7);
            var lip = new LiquidInPipeline(liq, pip);
            pip = new PipelineRound(33, 1, 0.092, 0.0025, 6);
            pip.AddLocalResistance("1 1");
            for (var i = 0; i < 7; i++)
                pip.AddLocalResistance("4 90 1");
            var lip2 = new LiquidInPipeline(liq, pip);
            var net = Network.Create(lip2, lip);
            net.SetProductivity(30000/3600.0);
            Network.Get().ChooseHeatExchanger(liq.BoilingPoint, liq.BoilingPoint + 20);
            net.ChooseCentrifugalPump(5.6);
            Console.WriteLine("Смесь: {0}", liq.Name);
            Console.WriteLine("\tТемпература: {0} град.", liq.Temperature);
            Console.WriteLine("\tДавление: {0} мм рт. ст.", liq.Pressure);
            Console.WriteLine("\tТемпература кипения: {0} град.", liq.BoilingPoint);
            Console.WriteLine("\tВязкость: {0} Па*с", liq.ViscosityDynamic);
            Console.WriteLine("\tТеплоемкость: {0} Дж/кг К", liq.ThermalCapacity);
            Console.WriteLine("\t: {0} Дж/кг К", liq.ThermalCapacity);
            Console.WriteLine("Трубопровод всасывающий");
            Console.WriteLine("\tРазмеры: {0}x{1} м", net.VacuumLine.Pipeline.ExternalDiameter,
                              net.VacuumLine.Pipeline.ExternalDiameter - net.VacuumLine.Pipeline.Diameter);
            Console.WriteLine("\tДлина: {0} м",net.VacuumLine.Pipeline.Length);
            Console.WriteLine("\tКоэффициент м.с.: {0}",net.VacuumLine.Pipeline.FactorOfLocalResistance);
            Console.WriteLine("Трубопровод нагнетательный");
            Console.WriteLine("\tРазмеры: {0}x{1} м", net.ForcingLine.Pipeline.ExternalDiameter,
                              net.ForcingLine.Pipeline.ExternalDiameter - net.ForcingLine.Pipeline.Diameter);
            Console.WriteLine("\tДлина: {0} м", net.ForcingLine.Pipeline.Length);
            Console.WriteLine("\tКоэффициент м.с.: {0}", net.ForcingLine.Pipeline.FactorOfLocalResistance);
            Console.WriteLine("Смесь во всасывающем ТП");
            Console.WriteLine("\tСкорость: {0} м/с",net.VacuumLine.Speed);
            Console.WriteLine("\tКритерий Рейнольдса: {0}",net.VacuumLine.Re);
            Console.WriteLine("\tКоэффициент трения: {0}", net.VacuumLine.FactorOfAFriction);
            Console.WriteLine("\tПотеря давления на трение: {0} Па",net.VacuumLine.LossOfPressureUponAFriction());
            Console.WriteLine("\tПотеря давления на м.с.: {0} Па",net.VacuumLine.LossOfPressureUponLocalResistances());
            Console.WriteLine("\tПотеря давления: {0} Па", net.VacuumLine.LossOfPressureUponLocalResistances() + net.VacuumLine.LossOfPressureUponAFriction());
            Console.WriteLine("\tПотеря напора: {0} м",
                              (net.VacuumLine.LossOfPressureUponLocalResistances() +
                               net.VacuumLine.LossOfPressureUponAFriction())/net.VacuumLine.Liquid.Density/9.81);
            Console.WriteLine("Смесь в нагнетательном ТП");
            Console.WriteLine("\tСкорость: {0} м/с", net.ForcingLine.Speed);
            Console.WriteLine("\tКритерий Рейнольдса: {0}", net.ForcingLine.Re);
            Console.WriteLine("\tКоэффициент трения: {0}", net.ForcingLine.FactorOfAFriction);
            Console.WriteLine("\tПотеря давления на трение: {0} Па", net.ForcingLine.LossOfPressureUponAFriction());
            Console.WriteLine("\tПотеря давления на м.с.: {0} Па", net.ForcingLine.LossOfPressureUponLocalResistances());
            Console.WriteLine("\tПотеря давления: {0} Па", net.ForcingLine.LossOfPressureUponLocalResistances() + net.ForcingLine.LossOfPressureUponAFriction());
            Console.WriteLine("\tПотеря напора: {0} м",
                              (net.ForcingLine.LossOfPressureUponLocalResistances() +
                               net.ForcingLine.LossOfPressureUponAFriction()) / net.ForcingLine.Liquid.Density / 9.81);
            Console.WriteLine("Смесь в трубном пространстве ТО");
            Console.WriteLine("\tСкорость: {0} м/с", net.HeatExchanger.LiquidInPipeline.Speed);
            Console.WriteLine("\tКритерий Рейнольдса: {0}", net.HeatExchanger.LiquidInPipeline.Re);
            Console.WriteLine("\tКоэффициент трения: {0}", net.HeatExchanger.LiquidInPipeline.FactorOfAFriction);
            Console.WriteLine("\tПотеря давления на трение: {0} Па", net.HeatExchanger.LiquidInPipeline.LossOfPressureUponAFriction());
            Console.WriteLine("\tПотеря давления на м.с.: {0} Па", net.HeatExchanger.LiquidInPipeline.LossOfPressureUponLocalResistances());
            Console.WriteLine("\tПотеря давления: {0} Па", net.HeatExchanger.LiquidInPipeline.LossOfPressureUponLocalResistances() + net.HeatExchanger.LiquidInPipeline.LossOfPressureUponAFriction());
            Console.WriteLine("\tПотеря напора: {0} м",
                              (net.HeatExchanger.LiquidInPipeline.LossOfPressureUponLocalResistances() +
                               net.HeatExchanger.LiquidInPipeline.LossOfPressureUponAFriction()) / net.HeatExchanger.LiquidInPipeline.Liquid.Density / 9.81);
            Console.WriteLine("Затраты на создание скорости потока: {0} Па", net.ForcingLine.LossOfPressureUponCreationOfSpeed());
            Console.WriteLine("Затраты на подъем жидкости: {0} Па", net.ForcingLine.LossOfPressureUponLifting(5.6));
            Console.WriteLine("Полный напор: {0} м", (net.VacuumLine.LossOfPressureUponLocalResistances() +
                                                 net.VacuumLine.LossOfPressureUponAFriction())/
                                                net.VacuumLine.Liquid.Density/9.81 +
                                                (net.ForcingLine.LossOfPressureUponLocalResistances() +
                                                 net.ForcingLine.LossOfPressureUponAFriction())/
                                                net.ForcingLine.Liquid.Density/9.81 +
                                                (net.HeatExchanger.LiquidInPipeline.LossOfPressureUponLocalResistances() +
                                                 net.HeatExchanger.LiquidInPipeline.LossOfPressureUponAFriction())/
                                                net.HeatExchanger.LiquidInPipeline.Liquid.Density/9.81 +
                                                net.ForcingLine.LossOfPressureUponLifting(5.6) / 9.81 / net.ForcingLine.Liquid.Density);
            Console.WriteLine("Для смеси {0} с параметрами t={1} и p={2} подходит ТО {3}, чтобы ее вскипятить.", liq.Id,
                              liq.Temperature, liq.Pressure, net.HeatExchanger.Id);
            Console.WriteLine("Выбранный насос: {0}.",net.Pump.Brand);
            var liq2 = new LiquidPure("6", 20, 760);
            Console.WriteLine("Коэффициент теплопроводности ацетона: {0}",liq2.ThermalConductivity / 1.163);
            Console.ReadKey();
        }
예제 #8
0
        /*
        private void Pressure_Out_Measure_Choose_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            var grid = this.Content as Grid;
            var Pressure_Out_Measure_Choose = grid.Children[22] as MyComboBox;

            if ((Pressure_Out_Measure_Choose.SelectedIndex == 0))
            {
                Pressure_In *= 760;
            }

            if (Pressure_Out_Measure_Choose.SelectedIndex == 2)
            {
                Pressure_Out = 100000 * Pressure_Out / 101325 * 760;
            }
        }

        private void Temperature_Out_Measure_Choose_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            var grid = this.Content as Grid;
            var Temperature_Out_Measure_Choose = grid.Children[25] as MyComboBox;

            if (Temperature_Out_Measure_Choose.SelectedIndex == 1)
            {
                Temperature_Out += 273;
            }
        }
        */
        private void Next_1_Click(object sender, RoutedEventArgs e)
        {
            bool g = true;
            var grid = this.Content as Grid;
            var Liquid = grid.Children[3] as MyComboBox;
            var Pressure_Input = grid.Children[6] as TextBox;
            var Pressure_Measure_Choose = grid.Children[7] as MyComboBox;
            var Temperature_Input = grid.Children[9] as TextBox;
            var Temperature_Measure_Choose = grid.Children[10] as MyComboBox;

            //var Pressure_Out_Input = grid.Children[21] as MyTextBox;
            //var Pressure_Out_Measure_Choose = grid.Children[22] as MyComboBox;
            var Temperature_Out_Input = grid.Children[21] as MyTextBox;
            var Temperature_Out_Measure_Choose = grid.Children[22] as MyComboBox;

            var Liquid_Type = grid.Children[1] as MyComboBox;
            var NK = grid.Children[25] as MyTextBox;

            var VysPod = grid.Children[27] as MyTextBox;

            double result = 0;

            if ((double.TryParse(Pressure_Input.Text, out result) == false) ||
                (double.TryParse(Temperature_Input.Text, out result) == false) ||
                (double.TryParse(Temperature_Out_Input.Text, out result) == false) ||
                (Liquid.SelectedIndex == Liquid.Items.Count - 1))
                g = false;

            double NK_dou = 0;

            if (NK.Visibility == Visibility.Hidden)
            {
                NK_dou = 0;
            }

            if (NK.Visibility == Visibility.Visible)
            {
                if (double.TryParse(NK.Text, out result) == false)
                {
                    g = false;
                }
                else
                {
                    NK_dou = double.Parse(NK.Text);
                    if ((NK_dou == 0) || (NK_dou >= 1))
                    {
                        g = false;
                    }
                }
            }

            double VP = 0;

            if (double.TryParse(VysPod.Text, out result) == false)
            {
                g = false;
            }
            else
            {
                VP = double.Parse(VysPod.Text);
            }

            if (g == true)
            {
                Pressure_In = double.Parse(Pressure_Input.Text);
                Temperature_In = double.Parse(Temperature_Input.Text);
                Temperature_Out = double.Parse(Temperature_Out_Input.Text);

                if (Pressure_Measure_Choose.SelectedIndex == 1)
                {
                    Pressure_In = Pressure_In * 1000000 / (101325 / 760);
                }
                if (Pressure_Measure_Choose.SelectedIndex == 2)
                {
                    Pressure_In = 100000 * Pressure_In / 101325 * 760;
                }
                if (Temperature_Measure_Choose.SelectedIndex == 1)
                {
                    Temperature_In -= 273;
                }
                if (Temperature_Out_Measure_Choose.SelectedIndex == 1)
                {
                    Temperature_Out -= 273;
                }
                /*
                if (Pressure_Out_Measure_Choose.SelectedIndex == 0)
                {
                    Pressure_Out *= 760;
                }
                if (Pressure_Out_Measure_Choose.SelectedIndex == 2)
                {
                    Pressure_Out = 100000 * Pressure_In / 101325 * 760;
                }

                if (Temperature_Out_Measure_Choose.SelectedIndex == 1)
                {
                    Temperature_Out += 273;
                }
                */
                //MessageBox.Show("Все круто!");

                bool gg = true;

                if (Temperature_Out < Temperature_In)
                {
                    gg = false;
                }

                EasyPACT.Liquid liq;
                if (gg)
                {
                    try
                    {
                        if (Liquid_Type.SelectedIndex == 0)
                        {
                            liq = new EasyPACT.LiquidPure(id_str[Liquid.SelectedIndex], Temperature_In, Pressure_In);
                        }
                        else
                        {
                            liq = new EasyPACT.LiquidMix(id_str[Liquid.SelectedIndex], NK_dou, Temperature_In, Pressure_In);
                        }
                        Window_Add_Pipeline New_Pipeline = new Window_Add_Pipeline(liq, Temperature_Out, NK_dou, VP);
                        New_Pipeline.Show();
                    }
                    catch
                    {
                        MessageBox.Show("Неправильно введены параметры");
                    }
                }
                else
                {
                    MessageBox.Show("Температура на выходе должна быть больше температуры на входе.");
                }

            }

            if (g == false)
            {
                MessageBox.Show("Некоторые поля не заполнены / введены неверно");
            }
        }
예제 #9
0
 /// <summary>
 /// Подобрать теплообменник к заданной сети.
 /// </summary>
 /// <param name="temperatureLiquid">Требуемая на выходе температура в градусах Цельсия.</param>
 /// <param name="temperatureSteam">Температура греющего пара в градусах Цельсия.</param>
 public void ChooseHeatExchanger(double temperatureLiquid,double temperatureSteam)
 {
     var t = (temperatureLiquid + this.ForcingLine.Liquid.Temperature)/2; // Средняя температура
     Liquid liq;
     if (this.ForcingLine.Liquid.GetType().ToString().IndexOf("Pure") != -1)
         liq = new LiquidPure(this.ForcingLine.Liquid.Id, t, this.ForcingLine.Liquid.Pressure);
     else
     {
         var l = this.ForcingLine.Liquid as LiquidMix;
         liq = new LiquidMix(l.Id, l.MolarFraction, t, l.Pressure);
     }
     var steam = new LiquidPure("10", temperatureSteam, Calculation.Pressure(10, temperatureSteam));
     steam.Evaporate();
     liq.Temperature = t;
     var Q = this.Productivity*liq.ThermalCapacity/1000*
             (temperatureLiquid - this.ForcingLine.Liquid.Temperature);
     var G1 = Q/steam.VaporizationHeat;
     var V1 = G1/steam.Density;
     var V2 = this.Productivity/liq.Density;
     var dtMax = steam.Temperature - this.ForcingLine.Liquid.Temperature;
     var dtMin = steam.Temperature - temperatureLiquid;
     var dt = (dtMax - dtMin)/Math.Log(dtMax/dtMin);
     var Kor = 120;
     var For = Q*1000/Kor/dt;
     var Re2min = 10000;
     var w2min = Re2min*liq.ViscosityDynamic/liq.Density/0.021;
     var nmax = Math.Ceiling(V2/0.785/0.021/0.021/w2min);
     var list =
         Database.Query(string.Format("SELECT id FROM XXXIV WHERE surface_area < {0} AND pipes_per_course < {1}",
                                      For, nmax))[0];
     var id = list.First();
     var he = new HeatExchangerPipe(Convert.ToInt32(id));
     he.SetLiquidInCase(steam);
     he.SetLiquidInPipes(this.ForcingLine.Liquid);
     double F = 0;
     while(true )
     {
         var Re2 = Re2min*(nmax*he.NumberOfCourses/he.NumberOfPipes);
         var Pr2 = liq.Pr;
         var Nu2 = 0.021*Math.Pow(Re2, 0.8)*Math.Pow(Pr2, 0.43);
         var a2 = Nu2*liq.ThermalConductivity/0.021;
         var q = Q/he.SurfaceArea;
         steam.Condence();
         var a1 = 1.21*steam.ThermalConductivity*
                  Math.Pow(
                      Math.Pow(steam.Density, 2)*steam.VaporizationHeat*9.81/steam.ViscosityDynamic/
                      he.PipesLength, 0.33)*Math.Pow(q, -0.33);
         var d = 0.002;
         var r = d/he.Pipeline.ThermalConductivity;
         var r1 = 1/1600.0;
         var r2 = 1/5800.0;
         r = r + r1 + r2;
         var K = 1/(1/a1 + r + 1/a2);
         F = Q*1000/K/dt;
         var zap = (he.SurfaceArea - F)/he.SurfaceArea;
         if((zap < 0.1) & list.Count > 1)
         {
             list.RemoveAt(0);
             id = list.First();
             he = new HeatExchangerPipe(Convert.ToInt32(id));
             he.SetLiquidInCase(steam);
             he.SetLiquidInPipes(this.ForcingLine.Liquid);
         }
         else
         {
             break;
         }
     }
     he.LiquidInCase.MassFlow = G1;
     this.HeatExchanger = he;
 }