项目V1.0.0发布
This commit is contained in:
commit
ab0146339f
69
.cursorrules
Normal file
69
.cursorrules
Normal file
@ -0,0 +1,69 @@
|
||||
|
||||
# C# 开发规则
|
||||
|
||||
您是一名C#开发专家。
|
||||
|
||||
## 代码风格和结构
|
||||
- 编写简洁、符合习惯的 C# 代码,并提供准确的示例。
|
||||
- 根据需要使用面向对象和函数式编程模式。
|
||||
- 优先使用 LINQ 和 lambda 表达式进行集合操作。
|
||||
- 使用描述性变量和方法名称(例如,'IsUserSignedIn', 'CalculateTotal')。
|
||||
|
||||
## 命名约定
|
||||
- 类名、方法名和公共成员使用 PascalCase。
|
||||
- 局部变量和私有字段使用 camelCase。
|
||||
- 常量使用 UPPERCASE。
|
||||
- 接口名称以 "I" 开头(例如,'IUserService')。
|
||||
|
||||
## C# 使用
|
||||
- 在适当的情况下使用 C# 10+ 特性(例如,记录类型、模式匹配、空合并赋值)。
|
||||
- 有效使用 Entity Framework Core 进行数据库操作。
|
||||
- 使用依赖注入实现松耦合和可测试性。
|
||||
- 使用主构造函数构建类,成员变量使用属性初始化。
|
||||
|
||||
## 语法和格式
|
||||
- 遵循 C# 编码约定(https://docs.microsoft.com/en-us/dotnet/csharp/fundamentals/coding-style/coding-conventions)
|
||||
- 使用 C# 的表达式语法(例如,空条件运算符、字符串插值)
|
||||
- 当类型明显时,使用 'var' 进行隐式类型声明。
|
||||
|
||||
## 错误处理和验证
|
||||
- 对于异常情况使用异常,而不是控制流。
|
||||
- 使用内置的 .NET 日志记录或第三方日志记录器实现适当的错误日志记录。
|
||||
- 使用数据注解或 Fluent Validation 进行模型验证。
|
||||
- 实现全局异常处理的中间件。
|
||||
- 返回适当的 HTTP 状态码和一致的错误响应。
|
||||
|
||||
## API 设计
|
||||
- 遵循 RESTful API 设计原则。
|
||||
- 在控制器中使用属性路由。
|
||||
- 为您的 API 实现版本控制。
|
||||
- 使用操作过滤器处理跨切关注点。
|
||||
|
||||
## 性能优化
|
||||
- 对于 I/O 密集型操作,使用 async/await 进行异步编程。
|
||||
- 使用 IMemoryCache 或分布式缓存实现缓存策略。
|
||||
- 使用高效的 LINQ 查询,避免 N+1 查询问题。
|
||||
- 对于大型数据集实现分页。
|
||||
|
||||
## 关键约定
|
||||
- 使用依赖注入实现松耦合和可测试性。
|
||||
- 根据复杂性实现仓储模式或直接使用 Entity Framework Core。
|
||||
- 如有需要,使用 AutoMapper 进行对象到对象的映射。
|
||||
- 使用 IHostedService 或 BackgroundService 实现后台任务。
|
||||
|
||||
## 测试
|
||||
- 使用 xUnit、NUnit 或 MSTest 编写单元测试。
|
||||
- 使用 Moq 或 NSubstitute 模拟依赖项。
|
||||
- 为 API 端点实现集成测试。
|
||||
|
||||
## 安全性
|
||||
- 使用身份验证和授权中间件。
|
||||
- 实现 JWT 身份验证以进行无状态 API 身份验证。
|
||||
- 使用 HTTPS 并强制 SSL。
|
||||
- 实现适当的 CORS 策略。
|
||||
|
||||
## API 文档
|
||||
- 使用 Swagger/OpenAPI 进行 API 文档(根据安装的 Swashbuckle.AspNetCore 包)。
|
||||
- 为控制器和模型提供 XML 注释,以增强 Swagger 文档。
|
||||
|
||||
遵循官方 Microsoft 文档,以获取路由、控制器、模型和其他 API 组件的最佳实践。
|
||||
51
.gitignore
vendored
Normal file
51
.gitignore
vendored
Normal file
@ -0,0 +1,51 @@
|
||||
# 构建结果
|
||||
[Bb]in/
|
||||
[Oo]bj/
|
||||
[Ll]ib/
|
||||
|
||||
# Visual Studio 文件
|
||||
.vs/
|
||||
*.user
|
||||
*.userosscache
|
||||
*.suo
|
||||
*.userprefs
|
||||
|
||||
# 编译文件
|
||||
*.dll
|
||||
*.exe
|
||||
*.pdb
|
||||
|
||||
# 日志文件
|
||||
*.log
|
||||
|
||||
# 临时文件
|
||||
[Tt]emp/
|
||||
[Tt]mp/
|
||||
|
||||
# 缓存文件
|
||||
*.cache
|
||||
*.bak
|
||||
|
||||
# 测试结果
|
||||
[Tt]est[Rr]esult*/
|
||||
[Bb]uild[Ll]og.*
|
||||
|
||||
# NuGet包
|
||||
*.nupkg
|
||||
**/packages/*
|
||||
!**/packages/build/
|
||||
|
||||
# Visual Studio Code 设置
|
||||
.vscode/
|
||||
|
||||
# Rider 设置
|
||||
.idea/
|
||||
|
||||
# 操作系统文件
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
|
||||
# 其他
|
||||
*.swp
|
||||
*.*~
|
||||
project.lock.json
|
||||
144
AirTransmission/AtmosphericTransmittanceCalculator.cs
Normal file
144
AirTransmission/AtmosphericTransmittanceCalculator.cs
Normal file
@ -0,0 +1,144 @@
|
||||
using System;
|
||||
|
||||
namespace AirTransmission
|
||||
{
|
||||
/// <summary>
|
||||
/// 提供各种大气传输模型的计算方法
|
||||
/// </summary>
|
||||
public static class AtmosphericTransmittanceCalculator
|
||||
{
|
||||
/// <summary>
|
||||
/// 计算激光在给定天气条件和距离下的大气透过率
|
||||
/// </summary>
|
||||
/// <param name="weather">天气条件</param>
|
||||
/// <param name="distance">传输距离(米)</param>
|
||||
/// <returns>大气透过率</returns>
|
||||
public static double CalcLaser(WeatherCondition weather, double distance)
|
||||
{
|
||||
var model = new LaserTransmittanceModel(weather);
|
||||
return model.CalculateTransmittance(distance);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 计算激光在有烟雾条件下的大气透过率
|
||||
/// </summary>
|
||||
/// <param name="weather">天气条件</param>
|
||||
/// <param name="distance">传输距离(米)</param>
|
||||
/// <param name="smokeConcentration">烟雾浓度</param>
|
||||
/// <param name="smokeThickness">烟雾厚度(米)</param>
|
||||
/// <returns>大气透过率</returns>
|
||||
public static double CalcLaserWithSmoke(WeatherCondition weather, double distance, double smokeConcentration = 0, double smokeThickness = 0)
|
||||
{
|
||||
var model = new LaserTransmittanceModel(weather);
|
||||
return model.CalculateTransmittanceWithSmoke(distance, smokeConcentration, smokeThickness);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 计算红外线在给定条件下的大气透过率
|
||||
/// </summary>
|
||||
/// <param name="weather">天气条件</param>
|
||||
/// <param name="distance">传输距离(米)</param>
|
||||
/// <param name="smokeConcentration">烟雾浓度</param>
|
||||
/// <param name="smokeThickness">烟雾厚度(米)</param>
|
||||
/// <returns>大气透过率</returns>
|
||||
public static double CalcIR(WeatherCondition weather, double distance, double smokeConcentration = 0, double smokeThickness = 0)
|
||||
{
|
||||
var model = new IRTransmittanceModel(weather);
|
||||
double transmittance = model.CalculateTransmittance(distance);
|
||||
double smokeTransmittance = TransmittanceModel.CalculateSmokeScreenTransmittance(smokeConcentration, smokeThickness);
|
||||
return transmittance * smokeTransmittance;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 计算毫米波在给定条件下的大气透过率
|
||||
/// </summary>
|
||||
/// <param name="weather">天气条件</param>
|
||||
/// <param name="distance">传输距离(米)</param>
|
||||
/// <param name="smokeConcentration">烟雾浓度</param>
|
||||
/// <param name="smokeThickness">烟雾厚度(米)</param>
|
||||
/// <returns>大气透过率</returns>
|
||||
public static double CalcMillimeterWave(WeatherCondition weather, double distance, double smokeConcentration = 0, double smokeThickness = 0)
|
||||
{
|
||||
var model = new MillimeterWaveTransmittanceModel(weather);
|
||||
double transmittance = model.CalculateTransmittance(distance);
|
||||
double smokeTransmittance = TransmittanceModel.CalculateSmokeScreenTransmittance(smokeConcentration, smokeThickness);
|
||||
return transmittance * smokeTransmittance;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 计算接收到的辐射功率
|
||||
/// </summary>
|
||||
/// <param name="transmittance">大气透过率</param>
|
||||
/// <param name="laserEnergy">激光能量(焦耳)</param>
|
||||
/// <param name="pulseWidth">脉冲宽度(纳秒)</param>
|
||||
/// <param name="targetDistance">目标距离(米)</param>
|
||||
/// <param name="receiverDistance">接收器距离(米)</param>
|
||||
/// <param name="targetReflectivity">目标反射率</param>
|
||||
/// <returns>接收到的辐射功率(瓦特)</returns>
|
||||
public static double CalculateReceivedRadiation(double transmittance, double laserEnergy, double pulseWidth, double targetDistance, double receiverDistance, double targetReflectivity)
|
||||
{
|
||||
double totalDistance = targetDistance + receiverDistance;
|
||||
// 计算峰值功率(W)
|
||||
double peakPower = laserEnergy / (pulseWidth * 1e-9);
|
||||
|
||||
// 假设坦克为朗伯反射体
|
||||
double reflectedPower = peakPower * targetReflectivity / Math.PI;
|
||||
|
||||
// 计算立体角(假设导弹导引头接收面积为10cm^2)
|
||||
double receiverArea = 0.001; // 10cm^2 转换为m^2
|
||||
double solidAngle = receiverArea / (receiverDistance * receiverDistance);
|
||||
|
||||
// 计算接收到的能量(J)
|
||||
double receivedEnergy = reflectedPower * transmittance * solidAngle * (pulseWidth * 1e-9);
|
||||
|
||||
// 输出计算过程中的关键参数
|
||||
Console.WriteLine($"Laser energy: {laserEnergy:F2} J");
|
||||
Console.WriteLine($"Pulse width: {pulseWidth} ns");
|
||||
Console.WriteLine($"Peak power: {peakPower:E2} W");
|
||||
Console.WriteLine($"Target distance: {targetDistance} km");
|
||||
Console.WriteLine($"Target reflected power: {reflectedPower:E2} W");
|
||||
Console.WriteLine($"Receiver distance: {receiverDistance} km");
|
||||
Console.WriteLine($"Double path transmittance: {transmittance:F4}");
|
||||
Console.WriteLine($"Received energy: {receivedEnergy:E2} J");
|
||||
Console.WriteLine($"Received power: {receivedEnergy / (pulseWidth * 1e-9):E2} W");
|
||||
|
||||
return receivedEnergy / (pulseWidth * 1e-9); // 返回接收功率(W)
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 计算单程传输中接收到的辐射功率
|
||||
/// </summary>
|
||||
/// <param name="transmittance">大气透过率</param>
|
||||
/// <param name="targetRadiation">目标辐射(W/Sr)</param>
|
||||
/// <param name="receiverDistance">接收器距离(米)</param>
|
||||
/// <returns>接收到的辐射功率(W/Sr)</returns>
|
||||
public static double CalculateReceivedRadiationSinglePath(double transmittance, double targetRadiation, double receiverDistance)
|
||||
{
|
||||
// 计算立体角(假设导弹导引头接收面积为10cm^2)
|
||||
double receiverArea = 0.001; // 10cm^2 转换为m^2
|
||||
double solidAngle = receiverArea / (receiverDistance * receiverDistance);
|
||||
|
||||
double receivedPower = targetRadiation * transmittance * solidAngle;
|
||||
|
||||
// 输出计算过程中的关键参数
|
||||
Console.WriteLine($"Target radiation: {targetRadiation} W/Sr");
|
||||
Console.WriteLine($"Receiver distance: {receiverDistance} m");
|
||||
Console.WriteLine($"Single path transmittance: {transmittance:F4}");
|
||||
Console.WriteLine($"Received power: {receivedPower:E2} W/Sr");
|
||||
|
||||
return receivedPower;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 计算紫外线在给定天气条件和距离下的大气透过率
|
||||
/// </summary>
|
||||
/// <param name="weather">天气条件</param>
|
||||
/// <param name="distance">传输距离(米)</param>
|
||||
/// <returns>大气透过率</returns>
|
||||
public static double CalcUV(WeatherCondition weather, double distance)
|
||||
{
|
||||
var model = new UVTransmittanceModel(weather);
|
||||
return model.CalculateTransmittance(distance);
|
||||
}
|
||||
}
|
||||
}
|
||||
126
AirTransmission/AtmosphericTurbulenceModel.cs
Normal file
126
AirTransmission/AtmosphericTurbulenceModel.cs
Normal file
@ -0,0 +1,126 @@
|
||||
/*
|
||||
* 版本历史:
|
||||
* 1.0.0 (2024-10-13): 初始版本,实现大气湍流对光传输影响的计算模型。作者:田建勇
|
||||
*/
|
||||
|
||||
using System;
|
||||
|
||||
namespace AirTransmission
|
||||
{
|
||||
/// <summary>
|
||||
/// 大气湍流模型类,用于计算大气湍流对光传输的影响
|
||||
/// </summary>
|
||||
public class AtmosphericTurbulenceModel
|
||||
{
|
||||
// 波数,假设波长为1.06微米(常用的激光波长)
|
||||
private const double k = 2 * Math.PI / 1.06e-6;
|
||||
|
||||
/// <summary>
|
||||
/// 计算大气湍流对光传输的综合影响
|
||||
/// </summary>
|
||||
/// <param name="distance">传输距离(米)</param>
|
||||
/// <param name="height">传输高度(米)</param>
|
||||
/// <param name="windSpeed">风速(米/秒)</param>
|
||||
/// <param name="C2n">大气折射率结构常数</param>
|
||||
/// <returns>湍流效应(0到1之间的值,1表示无影响,0表示完全衰减)</returns>
|
||||
public static double CalculateTurbulenceEffect(double distance, double height, double windSpeed, double C2n)
|
||||
{
|
||||
double r0 = CalculateFriedParameter(C2n, distance);
|
||||
double sigmaI2 = CalculateScintillationIndex(C2n, k, distance);
|
||||
double beamWander = CalculateBeamWander(C2n, distance, height);
|
||||
|
||||
// 修改综合湍流效应计算
|
||||
double turbulenceEffect = Math.Exp(-sigmaI2) * (1 - Math.Exp(-r0 / beamWander));
|
||||
|
||||
// 增加一个缩放因子,使效应更明显
|
||||
double scalingFactor = 0.8;
|
||||
turbulenceEffect = 1 - scalingFactor * (1 - turbulenceEffect);
|
||||
|
||||
return turbulenceEffect;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 使用修改后的 Hufnagel-Valley 模型计算大气折射率结构常数
|
||||
/// </summary>
|
||||
/// <param name="height">高度(米)</param>
|
||||
/// <param name="windSpeed">风速(米/秒)</param>
|
||||
/// <returns>大气折射率结构常数</returns>
|
||||
public static double CalculateC2n(double height, double windSpeed)
|
||||
{
|
||||
// 修改 Hufnagel-Valley 模型,增加湍流强度
|
||||
double A = 1.7e-13; // 增加了一个数量级
|
||||
double v = windSpeed;
|
||||
return A * Math.Pow(v / 27, 2) * Math.Pow(height * 1e-5, 10) * Math.Exp(-height / 1000)
|
||||
+ 2.7e-15 * Math.Exp(-height / 1500);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 计算弗里德参数(Fried parameter)
|
||||
/// </summary>
|
||||
/// <param name="C2n">大气折射率结构常数</param>
|
||||
/// <param name="L">传输距离(米)</param>
|
||||
/// <returns>弗里德参数(米)</returns>
|
||||
private static double CalculateFriedParameter(double C2n, double L)
|
||||
{
|
||||
return Math.Pow(0.423 * k * k * C2n * L, -3.0 / 5.0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 计算闪烁指数(Scintillation Index)
|
||||
/// </summary>
|
||||
/// <param name="C2n">大气折射率结构常数</param>
|
||||
/// <param name="k">波数</param>
|
||||
/// <param name="L">传输距离(米)</param>
|
||||
/// <returns>闪烁指数(无量纲)</returns>
|
||||
private static double CalculateScintillationIndex(double C2n, double k, double L)
|
||||
{
|
||||
return 1.23 * C2n * Math.Pow(k, 7.0 / 6.0) * Math.Pow(L, 11.0 / 6.0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 计算光束漂移(Beam Wander)
|
||||
/// </summary>
|
||||
/// <param name="C2n">大气折射率结构常数</param>
|
||||
/// <param name="L">传输距离(米)</param>
|
||||
/// <param name="h">传输高度(米)</param>
|
||||
/// <returns>光束漂移(弧度)</returns>
|
||||
private static double CalculateBeamWander(double C2n, double L, double h)
|
||||
{
|
||||
return 2.87 * Math.Pow(C2n * L * Math.Pow(h, 5.0/3.0), 1.0/3.0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 计算相干长度(Coherence Length)
|
||||
/// </summary>
|
||||
/// <param name="C2n">大气折射率结构常数</param>
|
||||
/// <param name="L">传输距离(米)</param>
|
||||
/// <returns>相干长度(米)</returns>
|
||||
private static double CalculateCoherenceLength(double C2n, double L)
|
||||
{
|
||||
return Math.Pow(1.46 * k * k * C2n * L, -3.0 / 5.0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 计算到达角(Angle of Arrival)
|
||||
/// </summary>
|
||||
/// <param name="C2n">大气折射率结构常数</param>
|
||||
/// <param name="L">传输距离(米)</param>
|
||||
/// <param name="D">接收器口径(米)</param>
|
||||
/// <returns>到达角(弧度)</returns>
|
||||
public static double CalculateAngleOfArrival(double C2n, double L, double D)
|
||||
{
|
||||
return 2.91 * Math.Pow(C2n * L / Math.Pow(D, 1.0/3.0), 0.6);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 计算等晕角(Isoplanatism Angle)
|
||||
/// </summary>
|
||||
/// <param name="C2n">大气折射率结构常数</param>
|
||||
/// <param name="L">传输距离(米)</param>
|
||||
/// <returns>等晕角(弧度)</returns>
|
||||
public static double CalculateIsoplanatismAngle(double C2n, double L)
|
||||
{
|
||||
return 0.314 * Math.Pow(C2n * k * k * L, -3.0 / 5.0);
|
||||
}
|
||||
}
|
||||
}
|
||||
189
AirTransmission/IRTransmittanceModel.cs
Normal file
189
AirTransmission/IRTransmittanceModel.cs
Normal file
@ -0,0 +1,189 @@
|
||||
/*
|
||||
* 版本历史:
|
||||
* 1.0.0 (2024-10-13): 初始版本,实现红外线在大气中的传输特性计算,包括水蒸气和CO2的影响。作者:田建勇
|
||||
*/
|
||||
|
||||
using System;
|
||||
|
||||
namespace AirTransmission
|
||||
{
|
||||
/// <summary>
|
||||
/// 红外线传输模型类,用于计算红外线在大气中的传输特性
|
||||
/// </summary>
|
||||
public class IRTransmittanceModel(WeatherCondition weather) : TransmittanceModel(weather)
|
||||
{
|
||||
// 红外线波长(微米)
|
||||
private const double IR_WAVELENGTH = 10.0;
|
||||
|
||||
/// <summary>
|
||||
/// 计算给定距离的红外线透过率
|
||||
/// </summary>
|
||||
/// <param name="distance">传输距离(米)</param>
|
||||
/// <returns>红外线透过率(0到1之间的值)</returns>
|
||||
public override double CalculateTransmittance(double distance)
|
||||
{
|
||||
double attenuationFactor = CalculateIRAttenuationFactor();
|
||||
double rainAttenuation = CalculateRainAttenuation(distance, IR_WAVELENGTH);
|
||||
double fogAttenuation = CalculateFogAttenuation(distance);
|
||||
double dustAttenuation = CalculateDustAttenuation(distance);
|
||||
double snowAttenuation = CalculateSnowAttenuation(distance, IR_WAVELENGTH);
|
||||
double waterVaporAttenuation = CalculateWaterVaporAttenuation(distance);
|
||||
double co2Attenuation = CalculateCO2Attenuation(distance);
|
||||
|
||||
double transmittance = Math.Exp(-attenuationFactor * distance - rainAttenuation - fogAttenuation - dustAttenuation - snowAttenuation - waterVaporAttenuation - co2Attenuation);
|
||||
|
||||
return Math.Max(0, Math.Min(1, transmittance));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 计算雨对红外线的衰减系数K
|
||||
/// </summary>
|
||||
/// <param name="wavelength">波长(微米)</param>
|
||||
/// <returns>雨衰减系数K</returns>
|
||||
protected override double CalculateRainKCoefficient(double wavelength)
|
||||
{
|
||||
if (wavelength >= 8 && wavelength <= 12)
|
||||
{
|
||||
// 对于远红外波段(8-12μm)
|
||||
return 0.187;
|
||||
}
|
||||
else if (wavelength >= 3 && wavelength <= 5)
|
||||
{
|
||||
// 对于中远红外波段(3-5μm)
|
||||
return 0.2656;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 计算雨对红外线的衰减系数α
|
||||
/// </summary>
|
||||
/// <param name="wavelength">波长(微米)</param>
|
||||
/// <returns>雨衰减系数α</returns>
|
||||
protected override double CalculateRainAlphaCoefficient(double wavelength)
|
||||
{
|
||||
if (wavelength >= 8 && wavelength <= 12)
|
||||
{
|
||||
// 对于远红外波段(8-12μm)
|
||||
return 0.784;
|
||||
}
|
||||
else if (wavelength >= 3 && wavelength <= 5)
|
||||
{
|
||||
// 对于中远红外波段(3-5μm)
|
||||
return 0.7978;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 计算雪对红外线的衰减系数K
|
||||
/// </summary>
|
||||
/// <param name="wavelength">波长(微米)</param>
|
||||
/// <returns>雪衰减系数K</returns>
|
||||
protected override double CalculateSnowKCoefficient(double wavelength)
|
||||
{
|
||||
return 0.365;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 计算雪对红外线的衰减系数α
|
||||
/// </summary>
|
||||
/// <param name="wavelength">波长(微米)</param>
|
||||
/// <returns>雪衰减系数α</returns>
|
||||
protected override double CalculateSnowAlphaCoefficient(double wavelength)
|
||||
{
|
||||
return 0.88;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 计算红外线的总衰减因子
|
||||
/// </summary>
|
||||
/// <returns>红外线总衰减因子</returns>
|
||||
private double CalculateIRAttenuationFactor()
|
||||
{
|
||||
double molecularFactor = CalculateIRMolecularFactor();
|
||||
double aerosolFactor = CalculateIRAerosolFactor();
|
||||
return molecularFactor + aerosolFactor;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 计算红外线的分子散射因子
|
||||
/// </summary>
|
||||
/// <returns>红外线分子散射因子</returns>
|
||||
private double CalculateIRMolecularFactor()
|
||||
{
|
||||
// 对于10μm波长,分子散射可以忽略不计
|
||||
return 0.0001;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 计算红外线的气溶胶散射因子
|
||||
/// </summary>
|
||||
/// <returns>红外线气溶胶散射因子</returns>
|
||||
private double CalculateIRAerosolFactor()
|
||||
{
|
||||
// 使用更适合IR的模型
|
||||
double beta = 0.0116 * Math.Pow(Visibility, -0.75);
|
||||
return beta;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 计算雾对红外线的衰减
|
||||
/// </summary>
|
||||
/// <param name="pathLength">传输路径长度(米)</param>
|
||||
/// <returns>雾对红外线的衰减</returns>
|
||||
private double CalculateFogAttenuation(double pathLength)
|
||||
{
|
||||
if (!IsFoggy)
|
||||
return 0;
|
||||
|
||||
double q = 0.585 * Math.Pow(Visibility, 1.0/3.0);
|
||||
double beta = 3.91 / Visibility * Math.Pow(IR_WAVELENGTH / 0.55, -q);
|
||||
return beta * pathLength * 0.5;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 计算水蒸气对红外线的衰减
|
||||
/// </summary>
|
||||
/// <param name="distance">传输距离(米)</param>
|
||||
/// <returns>水蒸气对红外线的衰减</returns>
|
||||
private double CalculateWaterVaporAttenuation(double distance)
|
||||
{
|
||||
double waterVaporDensity = CalculateWaterVaporDensity();
|
||||
double absorptionCoefficient = 0.0005; // 这个值需要根据具体波长调整
|
||||
return absorptionCoefficient * waterVaporDensity * distance;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 计算水蒸气密度
|
||||
/// </summary>
|
||||
/// <returns>水蒸气密度(g/m³)</returns>
|
||||
private double CalculateWaterVaporDensity()
|
||||
{
|
||||
// 使用Magnus公式计算饱和水汽压
|
||||
double a = 17.27;
|
||||
double b = 237.7;
|
||||
double saturationVaporPressure = 6.112 * Math.Exp((a * Temperature) / (b + Temperature));
|
||||
|
||||
// 计算实际水汽压
|
||||
double actualVaporPressure = (Humidity / 100.0) * saturationVaporPressure;
|
||||
|
||||
// 计算水汽密度 (g/m³)
|
||||
return (actualVaporPressure * 2.16679) / (Temperature + 273.15);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 计算二氧化碳对红外线的衰减
|
||||
/// </summary>
|
||||
/// <param name="distance">传输距离(米)</param>
|
||||
/// <returns>二氧化碳对红外线的衰减</returns>
|
||||
private double CalculateCO2Attenuation(double distance)
|
||||
{
|
||||
double co2Concentration = CO2Concentration; // ppm
|
||||
double absorptionCoefficient = 0.00001; // 这个值需要根据具体波长调整
|
||||
return absorptionCoefficient * (co2Concentration / 1000000) * distance;
|
||||
}
|
||||
}
|
||||
}
|
||||
205
AirTransmission/LaserTransmittanceModel.cs
Normal file
205
AirTransmission/LaserTransmittanceModel.cs
Normal file
@ -0,0 +1,205 @@
|
||||
/*
|
||||
* 版本历史:
|
||||
* 1.0.0 (2024-10-13): 初始版本,实现激光在大气中的传输特性计算,包括湍流效应。作者:田建勇
|
||||
*/
|
||||
|
||||
using System;
|
||||
|
||||
namespace AirTransmission
|
||||
{
|
||||
/// <summary>
|
||||
/// 激光传输模型类,用于计算激光在大气中的传输特性
|
||||
/// </summary>
|
||||
public class LaserTransmittanceModel(WeatherCondition weather) : TransmittanceModel(weather)
|
||||
{
|
||||
/// <summary>
|
||||
/// 激光波长(微米)
|
||||
/// </summary>
|
||||
private const double LASER_WAVELENGTH = 1.06;
|
||||
|
||||
/// <summary>
|
||||
/// 计算给定距离的激光透过率
|
||||
/// </summary>
|
||||
/// <param name="distance">传输距离(米)</param>
|
||||
/// <returns>激光透过率(0到1之间的值)</returns>
|
||||
public override double CalculateTransmittance(double distance)
|
||||
{
|
||||
double attenuationFactor = CalculateAttenuationFactor();
|
||||
double rainAttenuation = CalculateRainAttenuation(distance, LASER_WAVELENGTH);
|
||||
double snowAttenuation = CalculateSnowAttenuation(distance, LASER_WAVELENGTH);
|
||||
double fogAttenuation = CalculateFogAttenuation(distance);
|
||||
double dustAttenuation = CalculateDustAttenuation(distance);
|
||||
|
||||
double transmittance = Math.Pow(STANDARD_TRANSMITTANCE, attenuationFactor * distance) *
|
||||
Math.Exp(-rainAttenuation - snowAttenuation - fogAttenuation - dustAttenuation);
|
||||
|
||||
// 确保透过率在有效范围内
|
||||
transmittance = Math.Max(0, Math.Min(1, transmittance));
|
||||
|
||||
return transmittance;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 计算考虑湍流效应的激光透过率
|
||||
/// </summary>
|
||||
/// <param name="distance">传输距离(米)</param>
|
||||
/// <returns>考虑湍流效应的激光透过率</returns>
|
||||
public double CalculateTransmittanceWithTurbulence(double distance)
|
||||
{
|
||||
double transmittance = CalculateTransmittance(distance);
|
||||
return ApplyTurbulenceEffect(transmittance, distance);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 计算雨对激光的衰减系数K
|
||||
/// </summary>
|
||||
/// <param name="wavelength">波长(微米)</param>
|
||||
/// <returns>雨衰减系数K</returns>
|
||||
protected override double CalculateRainKCoefficient(double wavelength)
|
||||
{
|
||||
// 对于1.06μm激光
|
||||
return 0.25;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 计算雨对激光的衰减系数α
|
||||
/// </summary>
|
||||
/// <param name="wavelength">波长(微米)</param>
|
||||
/// <returns>雨衰减系数α</returns>
|
||||
protected override double CalculateRainAlphaCoefficient(double wavelength)
|
||||
{
|
||||
// 对于1.06μm激光
|
||||
return 0.659;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 计算雪对激光的衰减系数K
|
||||
/// </summary>
|
||||
/// <param name="wavelength">波长(微米)</param>
|
||||
/// <returns>雪衰减系数K</returns>
|
||||
protected override double CalculateSnowKCoefficient(double wavelength)
|
||||
{
|
||||
if (wavelength == LASER_WAVELENGTH)
|
||||
return 0.56;
|
||||
else if (wavelength == 10.6)
|
||||
return 0.8;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 计算雪对激光的衰减系数α
|
||||
/// </summary>
|
||||
/// <param name="wavelength">波长(微米)</param>
|
||||
/// <returns>雪衰减系数α</returns>
|
||||
protected override double CalculateSnowAlphaCoefficient(double wavelength)
|
||||
{
|
||||
if (wavelength == LASER_WAVELENGTH)
|
||||
return 0.57;
|
||||
else if (wavelength == 10.6)
|
||||
return 0.75;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 计算激光的总衰减因子
|
||||
/// </summary>
|
||||
/// <returns>激光总衰减因子</returns>
|
||||
private double CalculateAttenuationFactor()
|
||||
{
|
||||
double molecularFactor = CalculateMolecularFactor();
|
||||
double aerosolFactor = CalculateAerosolFactor();
|
||||
double visibilityFactor = CalculateVisibilityFactor();
|
||||
|
||||
return molecularFactor * aerosolFactor * visibilityFactor;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 计算分子散射因子
|
||||
/// </summary>
|
||||
/// <returns>分子散射因子</returns>
|
||||
private double CalculateMolecularFactor()
|
||||
{
|
||||
return (Pressure / 1013.25) * (288.15 / Temperature);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 计算气溶胶散射因子
|
||||
/// </summary>
|
||||
/// <returns>气溶胶散射因子</returns>
|
||||
private double CalculateAerosolFactor()
|
||||
{
|
||||
double q;
|
||||
if (Visibility > 50)
|
||||
q = 1.6;
|
||||
else if (Visibility > 6)
|
||||
q = 1.3;
|
||||
else if (Visibility > 1)
|
||||
q = 0.585 * Math.Pow(Visibility, 1.0/3.0);
|
||||
else
|
||||
q = 0.585 * Math.Pow(1, 1.0/3.0);
|
||||
|
||||
double aerosolFactor = 3.91 / Visibility * Math.Pow(LASER_WAVELENGTH / 0.55, -q);
|
||||
|
||||
if (Visibility < 5)
|
||||
{
|
||||
aerosolFactor *= (1 + (5 - Visibility) / 5);
|
||||
}
|
||||
|
||||
if (IsDusty)
|
||||
{
|
||||
aerosolFactor *= 1.3;
|
||||
}
|
||||
|
||||
return Math.Max(1, aerosolFactor);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 计算雾对激光的衰减
|
||||
/// </summary>
|
||||
/// <param name="pathLength">传输路径长度(米)</param>
|
||||
/// <returns>雾对激光的衰减</returns>
|
||||
private double CalculateFogAttenuation(double pathLength)
|
||||
{
|
||||
if (!IsFoggy)
|
||||
return 0;
|
||||
|
||||
double q = 0.585 * Math.Pow(Visibility, 1.0/3.0);
|
||||
double beta = 3.91 / Visibility * Math.Pow(LASER_WAVELENGTH / 0.55, -q);
|
||||
return beta * pathLength * 0.5;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 计算考虑烟雾的激光透过率
|
||||
/// </summary>
|
||||
/// <param name="distance">传输距离(米)</param>
|
||||
/// <param name="smokeConcentration">烟雾浓度</param>
|
||||
/// <param name="smokeThickness">烟雾厚度(米)</param>
|
||||
/// <returns>考虑烟雾的激光透过率</returns>
|
||||
public double CalculateTransmittanceWithSmoke(double distance, double smokeConcentration, double smokeThickness)
|
||||
{
|
||||
double transmittance = CalculateTransmittance(distance);
|
||||
double smokeTransmittance = CalculateSmokeScreenTransmittance(smokeConcentration, smokeThickness);
|
||||
return transmittance * smokeTransmittance;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 应用湍流效应到透过率
|
||||
/// </summary>
|
||||
/// <param name="transmittance">原始透过率</param>
|
||||
/// <param name="distance">传输距离(米)</param>
|
||||
/// <returns>考虑湍流效应后的透过率</returns>
|
||||
protected static double ApplyTurbulenceEffect(double transmittance, double distance)
|
||||
{
|
||||
double height = 10; // 假设光束平均高度为10米
|
||||
double windSpeed = 5; // 假设风速为5 m/s
|
||||
double C2n = AtmosphericTurbulenceModel.CalculateC2n(height, windSpeed);
|
||||
|
||||
double turbulenceEffect = AtmosphericTurbulenceModel.CalculateTurbulenceEffect(distance * 1000, height, windSpeed, C2n);
|
||||
|
||||
// 修改湍流效应的应用方式
|
||||
return transmittance * (0.7 + 0.3 * turbulenceEffect);
|
||||
}
|
||||
}
|
||||
}
|
||||
124
AirTransmission/MillimeterWaveTransmittanceModel.cs
Normal file
124
AirTransmission/MillimeterWaveTransmittanceModel.cs
Normal file
@ -0,0 +1,124 @@
|
||||
/*
|
||||
* 版本历史:
|
||||
* 1.0.0 (2024-10-13): 初始版本,实现毫米波在大气中的传输特性计算,包括氧气和水蒸气的影响。作者:田建勇
|
||||
*/
|
||||
|
||||
using System;
|
||||
|
||||
namespace AirTransmission
|
||||
{
|
||||
/// <summary>
|
||||
/// 毫米波传输模型类,用于计算毫米波在大气中的传输特性
|
||||
/// </summary>
|
||||
public class MillimeterWaveTransmittanceModel(WeatherCondition weather) : TransmittanceModel(weather)
|
||||
{
|
||||
/// <summary>
|
||||
/// 毫米波波长(毫米)
|
||||
/// </summary>
|
||||
private const double MILLIMETER_WAVE_WAVELENGTH = 3.19; // 毫米(对应94 GHz)
|
||||
|
||||
/// <summary>
|
||||
/// 计算给定距离的毫米波透过率
|
||||
/// </summary>
|
||||
/// <param name="distance">传输距离(米)</param>
|
||||
/// <returns>毫米波透过率(0到1之间的值)</returns>
|
||||
public override double CalculateTransmittance(double distance)
|
||||
{
|
||||
double attenuationFactor = CalculateMillimeterWaveAttenuationFactor();
|
||||
double rainAttenuation = CalculateRainAttenuation(distance, MILLIMETER_WAVE_WAVELENGTH);
|
||||
double fogAttenuation = CalculateMillimeterWaveFogAttenuation(distance);
|
||||
double snowAttenuation = CalculateSnowAttenuation(distance, MILLIMETER_WAVE_WAVELENGTH);
|
||||
double transmittance = Math.Exp(-attenuationFactor * distance - rainAttenuation - fogAttenuation - snowAttenuation);
|
||||
|
||||
return transmittance;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 计算雨对毫米波的衰减系数K
|
||||
/// </summary>
|
||||
/// <param name="wavelength">波长(毫米)</param>
|
||||
/// <returns>雨衰减系数K</returns>
|
||||
protected override double CalculateRainKCoefficient(double wavelength)
|
||||
{
|
||||
// 对应94 GHz毫米波
|
||||
return 0.926;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 计算雨对毫米波的衰减系数α
|
||||
/// </summary>
|
||||
/// <param name="wavelength">波长(毫米)</param>
|
||||
/// <returns>雨衰减系数α</returns>
|
||||
protected override double CalculateRainAlphaCoefficient(double wavelength)
|
||||
{
|
||||
// 对应94 GHz毫米波
|
||||
return 0.9551;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 计算雪对毫米波的衰减系数K
|
||||
/// </summary>
|
||||
/// <param name="wavelength">波长(毫米)</param>
|
||||
/// <returns>雪衰减系数K</returns>
|
||||
protected override double CalculateSnowKCoefficient(double wavelength)
|
||||
{
|
||||
return 0.997;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 计算雪对毫米波的衰减系数α
|
||||
/// </summary>
|
||||
/// <param name="wavelength">波长(毫米)</param>
|
||||
/// <returns>雪衰减系数α</returns>
|
||||
protected override double CalculateSnowAlphaCoefficient(double wavelength)
|
||||
{
|
||||
return 1.064;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 计算毫米波的总衰减因子
|
||||
/// </summary>
|
||||
/// <returns>毫米波总衰减因子</returns>
|
||||
private double CalculateMillimeterWaveAttenuationFactor()
|
||||
{
|
||||
double oxygenAttenuation = CalculateOxygenAttenuation();
|
||||
double waterVaporAttenuation = CalculateWaterVaporAttenuation();
|
||||
return oxygenAttenuation + waterVaporAttenuation;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 计算氧气对毫米波的衰减
|
||||
/// </summary>
|
||||
/// <returns>氧气衰减因子</returns>
|
||||
private double CalculateOxygenAttenuation()
|
||||
{
|
||||
double gamma = 0.01 * (MILLIMETER_WAVE_WAVELENGTH / 60.0) * (Temperature / 293.15);
|
||||
return gamma * (Pressure / 1013.25);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 计算水蒸气对毫米波的衰减
|
||||
/// </summary>
|
||||
/// <returns>水蒸气衰减因子</returns>
|
||||
private double CalculateWaterVaporAttenuation()
|
||||
{
|
||||
double rho = Humidity * 0.01 * 6.11 * Math.Exp(17.27 * (Temperature - 273.15) / (Temperature - 35.85));
|
||||
return 0.05 * rho * (MILLIMETER_WAVE_WAVELENGTH / 100.0) * (Temperature / 293.15);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 计算雾对毫米波的衰减
|
||||
/// </summary>
|
||||
/// <param name="pathLength">传输路径长度(米)</param>
|
||||
/// <returns>雾对毫米波的衰减</returns>
|
||||
private double CalculateMillimeterWaveFogAttenuation(double pathLength)
|
||||
{
|
||||
if (!IsFoggy)
|
||||
return 0;
|
||||
|
||||
double liquidWaterDensity = 0.05; // 假设的液态水密度,单位:g/m³
|
||||
double specificAttenuation = 0.4 * MILLIMETER_WAVE_WAVELENGTH * liquidWaterDensity / 1000.0;
|
||||
return specificAttenuation * pathLength;
|
||||
}
|
||||
}
|
||||
}
|
||||
287
AirTransmission/TransmittanceModel.cs
Normal file
287
AirTransmission/TransmittanceModel.cs
Normal file
@ -0,0 +1,287 @@
|
||||
/*
|
||||
* 版本历史:
|
||||
* 1.0.0 (2024-10-13): 初始版本,实现大气透过率模型的基类,包括各种天气条件下的衰减计算。作者:田建勇
|
||||
*/
|
||||
|
||||
using System;
|
||||
|
||||
namespace AirTransmission
|
||||
{
|
||||
/// <summary>
|
||||
/// 大气透过率模型的抽象基类,提供了各种大气条件下的透过率计算方法
|
||||
/// </summary>
|
||||
public abstract class TransmittanceModel(WeatherCondition weather)
|
||||
{
|
||||
// 常量
|
||||
/// <summary>
|
||||
/// 标准大气透过率
|
||||
/// </summary>
|
||||
protected const double STANDARD_TRANSMITTANCE = 0.979; // 标准大气透过率
|
||||
/// <summary>
|
||||
/// 标准能见度(公里)
|
||||
/// </summary>
|
||||
protected const double STANDARD_VISIBILITY = 23.0; // 标准能见度 (km)
|
||||
/// <summary>
|
||||
/// 标准气溶胶密度(粒子/立方厘米)
|
||||
/// </summary>
|
||||
protected const double STANDARD_AEROSOL_DENSITY = 100.0; // 标准气溶胶密度 (particles/cm³)
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 当前天气条件
|
||||
/// </summary>
|
||||
protected WeatherCondition weatherCondition = weather;
|
||||
// 大气模型参数
|
||||
/// <summary>
|
||||
/// 温度(开尔文)
|
||||
/// </summary>
|
||||
protected double Temperature { get; set; } = weather.Temperature + 273.15;
|
||||
/// <summary>
|
||||
/// 大气压力(百帕)
|
||||
/// </summary>
|
||||
protected double Pressure { get; set; } = 1013.25;
|
||||
/// <summary>
|
||||
/// 相对湿度(百分比)
|
||||
/// </summary>
|
||||
protected double Humidity { get; set; } = weather.RelativeHumidity;
|
||||
/// <summary>
|
||||
/// 气溶胶密度(粒子/立方厘米)
|
||||
/// </summary>
|
||||
protected double AerosolDensity { get; set; } = CalculateAerosolDensity(weather.Visibility);
|
||||
/// <summary>
|
||||
/// 能见度(公里)
|
||||
/// </summary>
|
||||
protected double Visibility { get; set; } = weather.Visibility;
|
||||
/// <summary>
|
||||
/// 是否下雨
|
||||
/// </summary>
|
||||
protected bool IsRaining { get; set; } = weather.Type == WeatherType.雨天;
|
||||
/// <summary>
|
||||
/// 降雨量(毫米/小时)
|
||||
/// </summary>
|
||||
protected double RainRate { get; set; } = weather.Type == WeatherType.雨天 ? (weather.Precipitation ?? 0) : 0;
|
||||
/// <summary>
|
||||
/// 是否有雾
|
||||
/// </summary>
|
||||
protected bool IsFoggy { get; set; } = weather.Type == WeatherType.雾天;
|
||||
/// <summary>
|
||||
/// 是否有沙尘
|
||||
/// </summary>
|
||||
protected bool IsDusty { get; set; } = weather.Type == WeatherType.沙尘;
|
||||
/// <summary>
|
||||
/// 是否下雪
|
||||
/// </summary>
|
||||
protected bool IsSnowing { get; set; } = weather.Type == WeatherType.雪天;
|
||||
/// <summary>
|
||||
/// 降雪量(毫米/小时)
|
||||
/// </summary>
|
||||
protected double SnowRate { get; set; } = weather.Type == WeatherType.雪天 ? (weather.Precipitation ?? 0) : 0;
|
||||
/// <summary>
|
||||
/// 二氧化碳浓度(ppm)
|
||||
/// </summary>
|
||||
protected double CO2Concentration { get; set; } = 415; // ppm, 默认值
|
||||
|
||||
/// <summary>
|
||||
/// 计算给定距离的大气透过率
|
||||
/// </summary>
|
||||
/// <param name="distance">传输距离(米)</param>
|
||||
/// <returns>大气透过率(0到1之间的值)</returns>
|
||||
public abstract double CalculateTransmittance(double distance);
|
||||
|
||||
/// <summary>
|
||||
/// 根据能见度计算气溶胶密度
|
||||
/// </summary>
|
||||
/// <param name="visibility">能见度(公里)</param>
|
||||
/// <returns>气溶胶密度(粒子/立方厘米)</returns>
|
||||
protected static double CalculateAerosolDensity(double visibility)
|
||||
{
|
||||
// 使用指数关系来计算气溶胶密度
|
||||
return STANDARD_AEROSOL_DENSITY * Math.Pow(STANDARD_VISIBILITY / Math.Max(visibility, 0.1), 0.75);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 计算雨对电磁波的衰减系数K
|
||||
/// </summary>
|
||||
/// <param name="wavelength">波长(微米或毫米)</param>
|
||||
/// <returns>雨衰减系数K</returns>
|
||||
protected abstract double CalculateRainKCoefficient(double wavelength);
|
||||
/// <summary>
|
||||
/// 计算雨对电磁波的衰减系数α
|
||||
/// </summary>
|
||||
/// <param name="wavelength">波长(微米或毫米)</param>
|
||||
/// <returns>雨衰减系数α</returns>
|
||||
protected abstract double CalculateRainAlphaCoefficient(double wavelength);
|
||||
|
||||
/// <summary>
|
||||
/// 计算雪对电磁波的衰减系数K
|
||||
/// </summary>
|
||||
/// <param name="wavelength">波长(微米或毫米)</param>
|
||||
/// <returns>雪衰减系数K</returns>
|
||||
protected abstract double CalculateSnowKCoefficient(double wavelength);
|
||||
/// <summary>
|
||||
/// 计算雪对电磁波的衰减系数α
|
||||
/// </summary>
|
||||
/// <param name="wavelength">波长(微米或毫米)</param>
|
||||
/// <returns>雪衰减系数α</returns>
|
||||
protected abstract double CalculateSnowAlphaCoefficient(double wavelength);
|
||||
/// <summary>
|
||||
/// 计算雨对电磁波的衰减
|
||||
/// </summary>
|
||||
/// <param name="pathLength">传输路径长度(米)</param>
|
||||
/// <param name="wavelength">波长(微米或毫米)</param>
|
||||
/// <returns>雨衰减(dB)</returns>
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 计算雪对电磁波的衰减
|
||||
/// </summary>
|
||||
/// <param name="pathLength">传输路径长度(米)</param>
|
||||
/// <param name="wavelength">波长(微米或毫米)</param>
|
||||
/// <returns>雪衰减(dB)</returns>
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 计算沙尘对电磁波的衰减
|
||||
/// </summary>
|
||||
/// <param name="pathLength">传输路径长度(米)</param>
|
||||
/// <returns>沙尘衰减(dB)</returns>
|
||||
protected double CalculateDustAttenuation(double pathLength)
|
||||
{
|
||||
if (!IsDusty)
|
||||
return 0;
|
||||
|
||||
// 沙尘天气衰减计算
|
||||
double dustFactor = 1.5; // 沙尘对衰减的额外影响因子
|
||||
double beta = (3.91 / Visibility) * dustFactor;
|
||||
return beta * pathLength;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 计算能见度因子
|
||||
/// </summary>
|
||||
/// <returns>能见度因子</returns>
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 计算烟幕对电磁波的透过率
|
||||
/// </summary>
|
||||
/// <param name="smokeConcentration">烟幕浓度(g/m³)</param>
|
||||
/// <param name="smokeThickness">烟幕厚度(米)</param>
|
||||
/// <returns>烟幕透过率(0到1之间的值)</returns>
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 打印天气信息
|
||||
/// </summary>
|
||||
/// <param name="weather">天气条件</param>
|
||||
public static void PrintWeatherInfo(WeatherCondition weather){
|
||||
Console.WriteLine($"---天气类型: {weather.Type}, 温度: {weather.Temperature}°C, 相对湿度: {weather.RelativeHumidity}%, 能见度: {weather.Visibility}km, 降水量: {weather.Precipitation ?? 0}mm/h");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 天气类型枚举
|
||||
/// </summary>
|
||||
public enum WeatherType
|
||||
{
|
||||
晴天,
|
||||
雨天,
|
||||
雪天,
|
||||
雾天,
|
||||
沙尘
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 天气条件类
|
||||
/// </summary>
|
||||
public class WeatherCondition(WeatherType type, double temperature, double relativeHumidity, double visibility, double? precipitation = null, double co2Concentration = 415)
|
||||
{
|
||||
/// <summary>
|
||||
/// 天气类型
|
||||
/// </summary>
|
||||
public WeatherType Type { get; set; } = type; // 天气类型
|
||||
/// <summary>
|
||||
/// 温度(摄氏度)
|
||||
/// </summary>
|
||||
public double Temperature { get; set; } = temperature; // 温度
|
||||
/// <summary>
|
||||
/// 相对湿度(百分比)
|
||||
/// </summary>
|
||||
public double RelativeHumidity { get; set; } = relativeHumidity; // 相对湿度
|
||||
/// <summary>
|
||||
/// 能见度(公里)
|
||||
/// </summary>
|
||||
public double Visibility { get; set; } = visibility; // 能见度
|
||||
/// <summary>
|
||||
/// 降水量(毫米/小时)
|
||||
/// </summary>
|
||||
public double? Precipitation { get; set; } = precipitation; // 降水量
|
||||
/// <summary>
|
||||
/// 二氧化碳浓度(ppm)
|
||||
/// </summary>
|
||||
public double CO2Concentration { get; set; } = co2Concentration;
|
||||
}
|
||||
}
|
||||
143
AirTransmission/UVTransmittanceModel.cs
Normal file
143
AirTransmission/UVTransmittanceModel.cs
Normal file
@ -0,0 +1,143 @@
|
||||
/*
|
||||
* 版本历史:
|
||||
* 1.0.0 (2024-10-13): 初始版本,实现紫外线在大气中的传输特性计算。作者:田建勇
|
||||
*/
|
||||
|
||||
using System;
|
||||
|
||||
namespace AirTransmission
|
||||
{
|
||||
/// <summary>
|
||||
/// 紫外线传输模型类,用于计算紫外线在大气中的传输特性
|
||||
/// </summary>
|
||||
public class UVTransmittanceModel(WeatherCondition weather) : TransmittanceModel(weather)
|
||||
{
|
||||
/// <summary>
|
||||
/// 紫外线波长(微米)
|
||||
/// </summary>
|
||||
private const double UV_WAVELENGTH = 0.308; // 微米 (308 nm)
|
||||
|
||||
/// <summary>
|
||||
/// 计算给定距离的紫外线透过率
|
||||
/// </summary>
|
||||
/// <param name="distance">传输距离(米)</param>
|
||||
/// <returns>紫外线透过率(0到1之间的值)</returns>
|
||||
public override double CalculateTransmittance(double distance)
|
||||
{
|
||||
double attenuationFactor = CalculateUVAttenuationFactor();
|
||||
double rainAttenuation = CalculateRainAttenuation(distance, UV_WAVELENGTH);
|
||||
double fogAttenuation = CalculateFogAttenuation(distance);
|
||||
double dustAttenuation = CalculateDustAttenuation(distance);
|
||||
double snowAttenuation = CalculateSnowAttenuation(distance, UV_WAVELENGTH);
|
||||
|
||||
double transmittance = Math.Pow(STANDARD_TRANSMITTANCE, attenuationFactor * distance) *
|
||||
Math.Exp(-rainAttenuation - fogAttenuation - dustAttenuation - snowAttenuation);
|
||||
|
||||
return Math.Max(0, Math.Min(1, transmittance));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 计算雨对紫外线的衰减系数K
|
||||
/// </summary>
|
||||
/// <param name="wavelength">波长(微米)</param>
|
||||
/// <returns>雨衰减系数K</returns>
|
||||
protected override double CalculateRainKCoefficient(double wavelength)
|
||||
{
|
||||
// 对于UV波段 (308 nm)
|
||||
return 0.4715;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 计算雨对紫外线的衰减系数α
|
||||
/// </summary>
|
||||
/// <param name="wavelength">波长(微米)</param>
|
||||
/// <returns>雨衰减系数α</returns>
|
||||
protected override double CalculateRainAlphaCoefficient(double wavelength)
|
||||
{
|
||||
// 对于UV波段 (308 nm)
|
||||
return 0.6296;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 计算雪对紫外线的衰减系数K
|
||||
/// </summary>
|
||||
/// <param name="wavelength">波长(微米)</param>
|
||||
/// <returns>雪衰减系数K</returns>
|
||||
protected override double CalculateSnowKCoefficient(double wavelength)
|
||||
{
|
||||
// 对于UV波段 (308 nm)
|
||||
return 0.5225;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 计算雪对紫外线的衰减系数α
|
||||
/// </summary>
|
||||
/// <param name="wavelength">波长(微米)</param>
|
||||
/// <returns>雪衰减系数α</returns>
|
||||
protected override double CalculateSnowAlphaCoefficient(double wavelength)
|
||||
{
|
||||
// 对于UV波段 (308 nm)
|
||||
return 0.7937;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 计算紫外线的总衰减因子
|
||||
/// </summary>
|
||||
/// <returns>紫外线总衰减因子</returns>
|
||||
private double CalculateUVAttenuationFactor()
|
||||
{
|
||||
double molecularFactor = CalculateUVMolecularFactor();
|
||||
double aerosolFactor = CalculateUVAerosolFactor();
|
||||
double visibilityFactor = CalculateVisibilityFactor();
|
||||
|
||||
return molecularFactor * aerosolFactor * visibilityFactor;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 计算紫外线的分子散射因子
|
||||
/// </summary>
|
||||
/// <returns>紫外线分子散射因子</returns>
|
||||
private double CalculateUVMolecularFactor()
|
||||
{
|
||||
// UV分子散射比可见光更强
|
||||
return (Pressure / 1013.25) * (288.15 / Temperature) * 2.0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 计算紫外线的气溶胶散射因子
|
||||
/// </summary>
|
||||
/// <returns>紫外线气溶胶散射因子</returns>
|
||||
private double CalculateUVAerosolFactor()
|
||||
{
|
||||
double q = 0.585 * Math.Pow(Visibility, 1.0/3.0);
|
||||
double aerosolFactor = 3.91 / Visibility * Math.Pow(UV_WAVELENGTH / 0.55, -q);
|
||||
|
||||
if (Visibility < 5)
|
||||
{
|
||||
aerosolFactor *= (1 + (5 - Visibility) / 5);
|
||||
}
|
||||
|
||||
if (IsDusty)
|
||||
{
|
||||
aerosolFactor *= 1.5;
|
||||
}
|
||||
|
||||
return Math.Max(1, aerosolFactor);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 计算雾对紫外线的衰减
|
||||
/// </summary>
|
||||
/// <param name="pathLength">传输路径长度(米)</param>
|
||||
/// <returns>雾对紫外线的衰减</returns>
|
||||
private double CalculateFogAttenuation(double pathLength)
|
||||
{
|
||||
if (!IsFoggy)
|
||||
return 0;
|
||||
|
||||
double q = 0.585 * Math.Pow(Visibility, 1.0/3.0);
|
||||
double beta = 3.91 / Visibility * Math.Pow(UV_WAVELENGTH / 0.55, -q);
|
||||
return beta * pathLength * 0.7; // UV在雾中的衰减可能比可见光更强
|
||||
}
|
||||
}
|
||||
}
|
||||
274
Program.cs
Normal file
274
Program.cs
Normal file
@ -0,0 +1,274 @@
|
||||
/*
|
||||
* 版本历史:
|
||||
* 1.0.0 (2024-10-13): 初始版本,实现基本的大气透过率计算和测试功能。作者:田建勇
|
||||
*/
|
||||
|
||||
using System;
|
||||
using AirTransmission;
|
||||
|
||||
class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
Console.WriteLine("脉冲激光目标指示器辐射能量计算");
|
||||
|
||||
// 创建一个晴天的天气条件
|
||||
var weatherCondition = new WeatherCondition(
|
||||
type: WeatherType.晴天,
|
||||
temperature: 25,
|
||||
relativeHumidity: 60,
|
||||
visibility: 10
|
||||
);
|
||||
|
||||
// 设置激光和目标参数
|
||||
double laserEnergy = 0.130; // 130 mJ
|
||||
double pulseWidth = 15; // 15 ns
|
||||
double targetDistance = 1; // 1公里
|
||||
double receiverDistance = 1; // 1公里
|
||||
double targetReflectivity = 0.2; // 假设坦克反射率为20%
|
||||
|
||||
// 计算激光透过率和接收功率
|
||||
double transmittance = AtmosphericTransmittanceCalculator.CalcLaser(weatherCondition, targetDistance);
|
||||
double receivedPower = AtmosphericTransmittanceCalculator.CalculateReceivedRadiation(transmittance, laserEnergy, pulseWidth, targetDistance, receiverDistance, targetReflectivity);
|
||||
|
||||
Console.WriteLine($"\n导弹导引头接收到的平均功率: {receivedPower:E2} W");
|
||||
|
||||
// 执行各种测试
|
||||
Console.WriteLine("\n单程辐射能量计算");
|
||||
CalculateSinglePathRadiation();
|
||||
|
||||
Console.WriteLine("\n烟幕影响计算");
|
||||
TestSmokeScreenEffect();
|
||||
|
||||
Console.WriteLine("\n不同天气条件下的激光透过率测试");
|
||||
TestLaserTransmittanceInDifferentWeather();
|
||||
|
||||
Console.WriteLine("\n不同天气条件下的红外线透过率测试");
|
||||
TestIRTransmittanceInDifferentWeather();
|
||||
|
||||
Console.WriteLine("\n不同天气条件下的毫米波透过率测试");
|
||||
TestMillimeterWaveTransmittanceInDifferentWeather();
|
||||
|
||||
Console.WriteLine("\n不同天气条件下的紫外线透过率测试");
|
||||
TestUVTransmittanceInDifferentWeather();
|
||||
|
||||
Console.WriteLine("\n湍流效应对激光透过率的影响");
|
||||
TestTurbulenceEffect();
|
||||
}
|
||||
|
||||
// 测试不同天气条件下的激光透过率
|
||||
static void TestLaserTransmittanceInDifferentWeather()
|
||||
{
|
||||
// 测试各种天气条件
|
||||
TestLaserTransmittance(WeatherType.晴天, "晴朗");
|
||||
TestLaserTransmittance(WeatherType.雨天, "小雨", relativeHumidity: 60, precipitation: 2.5, visibility: 5);
|
||||
TestLaserTransmittance(WeatherType.雨天, "大雨", relativeHumidity: 90, precipitation: 25, visibility: 2.5);
|
||||
TestLaserTransmittance(WeatherType.雾天, "雾", relativeHumidity: 70, visibility: 1);
|
||||
TestLaserTransmittance(WeatherType.沙尘, "沙尘", visibility: 0.5);
|
||||
TestLaserTransmittance(WeatherType.雪天, "雪天", temperature: -5, relativeHumidity: 80, visibility: 1, precipitation: 2.5);
|
||||
}
|
||||
|
||||
// 测试特定天气条件下的激光透过率
|
||||
static void TestLaserTransmittance(WeatherType type, string description,
|
||||
double temperature = 25, double relativeHumidity = 50,
|
||||
double visibility = 10, double? precipitation = null, double latitude = 30)
|
||||
{
|
||||
double[] distances = [0.1, 0.5, 1, 5, 10]; // 测试不同距离(公里)
|
||||
|
||||
// 创建天气条件
|
||||
var weatherCondition = new WeatherCondition(
|
||||
type: type,
|
||||
temperature: temperature,
|
||||
relativeHumidity: relativeHumidity,
|
||||
visibility: visibility,
|
||||
precipitation: precipitation
|
||||
);
|
||||
|
||||
// 输出结果
|
||||
Console.WriteLine($"\n[{description}条件下的激光透过率]");
|
||||
TransmittanceModel.PrintWeatherInfo(weatherCondition);
|
||||
foreach (var d in distances){
|
||||
double laserTransmittance = AtmosphericTransmittanceCalculator.CalcLaser(weatherCondition, d);
|
||||
Console.WriteLine($"距离:{d}公里, 1.06μm激光透过率为: {laserTransmittance:P2}");
|
||||
}
|
||||
}
|
||||
|
||||
// 计算单程辐射能量
|
||||
static void CalculateSinglePathRadiation()
|
||||
{
|
||||
// 创建天气条件
|
||||
var weatherCondition = new WeatherCondition(
|
||||
type: WeatherType.晴天,
|
||||
temperature: 25,
|
||||
relativeHumidity: 60,
|
||||
visibility: 10
|
||||
);
|
||||
|
||||
double targetRadiation = 2E+006; // 100 W/Sr
|
||||
double receiverDistance = 3; // 3公里
|
||||
|
||||
// 计算透过率和接收功率
|
||||
double transmittance = AtmosphericTransmittanceCalculator.CalcLaser(weatherCondition, receiverDistance);
|
||||
double receivedPower = AtmosphericTransmittanceCalculator.CalculateReceivedRadiationSinglePath(transmittance, targetRadiation, receiverDistance);
|
||||
|
||||
Console.WriteLine($"\n导弹导引头接收到的辐射能量: {receivedPower:E2} W/Sr");
|
||||
}
|
||||
|
||||
// 测试特定天气条件下的红外线透过率
|
||||
static void TestIRTransmittance(WeatherType type, string description,
|
||||
double temperature = 25, double relativeHumidity = 50,
|
||||
double visibility = 10, double? precipitation = null, double latitude = 30)
|
||||
{
|
||||
double[] distances = [0.1, 0.5, 1, 5, 10]; // 测试不同距离(公里)
|
||||
|
||||
// 创建天气条件
|
||||
var weatherCondition = new WeatherCondition(
|
||||
type: type,
|
||||
temperature: temperature,
|
||||
relativeHumidity: relativeHumidity,
|
||||
visibility: visibility,
|
||||
precipitation: precipitation
|
||||
);
|
||||
|
||||
// 输出结果
|
||||
Console.WriteLine($"\n[{description}条件下的红外线透过率]");
|
||||
TransmittanceModel.PrintWeatherInfo(weatherCondition);
|
||||
foreach (var d in distances)
|
||||
{
|
||||
double irTransmittance = AtmosphericTransmittanceCalculator.CalcIR(weatherCondition, d);
|
||||
Console.WriteLine($"距离:{d}公里, 红外线透过率为: {irTransmittance:P2}");
|
||||
}
|
||||
}
|
||||
|
||||
// 测试烟幕效应
|
||||
static void TestSmokeScreenEffect()
|
||||
{
|
||||
// 创建天气条件
|
||||
var weatherCondition = new WeatherCondition(
|
||||
type: WeatherType.晴天,
|
||||
temperature: 25,
|
||||
relativeHumidity: 60,
|
||||
visibility: 10
|
||||
);
|
||||
|
||||
double smokeConcentration = 0.5; // 假设烟幕浓度为0.5 g/m³
|
||||
double smokeThickness = 15; // 假设烟幕墙厚度为5米
|
||||
|
||||
// 计算烟幕透过率
|
||||
double smokeScreenTransmittance = TransmittanceModel.CalculateSmokeScreenTransmittance(smokeConcentration, smokeThickness);
|
||||
Console.WriteLine($"\n仅考虑烟幕的透过率: {smokeScreenTransmittance:P2}");
|
||||
}
|
||||
|
||||
// 测试不同天气条件下的毫米波透过率
|
||||
static void TestMillimeterWaveTransmittanceInDifferentWeather()
|
||||
{
|
||||
// 测试各种天气条件
|
||||
TestMillimeterWaveTransmittance(WeatherType.晴天, "晴朗");
|
||||
TestMillimeterWaveTransmittance(WeatherType.雨天, "小雨", relativeHumidity: 60, precipitation: 2.5, visibility: 5);
|
||||
TestMillimeterWaveTransmittance(WeatherType.雨天, "大雨", relativeHumidity: 90, precipitation: 25, visibility: 2.5);
|
||||
TestMillimeterWaveTransmittance(WeatherType.雾天, "雾", relativeHumidity: 70, visibility: 1);
|
||||
TestMillimeterWaveTransmittance(WeatherType.沙尘, "沙尘", visibility: 0.5);
|
||||
TestMillimeterWaveTransmittance(WeatherType.雪天, "雪天", temperature: -5, relativeHumidity: 80, visibility: 1, precipitation: 5);
|
||||
}
|
||||
|
||||
// 测试特定天气条件下的毫米波透过率
|
||||
static void TestMillimeterWaveTransmittance(WeatherType type, string description,
|
||||
double temperature = 25, double relativeHumidity = 50,
|
||||
double visibility = 10, double? precipitation = null)
|
||||
{
|
||||
double[] distances = [0.1, 0.5, 1, 5, 10]; // 测试不同距离(公里)
|
||||
|
||||
// 创建天气条件
|
||||
var weatherCondition = new WeatherCondition(
|
||||
type: type,
|
||||
temperature: temperature,
|
||||
relativeHumidity: relativeHumidity,
|
||||
visibility: visibility,
|
||||
precipitation: precipitation
|
||||
);
|
||||
|
||||
// 输出结果
|
||||
Console.WriteLine($"\n[{description}条件下的毫米波透过率]");
|
||||
TransmittanceModel.PrintWeatherInfo(weatherCondition);
|
||||
foreach (var d in distances)
|
||||
{
|
||||
double mmWaveTransmittance = AtmosphericTransmittanceCalculator.CalcMillimeterWave(weatherCondition, d);
|
||||
Console.WriteLine($"距离:{d}公里, 毫米波透过率为: {mmWaveTransmittance:P2}");
|
||||
}
|
||||
}
|
||||
|
||||
// 测试不同天气条件下的红外线透过率
|
||||
static void TestIRTransmittanceInDifferentWeather()
|
||||
{
|
||||
// 测试各种天气条件
|
||||
TestIRTransmittance(WeatherType.晴天, "晴朗");
|
||||
TestIRTransmittance(WeatherType.雨天, "小雨", relativeHumidity: 60, precipitation: 2.5, visibility: 5);
|
||||
TestIRTransmittance(WeatherType.雨天, "大雨", relativeHumidity: 90, precipitation: 25, visibility: 2.5);
|
||||
TestIRTransmittance(WeatherType.雾天, "雾", relativeHumidity: 70, visibility: 1);
|
||||
TestIRTransmittance(WeatherType.沙尘, "沙尘", visibility: 0.5);
|
||||
TestIRTransmittance(WeatherType.雪天, "雪天", temperature: -5, relativeHumidity: 80, visibility: 1, precipitation: 5);
|
||||
}
|
||||
|
||||
// 测试不同天气条件下的紫外线透过率
|
||||
static void TestUVTransmittanceInDifferentWeather()
|
||||
{
|
||||
// 测试各种天气条件
|
||||
TestUVTransmittance(WeatherType.晴天, "晴朗");
|
||||
TestUVTransmittance(WeatherType.雨天, "小雨", relativeHumidity: 60, precipitation: 2.5, visibility: 5);
|
||||
TestUVTransmittance(WeatherType.雨天, "大雨", relativeHumidity: 90, precipitation: 25, visibility: 2.5);
|
||||
TestUVTransmittance(WeatherType.雾天, "雾", relativeHumidity: 70, visibility: 1);
|
||||
TestUVTransmittance(WeatherType.沙尘, "沙尘", visibility: 0.5);
|
||||
TestUVTransmittance(WeatherType.雪天, "雪天", temperature: -5, relativeHumidity: 80, visibility: 1, precipitation: 5);
|
||||
}
|
||||
|
||||
// 测试特定天气条件下的紫外线透过率
|
||||
static void TestUVTransmittance(WeatherType type, string description,
|
||||
double temperature = 25, double relativeHumidity = 50,
|
||||
double visibility = 10, double? precipitation = null)
|
||||
{
|
||||
double[] distances = [0.1, 0.5, 1, 5, 10]; // 测试不同距离(公里)
|
||||
|
||||
// 创建天气条件
|
||||
var weatherCondition = new WeatherCondition(
|
||||
type: type,
|
||||
temperature: temperature,
|
||||
relativeHumidity: relativeHumidity,
|
||||
visibility: visibility,
|
||||
precipitation: precipitation
|
||||
);
|
||||
|
||||
// 输出结果
|
||||
Console.WriteLine($"\n[{description}条件下的紫外线透过率]");
|
||||
TransmittanceModel.PrintWeatherInfo(weatherCondition);
|
||||
foreach (var d in distances)
|
||||
{
|
||||
double uvTransmittance = AtmosphericTransmittanceCalculator.CalcUV(weatherCondition, d);
|
||||
Console.WriteLine($"距离:{d}公里, 紫外线透过率为: {uvTransmittance:P2}");
|
||||
}
|
||||
}
|
||||
|
||||
// 测试湍流效应对激光透过率的影响
|
||||
static void TestTurbulenceEffect()
|
||||
{
|
||||
// 创建天气条件
|
||||
var weatherCondition = new WeatherCondition(
|
||||
type: WeatherType.晴天,
|
||||
temperature: 25,
|
||||
relativeHumidity: 60,
|
||||
visibility: 10
|
||||
);
|
||||
|
||||
var laserModel = new LaserTransmittanceModel(weatherCondition);
|
||||
|
||||
double[] distances = [0.1, 0.5, 1, 5, 10]; // 测试不同距离(公里)
|
||||
|
||||
// 输出结果
|
||||
Console.WriteLine("\n[湍流效应对激光透过率的影响]");
|
||||
foreach (var d in distances)
|
||||
{
|
||||
double transmittanceWithoutTurbulence = laserModel.CalculateTransmittance(d);
|
||||
double transmittanceWithTurbulence = laserModel.CalculateTransmittanceWithTurbulence(d);
|
||||
Console.WriteLine($"距离:{d}公里, 无湍流透过率: {transmittanceWithoutTurbulence:P2}, 有湍流透过率: {transmittanceWithTurbulence:P2}");
|
||||
}
|
||||
}
|
||||
}
|
||||
69
README.md
Normal file
69
README.md
Normal file
@ -0,0 +1,69 @@
|
||||
# 大气透过率计算器
|
||||
|
||||
## 项目简介
|
||||
|
||||
大气透过率计算器是一个用于模拟和计算各种电磁波(包括激光、红外线、毫米波和紫外线)在不同大气条件下透过率的工具。本项目考虑了多种天气因素和大气湍流的影响,为光学和通信系统的设计与分析提供了有力支持。
|
||||
|
||||
## 功能特性
|
||||
|
||||
- 支持多种电磁波类型:激光、红外线、毫米波和紫外线
|
||||
- 考虑多种天气条件:晴天、雨天、雪天、雾天、沙尘天气
|
||||
- 模拟大气湍流对光传输的影响
|
||||
- 计算烟幕对透过率的影响
|
||||
- 灵活配置传输距离和天气参数
|
||||
- 提供详细的计算过程和结果输出
|
||||
|
||||
## 安装说明
|
||||
|
||||
1. 确保您的系统已安装 .NET Core 3.1 或更高版本。
|
||||
2. 克隆此仓库到本地机器: ```
|
||||
git clone https://github.com/tianjianyong/atmospheric-transmittance-calculator.git ```
|
||||
3. 进入项目目录: ```
|
||||
cd atmospheric-transmittance-calculator ```
|
||||
4. 编译项目: ```
|
||||
dotnet build ```
|
||||
|
||||
## 使用方法
|
||||
|
||||
1. 在项目根目录下运行程序: ```
|
||||
dotnet run ```
|
||||
2. 程序将自动执行一系列预设的测试场景,包括不同天气条件和传输距离。
|
||||
3. 查看控制台输出,了解各种条件下的透过率计算结果。
|
||||
|
||||
### 示例代码
|
||||
|
||||
如果您想在自己的程序中使用此计算器,可以参考Program.cs中的代码
|
||||
|
||||
## 项目结构
|
||||
|
||||
- `Program.cs`: 主程序入口,包含各种测试方法
|
||||
- `AtmosphericTransmittanceCalculator.cs`: 主要的计算接口
|
||||
- `TransmittanceModel.cs`: 透过率模型的基类
|
||||
- `LaserTransmittanceModel.cs`: 激光透过率模型
|
||||
- `IRTransmittanceModel.cs`: 红外线透过率模型
|
||||
- `MillimeterWaveTransmittanceModel.cs`: 毫米波透过率模型
|
||||
- `UVTransmittanceModel.cs`: 紫外线透过率模型
|
||||
- `AtmosphericTurbulenceModel.cs`: 大气湍流模型
|
||||
|
||||
## 版本历史
|
||||
|
||||
- 1.0.0 (2024-10-13): 初始版本发布
|
||||
|
||||
## 作者
|
||||
|
||||
田建勇
|
||||
|
||||
## 许可证
|
||||
|
||||
本项目采用 MIT 许可证。详情请见 [LICENSE](LICENSE) 文件。
|
||||
|
||||
## 联系方式
|
||||
|
||||
如有任何问题或建议,请通过以下方式联系我们:
|
||||
|
||||
- 电子邮件:<tianjianyong@gmail.com>
|
||||
- 项目 Issues:<https://github.com/yourusername/atmospheric-transmittance-calculator/issues>
|
||||
|
||||
## 致谢
|
||||
|
||||
感谢所有为本项目做出贡献的开发者和研究人员。
|
||||
10
air.csproj
Normal file
10
air.csproj
Normal file
@ -0,0 +1,10 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
25
air.sln
Normal file
25
air.sln
Normal file
@ -0,0 +1,25 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.5.002.0
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "air", "air.csproj", "{2A5A314C-58B2-4853-A6CA-F2B17F69A8E5}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{2A5A314C-58B2-4853-A6CA-F2B17F69A8E5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{2A5A314C-58B2-4853-A6CA-F2B17F69A8E5}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{2A5A314C-58B2-4853-A6CA-F2B17F69A8E5}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{2A5A314C-58B2-4853-A6CA-F2B17F69A8E5}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {16FD379F-2B2B-4334-A010-A5740A406481}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
Loading…
Reference in New Issue
Block a user