Skip to content

ProjectTorreyPines/TroyonBetaNN.jl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TroyonBetaNN.jl

Build Status

About the Package

This package uses pre-trained neural network (NN) models to predict Troyon (no-wall) $\beta_\mathrm{N}$ limits for a given equilibrium. There are two different NN models with either MLP or CNN architectures, whose training dataset were generated with the CHEASE and MARS-F codes for the equilibrium and MHD stability, respectively. This package employs the pre-trained NN models and provides some useful interfaces to make it compatible with the IMAS data structure and FUSE ecosystem.

About the NN models

Note that the following two models are each valid for a specific range of plasma parameters (e.g., aspect ratio and shape). For example, the MLP model can cover a wider range of aspect ratio ($A\in[1.3, 4.0]$), while the CNN model only targets a specific aspect ratio ($A \sim 2.74$) since it is designed for the HL-2M tokamak. On the other hand, the MLP model can only hanlde the positive triangularity ($\sigma>0$), but the CNN model can deal with a range of triangularity ($\sigma \in [-0.6, 0.8]$), including the negative triangularity.

1. MLP (Multi-Layer Perceptron) model

Developed and trained by Yueqiang Liu, et al.. (see [Y.Q. Liu, et al., PPCF (2020)] for details). This model can cover a wider range of plasma parameters

  • Input
    • 2D boundary shape
    • 1D safety factor
    • 1D plasma pressure
  • Output
    • Troyon $\beta_\mathrm{N}$ limits for $n=(1,2,3)$ toroidal modes

2. CNN (Convolutional Neural Network) model

Developed and trained by Yifei Zhao, et al.. (see [Y.F. Zhao, et al., PPCF (2022)] for details)

  • Input
    • 2D boundary shape
    • 1D safety factor
    • 1D plasma pressure
    • Internal inductance ($l_i$)
    • Pressure Peaking Factor (PPF)
  • Output
    • Troyon $\beta_\mathrm{N}$ limit for $n=1$ toroidal mode

Quick Examples

1. Basic usage (with simple output)

# Assuming that "FUSE" and "dd" are already in your scope

import TroyonBetaNN as TBNN

# The following function cacluates Troyon limits for all equilibrium time_slices in dd,
# and returns Vector{Troyon_Data}, which has all information about the result
TD_vec = TBNN.calculate_Troyon_beta_limits_for_IMAS_dd(dd); # To iterate

# Or one can specify a time_slice of equilibrium and calculate Troyon limits for it,
# which returns a single "Troyon_Data" struct
eqt = dd.equilibrium.time_slice[2];
TD = TBNN.calculate_Troyon_beta_limits_for_a_given_time_slice(eqt);

The above functions show a simple terminal output about Troyon $\beta_N$ limits.


2. Basic usage (with verbose output)

One can get more verbose information by adding a keyword argument "verbose=true".

# For all time_slices
TD_vec = TBNN.calculate_Troyon_beta_limits_for_IMAS_dd(dd; verbose=true);

# Or, for a specific time_slice
eqt = dd.equilibrium.time_slice[2];
TD = TBNN.calculate_Troyon_beta_limits_for_a_given_time_slice(eqt; verbose=true);

This will give the following verbose terminal output and write figure file of sampling points used for NN.


Sample points for a DIII-D equilibrium:


3. Advanced usage (reuse NN models)

We can load the NN models once, and reuse it for any equilibrium time slices as desired. Note that the following TD (TroyonData) instance has every input/output information inside.

# Loads NN Models and stores them inside TD (TroyonData)
TD = TBNN.load_predefined_Troyon_NN_Models();

# Pass TD as an argument to TBNN functions
# This is a more performant way than the previous basic usage
for eqt in dd.equilibrium.time_slice
    TBNN.calculate_Troyon_beta_limits_for_a_given_time_slice(TD, eqt; silence=true);

    # You can get any information from TD (TroyonData),
    # and post-process it as desired like the following
    println("For n=1 mode:")
    println("  MLP's βₙ_limit = $(TD.MLPs[1].βₙ_limit)")
    println("  CNN's βₙ_limit = $(TD.CNN.βₙ_limit)")

    # or like the following
    MLPs_toroidal_modes = getfield.(TD.MLPs, :n); # return 3-element Vector{Int64}
    MLPs_betaN_limits = getfield.(TD.MLPs, :βₙ_limit); # return 3-element Vector{Float64}
    println("For toroidal modes: $(MLPs_toroidal_modes)")
    println("MLP's betaN limits: $(MLPs_betaN_limits)")
end

Contact

Min-Gu Yoo Linkedin (General Atomics) [email protected]
Yueqiang Liu (General Atomics) [email protected]

Acknowledgments

We acknowledge Yeifei Zhao (Dalian University of Technology; [email protected]) for graciously providing the trained CNN models for this project.

References

Please refer to NOTICE.md for citations, if this package contributes to an academic publication.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages