Vacuum Module

The Vacuum module provides magnetostatic vacuum field calculations with plasma-wall interactions. Refactored/interfaced from/with VACUUM by M.S. Chance.

Overview

The module includes:

  • Interface to Fortran vacuum field calculations
  • Julia refactored version of the VACUUM code

API Reference

JPEC.VacuumMod.mscvacFunction
mscvac(wv, mpert, mtheta, mthvac, complex_flag, kernelsignin, wall_flag, farwal_flag, grrio, xzptso, op_ahgfile=nothing)

Compute the vacuum response matrix for magnetostatic perturbations.

Arguments

  • wv: Pre-allocated complex matrix (mpert × mpert) to store vacuum response (Array{ComplexF64,2})
  • mpert: Number of perturbation modes (Integer)
  • mtheta: Number of theta grid points for plasma (Integer)
  • mthvac: Number of theta grid points for vacuum region (Integer)
  • complex_flag: Whether to use complex arithmetic (Bool)
  • kernelsignin: Sign convention for vacuum kernels (Float64, typically -1.0)
  • wall_flag: Whether to include an externally defined wall shape (Bool)
  • farwal_flag: Whether to use far-wall approximation (Bool)
  • grrio: Green's function data (Array{Float64,2})
  • xzptso: Source point coordinates (Array{Float64,2})
  • op_ahgfile: Optional communication file for when setdconparams is not called (String or Nothing)

Returns

  • Modifies wv in-place with the computed vacuum response matrix
  • Returns the modified wv matrix

Note

Requires prior initialization with set_dcon_params() before calling this function.

Examples

# Initialize parameters first
set_dcon_params(mthin, lmin, lmax, nnin, qa1in, xin, zin, deltain)

# Set up vacuum calculation
mpert = 5
mtheta = 256
mthvac = 256
wv = zeros(ComplexF64, mpert, mpert)
complex_flag = true
kernelsignin = -1.0
wall_flag = false
farwal_flag = true
grrio = rand(Float64, 2 * (mthvac + 5), mpert * 2)
xzptso = rand(Float64, mthvac + 5, 4)

# Perform calculation
mscvac(wv, mpert, mtheta, mthvac, complex_flag, kernelsignin,
    wall_flag, farwal_flag, grrio, xzptso)
source
JPEC.VacuumMod.set_dcon_paramsMethod
set_dcon_params(mthin, lmin, lmax, nnin, qa1in, xin, zin, deltain)

Initialize DCON (Displacement CONtinuum) parameters for vacuum field calculations.

Arguments

  • mthin: Number of theta grid points (Integer)
  • lmin: Minimum poloidal mode number (Integer)
  • lmax: Maximum poloidal mode number (Integer)
  • nnin: Toroidal mode number (Integer)
  • qa1in: Safety factor parameter (Float64)
  • xin: Vector of radial coordinates at plasma boundary (Vector{Float64})
  • zin: Vector of vertical coordinates at plasma boundary (Vector{Float64})
  • deltain: Vector of displacement values (Vector{Float64})

Note

This function must be called before using mscvac to perform vacuum calculations. The coordinate and displacement vectors should have length lmax - lmin + 1.

Examples

mthin, lmin, lmax, nnin = Int32(4), Int32(1), Int32(4), Int32(2)
qa1in = 1.23
n_modes = lmax - lmin + 1
xin = rand(Float64, n_modes)
zin = rand(Float64, n_modes)
deltain = rand(Float64, n_modes)

set_dcon_params(mthin, lmin, lmax, nnin, qa1in, xin, zin, deltain)
source

Functions

setdconparams

JPEC.VacuumMod.set_dcon_paramsFunction
set_dcon_params(mthin, lmin, lmax, nnin, qa1in, xin, zin, deltain)

Initialize DCON (Displacement CONtinuum) parameters for vacuum field calculations.

