Skip to content

Commit

Permalink
Replacing OMAS with IMASDD everywhere
Browse files Browse the repository at this point in the history
Tested this but got following error:
```
(base) gupta@F-CJXNMY7L7 SD4SOLPS.jl % julia --project test/runtests.jl
Test Summary:         | Pass  Total  Time
lightweight_utilities |    4      4  1.0s
Test Summary: | Pass  Total  Time
actuator      |    2      2  1.7s
core_profile_extension: Error During Test at /Users/gupta/Git/ProjectTorreyPines/SD4SOLPS.jl/test/runtests.jl:166
  Got exception outside of a @test
  UndefVarError: `gradient` not defined
  Stacktrace:
   [1] extrapolate_core(edge_rho::Vector{Float64}, edge_quantity::Vector{Float64}, rho_output::Vector{Float64})
     @ SD4SOLPS ~/Git/ProjectTorreyPines/SD4SOLPS.jl/src/supersize_profile.jl:58
   [2] macro expansion
     @ ~/Git/ProjectTorreyPines/SD4SOLPS.jl/test/runtests.jl:171 [inlined]
   [3] macro expansion
     @ /Applications/Julia-1.9.app/Contents/Resources/julia/share/julia/stdlib/v1.9/Test/src/Test.jl:1498 [inlined]
   [4] top-level scope
     @ ~/Git/ProjectTorreyPines/SD4SOLPS.jl/test/runtests.jl:168
   [5] include(mod::Module, _path::String)
     @ Base ./Base.jl:457
   [6] exec_options(opts::Base.JLOptions)
     @ Base ./client.jl:307
   [7] _start()
     @ Base ./client.jl:522
Test Summary:          | Error  Total  Time
core_profile_extension |     1      1  0.5s
ERROR: LoadError: Some tests did not pass: 0 passed, 0 failed, 1 errored, 0 broken.
in expression starting at /Users/gupta/Git/ProjectTorreyPines/SD4SOLPS.jl/test/runtests.jl:165
```

For testing, following versions of the pacjages were used (these are the points where IMASDD was used instead of OMAS):
GGDUtils: ProjectTorreyPines/IMASggd.jl@b11ad15
SOLPS2IMAS: ProjectTorreyPines/SOLPS2imas.jl@f843e6a

The main issue is that OMAS.gradient() function is defined in https://github.com/ProjectTorreyPines/OMAS.jl/blob/master/src/math.jl
but no such function exists in IMASDD.
  • Loading branch information
anchal-physics committed Mar 23, 2024
1 parent 570cf41 commit 3597a61
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 28 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ ArgParse = "c7e460c6-2fb9-53a9-8c5b-16f535851c63"
Contour = "d38c429a-6771-53c6-b99e-75d170b6e991"
EFIT = "cda752c5-6b03-55a3-9e33-132a441b0c17"
GGDUtils = "b7b5e640-9b39-4803-84eb-376048795def"
IMASDD = "06b86afa-9f21-11ec-2ef8-e51b8960cfc5"
Interpolations = "a98d9a8b-a2ab-59e6-89dd-64a1c18fca59"
JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
OMAS = "91cfaa06-6526-4804-8666-b540b3feef2f"
PhysicalConstants = "5ad8b20f-a522-5ce9-bfc9-ddf1d5bda6ab"
PlotUtils = "995b91a9-d308-5afd-9ec6-746e21dbc043"
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
Expand Down
6 changes: 3 additions & 3 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@ env_with_cloned_repo r:
@echo "Cloning the repositories and generating Manifest.toml"
-dn=$(shell dirname $(shell pwd)); \
if [[ "$${dn:(-10)}" == ".julia/dev" ]]; then ext="" ; else ext=".jl";fi; \
git clone "git@github.com:ProjectTorreyPines/OMAS.jl.git" ../OMAS$${ext}; \
git clone "git@github.com:ProjectTorreyPines/IMASDD.jl.git" ../IMASDD$${ext}; \
git clone "git@github.com:ProjectTorreyPines/GGDUtils.jl.git" ../GGDUtils$${ext}; \
git clone "git@github.com:ProjectTorreyPines/SOLPS2IMAS.jl.git" ../SOLPS2IMAS$${ext}; \
julia --project=. -e 'using Pkg; Pkg.rm(["OMAS", "GGDUtils", "SOLPS2IMAS", "EFIT"]); Pkg.develop(path="../OMAS'$${ext}'"); Pkg.develop(path="../GGDUtils'$${ext}'"); Pkg.develop(path="../SOLPS2IMAS'$${ext}'"); Pkg.add(url="git@github.com:JuliaFusion/EFIT.jl.git", rev="master"); Pkg.instantiate()'
julia --project=. -e 'using Pkg; Pkg.rm(["IMASDD", "GGDUtils", "SOLPS2IMAS", "EFIT"]); Pkg.develop(path="../IMASDD'$${ext}'"); Pkg.develop(path="../GGDUtils'$${ext}'"); Pkg.develop(path="../SOLPS2IMAS'$${ext}'"); Pkg.add(url="git@github.com:JuliaFusion/EFIT.jl.git", rev="master"); Pkg.instantiate()'

