OSCR

Composable neural emulators accelerate thermoelectric generator design.

Code ↔ Paper

The paper beside its authors' code: matches between them have not been computed for this paper yet.

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

  1. #!/usr/bin/env python
  2. # coding: utf-8
  3. import numpy as np
  4. import pandas as pd
  5. import os
  6. import torch
  7. import math
  8. import torch.nn as nn
  9. import torch.optim as optim
  10. import matplotlib.pyplot as plt
  11. from scipy.interpolate import interp1d
  12. from scipy.interpolate import CubicSpline
  13. from scipy.integrate import quad
  14. from torch.optim.lr_scheduler import StepLR, CosineAnnealingLR, ReduceLROnPlateau, MultiStepLR, ExponentialLR
  15. import seaborn as sns
  16. import pandas as pd
  17. from sklearn.model_selection import train_test_split
  18. from sklearn.metrics import mean_absolute_error, mean_squared_error, r2_score
  19. # ==================== Data load and process ====================
  20. def load_dataset_from_csv(csv_file):
  21. if not os.path.exists(csv_file):
  22. raise FileNotFoundError(f"CSV file {csv_file} not existed!")
  23. X_columns = ['a', 'b', 'c', 'Tc', 'Th', 'Ih']
  24. Y_columns = ['V', 'Q']
  25. df = pd.read_csv(csv_file)
  26. X_cached = df[X_columns].copy().values
  27. Y_cached = df[Y_columns].copy().values
  28. X_cached[:, 5] = np.log1p(X_cached[:, 5])
  29. Y_offset = np.zeros((1, Y_cached.shape[1]))
  30. for i in range(Y_cached.shape[1]):
  31. min_val = Y_cached[:, i].min()
  32. if min_val <= 0:
  33. Y_offset[0, i] = -min_val + 1e-3
  34. Y_cached[:, i] += Y_offset[0, i]
  35. Y_cached[:, i] = np.log1p(Y_cached[:, i])
  36. X_mean = X_cached.mean(axis=0, keepdims=True)
  37. X_std = X_cached.std(axis=0, keepdims=True)
  38. Y_mean = Y_cached.mean(axis=0, keepdims=True)
  39. Y_std = Y_cached.std(axis=0, keepdims=True)
  40. X_norm = (X_cached - X_mean) / X_std
  41. Y_norm = (Y_cached - Y_mean) / Y_std
  42. X_tensor = torch.tensor(X_norm, dtype=torch.float32)
  43. Y_tensor = torch.tensor(Y_norm, dtype=torch.float32)
  44. X_cached_tensor = torch.tensor(X_cached, dtype=torch.float32)
  45. stats = {
  46. 'X_mean': torch.tensor(X_mean, dtype=torch.float32),
  47. 'X_std': torch.tensor(X_std, dtype=torch.float32),
  48. 'Y_mean': torch.tensor(Y_mean, dtype=torch.float32),
  49. 'Y_std': torch.tensor(Y_std, dtype=torch.float32),
  50. 'Y_offset': torch.tensor(Y_offset, dtype=torch.float32)
  51. }
  52. print(f"Load success:{X_tensor.shape[0]} sample size in total")
  53. return X_tensor, Y_tensor, stats, X_cached_tensor
  54. # ==================== Loss function ====================
  55. def loss_fn(model, X_norm, Y_norm, stats, X_raw):
  56. Y_pred = model(X_norm)
  57. v_true, q_true = Y_norm[:, 0], Y_norm[:, 1]
  58. v_pred, q_pred = Y_pred[:, 0], Y_pred[:, 1]
  59. v_loss = ((v_pred - v_true) ** 2).mean()
  60. q_loss = ((q_pred - q_true) ** 2).mean()
  61. loss = v_loss + 5*q_loss
  62. return loss, v_loss.item(), q_loss.item()
  63. # ==================== TEGNet ====================
  64. class TEGNet(nn.Module):
  65. def __init__(self):
  66. super().__init__()
  67. self.net = nn.Sequential(
  68. nn.Linear(6, 128),
  69. nn.SiLU(),
  70. nn.Linear(128, 128),
  71. nn.SiLU(),
  72. nn.Linear(128, 128),
  73. nn.SiLU(),
  74. nn.Linear(128, 2)
  75. )
  76. def forward(self, x):
  77. return self.net(x)
  78. # ==================== Model training ====================
  79. def train_model(model, X_train, Y_train, stats, X_raw, epochs=1000, lr=1e-3):
  80. optimizer = optim.Adam(model.parameters(), lr=lr)
  81. scheduler = CosineAnnealingLR(optimizer, T_max=epochs, eta_min=1e-4)
  82. train_loss_history = []
  83. for epoch in range(epochs):
  84. model.train()
  85. optimizer.zero_grad()
  86. loss, V_loss, Q_loss = loss_fn(model, X_train, Y_train, stats, X_raw)
  87. loss.backward()
  88. optimizer.step()
  89. train_loss_history.append(loss.item())
  90. scheduler.step()
  91. if epoch % 100 == 0:
  92. print(f"Epoch {epoch:4d} | Train: {loss.item():.4e} ")
  93. return train_loss_history, V_loss, Q_loss
  94. # ==================== Model evaluation ====================
  95. def evaluate_model(model, X_test, Y_test, stats, X_raw):
  96. model.eval()
  97. with torch.no_grad():
  98. test_loss, V_loss, Q_loss = loss_fn(model, X_test, Y_test, stats, X_raw)
  99. Y_pred_norm = model(X_test)
  100. Y_pred = Y_pred_norm * stats['Y_std'] + stats['Y_mean']
  101. Y_true = Y_test * stats['Y_std'] + stats['Y_mean']
  102. Y_pred = torch.expm1(Y_pred) - stats['Y_offset']
  103. Y_true = torch.expm1(Y_true) - stats['Y_offset']
  104. Y_pred_np = Y_pred.numpy()
  105. Y_true_np = Y_true.numpy()
  106. metrics = {}
  107. for i, name in enumerate(['Voltage', 'HeatFlux']):
  108. y_pred_i = Y_pred_np[:, i]
  109. y_true_i = Y_true_np[:, i]
  110. metrics[name] = {
  111. 'MSE': mean_squared_error(y_true_i, y_pred_i),
  112. 'RMSE': mean_squared_error(y_true_i, y_pred_i) ** 0.5,
  113. 'MAE': mean_absolute_error(y_true_i, y_pred_i),
  114. 'R2': r2_score(y_true_i, y_pred_i)
  115. }
  116. print("\n" + "=" * 50)
  117. print(f" Loss: {test_loss.item():.3e})")
  118. for k in metrics:
  119. print(f"- {k:10s}: MSE = {metrics[k]['MSE']:.3e} | RMSE = {metrics[k]['RMSE']:.3e} | MAE = {metrics[k]['MAE']:.3e} | R² = {metrics[k]['R2']:.4f}")
  120. print("=" * 50)
  121. return test_loss.item(), V_loss, Q_loss, metrics
  122. # ==================== Save model ====================
  123. def save_model(model, path):
  124. torch.save(model.state_dict(), path)
  125. print(f"Model is saved to {path}")
  126. # ==================== Main ====================
  127. device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
  128. parent_dir = os.path.abspath(os.path.join(os.getcwd(), ".."))
  129. csv_file = os.path.join(parent_dir, "data", "Ag2TeS.csv")
  130. if not os.path.exists(csv_file):
  131. raise FileNotFoundError(f"CSV file {csv_file} does not exist!")
  132. print("\n" + "=" * 50)
  133. X_tensor, Y_tensor, stats, X_raw = load_dataset_from_csv(csv_file)
  134. model = TEGNet().to(device)
  135. print("\n" + "=" * 50)
  136. print("Starting traning...")
  137. # 训练模型
  138. train_loss, V_train_loss, Q_train_loss = train_model(model, X_tensor, Y_tensor, stats, X_raw, epochs=6000, lr=1e-3)
  139. print("\n" + "=" * 50)
  140. model_dir = os.path.join(parent_dir, "model")
  141. os.makedirs(model_dir, exist_ok=True)
  142. model_path = os.path.join(model_dir, "Ag2TeS.pth")
  143. save_model(model, path=model_path)

