Skip to content

Commit

Permalink
Updated example demo and simple_demo with new makefile
Browse files Browse the repository at this point in the history
demo.ipynb and simple_demo.jl had become out of date because of recent
changes. Also, the demo envrionment creation was not good and used shell
scripts. This commit, uses new makefile that cleanly creates a set of
Porject.toml and Manifest.toml files that will work with demo. The
sample files are also sources from SD4SOLPS.jl/sample now.
  • Loading branch information
anchal-physics committed Apr 2, 2024
1 parent b1cab8d commit 8c075cf
Show file tree
Hide file tree
Showing 8 changed files with 81 additions and 150 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
# environment.
Manifest.toml
sd_input_data.json
example/Project.toml
38 changes: 0 additions & 38 deletions example/create_env_with_clone.sh

This file was deleted.

11 changes: 0 additions & 11 deletions example/create_env_with_git.sh

This file was deleted.

96 changes: 43 additions & 53 deletions example/demo.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,14 @@
"metadata": {},
"outputs": [],
"source": [
"b2gmtry = \"samples/b2fgmtry\"\n",
"b2output = \"samples/b2time.nc\"\n",
"b2mn = \"samples/b2mn.dat\""
"b2gmtry = \"../sample/ITER_Lore_2296_00000/baserun/b2fgmtry\"\n",
"b2output = \"../sample/ITER_Lore_2296_00000/run_time_dep_EIRENE_jdl_to_ss_cont_sine2_2d_output/b2time.nc\"\n",
"b2mn = \"../sample/ITER_Lore_2296_00000/run_time_dep_EIRENE_jdl_to_ss_cont_sine2_2d_output/b2mn.dat\"\n",
"fort = (\n",
" \"../sample/ITER_Lore_2296_00000/baserun/fort.33\",\n",
" \"../sample/ITER_Lore_2296_00000/baserun/fort.34\",\n",
" \"../sample/ITER_Lore_2296_00000/baserun/fort.35\",\n",
" )"
]
},
{
Expand All @@ -44,7 +49,7 @@
"metadata": {},
"outputs": [],
"source": [
"ids = SOLPS2IMAS.solps2imas(b2gmtry, b2output; b2mn=b2mn)"
"ids = SOLPS2IMAS.solps2imas(b2gmtry, b2output; b2mn=b2mn, fort=fort);"
]
},
{
Expand Down Expand Up @@ -77,8 +82,8 @@
"metadata": {},
"outputs": [],
"source": [
"grid_ggd = ids.edge_profiles.grid_ggd[1] # First grid_ggd time slice. It is allowed to vary in time\n",
"space = grid_ggd.space[1] # First space in this grid_ggd"
"grid_ggd = ids.edge_profiles.grid_ggd[1]; # First grid_ggd time slice. It is allowed to vary in time\n",
"space = grid_ggd.space[1]; # First space in this grid_ggd"
]
},
{
Expand All @@ -101,25 +106,25 @@
"plot(space) # Simply plot the grid described in space, all common arguments to plot can be given here\n",
"\n",
"# You can overlay any subset by giving a second argument\n",
"# Labels \n",
"plot!(space, GGDUtils.get_grid_subset(grid_ggd, 6), markercolor=:chocolate1)\n",
"plot!(space, GGDUtils.get_grid_subset(grid_ggd, 7), linecolor=:red, linewidth=2)\n",
"plot!(space, GGDUtils.get_grid_subset(grid_ggd, 8), linecolor=:darkred, linewidth=2)\n",
"plot!(space, GGDUtils.get_grid_subset(grid_ggd, 9), linecolor=:limegreen, linewidth=2)\n",
"plot!(space, GGDUtils.get_grid_subset(grid_ggd, 10), linecolor=:darkgreen, linewidth=2)\n",
"plot!(space, GGDUtils.get_grid_subset(grid_ggd, 11), linecolor=:cyan, linewidth=2)\n",
"# plot!(space, GGDUtils.get_grid_subset(grid_ggd, 12), linecolor=:teal, linewidth=1)\n",
"plot!(space, GGDUtils.get_grid_subset(grid_ggd, 13), linecolor=:royalblue1, linewidth=2)\n",
"plot!(space, GGDUtils.get_grid_subset(grid_ggd, 14), linecolor=:navyblue, linewidth=2)\n",
"plot!(space, GGDUtils.get_grid_subset(grid_ggd, 15), linecolor=:fuchsia, linewidth=2, linestyle=:dash)\n",
"plot!(space, GGDUtils.get_grid_subset(grid_ggd, 16), linecolor=:purple4, linewidth=2, linestyle=:dash)\n",
"# Labels\n",
"plot!(space, GGDUtils.get_grid_subset(grid_ggd, \"x_points\"), markercolor=:chocolate1, label=\"X-point\")\n",
"plot!(space, GGDUtils.get_grid_subset(grid_ggd, \"core_cut\"), linecolor=:red, linewidth=2, label=\"Core Cut\")\n",
"plot!(space, GGDUtils.get_grid_subset(grid_ggd, \"PFR_cut\"), linecolor=:darkred, linewidth=2, label=\"PFR Cut\")\n",
"plot!(space, GGDUtils.get_grid_subset(grid_ggd, \"outer_throat\"), linecolor=:limegreen, linewidth=2, label=\"Outer Throat\")\n",
"plot!(space, GGDUtils.get_grid_subset(grid_ggd, \"inner_throat\"), linecolor=:darkgreen, linewidth=2, label=\"Inner Throat\")\n",
"plot!(space, GGDUtils.get_grid_subset(grid_ggd, \"outer_midplane\"), linecolor=:cyan, linewidth=2, label=\"Outer midplane\")\n",
"# plot!(space, GGDUtils.get_grid_subset(grid_ggd, \"inner_midplane\"), linecolor=:teal, linewidth=2, label=\"Inner midplane\")\n",
"plot!(space, GGDUtils.get_grid_subset(grid_ggd, \"outer_target\"), linecolor=:royalblue1, linewidth=2, label=\"Outer target\")\n",
"plot!(space, GGDUtils.get_grid_subset(grid_ggd, \"inner_target\"), linecolor=:navyblue, linewidth=2, label=\"Inner target\")\n",
"plot!(space, GGDUtils.get_grid_subset(grid_ggd, \"core_boundary\"), linecolor=:fuchsia, linewidth=2, linestyle=:dash, label=\"Core boundary\")\n",
"plot!(space, GGDUtils.get_grid_subset(grid_ggd, \"separatrix\"), linecolor=:purple4, linewidth=2, linestyle=:dash, label=\"Separatrix\")\n",
"plot!(space, GGDUtils.get_grid_subset(grid_ggd, 101), markershape=:rect, markercolor=:royalblue1)\n",
"# plot!(space, GGDUtils.get_grid_subset(grid_ggd, 102), markershape=:rect, markercolor=:maroon)\n",
"plot!(space, GGDUtils.get_grid_subset(grid_ggd, 103), markershape=:diamond, markercolor=:fuchsia)\n",
"plot!(space, GGDUtils.get_grid_subset(grid_ggd, 104), markershape=:diamond, markercolor=:purple4)\n",
"\n",
"# Legend is supressed unless asked for specifically\n",
"plot!(legend=true)\n",
"plot!(legend=true, left_margin=10Plots.pt)\n",
"# Default labels are subset.identifier.name but can be changed by providing a label argument\n"
]
},
Expand All @@ -140,8 +145,9 @@
"gr() # Fast and can save pdf\n",
"# plotlyjs() # Use for interactive plot, can only save png\n",
"\n",
"n_e = GGDUtils.get_prop_with_grid_subset_index(ids.edge_profiles.ggd[1].electrons.density, 5)\n",
"plot(ids.edge_profiles.grid_ggd, n_e, colorbar_title=\"Electrons density / m^(-3)\")"
"n_e = GGDUtils.get_prop_with_grid_subset_index(ids.edge_profiles.ggd[1].electrons.density, -5)\n",
"plot(ids.edge_profiles.grid_ggd, n_e, colorbar_title=\"Electrons density / m^(-3)\",\n",
" left_margin=10Plots.pt)"
]
},
{
Expand All @@ -163,7 +169,8 @@
"# plotlyjs() # Use for interactive plot, can only save png\n",
"\n",
"plot(ids.edge_profiles.grid_ggd, n_e) # Note default label in colorbar\n",
"plot!(space, GGDUtils.get_grid_subset(grid_ggd, 16), linecolor=:black, linewidth=2, linestyle=:solid, label=\"Separatix\", legend=true)"
"plot!(space, GGDUtils.get_grid_subset(grid_ggd, 16), linecolor=:black, linewidth=2,\n",
" linestyle=:solid, label=\"Separatix\", legend=true, left_margin=10Plots.pt)"
]
},
{
Expand All @@ -188,8 +195,8 @@
"metadata": {},
"outputs": [],
"source": [
"eqdsk = \"samples/g002296.00200\"\n",
"SD4SOLPS.geqdsk_to_imas!(eqdsk, ids)"
"eqdsk = \"../sample/ITER_Lore_2296_00000/EQDSK/g002296.00200\"\n",
"SD4SOLPS.geqdsk_to_imas!(eqdsk, ids; set_time=0.2)"
]
},
{
Expand All @@ -205,28 +212,11 @@
"metadata": {},
"outputs": [],
"source": [
"SD4SOLPS.fill_in_extrapolated_core_profile!(ids, \"electrons.density\"; method=\"simple\")\n",
"SD4SOLPS.fill_in_extrapolated_core_profile!(ids, \"electrons.temperature\"; method=\"simple\")\n",
"SD4SOLPS.fill_in_extrapolated_core_profile!(ids, \"electrons.density\"; method=\"simple\", cell_subset_idx=-5)\n",
"SD4SOLPS.fill_in_extrapolated_core_profile!(ids, \"electrons.temperature\"; method=\"simple\", cell_subset_idx=-5)\n",
"# ... more profiles here as they become available in b2time"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Extend mesh outside SOLPS mesh to the device wall"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"\n",
"SD4SOLPS.cached_mesh_extension!(ids, eqdsk, b2gmtry)"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down Expand Up @@ -256,7 +246,7 @@
"metadata": {},
"outputs": [],
"source": [
"SynthDiag.add_interferometer!(\"samples/default_interferometer.json\", ids)"
"SynthDiag.add_interferometer!(SynthDiag.default_ifo, ids; n_e_gsi=-5);"
]
},
{
Expand All @@ -278,7 +268,7 @@
"\n",
"plot(space)\n",
"plot!(ids.interferometer) # Default plot_type is :los \n",
"plot!(legend=true)"
"plot!(legend=true, left_margin=10Plots.pt)"
]
},
{
Expand All @@ -300,7 +290,7 @@
"\n",
"plot(space)\n",
"plot!(ids.interferometer, mirror_length=0.7, linewidth=4, mirror_thickness=0.2)\n",
"plot!(legend=true)"
"plot!(legend=true, left_margin = 10Plots.pt)"
]
},
{
Expand All @@ -322,7 +312,7 @@
"\n",
"plot(space)\n",
"plot!(ids.interferometer, mirror=false)\n",
"plot!(legend=true)"
"plot!(legend=true, left_margin=10Plots.pt)"
]
},
{
Expand All @@ -344,7 +334,7 @@
"\n",
"plot(space)\n",
"plot!(ids.interferometer.channel[1], label=\"Channel 1\")\n",
"plot!(legend=true)"
"plot!(legend=true, left_margin=10Plots.pt)"
]
},
{
Expand All @@ -367,7 +357,7 @@
"gr() # Fast and can save pdf\n",
"# plotlyjs() # Use for interactive plot, can only save png\n",
"\n",
"plot(ids.interferometer, plot_type=:n_e)"
"plot(ids.interferometer, plot_type=:n_e, left_margin=10Plots.pt)"
]
},
{
Expand All @@ -380,7 +370,7 @@
"gr() # Fast and can save pdf\n",
"# plotlyjs() # Use for interactive plot, can only save png\n",
"\n",
"plot(ids.interferometer, plot_type=:n_e_average)"
"plot(ids.interferometer, plot_type=:n_e_average, left_margin=10Plots.pt)"
]
},
{
Expand All @@ -400,7 +390,7 @@
"gr() # Fast and can save pdf\n",
"# plotlyjs() # Use for interactive plot, can only save png\n",
"\n",
"plot(ids.interferometer.channel[1], plot_type=:n_e_average)"
"plot(ids.interferometer.channel[1], plot_type=:n_e_average, left_margin=10Plots.pt)"
]
},
{
Expand All @@ -418,7 +408,7 @@
"metadata": {},
"outputs": [],
"source": [
"SynthDiag.add_langmuir_probes!(\"samples/default_langmuir_probes.json\", ids)"
"SynthDiag.add_langmuir_probes!(SynthDiag.default_lp, ids; n_e_gsi=-5);"
]
},
{
Expand All @@ -438,7 +428,7 @@
"# plotlyjs() # Use for interactive plot, can only save png\n",
"\n",
"plot(ids.langmuir_probes.embedded[1].time, ids.langmuir_probes.embedded[1].n_e.data, label=ids.langmuir_probes.embedded[1].name)\n",
"plot!(ylabel=\"Electron density / m^(-3)\", xlabel=\"Time / s\", legend=true)"
"plot!(ylabel=\"Electron density / m^(-3)\", xlabel=\"Time / s\", legend=true, left_margin=10Plots.pt)"
]
}
],
Expand Down
48 changes: 33 additions & 15 deletions example/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,42 @@ SHELL := /bin/zsh
help:
@echo "Help Menu"
@echo
@echo "make env_with_cloned_repo: Creates a Julia environment with the cloned repositories"
@echo "make env_with_git_url: Creates a Julia environment with the git urls without creating local clones"
@echo "make env_with_cloned_repo (or make r): Creates a Julia environment with the cloned repositories"
@echo "make env_with_git_url (or make u): Creates a Julia environment with the git urls without creating local clones"
@echo "make clean: Deletes Project.toml and Manifest.toml for a fresh start"
@echo "make Clean: Deletes Project.toml, Manifest.toml, and any cloned repositories for a fresh start"
@echo