Arguments

  • mthin: Number of theta grid points (Integer)
  • lmin: Minimum poloidal mode number (Integer)
  • lmax: Maximum poloidal mode number (Integer)
  • nnin: Toroidal mode number (Integer)
  • qa1in: Safety factor parameter (Float64)
  • xin: Vector of radial coordinates at plasma boundary (Vector{Float64})
  • zin: Vector of vertical coordinates at plasma boundary (Vector{Float64})
  • deltain: Vector of displacement values (Vector{Float64})

Note

This function must be called before using mscvac to perform vacuum calculations. The coordinate and displacement vectors should have length lmax - lmin + 1.

Examples

mthin, lmin, lmax, nnin = Int32(4), Int32(1), Int32(4), Int32(2)
qa1in = 1.23
n_modes = lmax - lmin + 1
xin = rand(Float64, n_modes)
zin = rand(Float64, n_modes)
deltain = rand(Float64, n_modes)

set_dcon_params(mthin, lmin, lmax, nnin, qa1in, xin, zin, deltain)
source

mscvac

JPEC.VacuumMod.mscvacFunction
mscvac(wv, mpert, mtheta, mthvac, complex_flag, kernelsignin, wall_flag, farwal_flag, grrio, xzptso, op_ahgfile=nothing)

Compute the vacuum response matrix for magnetostatic perturbations.

Arguments

  • wv: Pre-allocated complex matrix (mpert × mpert) to store vacuum response (Array{ComplexF64,2})
  • mpert: Number of perturbation modes (Integer)
  • mtheta: Number of theta grid points for plasma (Integer)
  • mthvac: Number of theta grid points for vacuum region (Integer)
  • complex_flag: Whether to use complex arithmetic (Bool)
  • kernelsignin: Sign convention for vacuum kernels (Float64, typically -1.0)
  • wall_flag: Whether to include an externally defined wall shape (Bool)
  • farwal_flag: Whether to use far-wall approximation (Bool)
  • grrio: Green's function data (Array{Float64,2})
  • xzptso: Source point coordinates (Array{Float64,2})
  • op_ahgfile: Optional communication file for when setdconparams is not called (String or Nothing)

Returns

  • Modifies wv in-place with the computed vacuum response matrix
  • Returns the modified wv matrix

Note

Requires prior initialization with set_dcon_params() before calling this function.

Examples

# Initialize parameters first
set_dcon_params(mthin, lmin, lmax, nnin, qa1in, xin, zin, deltain)

# Set up vacuum calculation
mpert = 5
mtheta = 256
mthvac = 256
wv = zeros(ComplexF64, mpert, mpert)
complex_flag = true
kernelsignin = -1.0
wall_flag = false
farwal_flag = true
grrio = rand(Float64, 2 * (mthvac + 5), mpert * 2)
xzptso = rand(Float64, mthvac + 5, 4)

# Perform calculation
mscvac(wv, mpert, mtheta, mthvac, complex_flag, kernelsignin,
    wall_flag, farwal_flag, grrio, xzptso)
source

Example Usage

Basic Vacuum Calculation

using JPEC

# Set DCON parameters
mthin, lmin, lmax, nnin = Int32(4), Int32(1), Int32(4), Int32(2)
qa1in = 1.23
xin = rand(Float64, lmax - lmin + 1)
zin = rand(Float64, lmax - lmin + 1) 
deltain = rand(Float64, lmax - lmin + 1)

# Initialize DCON interface
JPEC.VacuumMod.set_dcon_params(mthin, lmin, lmax, nnin, qa1in, xin, zin, deltain)

# Set up vacuum calculation parameters
mpert = 5
mtheta = 256
mthvac = 256
wv = zeros(ComplexF64, mpert, mpert)
complex_flag = true
kernelsignin = -1.0
wall_flag = false
farwal_flag = true
grrio = rand(Float64, 2*(mthvac+5), mpert*2)
xzptso = rand(Float64, mthvac+5, 4)

# Perform vacuum calculation
JPEC.VacuumMod.mscvac(
    wv, mpert, mtheta, mthvac,
    complex_flag, kernelsignin,
    wall_flag, farwal_flag,
    grrio, xzptso
)

Notes

  • Requires proper initialization of DCON parameters before use
  • Supports both complex and real arithmetic depending on the application