Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Load equilibrium data into summary IDS during parsing #57

Merged
merged 8 commits into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/format_check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 9 additions & 4 deletions .github/workflows/make_docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
branches: ["master", "dev"]
paths:
- '.github/workflows/make_docs.yml'
- 'src/'
- 'src/**'
- 'docs/**'
push:
branches:
Expand All @@ -13,7 +13,7 @@ on:
- docs
paths:
- '.github/workflows/make_docs.yml'
- 'src/'
- 'src/**'
- 'docs/**'
tags: '*'
workflow_dispatch:
Expand All @@ -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
Expand All @@ -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 }}
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
5 changes: 3 additions & 2 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
23 changes: 23 additions & 0 deletions src/SD4SOLPS.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
8 changes: 7 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down
Loading