/* * 版本历史: * 1.0.0 (2024-10-13): 初始版本,实现大气透过率模型的基类,包括各种天气条件下的衰减计算。作者:田建勇 */ using System; namespace AirTransmission { /// /// 大气透过率模型的抽象基类,提供了各种大气条件下的透过率计算方法 /// public abstract class TransmittanceModel(WeatherCondition weather) { // 常量 /// /// 标准大气透过率 /// protected const double STANDARD_TRANSMITTANCE = 0.979; // 标准大气透过率 /// /// 标准能见度(公里) /// protected const double STANDARD_VISIBILITY = 23.0; // 标准能见度 (km) /// /// 标准气溶胶密度(粒子/立方厘米) /// protected const double STANDARD_AEROSOL_DENSITY = 100.0; // 标准气溶胶密度 (particles/cm³) /// /// 当前天气条件 /// protected WeatherCondition weatherCondition = weather; // 大气模型参数 /// /// 温度(开尔文) /// protected double Temperature { get; set; } = weather.Temperature + 273.15; /// /// 大气压力(百帕) /// protected double Pressure { get; set; } = 1013.25; /// /// 相对湿度(百分比) /// protected double Humidity { get; set; } = weather.RelativeHumidity; /// /// 气溶胶密度(粒子/立方厘米) /// protected double AerosolDensity { get; set; } = CalculateAerosolDensity(weather.Visibility); /// /// 能见度(公里) /// protected double Visibility { get; set; } = weather.Visibility; /// /// 是否下雨 /// protected bool IsRaining { get; set; } = weather.Type == WeatherType.雨天; /// /// 降雨量(毫米/小时) /// protected double RainRate { get; set; } = weather.Type == WeatherType.雨天 ? (weather.Precipitation ?? 0) : 0; /// /// 是否有雾 /// protected bool IsFoggy { get; set; } = weather.Type == WeatherType.雾天; /// /// 是否有沙尘 /// protected bool IsDusty { get; set; } = weather.Type == WeatherType.沙尘; /// /// 是否下雪 /// protected bool IsSnowing { get; set; } = weather.Type == WeatherType.雪天; /// /// 降雪量(毫米/小时) /// protected double SnowRate { get; set; } = weather.Type == WeatherType.雪天 ? (weather.Precipitation ?? 0) : 0; /// /// 二氧化碳浓度(ppm) /// protected double CO2Concentration { get; set; } = 415; // ppm, 默认值 /// /// 计算给定距离的大气透过率 /// /// 传输距离(米) /// 大气透过率(0到1之间的值) public abstract double CalculateTransmittance(double distance); /// /// 根据能见度计算气溶胶密度 /// /// 能见度(公里) /// 气溶胶密度(粒子/立方厘米) protected static double CalculateAerosolDensity(double visibility) { // 使用指数关系来计算气溶胶密度 return STANDARD_AEROSOL_DENSITY * Math.Pow(STANDARD_VISIBILITY / Math.Max(visibility, 0.1), 0.75); } /// /// 计算雨对电磁波的衰减系数K /// /// 波长(微米或毫米) /// 雨衰减系数K protected abstract double CalculateRainKCoefficient(double wavelength); /// /// 计算雨对电磁波的衰减系数α /// /// 波长(微米或毫米) /// 雨衰减系数α protected abstract double CalculateRainAlphaCoefficient(double wavelength); /// /// 计算雪对电磁波的衰减系数K /// /// 波长(微米或毫米) /// 雪衰减系数K protected abstract double CalculateSnowKCoefficient(double wavelength); /// /// 计算雪对电磁波的衰减系数α /// /// 波长(微米或毫米) /// 雪衰减系数α protected abstract double CalculateSnowAlphaCoefficient(double wavelength); /// /// 计算雨对电磁波的衰减 /// /// 传输路径长度(米) /// 波长(微米或毫米) /// 雨衰减(dB) protected double CalculateRainAttenuation(double pathLength, double wavelength) { if (!IsRaining || RainRate <= 0) return 0; // 计算 k 和 α 系数 double k = CalculateRainKCoefficient(wavelength); double alpha = CalculateRainAlphaCoefficient(wavelength); // 计算特定衰减(dB/km) double specificAttenuation = k * Math.Pow(RainRate, alpha); // 计算总衰减(dB) return specificAttenuation * pathLength; } /// /// 计算雪对电磁波的衰减 /// /// 传输路径长度(米) /// 波长(微米或毫米) /// 雪衰减(dB) protected double CalculateSnowAttenuation(double pathLength, double wavelength) { if (!IsSnowing || SnowRate <= 0) return 0; // 雪的衰减系数(这里使用一个简化模型,实际上可能需要更复杂的计算) double k = CalculateSnowKCoefficient(wavelength); double alpha = CalculateSnowAlphaCoefficient(wavelength); // 计算特定衰减(dB/km) double specificAttenuation = k * Math.Pow(SnowRate, alpha); // 计算总衰减(dB) return specificAttenuation * pathLength; } /// /// 计算沙尘对电磁波的衰减 /// /// 传输路径长度(米) /// 沙尘衰减(dB) protected double CalculateDustAttenuation(double pathLength) { if (!IsDusty) return 0; // 沙尘天气衰减计算 double dustFactor = 1.5; // 沙尘对衰减的额外影响因子 double beta = (3.91 / Visibility) * dustFactor; return beta * pathLength; } /// /// 计算能见度因子 /// /// 能见度因子 protected double CalculateVisibilityFactor() { // 调整能见度因子计算,减小低能见度的影响 double factor; if (Visibility >= STANDARD_VISIBILITY) factor = 1; else if (Visibility > 5) factor = Math.Pow(STANDARD_VISIBILITY / Visibility, 0.2); else factor = Math.Pow(STANDARD_VISIBILITY / Visibility, 0.3); if (IsDusty) { // 沙尘天气下,进一步降低能见度因子 factor *= 0.9; } return factor; } /// /// 计算烟幕对电磁波的透过率 /// /// 烟幕浓度(g/m³) /// 烟幕厚度(米) /// 烟幕透过率(0到1之间的值) public static double CalculateSmokeScreenTransmittance(double smokeConcentration, double smokeThickness) { if (smokeConcentration <= 0 || smokeThickness <= 0) return 1; // 如果没有烟幕,返回1(无衰减) // 烟幕衰减系数(假设值,需要根据实际烟幕特性调整) double smokeAttenuationCoefficient = 0.5; // 使用Beer-Lambert定律计算透过率 double transmittance = Math.Exp(-smokeAttenuationCoefficient * smokeConcentration * smokeThickness); Console.WriteLine($"烟幕透过率计算:"); Console.WriteLine($"烟幕浓度: {smokeConcentration:F2} g/m³"); Console.WriteLine($"烟幕厚度: {smokeThickness:F2} m"); Console.WriteLine($"烟幕透过率: {transmittance:F4}"); return transmittance; } /// /// 打印天气信息 /// /// 天气条件 public static void PrintWeatherInfo(WeatherCondition weather){ Console.WriteLine($"---天气类型: {weather.Type}, 温度: {weather.Temperature}°C, 相对湿度: {weather.RelativeHumidity}%, 能见度: {weather.Visibility}km, 降水量: {weather.Precipitation ?? 0}mm/h"); } } /// /// 天气类型枚举 /// public enum WeatherType { 晴天, 雨天, 雪天, 雾天, 沙尘 } /// /// 天气条件类 /// public class WeatherCondition(WeatherType type, double temperature, double relativeHumidity, double visibility, double? precipitation = null, double co2Concentration = 415) { /// /// 天气类型 /// public WeatherType Type { get; set; } = type; // 天气类型 /// /// 温度(摄氏度) /// public double Temperature { get; set; } = temperature; // 温度 /// /// 相对湿度(百分比) /// public double RelativeHumidity { get; set; } = relativeHumidity; // 相对湿度 /// /// 能见度(公里) /// public double Visibility { get; set; } = visibility; // 能见度 /// /// 降水量(毫米/小时) /// public double? Precipitation { get; set; } = precipitation; // 降水量 /// /// 二氧化碳浓度(ppm) /// public double CO2Concentration { get; set; } = co2Concentration; } }