env_with_git_url u:
@echo "Pulling sample files using dvc"
-dvc pull
@echo "Creating Julia environment with the git urls without creating local clones"
@echo "Generating Project.toml and Manifest.toml"
julia --project=. -e 'using Pkg; Pkg.rm(["OMAS", "GGDUtils", "SOLPS2IMAS", "EFIT"]); Pkg.add(url="git@github.com:ProjectTorreyPines/OMAS.jl.git", rev="master"); Pkg.add(url="git@github.com:ProjectTorreyPines/GGDUtils.jl.git", rev="master"); Pkg.add(url="git@github.com:ProjectTorreyPines/SOLPS2IMAS.jl.git", rev="master"); Pkg.add(url="git@github.com:JuliaFusion/EFIT.jl.git", rev="master"); Pkg.instantiate()'
julia --project=. -e 'using Pkg; Pkg.rm(["IMASDD", "GGDUtils", "SOLPS2IMAS", "EFIT"]); Pkg.add(url="git@github.com:ProjectTorreyPines/IMASDD.jl.git", rev="master"); Pkg.add(url="git@github.com:ProjectTorreyPines/GGDUtils.jl.git", rev="master"); Pkg.add(url="git@github.com:ProjectTorreyPines/SOLPS2IMAS.jl.git", rev="master"); Pkg.add(url="git@github.com:JuliaFusion/EFIT.jl.git", rev="master"); Pkg.instantiate()'

clean:
@echo "Deleting Manifest.toml"
Expand Down
4 changes: 2 additions & 2 deletions src/SD4SOLPS.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module SD4SOLPS

