tglfnn-ukaea
Neural network surrogate models of the TGLF quasilinear plasma turbulent transport simulator in various parameter spaces.
Paper for acknowledgment
If you use these models within your work, we request you cite the following paper:
- L. Zanisi et al., Data efficent digital twinning strategies and surrogate models of quasilinear turbulence in JET and STEP, International Atomic Energy Agency - Fusion Energy Conference, Chengdu, China, 2025
Usage
Various different methods exist for using the models:
- Loading from PyTorch checkpoint
- Loading traced ONNX model
- Loading traced TorchScript model
- Loading the parameters directly into pure Python
Loading the traced TorchScript model allows the model to be used in Fortran (see below). Loading the parameters directly is a minimal-dependency method designed for use with other machine learning frameworks.
1. Loading from PyTorch checkpoint
import torch
# Load the model
efe_gb_model = torch.load('MultiMachineHyper_1Aug25/regressor_efe_gb.pt')
# Call the model
input_tensor = torch.tensor([[...]], dtype=torch.float32) # Replace with appropriate input
output_tensor = efe_gb_model(input_tensor)
2. Loading traced ONNX model
import onnxruntime as ort
# Load the model
ort_session = ort.InferenceSession('MultiMachineHyper_1Aug25/regressor_efe_gb.onnx')
# Call the model
input_tensor = np.array([[...]], dtype=np.float32) # Replace with appropriate input
outputs = ort_session.run(None, {'input': input_tensor})
3. Loading traced TorchScript model
import torch
# Load the model
torchscript_model = torch.jit.load('MultiMachineHyper_1Aug25/regressor_efe_gb_torchscript.pt')
# Call the model
input_tensor = torch.tensor([[...]], dtype=torch.float32) # Replace with appropriate input
output_tensor = torchscript_model(input_tensor)
Using the traced TorchScript models in Fortran
The traced PyTorch models can be used in Fortran with FTorch, which provides Fortran bindings for LibTorch (the C++ backend of PyTorch). Please cite the Ftorch publication if using these models from Fortran.
Further details on the FTorch Implementation of these networks can be found in a related project.
Prerequisites
- LibTorch: Download the appropriate version (CPU or GPU) from the PyTorch website and ensure it is accessible in your environment. CPU versions of the
LibTorchandPippackages have been tested. TheLibTorchversion requires no Python to install or run. It is suggested to look at theFTorchinstructions below first. - FTorch: Install the FTorch library following the instructions in the FTorch repository. This also provides a compiler specific module (
ftorch.mod). - Fortran Compiler: Use a modern Fortran compiler (e.g.,
gfortranorifort) compatible with FTorch. - CMake: Version >= 3.1 required to build FTorch. Not essential, but helpful for building final Fortran code.
4. Compare TGLF and TGLFNN in JETTO production runs
- TGLFNN is only an approximation of TGLF and it will make mistakes
- scripts/tglf_vs_nn_jetto_trajectories.py shows how to plot the inputs and outputs spanned by TGLF and TGLFNN in a JETTO production run. NOTE: Available only in the following build on the JDC
/home/tn2395/jintrac-devel
Metadata
Release files for tglfnn-ukaea 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| tglfnn_ukaea-0.2.0.tar.gz | 118.9 MB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| tglfnn_ukaea-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 237.7 MB
Release files / tglfnn_ukaea-0.2.0.tar.gz
| Download URL | tglfnn_ukaea-0.2.0.tar.gz |
|---|---|
| Size | 118.9 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7a27eba077ba96b2810ddd021c58e4acc91cc69edc085f1aae728d3786d59418
|
|
BLAKE2b-256 checksum How to use checksums |
387bf16a59defdc66d0abf998996aa333cae9dc1ae2a02a44fe4c53020c6439f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.7
|
Release files / tglfnn_ukaea-0.2.0-py3-none-any.whl
| Download URL | tglfnn_ukaea-0.2.0-py3-none-any.whl |
|---|---|
| Size | 118.9 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b0765ec8aabdfbf60f96dd895388f7088a591167d9737f3599853d29f39b09fd
|
|
BLAKE2b-256 checksum How to use checksums |
9eaf19989fad0e1418bf789d32e1ae84d0557a3d724a8303449c03213b755a6f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.7
|