Files

67 lines
2.2 KiB
C#
Raw Permalink Normal View History

2026-04-18 19:00:34 +08:00
using CommunityToolkit.Mvvm.ComponentModel;
2026-05-26 19:37:04 +08:00
using System.Diagnostics; // 添加命名空间
2026-04-18 19:00:34 +08:00
namespace ASTM_D7896_Tester.ViewModels;
public partial class MeasurementResult : ObservableObject
{
[ObservableProperty]
private int _index;
[ObservableProperty]
private double _thermalConductivity; // W/m·K
[ObservableProperty]
2026-05-29 18:35:36 +08:00
private double _thermalDiffusivity; // m²/s
2026-04-18 19:00:34 +08:00
2026-05-20 19:46:52 +08:00
[ObservableProperty]
private double _specificHeatCapacity; // 比热容 J/(kg·K)
public void CalculateVhcAndCp(double density)
{
2026-05-27 19:06:19 +08:00
// 1. 计算体积热容 VHC = λ / α
// 注意ThermalDiffusivity 已经是标准单位 m²/s绝对不能再乘 1e-6
if (ThermalDiffusivity > 0)
{
double vhc_J = ThermalConductivity / ThermalDiffusivity; // 单位: J/(m³·K)
VolumetricHeatCapacity = vhc_J / 1000.0; // 转换为 kJ/(m³·K)
}
else
{
VolumetricHeatCapacity = 0;
}
2026-05-26 19:37:04 +08:00
2026-05-27 19:06:19 +08:00
// 2. 计算比热容 Cp = VHC / ρ
2026-05-20 19:46:52 +08:00
if (density > 0)
2026-05-26 19:37:04 +08:00
{
2026-05-27 19:06:19 +08:00
// VHC 转回 J/(m³·K) 除以密度
SpecificHeatCapacity = (VolumetricHeatCapacity * 1000.0) / density;
2026-05-26 19:37:04 +08:00
}
2026-05-20 19:46:52 +08:00
else
2026-05-26 19:37:04 +08:00
{
2026-05-20 19:46:52 +08:00
SpecificHeatCapacity = 0;
2026-05-26 19:37:04 +08:00
}
2026-05-27 19:06:19 +08:00
Debug.WriteLine($"[MeasurementResult] 计算完成: VHC={VolumetricHeatCapacity:F2} kJ/(m³·K), Cp={SpecificHeatCapacity:F2} J/(kg·K)");
2026-05-20 19:46:52 +08:00
}
2026-04-18 19:00:34 +08:00
[ObservableProperty]
private double _volumetricHeatCapacity; // kJ/m³·K (自动计算)
public void CalculateVhc()
{
2026-05-29 18:35:36 +08:00
Debug.WriteLine($"[MeasurementResult] 计算体积热容 - 热导率: {ThermalConductivity} W/(m·K), 热扩散率: {ThermalDiffusivity} m²/s");
2026-05-26 19:37:04 +08:00
2026-05-20 19:46:52 +08:00
if (ThermalDiffusivity > 0)
2026-05-26 19:37:04 +08:00
{
2026-05-29 18:35:36 +08:00
// VHC (kJ/(m³·K)) = (λ / α) / 1000
VolumetricHeatCapacity = ThermalConductivity / ThermalDiffusivity / 1000.0;
2026-05-26 19:37:04 +08:00
Debug.WriteLine($"[MeasurementResult] 计算得到体积热容: {VolumetricHeatCapacity} kJ/(m³·K)");
}
2026-04-18 19:00:34 +08:00
else
2026-05-26 19:37:04 +08:00
{
2026-04-18 19:00:34 +08:00
VolumetricHeatCapacity = 0;
2026-05-26 19:37:04 +08:00
Debug.WriteLine($"[MeasurementResult] 警告: 热扩散率为0体积热容设为0");
}
2026-04-18 19:00:34 +08:00
}
}