using OMAS: OMAS
using IMASDD: IMASDD
using SOLPS2IMAS: SOLPS2IMAS
using EFIT: EFIT
using Interpolations: Interpolations
Expand Down Expand Up @@ -287,7 +287,7 @@ function preparation(
println("Extrapolated edge profiles (but not really (placeholder only))")

if output_format == "json"
OMAS.imas2json(dd, filename * ".json")
IMASDD.imas2json(dd, filename * ".json")
else
throw(ArgumentError(string("Unrecognized output format: ", output_format)))
end
Expand Down
6 changes: 3 additions & 3 deletions src/repair_eq.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export check_rho_1d
Checks to see if rho exists and is valid in the equilibrium 1d profiles
"""
function check_rho_1d(dd::OMAS.dd; time_slice::Int64=1, throw_on_fail::Bool=false)
function check_rho_1d(dd::IMASDD.dd; time_slice::Int64=1, throw_on_fail::Bool=false)
rho = dd.equilibrium.time_slice[time_slice].profiles_1d.rho_tor_norm
if length(rho) < 1
rho_okay = false
Expand Down Expand Up @@ -48,11 +48,11 @@ function check_rho_1d(dd::OMAS.dd; time_slice::Int64=1, throw_on_fail::Bool=fals
end

"""
function add_rho_to_equilibrium(dd:OMAS.dd)
function add_rho_to_equilibrium(dd:IMASDD.dd)
Adds equilibrium rho profile to the DD
"""
function add_rho_to_equilibrium!(dd::OMAS.dd)
function add_rho_to_equilibrium!(dd::IMASDD.dd)
nt = length(dd.equilibrium.time_slice)
if nt < 1
println("No equilibrium time slices to work with; can't add rho")
Expand Down
30 changes: 15 additions & 15 deletions src/supersize_profile.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Utilities for extrapolating profiles
"""

# import CalculusWithJulia
using OMAS: OMAS
using IMASDD: IMASDD
using Interpolations: Interpolations
using GGDUtils:
GGDUtils, get_grid_subset, add_subset_element!, get_subset_boundary,
Expand Down Expand Up @@ -55,7 +55,7 @@ Concept:
integrate it to get the profile of the quantity in question
"""
function extrapolate_core(edge_rho, edge_quantity, rho_output)
grad = OMAS.gradient(edge_rho, edge_quantity)
grad = IMASDD.gradient(edge_rho, edge_quantity)
gf = grad[1]
rf = edge_rho[1]
gmid = -abs(gf) / 4.0
Expand Down Expand Up @@ -92,7 +92,7 @@ end
#!format off
"""
fill_in_extrapolated_core_profile!(
dd::OMAS.dd,
dd::IMASDD.dd,
quantity_name::String;
method::String="simple",
eq_time_idx::Int64=1,
Expand All @@ -108,7 +108,7 @@ edge_profiles data to rho, calls the function that performs the extrapolation (w
not a simple linear extrapolation but has some trickery to attempt to make a somewhat
convincing profile shape), and writes the result to core_profiles. This involves a bunch
of interpolations and stuff.
dd: an IMAS/OMAS data dictionary
dd: an IMAS data dictionary
quantity_name: the name of a quantity in edge_profiles.profiles_2d and
core_profiles.profiles_1d, such as "electrons.density"
method: Extrapolation method.
Expand All @@ -130,7 +130,7 @@ cell_subset_idx: index of the subset of cells to use for the extrapolation. The
"""
#!format on
function fill_in_extrapolated_core_profile!(
dd::OMAS.dd,
dd::IMASDD.dd,
quantity_name::String;
method::String="simple",
eq_time_idx::Int64=1,
Expand Down Expand Up @@ -300,7 +300,7 @@ Returns:
- normalized poloidal flux on the equilibrium grid
- a linear interpolation of norm pol flux vs. R and Z, ready to be evaluated
"""
function prep_flux_map(dd::OMAS.dd; eq_time_idx::Int64=1, eq_profiles_2d_idx::Int64=1)
function prep_flux_map(dd::IMASDD.dd; eq_time_idx::Int64=1, eq_profiles_2d_idx::Int64=1)
eqt = dd.equilibrium.time_slice[eq_time_idx]
p2 = eqt.profiles_2d[eq_profiles_2d_idx]
r_eq = p2.grid.dim1
Expand All @@ -316,7 +316,7 @@ end
#! format off
"""
mesh_psi_spacing(
dd::OMAS.dd;
dd::IMASDD.dd;
eq_time_idx::Int64=1,
eq_profiles_2d_idx::Int64=1,
grid_ggd_idx::Int64=1,
Expand Down Expand Up @@ -346,7 +346,7 @@ spacing_rule: "edge" or "mean" to make spacing of new cells (in psi_N) be the sa
"""
#! format on
function mesh_psi_spacing(
dd::OMAS.dd;
dd::IMASDD.dd;
eq_time_idx::Int64=1,
eq_profiles_2d_idx::Int64=1,
grid_ggd_idx::Int64=1,
Expand Down Expand Up @@ -417,7 +417,7 @@ out to the most distant (in flux space) point on the limiting surface.
Returns a vector of psi_N levels.
"""
function pick_extension_psi_range(
dd::OMAS.dd;
dd::IMASDD.dd;
eq_time_idx::Int64=1,
eq_profiles_2d_idx::Int64=1,
grid_ggd_idx::Int64=1,
Expand Down Expand Up @@ -553,7 +553,7 @@ function mesh_ext_follow_grad(
end

# Step along the paths of steepest descent to populate the mesh.
dpsindr, dpsindz = OMAS.gradient(r_eq, z_eq, psin_eq)
dpsindr, dpsindz = IMASDD.gradient(r_eq, z_eq, psin_eq)
dpdr = Interpolations.linear_interpolation((r_eq, z_eq), dpsindr)
dpdz = Interpolations.linear_interpolation((r_eq, z_eq), dpsindz)
rlim = (minimum(r_eq), maximum(r_eq))
Expand Down Expand Up @@ -596,7 +596,7 @@ mesh_r: matrix of R values for the extended mesh
mesh_z: matrix of Z values for the extended mesh
"""
function modify_mesh_ext_near_x!(
eqt::OMAS.equilibrium__time_slice,
eqt::IMASDD.equilibrium__time_slice,
mesh_r::Matrix{Float64},
mesh_z::Matrix{Float64},
)
Expand Down Expand Up @@ -873,7 +873,7 @@ clear_cache: delete any existing cache file (for use in testing)
"""
#!format on
function cached_mesh_extension!(
dd::OMAS.dd,
dd::IMASDD.dd,
eqdsk_file::String,
b2fgmtry::String;
eq_time_idx::Int64=1,
Expand Down Expand Up @@ -942,7 +942,7 @@ end
Extends the mesh out into the SOL
"""
function mesh_extension_sol!(
dd::OMAS.dd;
dd::IMASDD.dd;
eq_time_idx::Int64=1,
eq_profiles_2d_idx::Int64=1,
grid_ggd_idx::Int64=1,
Expand Down Expand Up @@ -989,13 +989,13 @@ end

"""
fill_in_extrapolated_edge_profile!(
dd::OMAS.dd, quantity_name::String; method::String="simple",
dd::IMASDD.dd, quantity_name::String; method::String="simple",
)
JUST A PLACEHOLDER FOR NOW. DOESN'T ACTUALLY WORK YET.
"""
function fill_in_extrapolated_edge_profile!(
dd::OMAS.dd,
dd::IMASDD.dd,
quantity_name::String;
method::String="simple",
eq_time_idx::Int64=1,
Expand Down
8 changes: 4 additions & 4 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using SD4SOLPS: SD4SOLPS
using SOLPS2IMAS: SOLPS2IMAS
using OMAS: OMAS
using IMASDD: IMASDD
using EFIT: EFIT
using Plots
using Test
Expand Down Expand Up @@ -289,7 +289,7 @@ if args["heavy_utilities"]

# Test for sweeping 1D core profiles into 2D R,Z
# (or anyway evaluating them at any R,Z location)
dd = OMAS.dd()
dd = IMASDD.dd()
eqdsk_file =
splitdir(pathof(SD4SOLPS))[1] * "/../sample/geqdsk_iter_small_sample"
SD4SOLPS.geqdsk_to_imas!(eqdsk_file, dd)
Expand Down Expand Up @@ -323,7 +323,7 @@ end
if args["repair_eq"]
@testset "repair_eq" begin
# Prepare sample
dd = OMAS.dd()
dd = IMASDD.dd()
eqdsk = splitdir(pathof(SD4SOLPS))[1] * "/../sample/geqdsk_iter_small_sample"
SD4SOLPS.geqdsk_to_imas!(eqdsk, dd)
# Make sure rho is missing
Expand Down Expand Up @@ -355,7 +355,7 @@ if args["geqdsk_to_imas"]
tslice = 1
for sample_file sample_files
println(sample_file)
dd = OMAS.dd()
dd = IMASDD.dd()
SD4SOLPS.geqdsk_to_imas!(sample_file, dd; time_index=tslice)
eqt = dd.equilibrium.time_slice[tslice]

Expand Down

0 comments on commit 3597a61

Please sign in to comment.