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;
}
///
/// 返回需要多少秒
///
///
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;
}
}
}