Skip to content

Commit

Permalink
Merge pull request #26 from ProjectTorreyPines/dep_update
Browse files Browse the repository at this point in the history
SOLPS2IMAS dependecy removed.

Simple PR, so merging without review.
  • Loading branch information
anchal-physics authored Nov 7, 2023
2 parents 67a41ac + b38075e commit 9f09158
Show file tree
Hide file tree
Showing 10 changed files with 41 additions and 277 deletions.
1 change: 0 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ Interpolations = "a98d9a8b-a2ab-59e6-89dd-64a1c18fca59"
NearestNeighbors = "b8a86587-4115-5ab1-83bc-aa920d37bbce"
OMAS = "91cfaa06-6526-4804-8666-b540b3feef2f"
RecipesBase = "3cdcf5f2-1ef4-517c-9805-6587b60abb01"
SOLPS2IMAS = "09becab6-0636-4c23-a92a-2b3723265c31"
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
5 changes: 1 addition & 4 deletions samples/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
/edge_profiles.h5
/b2time.nc
/b2mn.dat
/b2fgmtry
/time_dep_edge_profiles_last_step_only.json
12 changes: 0 additions & 12 deletions samples/b2fgmtry.dvc

This file was deleted.

12 changes: 0 additions & 12 deletions samples/b2mn.dat.dvc

This file was deleted.

13 changes: 0 additions & 13 deletions samples/b2time.nc.dvc

This file was deleted.

Binary file removed samples/b2time_red.nc
Binary file not shown.
12 changes: 0 additions & 12 deletions samples/edge_profiles.h5.dvc

This file was deleted.

196 changes: 0 additions & 196 deletions samples/gridspacedesc.yml

This file was deleted.

12 changes: 12 additions & 0 deletions samples/time_dep_edge_profiles_last_step_only.json.dvc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
md5: 3ea764e4095ca2b8a5359cd76259e26a
frozen: true
deps:
- path: ITER_Lore_2296_00000/IMAS/time_dep_edge_profiles_last_step_only.json
repo:
url: [email protected]:ProjectTorreyPines/SOLPSTestSamples.git
rev_lock: 88f14955a52cd4d4fd7e86e2274436a34f4203ec
outs:
- md5: db47dee590648770a5ce49c0e0706acf
size: 4087084
hash: md5
path: time_dep_edge_profiles_last_step_only.json
55 changes: 28 additions & 27 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import GGDUtils: interp, get_kdtree, project_prop_on_subset!, get_grid_subset_with_index
import OMAS: h5i2imas
import OMAS: json2imas
import Statistics: mean
import SOLPS2IMAS: solps2imas
using Test
using ArgParse: ArgParse

Expand Down Expand Up @@ -34,14 +33,18 @@ function parse_commandline()
end
args = parse_commandline()

print("json2imas() time: ")
@time ids = json2imas(
"$(@__DIR__)/../samples/time_dep_edge_profiles_last_step_only.json",
)

if args["interp"]
@testset "interp" begin
# ids = h5i2imas("$(@__DIR__)/../samples/edge_profiles.h5")
b2gmtry = "$(@__DIR__)/../samples/b2fgmtry"
b2output = "$(@__DIR__)/../samples/b2time.nc"
gsdesc = "$(@__DIR__)/../samples/gridspacedesc.yml"
b2mn = "$(@__DIR__)/../samples/b2mn.dat"
ids = solps2imas(b2gmtry, b2output, gsdesc, b2mn)
n_e = ids.edge_profiles.ggd[1].electrons.density[1]
grid_ggd = ids.edge_profiles.grid_ggd[1]
space = grid_ggd.space[1]
Expand All @@ -54,7 +57,8 @@ if args["interp"]
grid_val = ids.edge_profiles.ggd[1].electrons.density[1].values[chosen_index]

# test interp(prop, grid_ggd)
get_n_e = interp(n_e, grid_ggd)
print("interp(prop, grid_ggd) time: ")
@time get_n_e = interp(n_e, grid_ggd)
searched_val = get_n_e(cell_center...)
println("Electron density at: ", cell_center)
println("Grid Value: ", grid_val)
Expand All @@ -63,21 +67,26 @@ if args["interp"]

