tegkit 0.3.0__tar.gz
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-0.3.0/.github/ISSUE_TEMPLATE/bug_report.md +14 -0
- tegkit-0.3.0/.github/workflows/publish.yml +23 -0
- tegkit-0.3.0/.github/workflows/tests.yml +20 -0
- tegkit-0.3.0/.gitignore +6 -0
- tegkit-0.3.0/CHANGELOG.md +19 -0
- tegkit-0.3.0/CODE_OF_CONDUCT.md +7 -0
- tegkit-0.3.0/CONTRIBUTING.md +32 -0
- tegkit-0.3.0/LICENSE +21 -0
- tegkit-0.3.0/PKG-INFO +108 -0
- tegkit-0.3.0/README.md +88 -0
- tegkit-0.3.0/examples/peltier_cooler.py +16 -0
- tegkit-0.3.0/examples/quickstart.py +24 -0
- tegkit-0.3.0/pyproject.toml +35 -0
- tegkit-0.3.0/src/tegkit/__init__.py +24 -0
- tegkit-0.3.0/src/tegkit/__main__.py +51 -0
- tegkit-0.3.0/src/tegkit/array.py +51 -0
- tegkit-0.3.0/src/tegkit/curves.py +54 -0
- tegkit-0.3.0/src/tegkit/module.py +220 -0
- tegkit-0.3.0/src/tegkit/peltier.py +84 -0
- tegkit-0.3.0/src/tegkit/presets.py +115 -0
- tegkit-0.3.0/src/tegkit/sizing.py +59 -0
- tegkit-0.3.0/src/tegkit/units.py +13 -0
- tegkit-0.3.0/tests/test_module.py +102 -0
- tegkit-0.3.0/tests/test_presets.py +56 -0
- tegkit-0.3.0/tests/test_v02.py +125 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Bug report
|
|
3
|
+
about: Something gives a wrong number or crashes
|
|
4
|
+
labels: bug
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
**What did you run?**
|
|
8
|
+
|
|
9
|
+
```python
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
**What did you expect, and what did you get?**
|
|
13
|
+
|
|
14
|
+
**Source for the expected value** (datasheet, paper, hand calculation):
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
name: publish
|
|
2
|
+
|
|
3
|
+
# Publishes to PyPI when a GitHub release is published.
|
|
4
|
+
# One-time setup: on pypi.org add a "trusted publisher" for
|
|
5
|
+
# owner aysel-elsh, repo tegkit, workflow publish.yml, environment pypi.
|
|
6
|
+
|
|
7
|
+
on:
|
|
8
|
+
release:
|
|
9
|
+
types: [published]
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
pypi:
|
|
13
|
+
runs-on: ubuntu-latest
|
|
14
|
+
environment: pypi
|
|
15
|
+
permissions:
|
|
16
|
+
id-token: write
|
|
17
|
+
steps:
|
|
18
|
+
- uses: actions/checkout@v4
|
|
19
|
+
- uses: actions/setup-python@v5
|
|
20
|
+
with:
|
|
21
|
+
python-version: "3.12"
|
|
22
|
+
- run: pip install build && python -m build
|
|
23
|
+
- uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
name: tests
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
pull_request:
|
|
6
|
+
|
|
7
|
+
jobs:
|
|
8
|
+
test:
|
|
9
|
+
runs-on: ubuntu-latest
|
|
10
|
+
strategy:
|
|
11
|
+
fail-fast: false
|
|
12
|
+
matrix:
|
|
13
|
+
python-version: ["3.10", "3.12", "3.13"]
|
|
14
|
+
steps:
|
|
15
|
+
- uses: actions/checkout@v4
|
|
16
|
+
- uses: actions/setup-python@v5
|
|
17
|
+
with:
|
|
18
|
+
python-version: ${{ matrix.python-version }}
|
|
19
|
+
- run: pip install -e '.[dev]'
|
|
20
|
+
- run: pytest -q
|
tegkit-0.3.0/.gitignore
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.3.0 (2026-11-22)
|
|
4
|
+
|
|
5
|
+
- **Presets** from public datasheets: TEC1-12706, Wakefield TEC-40-36-127 and TEC-30-36-71, Marlow TG12-4, and TECTEG TEG2-126LDT. Each one stores its source URL and raw values, and is tested against them.
|
|
6
|
+
- `TEGModule.from_tec_datasheet(i_max, v_max, delta_t_max, t_hot)`.
|
|
7
|
+
- Documented the model's known bias on TEC datasheets (Qmax about 15-20% high, R about 10% low).
|
|
8
|
+
|
|
9
|
+
## 0.2.0 (2026-11-22)
|
|
10
|
+
|
|
11
|
+
- **Curves:** `iv_curve` and `max_power_point` for modules and arrays.
|
|
12
|
+
- **Peltier mode:** new `tegkit.peltier` module covering cooling power, input power, COP, max cooling current/power, max ΔT (cold- or hot-side referenced), and optimal-COP current.
|
|
13
|
+
- **Sizing:** `modules_for_power`, `suggest_array` and `required_cold_side_resistance`.
|
|
14
|
+
- **Command line:** `tegkit --seebeck ... --dt ...` (or `python -m tegkit`).
|
|
15
|
+
- Requires Python 3.10+.
|
|
16
|
+
|
|
17
|
+
## 0.1.0 (2026-11-22)
|
|
18
|
+
|
|
19
|
+
- First release: `TEGModule` (power, efficiency, ZT, contact-resistance divider), `TEGArray`, unit helpers.
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# Code of Conduct
|
|
2
|
+
|
|
3
|
+
This project follows the [Contributor Covenant, version 2.1](https://www.contributor-covenant.org/version/2/1/code_of_conduct/).
|
|
4
|
+
|
|
5
|
+
In short: be respectful, assume good intent, and help newcomers. Harassment of any kind isn't tolerated.
|
|
6
|
+
|
|
7
|
+
Report problems to the maintainer through GitHub (open a private security advisory, or message @aysel-elsh).
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# Contributing to tegkit
|
|
2
|
+
|
|
3
|
+
Thanks for helping! Students, hobbyists and researchers are all welcome.
|
|
4
|
+
|
|
5
|
+
## Getting set up
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
git clone https://github.com/<you>/tegkit
|
|
9
|
+
cd tegkit
|
|
10
|
+
pip install -e '.[dev]'
|
|
11
|
+
pytest
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Making a change
|
|
15
|
+
|
|
16
|
+
1. Pick an issue (or open one first for bigger ideas) and comment that you're on it.
|
|
17
|
+
2. Create a branch, make your change, and add or update a test in `tests/`.
|
|
18
|
+
3. Run `pytest`. Everything should pass.
|
|
19
|
+
4. Open a pull request that says what changed and why. Cite a source for any physics.
|
|
20
|
+
|
|
21
|
+
## Good first contributions
|
|
22
|
+
|
|
23
|
+
- Add a preset for a real module from its public datasheet
|
|
24
|
+
- Add an example or notebook
|
|
25
|
+
- Improve docstrings, or fix a unit or typo
|
|
26
|
+
- Add input validation for an edge case
|
|
27
|
+
|
|
28
|
+
## Ground rules
|
|
29
|
+
|
|
30
|
+
- Keep the core dependency-free (standard library only).
|
|
31
|
+
- SI units everywhere: V, A, ohm, W, K, W/K, K/W.
|
|
32
|
+
- Be kind. See [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md).
|
tegkit-0.3.0/LICENSE
ADDED
|
@@ -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.
|
tegkit-0.3.0/PKG-INFO
ADDED
|
@@ -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.
|
tegkit-0.3.0/README.md
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# tegkit
|
|
2
|
+
|
|
3
|
+
Small, dependency-free Python toolkit for modelling **thermoelectric generators (TEGs)**: the little ceramic modules that turn a temperature difference into electricity.
|
|
4
|
+
|
|
5
|
+
Use it to answer the usual first questions fast:
|
|
6
|
+
- How much power will this module give me at this ΔT?
|
|
7
|
+
- What load should I use: max power or max efficiency?
|
|
8
|
+
- How much ΔT do I actually lose to my heat sinks?
|
|
9
|
+
- What do 4 in series × 2 in parallel give me?
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
pip install tegkit # once published; for now: pip install git+https://github.com/aysel-elsh/tegkit
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Quick start
|
|
16
|
+
|
|
17
|
+
```python
|
|
18
|
+
from tegkit import TEGModule, TEGArray, c_to_k
|
|
19
|
+
|
|
20
|
+
# From the matched-load point on a datasheet
|
|
21
|
+
m = TEGModule.from_datasheet(matched_power=2.5, matched_voltage=2.1,
|
|
22
|
+
delta_t=80, thermal_conductance=0.45)
|
|
23
|
+
|
|
24
|
+
dt = m.module_delta_t(source_delta_t=60, hot_side_resistance=0.3, cold_side_resistance=0.5)
|
|
25
|
+
arr = TEGArray(m, series=4, parallel=2)
|
|
26
|
+
|
|
27
|
+
print(arr.max_power(dt), "W at", arr.matched_load(), "ohm")
|
|
28
|
+
print(m.max_efficiency(c_to_k(85), c_to_k(25)))
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Or straight from a bench test: `TEGModule.from_measurements(voc, isc, delta_t, thermal_conductance)`.
|
|
32
|
+
|
|
33
|
+
## What's inside
|
|
34
|
+
|
|
35
|
+
| Function | What it gives you |
|
|
36
|
+
|---|---|
|
|
37
|
+
| `open_circuit_voltage`, `current`, `load_voltage`, `power` | Electrical behaviour into a resistive load |
|
|
38
|
+
| `max_power` | Matched-load power, `Voc² / 4R` |
|
|
39
|
+
| `heat_in`, `efficiency` | Hot-side heat flow (Fourier + Peltier + Joule) and P/Qh |
|
|
40
|
+
| `figure_of_merit`, `zt`, `max_efficiency`, `optimal_efficiency_load` | Z, ZT and the ideal efficiency limit |
|
|
41
|
+
| `module_delta_t` | ΔT left after heat-sink / interface thermal resistances |
|
|
42
|
+
| `TEGArray` | Series/parallel arrays of identical modules |
|
|
43
|
+
| `iv_curve`, `max_power_point` | I-V / power sweep and the maximum power point |
|
|
44
|
+
| `modules_for_power`, `suggest_array` | How many modules, and in what series/parallel layout |
|
|
45
|
+
| `required_cold_side_resistance` | How good your heat sink must be to keep a target ΔT |
|
|
46
|
+
| `tegkit.peltier` | Cooler mode: cooling power, COP, max ΔT, optimal current |
|
|
47
|
+
|
|
48
|
+
## Real-module presets
|
|
49
|
+
|
|
50
|
+
```python
|
|
51
|
+
from tegkit import presets
|
|
52
|
+
presets.names() # ['TEC-30-36-71', 'TEC-40-36-127', 'TEC1-12706', 'TEG2-126LDT', 'TG12-4']
|
|
53
|
+
m = presets.get("TG12-4")
|
|
54
|
+
presets.info("TG12-4").source # datasheet URL + the raw numbers used
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
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)`.
|
|
58
|
+
|
|
59
|
+
**Adding a preset is a great first PR**: cite the datasheet and add a test.
|
|
60
|
+
|
|
61
|
+
## Command line
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
tegkit --seebeck 0.05 --resistance 2 --conductance 0.5 --dt 40 --series 4 --parallel 2 --points 5
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
prints open-circuit voltage, matched load, max power and an I-V table.
|
|
68
|
+
|
|
69
|
+
## Model and limits
|
|
70
|
+
|
|
71
|
+
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.
|
|
72
|
+
|
|
73
|
+
## Run the tests
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
pip install -e '.[dev]'
|
|
77
|
+
pytest
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## Contributing
|
|
81
|
+
|
|
82
|
+
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.
|
|
83
|
+
|
|
84
|
+
## License
|
|
85
|
+
|
|
86
|
+
MIT. See [LICENSE](LICENSE).
|
|
87
|
+
|
|
88
|
+
Made by [Aysel Elshenawy](https://github.com/aysel-elsh), EE student at FAU.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"""Use a module as a Peltier cooler: how cold can it get, and at what current?"""
|
|
2
|
+
|
|
3
|
+
from tegkit import TEGModule, c_to_k, peltier
|
|
4
|
+
|
|
5
|
+
# Generic 40 mm module (illustrative numbers, not a specific part)
|
|
6
|
+
m = TEGModule(seebeck=0.053, resistance=2.1, thermal_conductance=0.48, name="generic-40mm")
|
|
7
|
+
|
|
8
|
+
t_hot, t_cold = c_to_k(35), c_to_k(15)
|
|
9
|
+
|
|
10
|
+
print(f"Max dT, hot side at 35 C: {peltier.max_delta_t_at_hot(m, t_hot):.1f} K")
|
|
11
|
+
print(f"Max cooling at 20 K dT: {peltier.max_cooling_power(m, t_hot, t_cold):.2f} W "
|
|
12
|
+
f"at {peltier.max_cooling_current(m, t_cold):.2f} A")
|
|
13
|
+
|
|
14
|
+
i_opt = peltier.optimal_cop_current(m, t_hot, t_cold)
|
|
15
|
+
print(f"Best COP at 20 K dT: {peltier.max_cop(m, t_hot, t_cold):.2f} at {i_opt:.2f} A "
|
|
16
|
+
f"({peltier.cooling_power(m, i_opt, t_hot, t_cold):.2f} W pumped)")
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"""Size a small TEG array and print its power curve."""
|
|
2
|
+
|
|
3
|
+
from tegkit import TEGArray, TEGModule, c_to_k
|
|
4
|
+
|
|
5
|
+
# Matched-load point read off a generic 40 mm module datasheet:
|
|
6
|
+
# 2.5 W at 2.1 V with 80 K across the faces; ~0.45 W/K thermal conductance.
|
|
7
|
+
module = TEGModule.from_datasheet(
|
|
8
|
+
matched_power=2.5, matched_voltage=2.1, delta_t=80, thermal_conductance=0.45, name="generic-40mm"
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
# Only part of the source temperature difference reaches the module
|
|
12
|
+
# once heat-sink and interface resistances are included.
|
|
13
|
+
dt = module.module_delta_t(source_delta_t=60, hot_side_resistance=0.3, cold_side_resistance=0.5)
|
|
14
|
+
print(f"Module sees {dt:.1f} K of the 60 K available")
|
|
15
|
+
|
|
16
|
+
array = TEGArray(module, series=4, parallel=2)
|
|
17
|
+
r_match = array.matched_load()
|
|
18
|
+
print(f"Matched load: {r_match:.2f} ohm -> {array.max_power(dt):.2f} W")
|
|
19
|
+
|
|
20
|
+
for r in (0.5, 1, 2, 4, 8, 16):
|
|
21
|
+
print(f" R = {r:>4} ohm : {array.power(dt, r):6.2f} W")
|
|
22
|
+
|
|
23
|
+
th, tc = c_to_k(25 + dt), c_to_k(25)
|
|
24
|
+
print(f"Max efficiency of one module: {module.max_efficiency(th, tc) * 100:.2f} %")
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "tegkit"
|
|
7
|
+
version = "0.3.0"
|
|
8
|
+
description = "Small, dependency-free toolkit for modelling thermoelectric generators (TEGs)"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = "MIT"
|
|
11
|
+
license-files = ["LICENSE"]
|
|
12
|
+
authors = [{ name = "Aysel Elshenawy" }]
|
|
13
|
+
requires-python = ">=3.10"
|
|
14
|
+
keywords = ["thermoelectric", "TEG", "seebeck", "energy harvesting", "waste heat", "peltier"]
|
|
15
|
+
classifiers = [
|
|
16
|
+
"Programming Language :: Python :: 3",
|
|
17
|
+
"Intended Audience :: Science/Research",
|
|
18
|
+
"Intended Audience :: Education",
|
|
19
|
+
"Topic :: Scientific/Engineering :: Physics",
|
|
20
|
+
"Topic :: Scientific/Engineering :: Electronic Design Automation (EDA)",
|
|
21
|
+
]
|
|
22
|
+
dependencies = []
|
|
23
|
+
|
|
24
|
+
[project.optional-dependencies]
|
|
25
|
+
dev = ["pytest>=7"]
|
|
26
|
+
|
|
27
|
+
[project.scripts]
|
|
28
|
+
tegkit = "tegkit.__main__:main"
|
|
29
|
+
|
|
30
|
+
[project.urls]
|
|
31
|
+
Homepage = "https://github.com/aysel-elsh/tegkit"
|
|
32
|
+
Issues = "https://github.com/aysel-elsh/tegkit/issues"
|
|
33
|
+
|
|
34
|
+
[tool.pytest.ini_options]
|
|
35
|
+
testpaths = ["tests"]
|
|
@@ -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"
|
|
@@ -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())
|
|
@@ -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
|
|
@@ -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)
|