Files
ASTM-D7896-19TransientHot-W…/ViewModels/MeasurementResult.cs
2026-05-29 18:35:36 +08:00

67 lines
2.2 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using CommunityToolkit.Mvvm.ComponentModel;
using System.Diagnostics; // 添加命名空间
namespace ASTM_D7896_Tester.ViewModels;
public partial class MeasurementResult : ObservableObject
{
[ObservableProperty]
private int _index;
[ObservableProperty]
private double _thermalConductivity; // W/m·K
[ObservableProperty]
private double _thermalDiffusivity; // m²/s
[ObservableProperty]
private double _specificHeatCapacity; // 比热容 J/(kg·K)
public void CalculateVhcAndCp(double density)
{
// 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;
}
// 2. 计算比热容 Cp = VHC / ρ
if (density > 0)
{
// VHC 转回 J/(m³·K) 除以密度
SpecificHeatCapacity = (VolumetricHeatCapacity * 1000.0) / density;
}
else
{
SpecificHeatCapacity = 0;
}
Debug.WriteLine($"[MeasurementResult] 计算完成: VHC={VolumetricHeatCapacity:F2} kJ/(m³·K), Cp={SpecificHeatCapacity:F2} J/(kg·K)");
}
[ObservableProperty]
private double _volumetricHeatCapacity; // kJ/m³·K (自动计算)
public void CalculateVhc()
{
Debug.WriteLine($"[MeasurementResult] 计算体积热容 - 热导率: {ThermalConductivity} W/(m·K), 热扩散率: {ThermalDiffusivity} m²/s");
if (ThermalDiffusivity > 0)
{
// VHC (kJ/(m³·K)) = (λ / α) / 1000
VolumetricHeatCapacity = ThermalConductivity / ThermalDiffusivity / 1000.0;
Debug.WriteLine($"[MeasurementResult] 计算得到体积热容: {VolumetricHeatCapacity} kJ/(m³·K)");
}
else
{
VolumetricHeatCapacity = 0;
Debug.WriteLine($"[MeasurementResult] 警告: 热扩散率为0体积热容设为0");
}
}
}