env_with_cloned_repo:
chmod +x create_env_with_clone.sh
./create_env_with_clone.sh
env_with_cloned_repo r:
@echo "Pulling sample files using dvc"
-dvc pull
@echo "Creating Julia environment by creating local clones of dependent repositories"
@echo "Cloning the repositories and generating Manifest.toml"
-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; \
git clone "git@github.com:ProjectTorreyPines/SynthDiag.jl.git" ../../SynthDiag; \
git clone "git@github.com:ProjectTorreyPines/SD4SOLPS.jl.git" ../../SD4SOLPS;
-julia --project=. -e 'using Pkg; Pkg.rm(["IMASDD"]);'
-julia --project=. -e 'using Pkg; Pkg.rm(["GGDUtils"]);'
-julia --project=. -e 'using Pkg; Pkg.rm(["SOLPS2IMAS"]);'
-julia --project=. -e 'using Pkg; Pkg.rm(["SynthDiag"]);'
-julia --project=. -e 'using Pkg; Pkg.rm(["SD4SOLPS"]);'
-julia --project=. -e 'using Pkg; Pkg.rm(["EFIT"]);'
-julia --project=. -e 'using Pkg; Pkg.develop(path="../../IMASDD"); Pkg.develop(path="../../GGDUtils"); Pkg.develop(path="../../SOLPS2IMAS"); Pkg.develop(path="../../SynthDiag"); Pkg.develop(path="../../SD4SOLPS"); Pkg.add(url="git@github.com:JuliaFusion/EFIT.jl.git", rev="master"); Pkg.instantiate()'