# test interp(prop_arr, space, subset)
subset = get_grid_subset_with_index(grid_ggd, 5)
get_n_e = interp(ids.edge_profiles.ggd[1].electrons.density, space, subset)
print("interp(prop_arr, space, subset) time: ")
@time get_n_e =
interp(ids.edge_profiles.ggd[1].electrons.density, space, subset)
searched_val = get_n_e(cell_center...)
@test abs.((grid_val .- searched_val) ./ grid_val) < allowed_rtol

# test interp(prop_arr, grid_ggd, grid_subset_index)
get_n_e = interp(ids.edge_profiles.ggd[1].electrons.density, grid_ggd, 5)
print("interp(prop_arr, grid_ggd, grid_subset_index) time: ")
@time get_n_e = interp(ids.edge_profiles.ggd[1].electrons.density, grid_ggd, 5)
searched_val = get_n_e(cell_center...)
@test abs.((grid_val .- searched_val) ./ grid_val) < allowed_rtol

# Use the kdtree to interpolate several quantities using
# inverse distance weighing
kdtree = get_kdtree(space)
get_T_e =
print("interp(prop_arr, kdtree) time: ")
@time get_T_e =
interp(ids.edge_profiles.ggd[1].electrons.temperature[1].values, kdtree)
get_n_e = interp(ids.edge_profiles.ggd[1].electrons.density[1].values, kdtree)
@time get_n_e =
interp(ids.edge_profiles.ggd[1].electrons.density[1].values, kdtree)

grid_val =
ids.edge_profiles.ggd[1].electrons.temperature[1].values[chosen_index]
Expand Down Expand Up @@ -116,27 +125,24 @@ end

if args["projection"]
@testset "project_prop_on_subset!" begin
b2gmtry = "$(@__DIR__)/../samples/b2fgmtry"
b2output = "$(@__DIR__)/../samples/b2time.nc"
gsdesc = "$(@__DIR__)/../samples/gridspacedesc.yml"
b2mn = "$(@__DIR__)/../samples/b2mn.dat"
dd = solps2imas(b2gmtry, b2output, gsdesc, b2mn)
space = dd.edge_profiles.grid_ggd[1].space[1]
prop = dd.edge_profiles.ggd[1].electrons.density
space = ids.edge_profiles.grid_ggd[1].space[1]
prop = ids.edge_profiles.ggd[1].electrons.density
# All cells
from_subset = get_grid_subset_with_index(dd.edge_profiles.grid_ggd[1], 5)
kdtree = get_kdtree(space, from_subset)
from_subset = get_grid_subset_with_index(ids.edge_profiles.grid_ggd[1], 5)
# separatix
to_subset = get_grid_subset_with_index(dd.edge_profiles.grid_ggd[1], 16)
separatix_centers, values_at_separatix =
to_subset = get_grid_subset_with_index(ids.edge_profiles.grid_ggd[1], 16)
print("project_prop_on_subset!(prop, from_subset, to_subset, space) time: ")
@time separatix_centers, values_at_separatix =
project_prop_on_subset!(prop, from_subset, to_subset, space)
# println("Projected to separatix:")
# for ii ∈ eachindex(separatix_centers)
# println(separatix_centers[ii], ": ", values_at_separatix[ii])
# end

subset_core = get_grid_subset_with_index(dd.edge_profiles.grid_ggd[1], 22)
core_element_inds, values_at_core =
subset_core =
get_grid_subset_with_index(ids.edge_profiles.grid_ggd[1], 22)
print("project_prop_on_subset!(prop, from_subset, subset_core) time: ")
@time core_element_inds, values_at_core =
project_prop_on_subset!(prop, from_subset, subset_core)
# println("Project to core:")
# for ii ∈ eachindex(core_element_inds)
Expand All @@ -153,12 +159,7 @@ end

if args["in"]
@testset "test ∈" begin
b2gmtry = "$(@__DIR__)/../samples/b2fgmtry"
b2output = "$(@__DIR__)/../samples/b2time.nc"
gsdesc = "$(@__DIR__)/../samples/gridspacedesc.yml"
b2mn = "$(@__DIR__)/../samples/b2mn.dat"
dd = solps2imas(b2gmtry, b2output, gsdesc, b2mn)
grid_ggd = dd.edge_profiles.grid_ggd[1]
grid_ggd = ids.edge_profiles.grid_ggd[1]
space = grid_ggd.space[1]
subset_corebnd = get_grid_subset_with_index(grid_ggd, 15)
subset_sol = get_grid_subset_with_index(grid_ggd, 23)
Expand Down

0 comments on commit 9f09158

Please sign in to comment.