1 unstable release

0.0.1 May 29, 2022

#81 in #prelude

MIT/Apache

210KB
3K SLoC

te1d

te1d is a Rust library for simulation of thermoelectric effect using one-spatial-dimensional mathematical models.

  • te1d uses the external ndarray crate for matrix manipulation.

Features

  • Simulate Thermoelectric Power Generation for
    • Single-material, single-leg,
    • Maximum energy conversion efficiency.
  • Support Temperature-Dependent Material Properties.
  • Take account of Thermal diffusion, Joule heating, Thomson heating.

Task Lists

Examples

// 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));

Dependencies

~1.5MB
~26K SLoC