diff --git a/.github/workflows/format_check.yml b/.github/workflows/format_check.yml index eb8e7a3..39a9507 100644 --- a/.github/workflows/format_check.yml +++ b/.github/workflows/format_check.yml @@ -16,8 +16,8 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - julia-version: [1.9.3] - julia-arch: [x86] + julia-version: [1.x] + julia-arch: [x64] os: [ubuntu-latest] steps: - uses: julia-actions/setup-julia@latest diff --git a/.github/workflows/make_docs.yml b/.github/workflows/make_docs.yml index 81d4374..c664939 100644 --- a/.github/workflows/make_docs.yml +++ b/.github/workflows/make_docs.yml @@ -4,7 +4,7 @@ on: branches: ["master", "dev"] paths: - '.github/workflows/make_docs.yml' - - 'src/' + - 'src/**' - 'docs/**' push: branches: @@ -13,7 +13,7 @@ on: - docs paths: - '.github/workflows/make_docs.yml' - - 'src/' + - 'src/**' - 'docs/**' tags: '*' workflow_dispatch: @@ -25,7 +25,12 @@ jobs: contents: write statuses: write name: Documentation - runs-on: ubuntu-latest + runs-on: ${{ matrix.os }} + strategy: + matrix: + julia-version: [1.x] + julia-arch: [x64] + os: [ubuntu-latest] steps: - uses: actions/checkout@v4 - uses: julia-actions/setup-julia@latest @@ -36,7 +41,7 @@ jobs: id: extract_branch - name: Install dependencies run: | - julia --project=docs/ -e 'using Pkg; Pkg.add(; url="https://github.com/ProjectTorreyPines/IMASDD.jl.git"); Pkg.add(; url="https://github.com/ProjectTorreyPines/GGDUtils.jl.git", rev="${{ steps.extract_branch.outputs.branch }}"); Pkg.add(; url="https://github.com/ProjectTorreyPines/SOLPS2IMAS.jl.git", rev="${{ steps.extract_branch.outputs.branch }}"); Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate()' + julia --project=docs/ -e 'using Pkg; Pkg.add(; url="https://github.com/ProjectTorreyPines/IMASDD.jl.git"); Pkg.add(; url="https://github.com/ProjectTorreyPines/Fortran90Namelists.jl.git"); Pkg.add(; url="https://github.com/ProjectTorreyPines/GGDUtils.jl.git", rev="${{ steps.extract_branch.outputs.branch }}"); Pkg.add(; url="https://github.com/ProjectTorreyPines/SOLPS2IMAS.jl.git", rev="${{ steps.extract_branch.outputs.branch }}"); Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate()' - name: Build and deploy env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b47058c..52ffbaf 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -5,21 +5,21 @@ on: branches: ["master", "dev", "autotest"] paths: - '.github/workflows/test.yml' - - 'src/' - - 'test/' + - 'src/**' + - 'test/**' pull_request: branches: ["master", "dev"] paths: - '.github/workflows/test.yml' - - 'src/' - - 'test/' + - 'src/**' + - 'test/**' jobs: test: runs-on: ${{ matrix.os }} strategy: matrix: - julia-version: [1.9.3] - julia-arch: [x86] + julia-version: [1.x] + julia-arch: [x64] os: [ubuntu-latest] steps: - uses: julia-actions/setup-julia@latest @@ -46,7 +46,7 @@ jobs: id: extract_branch - name: Install dependencies run: | - julia --project=. -e 'using Pkg; Pkg.rm(["IMASDD", "GGDUtils", "SOLPS2IMAS", "EFIT"]); Pkg.add(; url="https://github.com/ProjectTorreyPines/IMASDD.jl.git"); Pkg.add(; url="https://github.com/ProjectTorreyPines/GGDUtils.jl.git", rev="${{ steps.extract_branch.outputs.branch }}"); Pkg.add(; url="https://github.com/ProjectTorreyPines/SOLPS2IMAS.jl.git", rev="${{ steps.extract_branch.outputs.branch }}"); Pkg.add(; url="https://github.com/JuliaFusion/EFIT.jl.git")' + julia --project=. -e 'using Pkg; Pkg.rm(["IMASDD", "Fortran90Namelists", "GGDUtils", "SOLPS2IMAS", "EFIT"]); Pkg.add(; url="https://github.com/ProjectTorreyPines/IMASDD.jl.git"); Pkg.add(; url="https://github.com/ProjectTorreyPines/Fortran90Namelists.jl.git"); Pkg.add(; url="https://github.com/ProjectTorreyPines/GGDUtils.jl.git", rev="${{ steps.extract_branch.outputs.branch }}"); Pkg.add(; url="https://github.com/ProjectTorreyPines/SOLPS2IMAS.jl.git", rev="${{ steps.extract_branch.outputs.branch }}"); Pkg.add(; url="https://github.com/JuliaFusion/EFIT.jl.git")' - uses: julia-actions/julia-runtest@v1 # Not set up yet # - uses: julia-actions/julia-processcoverage@v1 diff --git a/Project.toml b/Project.toml index ba9502f..84bb0d6 100644 --- a/Project.toml +++ b/Project.toml @@ -7,6 +7,7 @@ version = "1.0.0" ArgParse = "c7e460c6-2fb9-53a9-8c5b-16f535851c63" Contour = "d38c429a-6771-53c6-b99e-75d170b6e991" EFIT = "cda752c5-6b03-55a3-9e33-132a441b0c17" +Fortran90Namelists = "8fb689aa-71ff-4044-8071-0cffc910b57d" GGDUtils = "b7b5e640-9b39-4803-84eb-376048795def" IMASDD = "06b86afa-9f21-11ec-2ef8-e51b8960cfc5" Interpolations = "a98d9a8b-a2ab-59e6-89dd-64a1c18fca59" diff --git a/makefile b/makefile index e124ea4..385bb5e 100644 --- a/makefile +++ b/makefile @@ -15,14 +15,15 @@ env_with_cloned_repo r: -git clone "git@github.com:ProjectTorreyPines/IMASDD.jl.git" ../IMASDD; \ git clone "git@github.com:ProjectTorreyPines/GGDUtils.jl.git" ../GGDUtils; \ git clone "git@github.com:ProjectTorreyPines/SOLPS2IMAS.jl.git" ../SOLPS2IMAS; \ - julia --project=. -e 'using Pkg; Pkg.rm(["IMASDD", "GGDUtils", "SOLPS2IMAS", "EFIT"]); Pkg.develop(path="../IMASDD"); Pkg.develop(path="../GGDUtils"); Pkg.develop(path="../SOLPS2IMAS"); Pkg.add(url="git@github.com:JuliaFusion/EFIT.jl.git", rev="master"); Pkg.instantiate()' + git clone "git@github.com:ProjectTorreyPines/Fortran90Namelists.jl.git" ../Fortran90Namelists; \ + julia --project=. -e 'using Pkg; Pkg.rm(["IMASDD", "Fortran90Namelists", "GGDUtils", "SOLPS2IMAS", "EFIT"]); Pkg.develop(path="../IMASDD"); Pkg.develop(path="../Fortran90Namelists"); Pkg.develop(path="../GGDUtils"); Pkg.develop(path="../SOLPS2IMAS"); 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(["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()' + julia --project=. -e 'using Pkg; Pkg.rm(["IMASDD", "Fortran90Namelists", "GGDUtils", "SOLPS2IMAS", "EFIT"]); Pkg.add(url="git@github.com:ProjectTorreyPines/IMASDD.jl.git", rev="master"); Pkg.add(url="git@github.com:ProjectTorreyPines/Fortran90Namelists.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 fea8b06..e2fa4e0 100644 --- a/src/SD4SOLPS.jl +++ b/src/SD4SOLPS.jl @@ -83,6 +83,7 @@ function geqdsk_to_imas!( ) # https://github.com/JuliaFusion/EFIT.jl/blob/master/src/io.jl g = EFIT.readg(eqdsk_file; set_time=set_time) + gfilename = split(eqdsk_file, "/")[end] # Copying ideas from OMFIT: omfit/omfit_classes/omfit_eqdsk.py / to_omas() eq = dd.equilibrium if IMASDD.ismissing(eq, :time) @@ -95,6 +96,8 @@ function geqdsk_to_imas!( eqt = eq.time_slice[time_index] eqt.time = g.time + source_for_summary = "gEQDSK file $gfilename loaded during SD4SOLPS workflow." + # 0D gq = eqt.global_quantities gq.magnetic_axis.r = g.rmaxis @@ -107,6 +110,17 @@ function geqdsk_to_imas!( b0[time_index] = g.bcentr eq.vacuum_toroidal_field.b0 = b0 + if IMASDD.ismissing(dd.summary, :time) + dd.summary.time = Array{Float64}(undef, time_index) + end + dd.summary.time[time_index] = g.time + ip = Array{Float64}(undef, time_index) + ip[time_index] = g.current + dd.summary.global_quantities.ip.value = ip + dd.summary.global_quantities.r0.value = g.rcentr + dd.summary.global_quantities.b0.value = b0 + summarize = ["ip", "r0", "b0"] + # 1D p1 = eqt.profiles_1d nprof = length(g.pres) @@ -141,6 +155,10 @@ function geqdsk_to_imas!( gq.q_min.rho_tor_norm = g.rhovn[qmin_idx] end + dd.summary.global_quantities.q_95.value = Array{Float64}(undef, time_index) + dd.summary.global_quantities.q_95.value[time_index] = gq.q_95 + summarize = [summarize; "q_95"] + # X-points xrs, xzs, xpsins, xseps = EFIT.x_points(g; within_limiter_only=false) if length(xrs) > 0 @@ -187,6 +205,11 @@ function geqdsk_to_imas!( resize!(limiter.unit, 1) limiter.unit[1].outline.r = g.rlim limiter.unit[1].outline.z = g.zlim + + for s ∈ summarize + getproperty(dd.summary.global_quantities, Symbol(s)).source = source_for_summary + end + return end diff --git a/test/runtests.jl b/test/runtests.jl index fef62d7..7f28771 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -10,6 +10,8 @@ using ArgParse: ArgParse using GGDUtils: GGDUtils, get_grid_subset function parse_commandline() + # Define newARGS = ["--yourflag"] to run only tests on your flags when including runtests.jl + localARGS = @isdefined(newARGS) ? newARGS : ARGS # Thanks https://stackoverflow.com/a/44978474/6605826 s = ArgParse.ArgParseSettings(; description="Run tests. Default is all tests.") ArgParse.add_arg_table!(s, @@ -35,7 +37,7 @@ function parse_commandline() Dict(:help => "Test only preparation", :action => :store_true), ) - args = ArgParse.parse_args(s) + args = ArgParse.parse_args(localARGS, s) if !any(values(args)) # If no flags are set, run all tests for k ∈ keys(args) args[k] = true @@ -355,6 +357,10 @@ if args["geqdsk_to_imas"] @test gq.magnetic_axis.r > 0 @test dd.equilibrium.vacuum_toroidal_field.r0 > 0 + # Summary + @test dd.equilibrium.time[tslice] == dd.summary.time[tslice] + @test dd.summary.global_quantities.r0.value > 0 + # 1d p1 = eqt.profiles_1d nprof = length(p1.psi)