env_with_git_url:
chmod +x create_env_with_git.sh
./create_env_with_git.sh
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"]);'
-julia --project=. -e 'using Pkg; Pkg.rm(["GGDUtils"]);'
-julia --project=. -e 'using Pkg; Pkg.rm(["SOLPS2IMAS"]);'
-julia --project=. -e 'using Pkg; Pkg.rm(["SynthDiag"]);'
-julia --project=. -e 'using Pkg; Pkg.rm(["SD4SOLPS"]);'
-julia --project=. -e 'using Pkg; Pkg.rm(["EFIT"]);'
-julia --project=. -e 'using Pkg; 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:ProjectTorreyPines/SynthDiag.jl.git", rev="master"); Pkg.add(url="git@github.com:ProjectTorreyPines/SD4SOLPS.jl.git", rev="master"); Pkg.add(url="git@github.com:JuliaFusion/EFIT.jl.git", rev="master"); Pkg.instantiate()'

clean:
@echo "Deleting Project.toml and Manifest.toml"
rm Project.toml Manifest.toml

Clean: clean
chmod +x rm_cloned_repo.sh
./rm_cloned_repo.sh
@echo "Deleting Manifest.toml"
- rm Manifest.toml
32 changes: 0 additions & 32 deletions example/rm_cloned_repo.sh

This file was deleted.

1 change: 1 addition & 0 deletions example/simple_demo.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ solps2imas_samples = splitdir(pathof(SOLPS2IMAS))[1] * "/../samples"
dd = SD4SOLPS.preparation(
"Baseline2008-li0.70.x4.mod2.eqdsk",
[sample_path, solps2imas_samples]...;
eqdsk_set_time=0.0,
)

grid_ggd = dd.edge_profiles.grid_ggd[1] # First grid_ggd time slice. It is allowed to vary in time
Expand Down
Loading

0 comments on commit 8c075cf

Please sign in to comment.