Skip to content

Commit

Permalink
Name change: SOLPS2IMAS -> SOLPS2imas
Browse files Browse the repository at this point in the history
All occurences of SOLPS2IMAS have been replaced with SOLPS2imas. Also,
in anticipation of successful registration with Julia general registry,
the installation instructions have been modified.
  • Loading branch information
anchal-physics committed Oct 3, 2024
1 parent fec8948 commit c1abdec
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 96 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name = "SOLPS2IMAS"
name = "SOLPS2imas"
uuid = "09becab6-0636-4c23-a92a-2b3723265c31"
authors = ["David Eldon <[email protected]>"]
version = "1.0.3"
Expand Down
35 changes: 6 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,38 +1,15 @@
# SOLPS2IMAS.jl
# SOLPS2imas.jl

![Format Check](https://github.com/ProjectTorreyPines/SOLPS2IMAS.jl/actions/workflows/format_check.yml/badge.svg)
![Docs](https://github.com/ProjectTorreyPines/SOLPS2IMAS.jl/actions/workflows/make_docs.yml/badge.svg)
![Tests](https://github.com/ProjectTorreyPines/SOLPS2IMAS.jl/actions/workflows/test.yml/badge.svg)
![Format Check](https://github.com/ProjectTorreyPines/SOLPS2imas.jl/actions/workflows/format_check.yml/badge.svg)
![Docs](https://github.com/ProjectTorreyPines/SOLPS2imas.jl/actions/workflows/make_docs.yml/badge.svg)
![Tests](https://github.com/ProjectTorreyPines/SOLPS2imas.jl/actions/workflows/test.yml/badge.svg)

Utility for loading data from existing SOLPS runs, including custom data in b2time.nc,
from native SOLPS output format into IMAS. For installation and usage instructions, see the [online documentation](https://projecttorreypines.github.io/SOLPS2IMAS.jl/stable). For documentation on under development branch, see [dev online documentation](https://projecttorreypines.github.io/SOLPS2IMAS.jl/dev).
from native SOLPS output format into IMAS. For installation and usage instructions, see the [online documentation](https://projecttorreypines.github.io/SOLPS2imas.jl/stable). For documentation on under development branch, see [dev online documentation](https://projecttorreypines.github.io/SOLPS2imas.jl/dev).

## Installation

SOLPS2IMAS is registered with public repository [FuseRegistry](https://github.com/ProjectTorreyPines/FuseRegistry.jl/). For installation:

```
using Pkg
Pkg.Registry.add(RegistrySpec(url="https://github.com/ProjectTorreyPines/FuseRegistry.jl.git"))
Pkg.Registry.add("General")
Pkg.add("SOLPS2IMAS")
```

## Running tests:

Following code ensures it uses the enviroment described in ./Project.toml:

```bash
% julia --project test/runtests.jl
Test Summary: | Pass Total Time
Test index conversions | 1 1 0.0s
Test Summary: | Pass Total Time
Test file parsing in depth | 6 6 0.4s
Test Summary: | Pass Total Time
Test read_b2_output | 19 19 1.9s
solps2imas() time: 49.510687 seconds (154.81 M allocations: 10.512 GiB, 8.27% gc time, 96.47% compilation time)
Test Summary: | Pass Total Time
Test solps2imas() (overall workflow) | 4 4 50.4s
Test Summary: | Pass Total Time
Test triangular mesh generation from fort files | 23479 23479 3.7s
Pkg.add("SOLPS2imas")
```
8 changes: 4 additions & 4 deletions docs/make.jl
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
using Documenter
using SOLPS2IMAS
using SOLPS2imas

makedocs(;
modules=[SOLPS2IMAS],
modules=[SOLPS2imas],
format=Documenter.HTML(),
sitename="SOLPS2IMAS",
sitename="SOLPS2imas",
checkdocs=:none,
)

deploydocs(;
repo="github.com/ProjectTorreyPines/SOLPS2IMAS.jl.git",
repo="github.com/ProjectTorreyPines/SOLPS2imas.jl.git",
target="build",
branch="gh-pages",
devbranch="master",
Expand Down
60 changes: 29 additions & 31 deletions docs/src/index.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

# SOLPS2IMAS.jl
# SOLPS2imas.jl

```@contents
Pages = ["index.md"]
Expand All @@ -8,13 +8,11 @@ Depth = 5

## Installation

SOLPS2IMAS is registered with public repository [FuseRegistry](https://github.com/ProjectTorreyPines/FuseRegistry.jl/). For installation:
For installation:

```
using Pkg
Pkg.Registry.add(RegistrySpec(url="https://github.com/ProjectTorreyPines/FuseRegistry.jl.git"))
Pkg.Registry.add("General")
Pkg.add("SOLPS2IMAS")
Pkg.add("SOLPS2imas")
```

## solps2imas
Expand Down Expand Up @@ -44,37 +42,37 @@ read_b2_boundary_parameters
## SOLPS Mesh Tools

```@docs
SOLPS2IMAS.xytoc
SOLPS2IMAS.ctoxy
SOLPS2IMAS.data_xytoc
SOLPS2IMAS.search_point
SOLPS2IMAS.search_edges
SOLPS2IMAS.distance_between_nodes
SOLPS2IMAS.neighbour_inds
SOLPS2IMAS.get_neighbour_inds
SOLPS2IMAS.attach_neightbours!
SOLPS2imas.xytoc
SOLPS2imas.ctoxy
SOLPS2imas.data_xytoc
SOLPS2imas.search_point
SOLPS2imas.search_edges
SOLPS2imas.distance_between_nodes
SOLPS2imas.neighbour_inds
SOLPS2imas.get_neighbour_inds
SOLPS2imas.attach_neightbours!
```

## Subset Identification Tools

These functions provide a way to identify if a linear cell index in SOLPS notation belongs to a grid subset.

```@docs
SOLPS2IMAS.in_core
SOLPS2IMAS.in_sol
SOLPS2IMAS.in_idr
SOLPS2IMAS.in_odr
SOLPS2IMAS.is_x_aligned
SOLPS2IMAS.is_y_aligned
SOLPS2IMAS.is_core_cut
SOLPS2IMAS.is_pfr_cut
SOLPS2IMAS.is_outer_throat
SOLPS2IMAS.is_inner_throat
SOLPS2IMAS.is_outer_midplane
SOLPS2IMAS.is_inner_midplane
SOLPS2IMAS.is_outer_target
SOLPS2IMAS.is_inner_target
SOLPS2IMAS.is_core_boundary
SOLPS2IMAS.is_separatrix
SOLPS2IMAS.get_xpoint_nodes
SOLPS2imas.in_core
SOLPS2imas.in_sol
SOLPS2imas.in_idr
SOLPS2imas.in_odr
SOLPS2imas.is_x_aligned
SOLPS2imas.is_y_aligned
SOLPS2imas.is_core_cut
SOLPS2imas.is_pfr_cut
SOLPS2imas.is_outer_throat
SOLPS2imas.is_inner_throat
SOLPS2imas.is_outer_midplane
SOLPS2imas.is_inner_midplane
SOLPS2imas.is_outer_target
SOLPS2imas.is_inner_target
SOLPS2imas.is_core_boundary
SOLPS2imas.is_separatrix
SOLPS2imas.get_xpoint_nodes
```
4 changes: 2 additions & 2 deletions src/SOLPS2IMAS.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module SOLPS2IMAS
module SOLPS2imas

using IMASdd: IMASdd
using NCDatasets: Dataset, dimnames
Expand Down Expand Up @@ -795,4 +795,4 @@ function solps2imas(
return ids
end

end # module SOLPS2IMAS
end # module SOLPS2imas
52 changes: 26 additions & 26 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using SOLPS2IMAS: SOLPS2IMAS
using SOLPS2imas: SOLPS2imas
using Test
using YAML: load_file as YAML_load_file
using ArgParse: ArgParse
using IMASdd: IMASdd
import SOLPS2IMAS: get_grid_subset, read_b2_boundary_parameters
import SOLPS2imas: get_grid_subset, read_b2_boundary_parameters

allowed_rtol = 1e-4

Expand Down Expand Up @@ -52,9 +52,9 @@ if args["ind"]
success = true
for iy 1:ny
for ix 1:nx
cxy = SOLPS2IMAS.ctoxy(SOLPS2IMAS.xytoc(ix, iy; nx=nx); nx=nx)
cxy = SOLPS2imas.ctoxy(SOLPS2imas.xytoc(ix, iy; nx=nx); nx=nx)
if cxy != (ix, iy)
ic = SOLPS2IMAS.xytoc(ix, iy; nx=nx)
ic = SOLPS2imas.xytoc(ix, iy; nx=nx)
println(
"ic: ",
ic,
Expand All @@ -71,9 +71,9 @@ if args["ind"]
end

for ic 1:nx*ny
cic = SOLPS2IMAS.xytoc(SOLPS2IMAS.ctoxy(ic; nx=nx)...; nx=nx)
cic = SOLPS2imas.xytoc(SOLPS2imas.ctoxy(ic; nx=nx)...; nx=nx)
if cic != ic
ix, iy = SOLPS2IMAS.ctoxy(ic; nx=nx)
ix, iy = SOLPS2imas.ctoxy(ic; nx=nx)
println(
"ic: ",
ic,
Expand All @@ -99,7 +99,7 @@ if args["parser"]
]
always_required_keys = ["b2mndr_ntim", "b2mndr_dtim"]
for b2mn_sample b2mn_samples
b2mn_data = SOLPS2IMAS.read_b2mn_output(b2mn_sample)
b2mn_data = SOLPS2imas.read_b2mn_output(b2mn_sample)
for ark always_required_keys
@test ark in keys(b2mn_data)
end
Expand All @@ -111,7 +111,7 @@ end

if args["b2"]
@testset "Test read_b2_output" begin
contents = SOLPS2IMAS.read_b2_output("$(@__DIR__)/../samples/b2fstate")
contents = SOLPS2imas.read_b2_output("$(@__DIR__)/../samples/b2fstate")
nt = contents["dim"]["time"]
nx = contents["dim"]["nx"]
ny = contents["dim"]["ny"]
Expand All @@ -121,7 +121,7 @@ if args["b2"]
@test size(contents["data"]["fna"]) == (nt, ns, 2, ny, nx)
@test size(contents["data"]["fhe"]) == (nt, ns, ny, nx)

contents = SOLPS2IMAS.read_b2_output("$(@__DIR__)/../samples/b2fgmtry")
contents = SOLPS2imas.read_b2_output("$(@__DIR__)/../samples/b2fgmtry")
nt = contents["dim"]["time"]
nxg = contents["dim"]["nx"]
nyg = contents["dim"]["ny"]
Expand All @@ -130,7 +130,7 @@ if args["b2"]
@test nyg == ny
@test nxg == nx

contents = SOLPS2IMAS.read_b2_output("$(@__DIR__)/../samples/b2time_red.nc")
contents = SOLPS2imas.read_b2_output("$(@__DIR__)/../samples/b2time_red.nc")
nx = contents["dim"]["nx"]
ny = contents["dim"]["ny"]
nybl = contents["dim"]["nybl"]
Expand All @@ -156,10 +156,10 @@ if args["solps2imas"]
b2gmtry = "$(@__DIR__)/../samples/b2fgmtry"
b2output = "$(@__DIR__)/../samples/b2time.nc"
b2mn = "$(@__DIR__)/../samples/b2mn.dat"
b2t = SOLPS2IMAS.read_b2_output(b2output)
b2t = SOLPS2imas.read_b2_output(b2output)
nx = b2t["dim"]["nx"]
print("solps2imas() time: ")
@time dd = SOLPS2IMAS.solps2imas(b2gmtry, b2output; b2mn=b2mn, load_bb=false)
@time dd = SOLPS2imas.solps2imas(b2gmtry, b2output; b2mn=b2mn, load_bb=false)
# Check time stamp 3 at iy=4, ix=5
it = 3
iy = 4
Expand All @@ -174,15 +174,15 @@ if args["solps2imas"]
# as using a brute force definition which is too dependent
# on the correct ordering of nodes in SOLPS data files.
cut_keys = ["leftcut", "rightcut", "bottomcut", "topcut"]
gmtry = SOLPS2IMAS.read_b2_output(b2gmtry)
gmtry = SOLPS2imas.read_b2_output(b2gmtry)
ny = gmtry["dim"]["ny"]
cuts = Dict([(Symbol(key), gmtry["data"][key][1]) for key cut_keys])
subset_pfrcut =
SOLPS2IMAS.get_grid_subset(dd.edge_profiles.grid_ggd[1], 8)
SOLPS2imas.get_grid_subset(dd.edge_profiles.grid_ggd[1], 8)
subset_corebnd =
SOLPS2IMAS.get_grid_subset(dd.edge_profiles.grid_ggd[1], 15)
SOLPS2imas.get_grid_subset(dd.edge_profiles.grid_ggd[1], 15)
subset_separatrix =
SOLPS2IMAS.get_grid_subset(dd.edge_profiles.grid_ggd[1], 16)
SOLPS2imas.get_grid_subset(dd.edge_profiles.grid_ggd[1], 16)
cells = dd.edge_profiles.grid_ggd[1].space[1].objects_per_dimension[3].object
subset_pfrcut_element_list =
[ele.object[1].index for ele subset_pfrcut.element]
Expand All @@ -197,12 +197,12 @@ if args["solps2imas"]
for ix 1:nx
for boundary_ind 1:4
edge_ind =
cells[SOLPS2IMAS.xytoc(ix, iy; nx)].boundary[boundary_ind].index
if SOLPS2IMAS.is_pfr_cut(; ix, iy, cells, nx, boundary_ind, cuts...)
cells[SOLPS2imas.xytoc(ix, iy; nx)].boundary[boundary_ind].index
if SOLPS2imas.is_pfr_cut(; ix, iy, cells, nx, boundary_ind, cuts...)
append!(brute_force_pfrcut_list, edge_ind)
elseif SOLPS2IMAS.is_core_boundary(; ix, iy, boundary_ind, cuts...)
elseif SOLPS2imas.is_core_boundary(; ix, iy, boundary_ind, cuts...)
append!(brute_force_corebnd_list, edge_ind)
elseif SOLPS2IMAS.is_separatrix(; iy, boundary_ind, cuts...)
elseif SOLPS2imas.is_separatrix(; iy, boundary_ind, cuts...)
append!(brute_force_separatrix_list, edge_ind)
end
end
Expand All @@ -213,7 +213,7 @@ if args["solps2imas"]
@test Set(brute_force_separatrix_list) == Set(subset_separatrix_element_list)

# Test loading of magnetic field data from b2fgmtry to equilibrium IDS
@time ddbb = SOLPS2IMAS.solps2imas(b2gmtry, b2output; b2mn=b2mn, load_bb=true)
@time ddbb = SOLPS2imas.solps2imas(b2gmtry, b2output; b2mn=b2mn, load_bb=true)
btor = ddbb.equilibrium.time_slice[1].ggd[1].b_field_tor[1].values
bz = ddbb.equilibrium.time_slice[1].ggd[1].b_field_z[1].values
br = ddbb.equilibrium.time_slice[1].ggd[1].b_field_r[1].values
Expand All @@ -232,7 +232,7 @@ if args["fort"]
b2gmtry = "$(@__DIR__)/../samples/b2fgmtry"
b2output = "$(@__DIR__)/../samples/b2time.nc"
b2mn = "$(@__DIR__)/../samples/b2mn.dat"
ids = SOLPS2IMAS.solps2imas(b2gmtry, b2output; b2mn=b2mn, fort=fort)
ids = SOLPS2imas.solps2imas(b2gmtry, b2output; b2mn=b2mn, fort=fort)
grid_ggd = ids.edge_profiles.grid_ggd[1]
space = grid_ggd.space[1]

Expand All @@ -253,7 +253,7 @@ if args["fort"]
edges = grid_ggd.space[1].objects_per_dimension[2].object
cells = grid_ggd.space[1].objects_per_dimension[3].object

gmtry = SOLPS2IMAS.read_b2_output(b2gmtry)
gmtry = SOLPS2imas.read_b2_output(b2gmtry)
nx = gmtry["dim"]["nx"]
ny = gmtry["dim"]["ny"]
extra_nodes = 2 * (nx + ny)
Expand All @@ -276,7 +276,7 @@ if args["fort"]
cells[cells[tricell_ind].boundary[bnd_ind].neighbours[1]].nodes,
)
vert_no = Tuple(indexin(common_nodes, cells[tricell_ind].nodes))
@test SOLPS2IMAS.chosen_tri_edge_order[bnd_ind][2] == vert_no
@test SOLPS2imas.chosen_tri_edge_order[bnd_ind][2] == vert_no
end
end
end
Expand All @@ -287,7 +287,7 @@ if args["namelist"]
@testset "Test parsing of namelists" begin
# Basic parameters namelist parsing
testfile = "$(@__DIR__)/../samples/b2.boundary.parameters"
boundary_params = SOLPS2IMAS.read_b2_boundary_parameters(testfile)
boundary_params = SOLPS2imas.read_b2_boundary_parameters(testfile)
println(boundary_params)
@test boundary_params["power_electrons"] > 0.0
@test boundary_params["power_ions"] > 0.0
Expand All @@ -296,7 +296,7 @@ if args["namelist"]

# Using parameters namelist to populate summary data
ids = IMASdd.dd()
SOLPS2IMAS.load_summary_data!(ids, (testfile, "", "", ""))
SOLPS2imas.load_summary_data!(ids, (testfile, "", "", ""))
@test !(ismissing(ids.summary.heating_current_drive.power_ec, :value))
end
end
6 changes: 3 additions & 3 deletions test/speedtest.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using SOLPS2IMAS: SOLPS2IMAS
using SOLPS2imas: SOLPS2imas

println("-----------------------------------------------------------------------------")
b2gmtry = "$(@__DIR__)/../samples/b2fgmtry"
Expand All @@ -9,6 +9,6 @@ fort = (
"$(@__DIR__)/../samples/fort.34",
"$(@__DIR__)/../samples/fort.35")
print("solps2imas(b2gmtry, b2output; b2mn, fort) time with compilation: ")
@time dd = SOLPS2IMAS.solps2imas(b2gmtry, b2output; b2mn, fort);
@time dd = SOLPS2imas.solps2imas(b2gmtry, b2output; b2mn, fort);
print("solps2imas(b2gmtry, b2output; b2mn, fort) time (true runtime): ")
@time dd = SOLPS2IMAS.solps2imas(b2gmtry, b2output; b2mn, fort);
@time dd = SOLPS2imas.solps2imas(b2gmtry, b2output; b2mn, fort);

0 comments on commit c1abdec

Please sign in to comment.