From 057c8d17e04b62e7cc41a5b8e439da867ff6038a Mon Sep 17 00:00:00 2001 From: Anchal Gupta Date: Wed, 20 Mar 2024 14:50:44 -0700 Subject: [PATCH] Replacing OMAS with IMASDD everywhere 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: https://github.com/ProjectTorreyPines/GGDUtils.jl/commit/b11ad1581718a7bf4a50c2551b2a2a7b84a3394e SOLPS2IMAS: https://github.com/ProjectTorreyPines/SOLPS2IMAS.jl/commit/f843e6a64ccd597e0eb77ab4f953c922614d99e4 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. --- Project.toml | 2 +- makefile | 6 +++--- src/SD4SOLPS.jl | 4 ++-- src/repair_eq.jl | 6 +++--- src/supersize_profile.jl | 30 +++++++++++++++--------------- test/runtests.jl | 8 ++++---- 6 files changed, 28 insertions(+), 28 deletions(-) diff --git a/Project.toml b/Project.toml index a3e1890..889b1db 100644 --- a/Project.toml +++ b/Project.toml @@ -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" diff --git a/makefile b/makefile index 53b0b8f..0e366bd 100644 --- a/makefile +++ b/makefile @@ -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" diff --git a/src/SD4SOLPS.jl b/src/SD4SOLPS.jl index ae713b3..129ce90 100644 --- a/src/SD4SOLPS.jl +++ b/src/SD4SOLPS.jl @@ -1,6 +1,6 @@ module SD4SOLPS -using OMAS: OMAS +using IMASDD: IMASDD using SOLPS2IMAS: SOLPS2IMAS using EFIT: EFIT using Interpolations: Interpolations @@ -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 diff --git a/src/repair_eq.jl b/src/repair_eq.jl index 54e7937..ead09f8 100644 --- a/src/repair_eq.jl +++ b/src/repair_eq.jl @@ -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 @@ -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") diff --git a/src/supersize_profile.jl b/src/supersize_profile.jl index 703084a..651871f 100644 --- a/src/supersize_profile.jl +++ b/src/supersize_profile.jl @@ -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_with_index, add_subset_element!, get_subset_boundary, @@ -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 @@ -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, @@ -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. @@ -126,7 +126,7 @@ space_idx: index of the space to use. For a typical SOLPS run, there will be onl """ #!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, @@ -295,7 +295,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 @@ -311,7 +311,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, @@ -341,7 +341,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, @@ -412,7 +412,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, @@ -548,7 +548,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)) @@ -591,7 +591,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}, ) @@ -868,7 +868,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, @@ -937,7 +937,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, @@ -984,13 +984,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, diff --git a/test/runtests.jl b/test/runtests.jl index a8296e3..c9246a3 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,6 +1,6 @@ using SD4SOLPS: SD4SOLPS using SOLPS2IMAS: SOLPS2IMAS -using OMAS: OMAS +using IMASDD: IMASDD using EFIT: EFIT using Plots using Test @@ -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) @@ -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 @@ -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]