1个不稳定版本
0.0.1 | 2022年5月29日 |
---|
#76 in #prelude
210KB
3K SLoC
te1d
te1d
是一个使用一维空间数学模型模拟热电效应的Rust库。
te1d
使用外部ndarray
crate进行矩阵操作。
特性
- 模拟热电发电
- 单材料、单腿,
- 最大能量转换效率。
- 支持温度依赖性材料属性。
- 考虑热扩散、焦耳加热、汤姆孙加热。
任务列表
- 稳态发电
- 单材料单腿模拟:
SingleLeg
- 固定电流:
SingleLeg::simulate_fixed_elec_cur()
- 固定负载电阻:
SingleLeg::simulate_fixed_load_resistance()
- 固定负载电阻比:
SingleLeg::simulate_fixed_load_ratio()
- 功率最大化:
SingleLeg::maximize_power_auto_range()
- 效率最大化:
SingleLeg::maximize_efficiency_auto_range()
- 近似最大功率
- 近似最大效率
- 固定电流:
- 多材料和多接触电阻的分段腿
- 具有p型和n型腿的模块
- 边界条件
- 固定温度:
FixedTempBc
- 固定热通量:
FixedHeatFluxBc
- 对流:
ConvectionBc
- 固定温度:
- 横向热损失
- 对流损失
- 辐射损失
- 分支分析
- 单材料单腿模拟:
- 稳态冷却
- 瞬态发电
- 瞬态冷却
示例
- 我们使用AgSbTe2材料(含2% GeTe),如Y. Chen等人(2012年)报道的图5中所示。
// Goal: Find the maximum efficiency of a single leg using a AgSbTe2 material
// Import libraries
use ndarray::prelude::*;
use te1d::teg::prelude::*;
// Set the material properties
let seebeck_array: Array2<f64> = array![
[317.358, 1.96E-04], [340.4, 2.12E-04], [366.747, 2.23E-04], [390.492, 2.20E-04],
[412.868, 2.38E-04], [435.936, 2.42E-04], [458.998, 2.48E-04], [480.75, 2.51E-04],
[506.455, 2.55E-04], [528.907, 2.40E-04], [552.646, 2.39E-04], [576.396, 2.33E-04],
[600.135, 2.32E-04]];
let elec_cond_array: Array2<f64> = array![
[315.737, 10147.0], [341.864, 9861.0], [365.309, 9683.0], [389.428, 9396.0],
[413.553, 8966.0], [436.995, 8860.0], [460.443, 8610.0], [481.873, 8576.0],
[504.642, 8543.0], [528.739, 8799.0], [552.82, 9416.0], [574.887, 10178.0],
[599.653, 10434.0]];
let thrm_cond_array: Array2<f64> = array![
[304.113, 0.66], [373.047, 0.67], [475.351, 0.65], [526.115, 0.64],
[572.9, 0.75], [625.049, 0.83]];
let tep: Tep = Tep::from_raw_data_elec_cond(
&seebeck_array, &elec_cond_array, &thrm_cond_array);
// Set the leg spec
let length: f64 = 1e-3; // (m)
let area: f64 = 1e-6; // (mm^2)
// Set the boundary condition (Dirichlet boundary conditions)
let hot_temp: f64 = 500.0;
let cold_temp: f64 = 300.0;
let left_bc = FixedTempBc::new(hot_temp);
let right_bc = FixedTempBc::new(cold_temp);
// Set simulation parameters
let minimizer_kind = MinimizerKind::Bfgs;
let minimizer_param = MinimizerParam {
grad_tol: 1e-5,
max_iter: 300,
..MinimizerParam::default(minimizer_kind)
};
let simul_param = SimulationParam {
dx: length/10.0,
dtemp: (hot_temp - cold_temp)/10.0,
minimizer_kind,
minimizer_param,
..SimulationParam::default()
};
// Create a leg
let leg = SingleLeg::new(&tep, length, area, simul_param);
// Find the maximum efficiency: takes about 4.0s
let result = leg.maximize_power_auto_range(&left_bc, &right_bc, hot_temp, cold_temp);
assert!(result.success);
// Compare with an approximation: 2% relative error
let approx_max_efficiency = leg.estimate_max_efficiency(hot_temp, cold_temp);
assert!(is_close(approx_max_efficiency, result.efficiency, 2e-2, 0.0));
依赖关系
~1.5MB
~25K SLoC