Skip to content

Commit

Permalink
Merge pull request #43 from ProjectTorreyPines/bb
Browse files Browse the repository at this point in the history
Fix reading mag field data from b2fgmtry, on by default, add test
  • Loading branch information
anchal-physics authored Jul 23, 2024
2 parents 4134835 + d5e8fba commit dc5bff7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/SOLPS2IMAS.jl
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ function solps2imas(
fort::Tuple{String, String, String}=("", "", ""),
fort_tol::Float64=1e-6,
b2_parameters::Tuple{String, String, String, String}=("", "", "", ""),
load_bb::Bool=false,
load_bb::Bool=true,
)::IMASDD.dd
# Initialize an empty IMAS data structre
ids = IMASDD.dd()
Expand Down Expand Up @@ -765,9 +765,9 @@ function solps2imas(
b_z.grid_index =
b_r.grid_index = b_t.grid_index = gsdesc["identifier"]["index"]
b_z.grid_subset_index = b_r.grid_subset_index = b_t.grid_subset_index = 5
resize!(b_z.values, ncell)
resize!(b_r.values, ncell)
resize!(b_t.values, ncell)
b_z.values = zeros(ncell)
b_r.values = zeros(ncell)
b_t.values = zeros(ncell)
for iy 1:ny
for ix 1:nx
ic::Int = (iy - 1) * nx + ix
Expand Down
11 changes: 10 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ if args["solps2imas"]
b2t = SOLPS2IMAS.read_b2_output(b2output)
nx = b2t["dim"]["nx"]
print("solps2imas() time: ")
@time dd = SOLPS2IMAS.solps2imas(b2gmtry, b2output; b2mn=b2mn)
@time dd = SOLPS2IMAS.solps2imas(b2gmtry, b2output; b2mn=b2mn, load_bb=false)
# Check time stamp 3 at iy=4, ix=5
it = 3
iy = 4
Expand Down Expand Up @@ -211,6 +211,15 @@ if args["solps2imas"]
@test Set(brute_force_pfrcut_list) == Set(subset_pfrcut_element_list)
@test Set(brute_force_corebnd_list) == Set(subset_corebnd_element_list)
@test Set(brute_force_separatrix_list) == Set(subset_separatrix_element_list)

# Test loading of magnetic field data from b2fgmtry to equilibrium IDS
@time ddbb = SOLPS2IMAS.solps2imas(b2gmtry, b2output; b2mn=b2mn, load_bb=true)
btor = ddbb.equilibrium.time_slice[1].ggd[1].b_field_tor[1].values
bz = ddbb.equilibrium.time_slice[1].ggd[1].b_field_z[1].values
br = ddbb.equilibrium.time_slice[1].ggd[1].b_field_r[1].values
@test length(btor) == (nx * ny)
@test length(bz) == length(btor)
@test length(br) == length(bz)
end
end

Expand Down

0 comments on commit dc5bff7

Please sign in to comment.