Ag2TeS_model training.py at commit a5c868d, under Apache-2.0 · at the source

Overview

Authors: Airan Li1, Xinzhi Wu1, Longquan Wang1, Gang Wu1, Jiankang Li1,2, Zhao Hu1,2, Xinyuan Wang1,2, Takao Mori1,2
  1. Research Center for Materials Nanoarchitectonics (MANA), National Institute for Materials Science (NIMS),Tsukuba, Japan
  2. Graduate School of Pure and Applied Sciences, University of Tsukuba,Tsukuba, Japan
Journal: Nature, volume 652, issue 8110, pages 643-649
Dates: received 28 September 2025; accepted 2 February 2026; published online 15 April 2026; in print 2026
Type: Research article · Language: English
License: CC BY-NC-ND
Identifiers: DOI 10.1038/s41586-026-10223-1 · PMID 41986625 · PMCID PMC13083250 · OpenAlex W7154477652
Open access: hybrid, a free copy (OpenAlex)
Status: code verified
Methods: Machine learning
Keywords: Thermoelectric devices and materials, Thermoelectrics
Topic: Advanced Thermoelectric Materials and Devices (Materials Chemistry, Materials Science), according to OpenAlex
Funding: Japan Society for the Promotion of Science; JST-Mirai Program
Citations: not cited yet (Europe PMC); 45 references in the paper

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

License: Apache-2.0
State: the link answers, verified on 29 September 2026
Evidence: files inventoried
Commit: a5c868d9f84460cd3ee4833dad91cf730372fd72, 14 November 2025
Languages: Python (18)
Size: 73 files, 18 scripts
Software Heritage: not archived
Found in: “Code availability”
Holds: README, license file, environment (environment.yml)
Not found: CITATION.cff, tests, continuous integration, documentation
Tools: Matplotlib (18 files), NumPy (18 files), pandas (18 files), PyTorch (18 files), scikit-learn (18 files), SciPy (18 files), seaborn (18 files)
Availability: 1 check, the latest on 29 September 2026: the link answers
  • 29 September 2026: the link answers
20 files

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:

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://doi.org/10.1038/s41586-026-10223-1

BibTeX

@article{li2026composable,
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/s41586-026-10223-1},
url = {https://doi.org/10.1038/s41586-026-10223-1},
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/04/15
VL - 652
IS - 8110
SP - 643
EP - 649
SN - 0028-0836
PB - Nature Portfolio
DO - 10.1038/s41586-026-10223-1
UR - https://doi.org/10.1038/s41586-026-10223-1
LA - en
ER -

CSL-JSON

{
"id": "10.1038/s41586-026-10223-1",
"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": "Nature",
"volume": "652",
"issue": "8110",
"page": "643-649",
"DOI": "10.1038/s41586-026-10223-1",
"PMID": "41986625",
"PMCID": "PMC13083250",
"ISSN": "0028-0836",
"publisher": "Nature Portfolio",
"URL": "https://doi.org/10.1038/s41586-026-10223-1",
"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 advances
In 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.

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.