Composable neural emulators accelerate thermoelectric generator design.
Paper
Loaded from Europe PMC by your browser, not stored by OSCR: doi.org · Europe PMC
The paper is loaded when this pane is shown.
The authors' code
Python · 189 lines · 6.1 KB · Apache-2.0
- #!/usr/bin/env python
- # coding: utf-8
- import numpy as np
- import pandas as pd
- import os
- import torch
- import math
- import torch.nn as nn
- import torch.optim as optim
- import matplotlib.pyplot as plt
- from scipy.interpolate import interp1d
- from scipy.interpolate import CubicSpline
- from scipy.integrate import quad
- from torch.optim.lr_scheduler import StepLR, CosineAnnealingLR, ReduceLROnPlateau, MultiStepLR, ExponentialLR
- import seaborn as sns
- import pandas as pd
- from sklearn.model_selection import train_test_split
- from sklearn.metrics import mean_absolute_error, mean_squared_error, r2_score
- # ==================== Data load and process ====================
- def load_dataset_from_csv(csv_file):
- if not os.path.exists(csv_file):
- raise FileNotFoundError(f"CSV file {csv_file} not existed!")
- X_columns = ['a', 'b', 'c', 'Tc', 'Th', 'Ih']
- Y_columns = ['V', 'Q']
- df = pd.read_csv(csv_file)
- X_cached = df[X_columns].copy().values
- Y_cached = df[Y_columns].copy().values
- X_cached[:, 5] = np.log1p(X_cached[:, 5])
- Y_offset = np.zeros((1, Y_cached.shape[1]))
- for i in range(Y_cached.shape[1]):
- min_val = Y_cached[:, i].min()
- if min_val <= 0:
- Y_offset[0, i] = -min_val + 1e-3
- Y_cached[:, i] += Y_offset[0, i]
- Y_cached[:, i] = np.log1p(Y_cached[:, i])
- X_mean = X_cached.mean(axis=0, keepdims=True)
- X_std = X_cached.std(axis=0, keepdims=True)
- Y_mean = Y_cached.mean(axis=0, keepdims=True)
- Y_std = Y_cached.std(axis=0, keepdims=True)
- X_norm = (X_cached - X_mean) / X_std
- Y_norm = (Y_cached - Y_mean) / Y_std
- X_tensor = torch.tensor(X_norm, dtype=torch.float32)
- Y_tensor = torch.tensor(Y_norm, dtype=torch.float32)
- X_cached_tensor = torch.tensor(X_cached, dtype=torch.float32)
- stats = {
- 'X_mean': torch.tensor(X_mean, dtype=torch.float32),
- 'X_std': torch.tensor(X_std, dtype=torch.float32),
- 'Y_mean': torch.tensor(Y_mean, dtype=torch.float32),
- 'Y_std': torch.tensor(Y_std, dtype=torch.float32),
- 'Y_offset': torch.tensor(Y_offset, dtype=torch.float32)
- }
- print(f"Load success:{X_tensor.shape[0]} sample size in total")
- return X_tensor, Y_tensor, stats, X_cached_tensor
- # ==================== Loss function ====================
- def loss_fn(model, X_norm, Y_norm, stats, X_raw):
- Y_pred = model(X_norm)
- v_true, q_true = Y_norm[:, 0], Y_norm[:, 1]
- v_pred, q_pred = Y_pred[:, 0], Y_pred[:, 1]
- v_loss = ((v_pred - v_true) ** 2).mean()
- q_loss = ((q_pred - q_true) ** 2).mean()
- loss = v_loss + 5*q_loss
- return loss, v_loss.item(), q_loss.item()
- # ==================== TEGNet ====================
- class TEGNet(nn.Module):
- def __init__(self):
- super().__init__()
- self.net = nn.Sequential(
- nn.Linear(6, 128),
- nn.SiLU(),
- nn.Linear(128, 128),
- nn.SiLU(),
- nn.Linear(128, 128),
- nn.SiLU(),
- nn.Linear(128, 2)
- )
- def forward(self, x):
- return self.net(x)
- # ==================== Model training ====================
- def train_model(model, X_train, Y_train, stats, X_raw, epochs=1000, lr=1e-3):
- optimizer = optim.Adam(model.parameters(), lr=lr)
- scheduler = CosineAnnealingLR(optimizer, T_max=epochs, eta_min=1e-4)
- train_loss_history = []
- for epoch in range(epochs):
- model.train()
- optimizer.zero_grad()
- loss, V_loss, Q_loss = loss_fn(model, X_train, Y_train, stats, X_raw)
- loss.backward()
- optimizer.step()
- train_loss_history.append(loss.item())
- scheduler.step()
- if epoch % 100 == 0:
- print(f"Epoch {epoch:4d} | Train: {loss.item():.4e} ")
- return train_loss_history, V_loss, Q_loss
- # ==================== Model evaluation ====================
- def evaluate_model(model, X_test, Y_test, stats, X_raw):
- model.eval()
- with torch.no_grad():
- test_loss, V_loss, Q_loss = loss_fn(model, X_test, Y_test, stats, X_raw)
- Y_pred_norm = model(X_test)
- Y_pred = Y_pred_norm * stats['Y_std'] + stats['Y_mean']
- Y_true = Y_test * stats['Y_std'] + stats['Y_mean']
- Y_pred = torch.expm1(Y_pred) - stats['Y_offset']
- Y_true = torch.expm1(Y_true) - stats['Y_offset']
- Y_pred_np = Y_pred.numpy()
- Y_true_np = Y_true.numpy()
- metrics = {}
- for i, name in enumerate(['Voltage', 'HeatFlux']):
- y_pred_i = Y_pred_np[:, i]
- y_true_i = Y_true_np[:, i]
- metrics[name] = {
- 'MSE': mean_squared_error(y_true_i, y_pred_i),
- 'RMSE': mean_squared_error(y_true_i, y_pred_i) ** 0.5,
- 'MAE': mean_absolute_error(y_true_i, y_pred_i),
- 'R2': r2_score(y_true_i, y_pred_i)
- }
- print("\n" + "=" * 50)
- print(f" Loss: {test_loss.item():.3e})")
- for k in metrics:
- print(f"- {k:10s}: MSE = {metrics[k]['MSE']:.3e} | RMSE = {metrics[k]['RMSE']:.3e} | MAE = {metrics[k]['MAE']:.3e} | R² = {metrics[k]['R2']:.4f}")
- print("=" * 50)
- return test_loss.item(), V_loss, Q_loss, metrics
- # ==================== Save model ====================
- def save_model(model, path):
- torch.save(model.state_dict(), path)
- print(f"Model is saved to {path}")
- # ==================== Main ====================
- device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
- parent_dir = os.path.abspath(os.path.join(os.getcwd(), ".."))
- csv_file = os.path.join(parent_dir, "data", "Ag2TeS.csv")
- if not os.path.exists(csv_file):
- raise FileNotFoundError(f"CSV file {csv_file} does not exist!")
- print("\n" + "=" * 50)
- X_tensor, Y_tensor, stats, X_raw = load_dataset_from_csv(csv_file)
- model = TEGNet().to(device)
- print("\n" + "=" * 50)
- print("Starting traning...")
- # 训练模型
- train_loss, V_train_loss, Q_train_loss = train_model(model, X_tensor, Y_tensor, stats, X_raw, epochs=6000, lr=1e-3)
- print("\n" + "=" * 50)
- model_dir = os.path.join(parent_dir, "model")
- os.makedirs(model_dir, exist_ok=True)
- model_path = os.path.join(model_dir, "Ag2TeS.pth")
- save_model(model, path=model_path)
Ag2TeS_model training.py at commit a5c868d, under Apache-2.0 · at the source
Overview
- Research Center for Materials Nanoarchitectonics (MANA), National Institute for Materials Science (NIMS),Tsukuba, Japan
- Graduate School of Pure and Applied Sciences, University of Tsukuba,Tsukuba, Japan
Abstract
The abstract is not reproduced here: the paper's license (CC BY-NC-ND) does not allow it. Read it in the paper, at the publisher or on Europe PMC.
Repository
Its files are read in the Code ↔ Paper reader above.
airannims/TEGNet
a5c868d9f84460cd3ee4833dad91cf730372fd72, 14 November 2025Availability: 1 check, the latest on 29 September 2026: the link answers
- 29 September 2026: the link answers
20 files
- model training/
Ag2TeS_model training.py , Python, 189 lines - model training/
Bi2Te3_model training.py , Python, 187 lines - model training/
CoSb3_model training.py , Python, 187 lines - model training/
GeTe_model training.py , Python, 187 lines - model training/
Mg3Bi2_model training.py , Python, 187 lines - model training/
Mg3Sb2_model training.py , Python, 187 lines - model training/
MgAgSb_model training.py , Python, 187 lines - model training/
NbFeSb_model training.py , Python, 187 lines - model training/
PbTe_model training.py , Python, 187 lines - model training/
SnS_model training.py , Python, 187 lines - model training/
SnSe_model training.py , Python, 187 lines - model training/
Zintl_model training.py , Python, 187 lines - n-p paired with segmented/
paired_GeTe_Mg3Bi2_Mg3Sb , Python, 544 lines2.py - n-p paired/
paired_Mg3Sb2_SnS.py , Python, 329 lines - n-p paired/
paired_MgAgSb_Mg3Bi2.py , Python, 326 lines - segemented leg/
segmented_MgAgSb_Bi2Te3. , Python, 388 linespy - single leg/
single_Bi2Te3.py , Python, 297 lines - single leg/
single_MgAgSb.py , Python, 298 lines - LICENSE, License, 201 lines
- README.md, Text, 97 lines
Code availability statement
The paper has a code availability statement. Its license (CC BY-NC-ND) does not allow reproducing it here; in short, from what the harvester recognized in it:
- it points to the authors' code: airannims/
TEGNet
Read it in the paper: doi.org/10.1038/s41586-026-10223-1.
Tracing map
Proposed by the machine: these links were found in the paper and verified at the source, without human review. The map will receive a Zenodo DOI once one of the paper's authors has validated it with their ORCID.
What the map holds:
- 1 repository of the authors' code, each at its verified commit, with its license and how the link was found in the paper;
- 18 scripts, each with its path and the digest of its content;
- no match between paragraphs and code yet;
- neither the text of the paper nor the code itself.
Its JSON (tracing-map.json) is deposited on Zenodo with its DOI once the map is validated.
Data
No dataset and no data link were found in the paper.
Data availability statement
The paper has a data availability statement. Its license (CC BY-NC-ND) does not allow reproducing it here; in short, from what the harvester recognized in it:
- no repository, dataset or request procedure was recognized in it
Read it in the paper: doi.org/10.1038/s41586-026-10223-1.
Versions
The history of this record: each version stored by the harvester or made by a correction of its authors or of the maintainers of its code, and what changed in its facts. The texts of the paper (its abstract, its availability statements) are not part of it; versions that changed only those are not listed.
Version 1, 29 September 2026: the first record
Recorded: type, language, journal, volume, issue, pages, dates, 8 authors, 2 keywords, 2 funders, 44 references.
Cite
This paper
Li, A., Wu, X., Wang, L., Wu, G., Li, J., Hu, Z., Wang, X., & Mori, T. (2026). Composable neural emulators accelerate thermoelectric generator design. Nature, 652(8110), 643-649. https://
BibTeX
@article{li2026composabl
author = {Li, Airan and Wu, Xinzhi and Wang, Longquan and Wu, Gang and Li, Jiankang and Hu, Zhao and Wang, Xinyuan and Mori, Takao},
title = {{Composable neural emulators accelerate thermoelectric generator design}},
journal = {Nature},
year = {2026},
month = apr,
volume = {652},
number = {8110},
pages = {643--649},
publisher = {Nature Portfolio},
issn = {0028-0836},
doi = {10.1038/
url = {https://
pmid = {41986625},
pmcid = {PMC13083250}
}
RIS
TY - JOUR
AU - Li, Airan
AU - Wu, Xinzhi
AU - Wang, Longquan
AU - Wu, Gang
AU - Li, Jiankang
AU - Hu, Zhao
AU - Wang, Xinyuan
AU - Mori, Takao
TI - Composable neural emulators accelerate thermoelectric generator design
T2 - Nature
J2 - Nature
PY - 2026
DA - 2026/
VL - 652
IS - 8110
SP - 643
EP - 649
SN - 0028-0836
PB - Nature Portfolio
DO - 10.1038/
UR - https://
LA - en
ER -
CSL-JSON
{
"id": "10.1038/
"type": "article-journal",
"title": "Composable neural emulators accelerate thermoelectric generator design",
"container-title": "Nature",
"author": [
{
"family": "Li",
"given": "Airan"
},
{
"family": "Wu",
"given": "Xinzhi"
},
{
"family": "Wang",
"given": "Longquan"
},
{
"family": "Wu",
"given": "Gang"
},
{
"family": "Li",
"given": "Jiankang"
},
{
"family": "Hu",
"given": "Zhao"
},
{
"family": "Wang",
"given": "Xinyuan"
},
{
"family": "Mori",
"given": "Takao"
}
],
"container-title-short":
"volume": "652",
"issue": "8110",
"page": "643-649",
"DOI": "10.1038/
"PMID": "41986625",
"PMCID": "PMC13083250",
"ISSN": "0028-0836",
"publisher": "Nature Portfolio",
"URL": "https://
"language": "en",
"issued": {
"date-parts": [
[
2026,
4,
15
]
]
}
}
The tracing map gets a citation of its own once an author has validated it and it has a DOI.
Similar papers
The papers with a page that share the most with this one: the tools found in their code, their categories, datasets, cited references and authors, the rarest counting most.
- [1] doi:10.1126/sciadv.aec6633
- Topological acoustic synapse for high-dimensional neuromorphic computing.Journal: Science advancesIn common: 1 reference
Contribute
The authors of this paper can claim it, correct its record and validate its tracing map, and the maintainers of its code (its owner, or a public member of its organization) correct what it says of their repository; anyone signed in can ask for its removal. Every request goes to OSCR's own machine, which answers it; your account page follows them.
Sign in with ORCID to claim this paper as one of its authors, correct its record or validate its tracing map: when the paper's metadata lists your ORCID iD, you are recognized at once. Maintainers of its code: sign in with GitHub, then claim the repository on your account page.
Claim this paper
Correct its record
Say what each link of this record is, remove the ones that are not the paper's, add the ones that are missing. The correction becomes a new version of the record, in its Versions section.
Validate its tracing map
You validate the map as this page shows it: 1 repository of the authors' code, each at its verified commit and with its license, 18 scripts, and 0 matches between paragraphs and code (see the Code and Map sections). It then receives a DOI on Zenodo, with you (your ORCID iD) and OSCR as its creators; the code itself is not deposited.
The map's fingerprint: sha256:2f088421d9c774d2…
Add the badge to its README
The badge links the code to this page. Copy one of these into the README of the paper's code: only you decide where it goes, and nothing is changed for you.
Markdown
[, paste the snippet at the top, then “Commit changes…” and, to review it first, “Create a new branch and start a pull request”. You open the pull request; OSCR asks for no permission.
Request its removal
To ask OSCR to remove this record, the copies of its authors' scripts or its tracing map, use the removal request page: signed in, you say who you are, what to remove and why, then review and confirm the request. Published rules decide every request (how).
Discussion, reproductions, activity
Discussion: questions and error reports about this paper and its code, from signed-in readers and its authors. It opens with sign-in.
Reproductions: reports from readers who ran the authors' code: what they reproduced, with which environment, commit and data. It opens with sign-in.
Activity: what happens around this paper: new versions of its record, its map's validation, discussions and reproductions. It opens with sign-in.
