tegkit 0.3.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
tegkit/__init__.py ADDED
@@ -0,0 +1,24 @@
1
+ """tegkit: small, dependency-free toolkit for modelling thermoelectric generators."""
2
+
3
+ from . import peltier, presets
4
+ from .array import TEGArray
5
+ from .curves import OperatingPoint, iv_curve, max_power_point
6
+ from .module import TEGModule
7
+ from .sizing import modules_for_power, required_cold_side_resistance, suggest_array
8
+ from .units import c_to_k, k_to_c
9
+
10
+ __all__ = [
11
+ "TEGModule",
12
+ "TEGArray",
13
+ "OperatingPoint",
14
+ "iv_curve",
15
+ "max_power_point",
16
+ "modules_for_power",
17
+ "suggest_array",
18
+ "required_cold_side_resistance",
19
+ "peltier",
20
+ "presets",
21
+ "c_to_k",
22
+ "k_to_c",
23
+ ]
24
+ __version__ = "0.3.0"
tegkit/__main__.py ADDED
@@ -0,0 +1,51 @@
1
+ """Command line: ``python -m tegkit --seebeck 0.05 --resistance 2 --conductance 0.5 --dt 40``."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import argparse
6
+ import sys
7
+
8
+ from . import __version__
9
+ from .array import TEGArray
10
+ from .curves import iv_curve, max_power_point
11
+ from .module import TEGModule
12
+
13
+
14
+ def build_parser() -> argparse.ArgumentParser:
15
+ p = argparse.ArgumentParser(prog="tegkit", description="Thermoelectric generator calculator")
16
+ p.add_argument("--seebeck", type=float, required=True, help="module Seebeck coefficient, V/K")
17
+ p.add_argument("--resistance", type=float, required=True, help="internal resistance, ohm")
18
+ p.add_argument("--conductance", type=float, required=True, help="thermal conductance, W/K")
19
+ p.add_argument("--dt", type=float, required=True, help="temperature difference across the module, K")
20
+ p.add_argument("--series", type=int, default=1, help="modules in series (default 1)")
21
+ p.add_argument("--parallel", type=int, default=1, help="parallel strings (default 1)")
22
+ p.add_argument("--points", type=int, default=0, help="also print an I-V table with this many points")
23
+ p.add_argument("--version", action="version", version=f"tegkit {__version__}")
24
+ return p
25
+
26
+
27
+ def main(argv: list[str] | None = None) -> int:
28
+ args = build_parser().parse_args(argv)
29
+ try:
30
+ module = TEGModule(args.seebeck, args.resistance, args.conductance)
31
+ source = TEGArray(module, args.series, args.parallel)
32
+ except ValueError as exc:
33
+ print(f"error: {exc}", file=sys.stderr)
34
+ return 2
35
+
36
+ mpp = max_power_point(source, args.dt)
37
+ print(f"Array: {args.series}S{args.parallel}P ({source.count} modules)")
38
+ print(f"Open-circuit V: {source.open_circuit_voltage(args.dt):.3f} V")
39
+ print(f"Matched load: {source.matched_load():.3f} ohm")
40
+ print(f"Max power: {mpp.power:.3f} W at {mpp.voltage:.3f} V, {mpp.current:.3f} A")
41
+
42
+ if args.points:
43
+ print()
44
+ print(f"{'I (A)':>10} {'V (V)':>10} {'P (W)':>10}")
45
+ for pt in iv_curve(source, args.dt, args.points):
46
+ print(f"{pt.current:10.3f} {pt.voltage:10.3f} {pt.power:10.3f}")
47
+ return 0
48
+
49
+
50
+ if __name__ == "__main__":
51
+ raise SystemExit(main())
tegkit/array.py ADDED
@@ -0,0 +1,51 @@
1
+ """Series/parallel arrays of identical TEG modules."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from dataclasses import dataclass
6
+
7
+ from .module import TEGModule
8
+
9
+ __all__ = ["TEGArray"]
10
+
11
+
12
+ @dataclass(frozen=True)
13
+ class TEGArray:
14
+ """``series`` modules per string, ``parallel`` strings, all identical and
15
+ all seeing the same temperature difference.
16
+ """
17
+
18
+ module: TEGModule
19
+ series: int = 1
20
+ parallel: int = 1
21
+
22
+ def __post_init__(self) -> None:
23
+ if self.series < 1 or self.parallel < 1:
24
+ raise ValueError("series and parallel must be >= 1")
25
+
26
+ @property
27
+ def count(self) -> int:
28
+ return self.series * self.parallel
29
+
30
+ def as_module(self) -> TEGModule:
31
+ """Equivalent single module (Thevenin source plus total conductance)."""
32
+ m = self.module
33
+ return TEGModule(
34
+ seebeck=m.seebeck * self.series,
35
+ resistance=m.resistance * self.series / self.parallel,
36
+ thermal_conductance=m.thermal_conductance * self.count,
37
+ name=f"{self.series}S{self.parallel}P {m.name}".strip(),
38
+ )
39
+
40
+ def open_circuit_voltage(self, delta_t: float) -> float:
41
+ return self.as_module().open_circuit_voltage(delta_t)
42
+
43
+ def power(self, delta_t: float, load_resistance: float) -> float:
44
+ return self.as_module().power(delta_t, load_resistance)
45
+
46
+ def max_power(self, delta_t: float) -> float:
47
+ return self.as_module().max_power(delta_t)
48
+
49
+ def matched_load(self) -> float:
50
+ """Load resistance (ohm) for maximum power."""
51
+ return self.as_module().resistance
tegkit/curves.py ADDED
@@ -0,0 +1,54 @@
1
+ """Operating curves: I-V, power and the maximum power point."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import NamedTuple, Union
6
+
7
+ from .array import TEGArray
8
+ from .module import TEGModule
9
+
10
+ __all__ = ["OperatingPoint", "iv_curve", "max_power_point", "as_module"]
11
+
12
+ Source = Union[TEGModule, TEGArray]
13
+
14
+
15
+ class OperatingPoint(NamedTuple):
16
+ current: float # A
17
+ voltage: float # V
18
+ power: float # W
19
+
20
+
21
+ def as_module(source: Source) -> TEGModule:
22
+ """Return a single equivalent :class:`TEGModule` for a module or array."""
23
+ if isinstance(source, TEGArray):
24
+ return source.as_module()
25
+ if isinstance(source, TEGModule):
26
+ return source
27
+ raise TypeError(f"expected TEGModule or TEGArray, got {type(source).__name__}")
28
+
29
+
30
+ def iv_curve(source: Source, delta_t: float, points: int = 21) -> list[OperatingPoint]:
31
+ """Sweep current from 0 (open circuit) to short circuit.
32
+
33
+ The generator is a Thevenin source, so ``V = Voc - I*R`` is a straight line
34
+ and power is a parabola peaking at half the short-circuit current.
35
+ """
36
+ if points < 2:
37
+ raise ValueError("points must be >= 2")
38
+ m = as_module(source)
39
+ voc = m.open_circuit_voltage(delta_t)
40
+ isc = voc / m.resistance
41
+ curve = []
42
+ for k in range(points):
43
+ i = isc * k / (points - 1)
44
+ v = voc - i * m.resistance
45
+ curve.append(OperatingPoint(i, v, i * v))
46
+ return curve
47
+
48
+
49
+ def max_power_point(source: Source, delta_t: float) -> OperatingPoint:
50
+ """Current, voltage and power at the maximum power point (I = Isc/2)."""
51
+ m = as_module(source)
52
+ voc = m.open_circuit_voltage(delta_t)
53
+ i = voc / (2.0 * m.resistance)
54
+ return OperatingPoint(i, voc / 2.0, voc * i / 2.0)
tegkit/module.py ADDED
@@ -0,0 +1,220 @@
1
+ """Lumped-parameter model of a single thermoelectric generator (TEG) module.
2
+
3
+ The model is the standard textbook one (see e.g. Rowe, *CRC Handbook of
4
+ Thermoelectrics*): a module is described by an effective Seebeck coefficient
5
+ ``S`` (V/K), an internal electrical resistance ``R`` (ohm) and a thermal
6
+ conductance ``K`` (W/K). Temperature dependence of S, R and K is ignored.
7
+ """
8
+
9
+ from __future__ import annotations
10
+
11
+ import math
12
+ from dataclasses import dataclass
13
+
14
+ __all__ = ["TEGModule"]
15
+
16
+
17
+ def _check_positive(name: str, value: float) -> None:
18
+ if not value > 0:
19
+ raise ValueError(f"{name} must be positive, got {value!r}")
20
+
21
+
22
+ @dataclass(frozen=True)
23
+ class TEGModule:
24
+ """A single thermoelectric module.
25
+
26
+ Parameters
27
+ ----------
28
+ seebeck:
29
+ Effective module Seebeck coefficient in V/K (all couples combined).
30
+ resistance:
31
+ Internal electrical resistance in ohm.
32
+ thermal_conductance:
33
+ Module thermal conductance in W/K (hot face to cold face).
34
+ name:
35
+ Optional label, e.g. the part number.
36
+ """
37
+
38
+ seebeck: float
39
+ resistance: float
40
+ thermal_conductance: float
41
+ name: str = ""
42
+
43
+ def __post_init__(self) -> None:
44
+ _check_positive("seebeck", self.seebeck)
45
+ _check_positive("resistance", self.resistance)
46
+ _check_positive("thermal_conductance", self.thermal_conductance)
47
+
48
+ # ------------------------------------------------------------------ #
49
+ # Constructors
50
+ # ------------------------------------------------------------------ #
51
+ @classmethod
52
+ def from_measurements(
53
+ cls,
54
+ open_circuit_voltage: float,
55
+ short_circuit_current: float,
56
+ delta_t: float,
57
+ thermal_conductance: float,
58
+ name: str = "",
59
+ ) -> "TEGModule":
60
+ """Build a module from a bench measurement at a known face-to-face
61
+ temperature difference ``delta_t`` (K).
62
+
63
+ ``S = Voc / dT`` and ``R = Voc / Isc``.
64
+ """
65
+ _check_positive("open_circuit_voltage", open_circuit_voltage)
66
+ _check_positive("short_circuit_current", short_circuit_current)
67
+ _check_positive("delta_t", delta_t)
68
+ return cls(
69
+ seebeck=open_circuit_voltage / delta_t,
70
+ resistance=open_circuit_voltage / short_circuit_current,
71
+ thermal_conductance=thermal_conductance,
72
+ name=name,
73
+ )
74
+
75
+ @classmethod
76
+ def from_datasheet(
77
+ cls,
78
+ matched_power: float,
79
+ matched_voltage: float,
80
+ delta_t: float,
81
+ thermal_conductance: float,
82
+ name: str = "",
83
+ ) -> "TEGModule":
84
+ """Build a module from the matched-load point most datasheets list.
85
+
86
+ At matched load the load voltage is half the open-circuit voltage and
87
+ ``P = Voc**2 / (4 R)``.
88
+ """
89
+ _check_positive("matched_power", matched_power)
90
+ _check_positive("matched_voltage", matched_voltage)
91
+ _check_positive("delta_t", delta_t)
92
+ voc = 2.0 * matched_voltage
93
+ return cls(
94
+ seebeck=voc / delta_t,
95
+ resistance=voc**2 / (4.0 * matched_power),
96
+ thermal_conductance=thermal_conductance,
97
+ name=name,
98
+ )
99
+
100
+ @classmethod
101
+ def from_tec_datasheet(
102
+ cls,
103
+ i_max: float,
104
+ v_max: float,
105
+ delta_t_max: float,
106
+ t_hot: float,
107
+ name: str = "",
108
+ ) -> "TEGModule":
109
+ """Build a module from the four numbers every Peltier (TEC) datasheet
110
+ lists: Imax (A), Vmax (V) and dTmax (K) at hot-side temperature
111
+ ``t_hot`` (kelvin).
112
+
113
+ Uses the standard inversion of the constant-property model::
114
+
115
+ S = Vmax / Th
116
+ R = (Vmax / Imax) * (Th - dTmax) / Th
117
+ K = Imax * Vmax * (Th - dTmax) / (2 * Th * dTmax)
118
+ """
119
+ for label, value in (("i_max", i_max), ("v_max", v_max), ("delta_t_max", delta_t_max), ("t_hot", t_hot)):
120
+ _check_positive(label, value)
121
+ if delta_t_max >= t_hot:
122
+ raise ValueError("delta_t_max must be smaller than t_hot")
123
+ t_cold = t_hot - delta_t_max
124
+ return cls(
125
+ seebeck=v_max / t_hot,
126
+ resistance=(v_max / i_max) * t_cold / t_hot,
127
+ thermal_conductance=i_max * v_max * t_cold / (2.0 * t_hot * delta_t_max),
128
+ name=name,
129
+ )
130
+
131
+ # ------------------------------------------------------------------ #
132
+ # Electrical behaviour
133
+ # ------------------------------------------------------------------ #
134
+ def open_circuit_voltage(self, delta_t: float) -> float:
135
+ """Open-circuit voltage (V) for a face-to-face difference ``delta_t`` (K)."""
136
+ return self.seebeck * delta_t
137
+
138
+ def current(self, delta_t: float, load_resistance: float) -> float:
139
+ """Current (A) into a resistive load (ohm)."""
140
+ if load_resistance < 0:
141
+ raise ValueError("load_resistance must be >= 0")
142
+ return self.open_circuit_voltage(delta_t) / (self.resistance + load_resistance)
143
+
144
+ def load_voltage(self, delta_t: float, load_resistance: float) -> float:
145
+ """Voltage (V) across a resistive load."""
146
+ return self.current(delta_t, load_resistance) * load_resistance
147
+
148
+ def power(self, delta_t: float, load_resistance: float) -> float:
149
+ """Power (W) delivered to a resistive load."""
150
+ i = self.current(delta_t, load_resistance)
151
+ return i * i * load_resistance
152
+
153
+ def max_power(self, delta_t: float) -> float:
154
+ """Maximum power (W), reached when the load equals the internal resistance."""
155
+ voc = self.open_circuit_voltage(delta_t)
156
+ return voc * voc / (4.0 * self.resistance)
157
+
158
+ # ------------------------------------------------------------------ #
159
+ # Thermal behaviour and efficiency
160
+ # ------------------------------------------------------------------ #
161
+ def heat_in(self, t_hot: float, t_cold: float, load_resistance: float) -> float:
162
+ """Heat (W) absorbed at the hot face, including Peltier and Joule terms.
163
+
164
+ ``Qh = S*I*Th + K*dT - I**2*R/2`` with temperatures in kelvin.
165
+ """
166
+ _check_positive("t_hot", t_hot)
167
+ dt = t_hot - t_cold
168
+ i = self.current(dt, load_resistance)
169
+ return self.seebeck * i * t_hot + self.thermal_conductance * dt - 0.5 * i * i * self.resistance
170
+
171
+ def efficiency(self, t_hot: float, t_cold: float, load_resistance: float) -> float:
172
+ """Conversion efficiency P / Qh (0..1). Temperatures in kelvin."""
173
+ dt = t_hot - t_cold
174
+ q = self.heat_in(t_hot, t_cold, load_resistance)
175
+ return self.power(dt, load_resistance) / q if q > 0 else 0.0
176
+
177
+ def figure_of_merit(self) -> float:
178
+ """Device figure of merit Z = S**2 / (R*K) in 1/K."""
179
+ return self.seebeck**2 / (self.resistance * self.thermal_conductance)
180
+
181
+ def zt(self, t_hot: float, t_cold: float) -> float:
182
+ """Dimensionless ZT evaluated at the mean temperature (kelvin)."""
183
+ return self.figure_of_merit() * (t_hot + t_cold) / 2.0
184
+
185
+ def max_efficiency(self, t_hot: float, t_cold: float) -> float:
186
+ """Ideal maximum efficiency for this module's ZT (kelvin inputs).
187
+
188
+ ``eta = (dT/Th) * (sqrt(1+ZT) - 1) / (sqrt(1+ZT) + Tc/Th)``
189
+ """
190
+ _check_positive("t_hot", t_hot)
191
+ _check_positive("t_cold", t_cold)
192
+ if t_hot <= t_cold:
193
+ return 0.0
194
+ m = math.sqrt(1.0 + self.zt(t_hot, t_cold))
195
+ return (t_hot - t_cold) / t_hot * (m - 1.0) / (m + t_cold / t_hot)
196
+
197
+ def optimal_efficiency_load(self, t_hot: float, t_cold: float) -> float:
198
+ """Load resistance (ohm) that maximises efficiency: R * sqrt(1+ZT)."""
199
+ return self.resistance * math.sqrt(1.0 + self.zt(t_hot, t_cold))
200
+
201
+ # ------------------------------------------------------------------ #
202
+ # Thermal contact
203
+ # ------------------------------------------------------------------ #
204
+ def module_delta_t(
205
+ self,
206
+ source_delta_t: float,
207
+ hot_side_resistance: float = 0.0,
208
+ cold_side_resistance: float = 0.0,
209
+ ) -> float:
210
+ """Temperature difference (K) that actually appears across the module.
211
+
212
+ Treats the hot-side and cold-side thermal resistances (K/W, e.g. heat
213
+ exchanger plus interface material) as a series divider with the
214
+ module's own thermal resistance ``1/K``. Peltier and Joule effects are
215
+ neglected, so this is the open-circuit estimate.
216
+ """
217
+ if hot_side_resistance < 0 or cold_side_resistance < 0:
218
+ raise ValueError("thermal resistances must be >= 0")
219
+ r_module = 1.0 / self.thermal_conductance
220
+ return source_delta_t * r_module / (r_module + hot_side_resistance + cold_side_resistance)
tegkit/peltier.py ADDED
@@ -0,0 +1,84 @@
1
+ """Running a module the other way round: as a Peltier cooler (TEC).
2
+
3
+ Same constant-property model as :class:`tegkit.TEGModule`. All temperatures in
4
+ kelvin; ``t_cold`` is the side being cooled.
5
+ """
6
+
7
+ from __future__ import annotations
8
+
9
+ import math
10
+
11
+ from .module import TEGModule
12
+
13
+ __all__ = [
14
+ "cooling_power",
15
+ "input_power",
16
+ "cop",
17
+ "max_cooling_current",
18
+ "max_cooling_power",
19
+ "max_delta_t",
20
+ "max_delta_t_at_hot",
21
+ "optimal_cop_current",
22
+ "max_cop",
23
+ ]
24
+
25
+
26
+ def cooling_power(m: TEGModule, current: float, t_hot: float, t_cold: float) -> float:
27
+ """Heat pumped from the cold side (W): ``S*I*Tc - I**2*R/2 - K*dT``."""
28
+ dt = t_hot - t_cold
29
+ return m.seebeck * current * t_cold - 0.5 * current**2 * m.resistance - m.thermal_conductance * dt
30
+
31
+
32
+ def input_power(m: TEGModule, current: float, t_hot: float, t_cold: float) -> float:
33
+ """Electrical power the module draws (W): ``S*I*dT + I**2*R``."""
34
+ return m.seebeck * current * (t_hot - t_cold) + current**2 * m.resistance
35
+
36
+
37
+ def cop(m: TEGModule, current: float, t_hot: float, t_cold: float) -> float:
38
+ """Coefficient of performance Qc / P_in (0 if nothing is drawn)."""
39
+ p = input_power(m, current, t_hot, t_cold)
40
+ return cooling_power(m, current, t_hot, t_cold) / p if p > 0 else 0.0
41
+
42
+
43
+ def max_cooling_current(m: TEGModule, t_cold: float) -> float:
44
+ """Current that maximises cooling power (A): ``S*Tc/R``."""
45
+ return m.seebeck * t_cold / m.resistance
46
+
47
+
48
+ def max_cooling_power(m: TEGModule, t_hot: float, t_cold: float) -> float:
49
+ """Largest heat the module can pump at this dT (W)."""
50
+ return cooling_power(m, max_cooling_current(m, t_cold), t_hot, t_cold)
51
+
52
+
53
+ def max_delta_t(m: TEGModule, t_cold: float) -> float:
54
+ """Largest dT reachable with no heat load (K): ``Z*Tc**2/2``."""
55
+ return 0.5 * m.figure_of_merit() * t_cold**2
56
+
57
+
58
+ def max_delta_t_at_hot(m: TEGModule, t_hot: float) -> float:
59
+ """Largest dT with no heat load when the *hot* side is held at ``t_hot``
60
+ (how datasheets quote dTmax). Solves ``Th - Tc = Z*Tc**2/2`` for Tc."""
61
+ z = m.figure_of_merit()
62
+ t_cold = (math.sqrt(1.0 + 2.0 * z * t_hot) - 1.0) / z
63
+ return t_hot - t_cold
64
+
65
+
66
+ def _root(m: TEGModule, t_hot: float, t_cold: float) -> float:
67
+ return math.sqrt(1.0 + m.zt(t_hot, t_cold))
68
+
69
+
70
+ def optimal_cop_current(m: TEGModule, t_hot: float, t_cold: float) -> float:
71
+ """Current that maximises COP (A): ``S*dT / (R*(sqrt(1+ZTm) - 1))``."""
72
+ dt = t_hot - t_cold
73
+ if dt <= 0:
74
+ raise ValueError("t_hot must be greater than t_cold")
75
+ return m.seebeck * dt / (m.resistance * (_root(m, t_hot, t_cold) - 1.0))
76
+
77
+
78
+ def max_cop(m: TEGModule, t_hot: float, t_cold: float) -> float:
79
+ """Ideal maximum COP: ``(Tc/dT) * (sqrt(1+ZTm) - Th/Tc) / (sqrt(1+ZTm) + 1)``."""
80
+ dt = t_hot - t_cold
81
+ if dt <= 0:
82
+ raise ValueError("t_hot must be greater than t_cold")
83
+ r = _root(m, t_hot, t_cold)
84
+ return (t_cold / dt) * (r - t_hot / t_cold) / (r + 1.0)
tegkit/presets.py ADDED
@@ -0,0 +1,115 @@
1
+ """Ready-made modules built from public manufacturer datasheets.
2
+
3
+ Each preset keeps the raw datasheet numbers it was derived from, so anyone can
4
+ check the conversion. Real parts vary (datasheets typically quote about
5
+ +-10%), and the constant-property model is a first-pass approximation.
6
+
7
+ Known bias for TEC presets: deriving S, R, K from Imax/Vmax/dTmax reproduces
8
+ dTmax exactly but gives Qmax about 15-20% high and R about 10% low compared
9
+ with the datasheet, because the model ignores contact resistance and Thomson
10
+ heat. ``tests/test_presets.py`` pins this range.
11
+
12
+ >>> from tegkit import presets
13
+ >>> m = presets.get("TEC1-12706")
14
+ >>> presets.names()
15
+ """
16
+
17
+ from __future__ import annotations
18
+
19
+ from dataclasses import dataclass, field
20
+
21
+ from .module import TEGModule
22
+ from .units import c_to_k
23
+
24
+ __all__ = ["Preset", "get", "info", "names"]
25
+
26
+
27
+ @dataclass(frozen=True)
28
+ class Preset:
29
+ name: str
30
+ kind: str # "TEC" (Peltier cooler) or "TEG" (generator)
31
+ manufacturer: str
32
+ source: str
33
+ conditions: str
34
+ datasheet: dict = field(default_factory=dict)
35
+ module: TEGModule | None = None
36
+
37
+
38
+ def _tec(name, manufacturer, source, i_max, v_max, dt_max, th_c, extra=None):
39
+ data = {"Imax_A": i_max, "Vmax_V": v_max, "dTmax_K": dt_max, "Th_C": th_c, **(extra or {})}
40
+ m = TEGModule.from_tec_datasheet(i_max, v_max, dt_max, c_to_k(th_c), name=name)
41
+ return Preset(name, "TEC", manufacturer, source, f"Th = {th_c} C", data, m)
42
+
43
+
44
+ def _teg_marlow_tg12_4() -> Preset:
45
+ # Datasheet row: Th = 230 C, Tc = 50 C
46
+ voc, i_sc, r_th = 9.45, 1.71, 2.21
47
+ dt = 230 - 50
48
+ m = TEGModule(seebeck=voc / dt, resistance=voc / i_sc, thermal_conductance=1.0 / r_th, name="TG12-4")
49
+ return Preset(
50
+ "TG12-4",
51
+ "TEG",
52
+ "Marlow Industries (Coherent)",
53
+ "https://www.coherent.com/resources/datasheet/materials/single-stage-thermoelectric-generator-tg12-4-ds.pdf",
54
+ "Th = 230 C, Tc = 50 C",
55
+ {"Voc_V": voc, "Isc_A": i_sc, "Rth_K_per_W": r_th, "P_opt_W": 4.05, "R_load_opt_eta_ohm": 6.83,
56
+ "Th_C": 230, "Tc_C": 50},
57
+ m,
58
+ )
59
+
60
+
61
+ def _teg_tecteg_teg2_126ldt() -> Preset:
62
+ # Datasheet: Th = 200 C, Tc = 30 C; matched-load point plus heat flow.
63
+ voc, r_match, q_h = 8.6, 6.0, 52.0
64
+ th, tc = c_to_k(200), c_to_k(30)
65
+ dt = th - tc
66
+ s = voc / dt
67
+ i = voc / (2 * r_match)
68
+ # Qh = S*I*Th + K*dT - I^2*R/2 -> solve for K
69
+ k = (q_h - s * i * th + 0.5 * i * i * r_match) / dt
70
+ m = TEGModule(seebeck=s, resistance=r_match, thermal_conductance=k, name="TEG2-126LDT")
71
+ return Preset(
72
+ "TEG2-126LDT",
73
+ "TEG",
74
+ "TECTEG MFR",
75
+ "https://thermoelectric-generator.com/wp-content/uploads/2026/05/TEG2-126LDT-Spec.-sheet.1.1.pdf",
76
+ "Th = 200 C, Tc = 30 C",
77
+ {"Voc_V": voc, "R_matched_ohm": r_match, "V_matched_V": 4.3, "I_matched_A": 0.7, "P_matched_W": 3.0,
78
+ "Qh_W": q_h, "Th_C": 200, "Tc_C": 30},
79
+ m,
80
+ )
81
+
82
+
83
+ _PRESETS: dict[str, Preset] = {
84
+ p.name: p
85
+ for p in (
86
+ _tec("TEC1-12706", "HB Corporation (Hebei I.T.)", "https://digsys.upc.edu/csd/DEE/chamber/TEC1-12706.pdf",
87
+ 6.4, 14.4, 66, 25, {"Qmax_W": 50, "R_ohm": 1.98}),
88
+ _tec("TEC-40-36-127", "Wakefield Thermal",
89
+ "https://wakefieldthermal.com/content/data_sheets/December2025/ThermoElectricCoolersCatalog.pdf",
90
+ 6.0, 15.4, 68, 27, {"Qmax_W": 51.4, "R_ohm": 2.17}),
91
+ _tec("TEC-30-36-71", "Wakefield Thermal",
92
+ "https://wakefieldthermal.com/content/data_sheets/December2025/ThermoElectricCoolersCatalog.pdf",
93
+ 6.0, 8.6, 68, 27, {"Qmax_W": 28.7, "R_ohm": 1.24}),
94
+ _teg_marlow_tg12_4(),
95
+ _teg_tecteg_teg2_126ldt(),
96
+ )
97
+ }
98
+
99
+
100
+ def names() -> list[str]:
101
+ """All preset names."""
102
+ return sorted(_PRESETS)
103
+
104
+
105
+ def info(name: str) -> Preset:
106
+ """Full preset record: source URL, test conditions and raw datasheet values."""
107
+ try:
108
+ return _PRESETS[name]
109
+ except KeyError:
110
+ raise KeyError(f"unknown preset {name!r}; choose from {names()}") from None
111
+
112
+
113
+ def get(name: str) -> TEGModule:
114
+ """The :class:`TEGModule` for a preset."""
115
+ return info(name).module
tegkit/sizing.py ADDED
@@ -0,0 +1,59 @@
1
+ """Quick sizing helpers: how many modules, and how good a heat sink."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import math
6
+
7
+ from .array import TEGArray
8
+ from .module import TEGModule
9
+
10
+ __all__ = ["modules_for_power", "suggest_array", "required_cold_side_resistance"]
11
+
12
+
13
+ def modules_for_power(m: TEGModule, delta_t: float, target_power: float) -> int:
14
+ """Smallest number of identical modules whose matched-load power reaches
15
+ ``target_power`` (W) at module temperature difference ``delta_t`` (K)."""
16
+ if target_power <= 0:
17
+ raise ValueError("target_power must be positive")
18
+ p = m.max_power(delta_t)
19
+ if p <= 0:
20
+ raise ValueError("module produces no power at this delta_t")
21
+ return max(1, math.ceil(target_power / p - 1e-12))
22
+
23
+
24
+ def suggest_array(
25
+ m: TEGModule, delta_t: float, target_power: float, target_voltage: float
26
+ ) -> TEGArray:
27
+ """Series/parallel layout that meets both a power and a matched-load
28
+ voltage target. Modules in series set the voltage (Voc/2 each at matched
29
+ load); parallel strings make up the remaining power."""
30
+ if target_voltage <= 0:
31
+ raise ValueError("target_voltage must be positive")
32
+ v_each = m.open_circuit_voltage(delta_t) / 2.0
33
+ if v_each <= 0:
34
+ raise ValueError("module produces no voltage at this delta_t")
35
+ series = max(1, math.ceil(target_voltage / v_each - 1e-12))
36
+ total = max(series, modules_for_power(m, delta_t, target_power))
37
+ parallel = math.ceil(total / series)
38
+ return TEGArray(m, series=series, parallel=parallel)
39
+
40
+
41
+ def required_cold_side_resistance(
42
+ m: TEGModule,
43
+ source_delta_t: float,
44
+ target_module_delta_t: float,
45
+ hot_side_resistance: float = 0.0,
46
+ ) -> float:
47
+ """Largest cold-side thermal resistance (K/W, heat sink plus interface)
48
+ that still leaves ``target_module_delta_t`` across the module.
49
+
50
+ Inverts :meth:`TEGModule.module_delta_t`. Raises ``ValueError`` if the
51
+ target can't be reached even with a perfect heat sink.
52
+ """
53
+ if not 0 < target_module_delta_t <= source_delta_t:
54
+ raise ValueError("target_module_delta_t must be in (0, source_delta_t]")
55
+ r_module = 1.0 / m.thermal_conductance
56
+ r_cold = r_module * source_delta_t / target_module_delta_t - r_module - hot_side_resistance
57
+ if r_cold < 0:
58
+ raise ValueError("target is unreachable with this hot-side resistance")
59
+ return r_cold
tegkit/units.py ADDED
@@ -0,0 +1,13 @@
1
+ """Tiny unit helpers."""
2
+
3
+ ZERO_C_IN_K = 273.15
4
+
5
+
6
+ def c_to_k(celsius: float) -> float:
7
+ """Degrees Celsius to kelvin."""
8
+ return celsius + ZERO_C_IN_K
9
+
10
+
11
+ def k_to_c(kelvin: float) -> float:
12
+ """Kelvin to degrees Celsius."""
13
+ return kelvin - ZERO_C_IN_K
@@ -0,0 +1,108 @@
1
+ Metadata-Version: 2.5
2
+ Name: tegkit
3
+ Version: 0.3.0
4
+ Summary: Small, dependency-free toolkit for modelling thermoelectric generators (TEGs)
5
+ Project-URL: Homepage, https://github.com/aysel-elsh/tegkit
6
+ Project-URL: Issues, https://github.com/aysel-elsh/tegkit/issues
7
+ Author: Aysel Elshenawy
8
+ License-Expression: MIT
9
+ License-File: LICENSE
10
+ Keywords: TEG,energy harvesting,peltier,seebeck,thermoelectric,waste heat
11
+ Classifier: Intended Audience :: Education
12
+ Classifier: Intended Audience :: Science/Research
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Topic :: Scientific/Engineering :: Electronic Design Automation (EDA)
15
+ Classifier: Topic :: Scientific/Engineering :: Physics
16
+ Requires-Python: >=3.10
17
+ Provides-Extra: dev
18
+ Requires-Dist: pytest>=7; extra == 'dev'
19
+ Description-Content-Type: text/markdown
20
+
21
+ # tegkit
22
+
23
+ Small, dependency-free Python toolkit for modelling **thermoelectric generators (TEGs)**: the little ceramic modules that turn a temperature difference into electricity.
24
+
25
+ Use it to answer the usual first questions fast:
26
+ - How much power will this module give me at this ΔT?
27
+ - What load should I use: max power or max efficiency?
28
+ - How much ΔT do I actually lose to my heat sinks?
29
+ - What do 4 in series × 2 in parallel give me?
30
+
31
+ ```bash
32
+ pip install tegkit # once published; for now: pip install git+https://github.com/aysel-elsh/tegkit
33
+ ```
34
+
35
+ ## Quick start
36
+
37
+ ```python
38
+ from tegkit import TEGModule, TEGArray, c_to_k
39
+
40
+ # From the matched-load point on a datasheet
41
+ m = TEGModule.from_datasheet(matched_power=2.5, matched_voltage=2.1,
42
+ delta_t=80, thermal_conductance=0.45)
43
+
44
+ dt = m.module_delta_t(source_delta_t=60, hot_side_resistance=0.3, cold_side_resistance=0.5)
45
+ arr = TEGArray(m, series=4, parallel=2)
46
+
47
+ print(arr.max_power(dt), "W at", arr.matched_load(), "ohm")
48
+ print(m.max_efficiency(c_to_k(85), c_to_k(25)))
49
+ ```
50
+
51
+ Or straight from a bench test: `TEGModule.from_measurements(voc, isc, delta_t, thermal_conductance)`.
52
+
53
+ ## What's inside
54
+
55
+ | Function | What it gives you |
56
+ |---|---|
57
+ | `open_circuit_voltage`, `current`, `load_voltage`, `power` | Electrical behaviour into a resistive load |
58
+ | `max_power` | Matched-load power, `Voc² / 4R` |
59
+ | `heat_in`, `efficiency` | Hot-side heat flow (Fourier + Peltier + Joule) and P/Qh |
60
+ | `figure_of_merit`, `zt`, `max_efficiency`, `optimal_efficiency_load` | Z, ZT and the ideal efficiency limit |
61
+ | `module_delta_t` | ΔT left after heat-sink / interface thermal resistances |
62
+ | `TEGArray` | Series/parallel arrays of identical modules |
63
+ | `iv_curve`, `max_power_point` | I-V / power sweep and the maximum power point |
64
+ | `modules_for_power`, `suggest_array` | How many modules, and in what series/parallel layout |
65
+ | `required_cold_side_resistance` | How good your heat sink must be to keep a target ΔT |
66
+ | `tegkit.peltier` | Cooler mode: cooling power, COP, max ΔT, optimal current |
67
+
68
+ ## Real-module presets
69
+
70
+ ```python
71
+ from tegkit import presets
72
+ presets.names() # ['TEC-30-36-71', 'TEC-40-36-127', 'TEC1-12706', 'TEG2-126LDT', 'TG12-4']
73
+ m = presets.get("TG12-4")
74
+ presets.info("TG12-4").source # datasheet URL + the raw numbers used
75
+ ```
76
+
77
+ Every preset is derived from a public datasheet, and the tests check it reproduces that datasheet's own numbers. Or build your own from any Peltier datasheet with `TEGModule.from_tec_datasheet(i_max, v_max, delta_t_max, t_hot)`.
78
+
79
+ **Adding a preset is a great first PR**: cite the datasheet and add a test.
80
+
81
+ ## Command line
82
+
83
+ ```bash
84
+ tegkit --seebeck 0.05 --resistance 2 --conductance 0.5 --dt 40 --series 4 --parallel 2 --points 5
85
+ ```
86
+
87
+ prints open-circuit voltage, matched load, max power and an I-V table.
88
+
89
+ ## Model and limits
90
+
91
+ Constant-property, lumped model (S, R, K don't change with temperature). It's the standard first-pass model from the thermoelectrics literature, good for sizing and teaching and not a replacement for FEM or measured curves. Contributions that add temperature-dependent properties are very welcome.
92
+
93
+ ## Run the tests
94
+
95
+ ```bash
96
+ pip install -e '.[dev]'
97
+ pytest
98
+ ```
99
+
100
+ ## Contributing
101
+
102
+ New here? Look for issues labelled **good first issue**, and read [CONTRIBUTING.md](CONTRIBUTING.md). Physics corrections, real datasheet presets and examples are all great first PRs.
103
+
104
+ ## License
105
+
106
+ MIT. See [LICENSE](LICENSE).
107
+
108
+ Made by [Aysel Elshenawy](https://github.com/aysel-elsh), EE student at FAU.
@@ -0,0 +1,14 @@
1
+ tegkit/__init__.py,sha256=vi34F1gr2gM5mYVobCVBCebbOdR3YGndgRBUJCGihj4,628
2
+ tegkit/__main__.py,sha256=XbcZjAKm_yGRxUtinedtlOPTrh0Dw2wt6zFug2jEat8,2220
3
+ tegkit/array.py,sha256=WcHx87kwDRjR7bgvnXgLrgb1pmdSNGvcNP8h_63NbzE,1586
4
+ tegkit/curves.py,sha256=UCufxoaygSLw5IZCI4W7l6gQelM_K1yB5h2HjUa_lms,1717
5
+ tegkit/module.py,sha256=HgLeBa92cjkuXr9E2kZbjsYCnppbbLmuY64BS2hckUk,8697
6
+ tegkit/peltier.py,sha256=zVf5J0fnn6uhPPACDjZUW7H8T-fGv8Q17NVYQ5yXirM,2963
7
+ tegkit/presets.py,sha256=GscfHu8UFJoAiEngAxqpWIZa_kyc0IBArAZd34R4tGU,4155
8
+ tegkit/sizing.py,sha256=Skmh3dKsvRJXUmdj95iWNSMB9Qq6iDScZLZt33wpdYQ,2382
9
+ tegkit/units.py,sha256=8Bpp1ktOJbMJDsXHKuK9mfbLjbBlQkJVJn_ilkPnaoU,263
10
+ tegkit-0.3.0.dist-info/METADATA,sha256=exXvTofgv5bPJ2ob8GD7mAn6qLptOZCsHXsob4Fx28k,4356
11
+ tegkit-0.3.0.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
12
+ tegkit-0.3.0.dist-info/entry_points.txt,sha256=MfUuiOuv5B_TKG7nEQ3Gsa5Nq-MarShcGSJqMdzbiAc,48
13
+ tegkit-0.3.0.dist-info/licenses/LICENSE,sha256=emQf0qaGKNXI6eObeoDj2kNlKWk-TYY6TkHMZNqXRuw,1072
14
+ tegkit-0.3.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.33.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ tegkit = tegkit.__main__:main
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Aysel Elshenawy
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.