qinjie
2023-12-19 15d15d24fbccb9b70a305b46b71453b2ab1a720e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace CloudWaterNetwork
{
   
 
    public class 排空时间计算
    {
        static double GetVelocity(double d, double height, double pressure)
        {
            // 计算速度
            double rho = 1000; // 水密度
            double g = 9.8; // 重力加速度
            double v = Math.Sqrt(2 * (pressure - rho * g * height) / rho);
            return v;
        }
        /// <summary>
        /// 返回需要多少秒
        /// </summary>
        /// <returns></returns>
        public static double GetTime()
        {
            // 已知数据
            double dn_pipe = 400; // 管道直径,单位毫米
            double dn_valve = 100; // 排泥阀直径,单位毫米
            double length = 75; // 管道长度,单位米
            double pressure = 0.3; // 初始压力,单位兆帕
            double height = length; // 初始水位,即管道长度,单位米
            double interval = 10; // 时间间隔,单位秒
 
            // 计算管道与排泥阀的截面积
            double area_pipe = Math.PI * Math.Pow(dn_pipe / 1000 / 2, 2);
            double area_valve = Math.PI * Math.Pow(dn_valve / 1000 / 2, 2);
 
            // 计算初始速度
            double velocity = GetVelocity(dn_pipe / 1000, height, pressure);
 
            // 循环输出水位和流速
            while (height > 0)
            {
                double volume = area_pipe * height; // 计算体积
                double q = area_valve * velocity; // 计算流量
                height -= q * interval / volume; // 更新水位
                velocity = GetVelocity(dn_pipe / 1000, height, pressure); // 更新速度
                Console.WriteLine($"Time:{DateTime.Now.ToString()} Height:{height.ToString("F2")} Velocity:{velocity.ToString("F2")}");
                System.Threading.Thread.Sleep((int)interval * 1000); // 等待一段时间
            }
            return velocity;
        }
    }
}