Skip to content

Commit

Permalink
Merge pull request #41 from ProjectTorreyPines/solps2imas_update
Browse files Browse the repository at this point in the history
Updating use of solp2imas
  • Loading branch information
anchal-physics authored Feb 16, 2024
2 parents ea7308f + 32e649a commit 4114ca1
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 19 deletions.
3 changes: 1 addition & 2 deletions example/demo.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
"source": [
"b2gmtry = \"samples/b2fgmtry\"\n",
"b2output = \"samples/b2time.nc\"\n",
"gsdesc = \"samples/gridspacedesc.yml\"\n",
"b2mn = \"samples/b2mn.dat\""
]
},
Expand All @@ -45,7 +44,7 @@
"metadata": {},
"outputs": [],
"source": [
"ids = SOLPS2IMAS.solps2imas(b2gmtry, b2output, gsdesc, b2mn)"
"ids = SOLPS2IMAS.solps2imas(b2gmtry, b2output; b2mn=b2mn)"
]
},
{
Expand Down
9 changes: 4 additions & 5 deletions src/SD4SOLPS.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ function find_files_in_allowed_folders(
recursive=true,
allow_reduced_versions=false,
)
files = ["b2fgmtry", "b2time.nc", "b2mn.dat", "gridspacedesc.yml", eqdsk_file]
files = ["b2fgmtry", "b2time.nc", "b2mn.dat", eqdsk_file]
reduced_files =
["b2fgmtry_red", "b2time_red.nc", "b2mn.dat", "gridspacedesc.yml", eqdsk_file]
["b2fgmtry_red", "b2time_red.nc", "b2mn.dat", eqdsk_file]
output_files = fill("", length(files))
if recursive
dirs = []
Expand Down Expand Up @@ -262,16 +262,15 @@ function preparation(
filename::String="sd_input_data",
output_format::String="json",
)
b2fgmtry, b2time, b2mn, gridspec, eqdsk =
b2fgmtry, b2time, b2mn, eqdsk =
find_files_in_allowed_folders(dirs...; eqdsk_file=eqdsk_file)
println("Found source files:")
println(" b2fgmtry = ", b2fgmtry)
println(" b2time = ", b2time)
println(" b2mn.dat = ", b2mn)
println(" gridspec = ", gridspec)
println(" eqdsk = ", eqdsk)

dd = SOLPS2IMAS.solps2imas(b2fgmtry, b2time, gridspec, b2mn)
dd = SOLPS2IMAS.solps2imas(b2fgmtry, b2time; b2mn=b2mn)
geqdsk_to_imas!(eqdsk, dd)
println("Loaded input data into IMAS DD")

Expand Down
20 changes: 8 additions & 12 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,11 @@ function define_default_sample_set()
eqdsk_file="thereisntoneyet",
allow_reduced_versions=false,
)
b2fgmtry, b2time, b2mn, gridspec, eqdsk = file_list
b2fgmtry, b2time, b2mn, eqdsk = file_list
eqdsk =
splitdir(pathof(SD4SOLPS))[1] *
"/../sample/ITER_Lore_2296_00000/EQDSK/g002296.00200"
return b2fgmtry, b2time, b2mn, gridspec, eqdsk
return b2fgmtry, b2time, b2mn, eqdsk
end

if args["lightweight_utilities"]
Expand Down Expand Up @@ -173,19 +173,17 @@ if args["core_profile_extension"]

# The full workflow --------------------------------------
# Setup sample DD
b2fgmtry, b2time, b2mn, gridspec, eqdsk = define_default_sample_set()
b2fgmtry, b2time, b2mn, eqdsk = define_default_sample_set()
println(b2fgmtry)
println(b2time)
println(b2mn)
println(gridspec)
println(eqdsk)
# If these files don't exist, complete the DVC sample setup and try again
@test isfile(b2fgmtry)
@test isfile(b2time)
@test isfile(b2mn)
@test isfile(gridspec)
@test isfile(eqdsk)
dd = SOLPS2IMAS.solps2imas(b2fgmtry, b2time, gridspec, b2mn)
dd = SOLPS2IMAS.solps2imas(b2fgmtry, b2time; b2mn=b2mn)
SD4SOLPS.geqdsk_to_imas!(eqdsk, dd)
rho = dd.equilibrium.time_slice[1].profiles_1d.rho_tor_norm

Expand Down Expand Up @@ -220,8 +218,8 @@ end
if args["edge_profile_extension"]
@testset "edge_profile_extension" begin
# Test for getting mesh spacing
b2fgmtry, b2time, b2mn, gridspec, eqdsk = define_default_sample_set()
dd = SOLPS2IMAS.solps2imas(b2fgmtry, b2time, gridspec, b2mn)
b2fgmtry, b2time, b2mn, eqdsk = define_default_sample_set()
dd = SOLPS2IMAS.solps2imas(b2fgmtry, b2time; b2mn=b2mn)
SD4SOLPS.geqdsk_to_imas!(eqdsk, dd)
dpsin = SD4SOLPS.mesh_psi_spacing(dd)
@test dpsin > 0.0
Expand Down Expand Up @@ -280,16 +278,14 @@ if args["heavy_utilities"]
file_list = SD4SOLPS.find_files_in_allowed_folders(
sample_path; eqdsk_file="thereisntoneyet", allow_reduced_versions=true,
)
@test length(file_list) == 5
b2fgmtry, b2time, b2mn, gridspec, eqdsk = file_list
@test length(file_list) == 4
b2fgmtry, b2time, b2mn, eqdsk = file_list
@test length(b2fgmtry) > 10
@test endswith(b2fgmtry, "b2fgmtry_red") | endswith(b2fgmtry, "b2fgmtry")
@test length(b2time) > 10
@test endswith(b2time, "b2time_red.nc") | endswith(b2time, "b2time.nc")
@test length(b2mn) > 10
@test endswith(b2mn, "b2mn.dat")
@test length(gridspec) > 10
@test endswith(gridspec, "gridspacedesc.yml")

# Test for sweeping 1D core profiles into 2D R,Z
# (or anyway evaluating them at any R,Z location)
Expand Down

0 comments on commit 4114ca1

Please sign in to comment.