SOLPS2imas.jl
Installation
For installation:
using Pkg
Pkg.add("SOLPS2imas")
solps2imas
The main function of this module is solps2imas which reads SOLPS input and output files and creates an IMAS IDS instance.
SOLPS2imas.solps2imas
— Functionsolps2imas(
b2gmtry::String,
b2output::String="";
gsdesc::String=default_gsdesc,
b2mn::String="",
fort::Tuple{String, String, String}=("", "", ""),
fort_tol::Float64=1e-6,
b2_boundary_parameters::String="",
load_bb::Bool=false,
)::IMASdd.dd
Main function of the module. Takes in a geometry file and an (optional) output file (either b2time or b2fstate) and a grid_ggd description in the form of a Dict or filename to equivalent YAML file. Additionally, EIRENE fort
files can be provided as tuple of 3 filenames consisting fort.33, fort.34, and fort.35 files. The grids in these files are matched with SOLPS grid with a tolerance of fort_tol
(defaults to 1e-6). Further settings can be loaded from b2.*.parameters files and equilibrium files.
The main solps2imas feature can be called to load everything. However, some special cases may demand only subsets of the data. In these cases, it is possible to call subcomponents of the SOLPS to IMAS data transfer feature by using these functions:
SOLPS2imas.load_summary_data!
— Functionload_summary_data!(
ids::IMASdd.dd,
b2_parameters::Tuple{String, String, String, String}=("", "", "", "");
)
Loads high level shot summary data into the summary IDS after reading and interpreting SOLPS input files, such as b2.*.parameters.
Parsing tools
This module uses some parsing functions which can be used standalone as well
SOLPS2imas.read_b2_output
— Functionread_b2_output(filename::String)::Dict{String, Dict{String, Any}}
Read final state b2 output file (b2fstate or b2time.nc) or b2fgmtry file and return a dictionary with structure: Dict("dim" => Dict{String, Any}, "data" => Dict{String, Any}) where "dim" contains the dimensions of the data and "data" contains the data itself, with keys corresponding to the field names.
Supported SOLPS files as input via filename:
- b2fstate
- b2fstati
- b2time.nc
- b2fgmtry
SOLPS2imas.read_b2mn_output
— Functionread_b2mn_output(filename::String)::Dict{String, Any}
Read b2mn output file and store the quantities in a dictionary.
Supported SOLPS files as input via filename:
- b2mn.dat
SOLPS2imas.read_b2time_output
— Functionread_b2time_output(filename::String)::Dict{String, Dict{String, Any}}
Read time dependent b2 output file and return a dictionary with structure: Dict("dim" => Dict{String, Any}, "data" => Dict{String, Any}) where "dim" contains the dimensions of the data and "data" contains the data itself, with keys corresponding to the field names.
Supported SOLPS files as input via filename:
- b2time.nc
SOLPS2imas.read_b2_boundary_parameters
— Functionread_b2_boundary_parameters(filename::String)::Dict{String, Any}
Reads and interprets the b2.boundary.parameters file from the SOLPS input deck. This file has boundary conditions like power crossing into the mesh from the core as well as particle fluxes. Returns a dictionary of interpreted results.
SOLPS Mesh Tools
SOLPS2imas.xytoc
— Functionxytoc(ix::Int, iy::Int; nx::Int)::Int
Converts SOLPS indices for crx, cry (ix
, iy
) that go from 1:nx
, 1:ny
into the linear index ic
used in IMAS for corresponding cells.
SOLPS2imas.ctoxy
— Functionctoxy(ic::Int; nx::Int)::Tuple{Int, Int}
Inverse of xytoc.
SOLPS2imas.data_xytoc
— Functiondata_xytoc(data::Matrix{Float64}; nx::Int)::Vector{Float64}
Flattens 2d data given on cell indices ix
, iy
into 1d data on linear index ic
. ic
is calculated using xytoc function. Data is assumed to have dimensions (ny, nx
) where ny is not required in this conversion.
SOLPS2imas.search_point
— Functionsearch_point(
nodes::IMASdd.IDSvector{IMASdd.edge_profiles__grid_ggd___space___objects_per_dimension___object{T}},
r::Real,
z::Real;
tol::Float64=0.0,
)::Int where {T}
Search if a point (r
, z
) is present in the nodes array. Here nodes
is generally available in ids.edge_profiles.grid_ggd[:].space[:].objects_per_dimension[1].object
If the point is not found, the function returns 0.
SOLPS2imas.search_edges
— Functionsearch_edges(
edges::IMASdd.IDSvector{IMASdd.edge_profiles__grid_ggd___space___objects_per_dimension___object{T}},
edge_nodes::Array{Int, 1}
)::Int where {T}
Search if an edge with nodes as edge_nodes
already exists in the edges
array. edges
is generally available in ids.edge_profiles.grid_ggd[:].space[:].objects_per_dimension[2].object
If the edge is not found, the function returns 0.
SOLPS2imas.distance_between_nodes
— Functiondistance_between_nodes(nodes::edges_nodes_type, node_inds::Array{Int, 1})
Return distance between two nodes with indices node_inds
in nodes
array. nodes
is generally available in ids.edge_profiles.grid_ggd[:].space[:].objects_per_dimension[1].object
.
SOLPS2imas.neighbour_inds
— Functionneighbour_inds(
ic::Int;
nx::Int,
ny::Int,
leftcut::Int,
rightcut::Int,
topcut::Int,
bottomcut::Int,
)::Vector{Int}
(deprecated function)
Returns indices of neighbours of cell with linear index ic
. This function uses the SOLPS grid generation algorithm to determine the neighbours. However, SOLPS geometry file actually provides the neighbor indices directly. Thus, this function is not used in the code anywhere but is kept here for reference.
SOLPS2imas.get_neighbour_inds
— Functionget_neighbour_inds(
ic::Int,
gmtry::Dict{String, Dict{String, Any}},
it::Int,
)::Vector{Int}
Returns indices of neighbours of cell with linear index ic
. This function uses the parsed SOLPS geometry file to determine the neighbours by using matrices named as leftix, rightix, topix, bottomix, leftiy, rightiy, topiy, and bottomiy.
SOLPS2imas.attach_neightbours!
— Functionattach_neightbours!(
cells::IMASdd.IDSvector{IMASdd.edge_profiles__grid_ggd___space___objects_per_dimension___object{T}},
edges::IMASdd.IDSvector{IMASdd.edge_profiles__grid_ggd___space___objects_per_dimension___object{T}},
gmtry::Dict{String, Dict{String, Any}},
it::Int,
) where {T}
This function attaches neighbours to each boundary of each cell and each boundary of each edge using the parsed SOLPS geometry file.
Subset Identification Tools
These functions provide a way to identify if a linear cell index in SOLPS notation belongs to a grid subset.
SOLPS2imas.in_core
— Functionin_core(; ix, iy, topcut, bottomcut, leftcut, rightcut)::Bool
Returns true if cell indexed ix
, iy
lie inside the core.
SOLPS2imas.in_sol
— Functionin_sol(; iy, topcut, kwargs...)::Bool
Returns true if cell indexed ix
, iy
lie inside the SOL.
SOLPS2imas.in_idr
— Functionin_idr(; ix, iy, topcut, bottomcut, leftcut, kwargs...)::Bool
Returns true if cell indexed ix
, iy
lie inside the inner divertor region.
SOLPS2imas.in_odr
— Functionin_odr(; ix, iy, topcut, bottomcut, rightcut, kwargs...)::Bool
Returns true if cell indexed ix
, iy
lie inside the outer divertor region.
SOLPS2imas.is_x_aligned
— Functionis_x_aligned(;boundary_ind)::Bool
x_aligned edges will have odd boundary_ind
based on chosen order of numbering them.
SOLPS2imas.is_y_aligned
— Functionis_y_aligned(; boundary_ind)::Bool
y_aligned edges will have even boundary_ind
based on chosen order of numbering them.
SOLPS2imas.is_core_cut
— Functionis_core_cut(;
ix,
iy,
cells,
nx,
boundary_ind,
topcut,
bottomcut,
leftcut,
rightcut,
)::Bool
Returns true if boundary_ind
of a cell at ix
, iy
is on core_cut (Y-aliged edge).
SOLPS2imas.is_pfr_cut
— Functionis_pfr_cut(;
ix,
iy,
cells,
nx,
boundary_ind,
topcut,
bottomcut,
leftcut,
rightcut,
)::Bool
Returns true if boundary_ind
of a cell at ix
, iy
is on core_cut (y-aliged edge).
SOLPS2imas.is_outer_throat
— Functionis_outer_throat(; ix, iy, boundary_ind, topcut, rightcut, kwargs...)::Bool
Returns true if boundary_ind
of a cell at ix
, iy
is on outer throat.
SOLPS2imas.is_inner_throat
— Functionis_inner_throat(; ix, iy, boundary_ind, topcut, leftcut, kwargs...)::Bool
Returns true if boundary_ind
of a cell at ix
, iy
is on outer throat.
SOLPS2imas.is_outer_midplane
— Functionis_outer_midplane(; ix, jxa, boundary_ind)
Returns true if boundary_ind
of a cell at ix
, iy
is on outer midplane.
SOLPS2imas.is_inner_midplane
— Functionis_inner_midplane(; ix, jxa, boundary_ind)
Returns true if boundary_ind
of a cell at ix
, iy
is on outer midplane.
SOLPS2imas.is_outer_target
— Functionis_outer_target(; ix, nx, boundary_ind)
Returns true if boundary_ind
of a cell at ix
, iy
is on outer target.
SOLPS2imas.is_inner_target
— Functionis_inner_target(; ix, boundary_ind, kwargs...)::Bool
Returns true if boundary_ind
of a cell at ix
, iy
is on inner target.
SOLPS2imas.is_core_boundary
— Functionis_core_boundary(;
ix,
iy,
boundary_ind,
bottomcut,
leftcut,
rightcut,
kwargs...,
)
Returns true if boundary_ind
of a cell at ix
, iy
is on core boundary (central blank spot boundary).
SOLPS2imas.is_separatrix
— Functionis_separatrix(; iy, boundary_ind, topcut, kwargs...)::Bool
Returns true if boundary_ind
of a cell at ix
, iy
is on separatrix.
SOLPS2imas.get_xpoint_nodes
— Functionget_xpoint_nodes(
gmtry::Dict{String, Dict{String, Any}},
)::Vector{Vector{Vector{Float64}}}
Limited to finding first x-point for now. Returns x-point (r, z) for each time index of grid_ggd for the first x-point only. Thus second index correspond to the rank of x-point which is always 1 from output of this function for now.