Skip to content

Commit d7a1f78

Browse files
authored
Merge pull request #8 from pabloprf/development_upgrade
Refactored remote execution handler, general improvements and bug fixes in preparation for release
2 parents c19778d + 2e4959c commit d7a1f78

File tree

101 files changed

+5803
-5323
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

101 files changed

+5803
-5323
lines changed

config/config_user_example.json

+17-3
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,26 @@
2020
"scratch": "/Users/exampleusername/scratch/",
2121
"modules": ""
2222
},
23+
"perlmutter": {
24+
"machine": "perlmutter.nersc.gov",
25+
"username": "exampleusername",
26+
"scratch": "/pscratch/sd/p/exampleusername/",
27+
"identity": "$HOME/.ssh/nersc",
28+
"slurm": {
29+
"account": "m3195_g",
30+
"partition": "debug",
31+
"constraint": "gpu",
32+
"mem": "4GB",
33+
"email": "optional@email"
34+
}
35+
},
2336
"engaging": {
2437
"machine": "eofe7.mit.edu",
2538
"username": "exampleusername",
26-
"partition": "sched_mit_psfc",
39+
"slurm": {
40+
"partition": "sched_mit_psfc",
41+
"exclude": "node584"
42+
},
2743
"identity": "~/.ssh/id_rsa",
2844
"scratch": "/nobackup1/exampleusername/",
2945
"modules": ""
@@ -39,7 +55,6 @@
3955
"machine": "mfews02.psfc.mit.edu",
4056
"username": "exampleusername",
4157
"tunnel": "mferws01.psfc.mit.edu",
42-
"scratch_tunnel": "/home/exampleusername/scratch/",
4358
"port": 9224,
4459
"scratch": "/home/exampleusername/scratch/",
4560
"modules": ""
@@ -48,7 +63,6 @@
4863
"machine": "irisa.gat.com",
4964
"username": "exampleusername",
5065
"tunnel": "cybele.gat.com",
51-
"scratch_tunnel": "/home/exampleusername/scratch/",
5266
"port": 2039,
5367
"scratch": "/cluster-scratch/exampleusername/",
5468
"modules": ""

config/machines_sources/aliases.bashrc

+24-13
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,34 @@
33
# ---------------------------------------------------------------------------------------------------------------------
44

55
# mitim_tools interfaces: read, run, plot
6-
alias mitim_plot_gacode="ipython3 -i -- $MITIM_PATH/src/mitim_tools/gacode_tools/exe/read_gacodes.py --files $1"
7-
alias mitim_plot_tgyro="ipython3 -i -- $MITIM_PATH/src/mitim_tools/gacode_tools/exe/read_tgyros.py --folders $1"
8-
alias mitim_plot_tglf="ipython3 -i -- $MITIM_PATH/src/mitim_tools/gacode_tools/exe/read_tglf.py --folder $1" # [--suffix _0.55] [--gacode input.gacode]
9-
alias mitim_plot_eq="ipython3 -i -- $MITIM_PATH/src/mitim_tools/gs_tools/exe/read_eqs.py --files $1"
10-
alias mitim_read_transp="ipython3 -i -- $MITIM_PATH/src/mitim_tools/transp_tools/exe/read_transp.py --files $1"
11-
alias mitim_run_tglf="ipython3 -i -- $MITIM_PATH/src/mitim_tools/gacode_tools/exe/run_tglf.py --folder $1 --tglf $2" #[--gacode input.gacode] [--scan RLTS_2] [--drives True]
6+
7+
alias mitim_plot_gacode="ipython3 -i -- $MITIM_PATH/src/mitim_tools/gacode_tools/exe/read_gacode.py $1"
8+
alias mitim_plot_tgyro="ipython3 -i -- $MITIM_PATH/src/mitim_tools/gacode_tools/exe/read_tgyro.py $1"
9+
alias mitim_plot_tglf="ipython3 -i -- $MITIM_PATH/src/mitim_tools/gacode_tools/exe/read_tglf.py $1" # [--suffix _0.55] [--gacode input.gacode]
10+
alias mitim_plot_cgyro="ipython3 -i -- $MITIM_PATH/src/mitim_tools/gacode_tools/exe/read_cgyro.py $1"
11+
alias mitim_plot_eq="ipython3 -i -- $MITIM_PATH/src/mitim_tools/gs_tools/exe/read_eq.py $1"
12+
alias mitim_plot_transp="ipython3 -i -- $MITIM_PATH/src/mitim_tools/transp_tools/exe/read_transp.py $1"
13+
14+
alias mitim_run_tglf="ipython3 -i -- $MITIM_PATH/src/mitim_tools/gacode_tools/exe/run_tglf.py $1 $2" # (folder input.tglf) [--gacode input.gacode] [--scan RLTS_2] [--drives True]
1215

1316
# Optimizations
14-
alias mitim_plot_opt="ipython3 -i -- $MITIM_PATH/src/mitim_tools/opt_tools/exe/read.py --type 4 --resolution 20 --folders $1"
15-
alias mitim_plot_portalsSR="ipython3 -i -- $MITIM_PATH/src/mitim_modules/portals/exe/check_initialization.py $1"
16-
alias mitim_plot_portals="mitim_plot_opt $1"
17+
alias mitim_plot_opt="ipython3 -i -- $MITIM_PATH/src/mitim_tools/opt_tools/exe/read.py --type 4 --resolution 20 $1"
18+
alias mitim_plot_portals="ipython3 -i -- $MITIM_PATH/src/mitim_modules/portals/exe/readMetrics.py $1"
19+
alias mitim_slurm="python3 $MITIM_PATH/src/mitim_tools/opt_tools/exe/slurm.py $1"
1720

1821
# TRANSP
19-
alias mitim_trcheck="python3 $MITIM_PATH/src/mitim_tools/transp_tools/exe/run_check.py $1" # mitim_trcheck pablorf
20-
alias mitim_trclean="python3 $MITIM_PATH/src/mitim_tools/transp_tools/exe/run_clean.py $1" # mitim_trclean 88664P CMOD --numbers 1,2,3
21-
alias mitim_trlook="ipython3 -i -- $MITIM_PATH/src/mitim_tools/transp_tools/exe/run_look.py $1" # mitim_trlook 152895P01 CMOD --nofull --plot --remove
22+
alias mitim_trcheck="python3 $MITIM_PATH/src/mitim_tools/transp_tools/exe/run_check.py $1" # mitim_trcheck pablorf
23+
alias mitim_trcheck_p="python3 $MITIM_PATH/src/mitim_tools/transp_tools/exe/run_check_periodic.py $1" # mitim_trcheck_p pablorf
24+
alias mitim_trclean="python3 $MITIM_PATH/src/mitim_tools/transp_tools/exe/run_clean.py $1" # mitim_trclean 88664P CMOD --numbers 1,2,3
25+
alias mitim_trlook="ipython3 -i -- $MITIM_PATH/src/mitim_tools/transp_tools/exe/run_look.py $1" # mitim_trlook 152895P01 CMOD --nofull --plot --remove
26+
27+
# To run TRANSP (in folder with required files): transp 88664 P01 CMOD --version tshare --trmpi 32 --toricmpi 32 --ptrmpi 32
28+
alias transp="python3 $MITIM_PATH/src/mitim_tools/transp_tools/exe/run_transp.py"
29+
30+
# IM Aliases
31+
alias runim="python3 $MITIM_PATH/src/mitim_tools/im_tools/exe/run_im.py ./" # To run complete IM evaluation: runim 7 [DebugOption: --debug 0]
32+
alias runmitim="python3 $MITIM_PATH/mitim_opt/scenarios_tools/routines/runMITIM_BO.py" # To peform scenario optimization
2233

2334
# Others
2435
alias compare_nml="python3 $MITIM_PATH/src/mitim_tools/transp_tools/routines/compareNML.py $1"
25-
alias eff_job="python3 $MITIM_PATH/src/mitim_tools/misc_tools/PARALLELtools.py $1" # Give sbatch.out or slurm_output.dat
36+
alias eff_job="python3 $MITIM_PATH/src/mitim_tools/misc_tools/PARALLELtools.py $1" # Give mitim.out or slurm_output.dat

config/machines_sources/eofe.bashrc

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# This is a setup file for the EOFE cluster. Remember (see Installation guide) that this is not
2+
# stricly necessary. However, it is convenient to have it here, so that you can load the modules
3+
# with a single command. If you do not want to use this file, you can load the modules manually
4+
# if you have these lines in your .bashrc (or equivalent)
15

26
module use /home/software/psfc/modulefiles/
37

@@ -64,7 +68,7 @@ then
6468
# --------------------------------------------------------------------------------
6569

6670
export GACODE_PLATFORM=PSFC_EOFE_RPP
67-
export GACODE_ROOT=/home/$USER/gacode_sparc
71+
export GACODE_ROOT=/home/$USER/gacode_rpp
6872

6973
# --------------------------------------------------------------------------------
7074
# ASTRA

config/machines_sources/iris.bashrc

+6-11
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
1-
# Stuff only for IRIS machine
1+
# This is a setup file for the IRIS cluster. Remember (see Installation guide) that this is not
2+
# stricly necessary. However, it is convenient to have it here, so that you can load the modules
3+
# with a single command. If you do not want to use this file, you can load the modules manually
4+
# if you have these lines in your .bashrc (or equivalent)
25

36
# ------------------------------------------------------------------------------------------------
47
# GACODE
58
# ------------------------------------------------------------------------------------------------
69

7-
# module load atom/pygacode
8-
910
! [ -z "$PS1" ] && echo " * Proceeding to load GACODE modules"
1011

1112
export GACODE_PLATFORM=IRIS
1213
export GACODE_ROOT=/home/$USER/gacode
13-
1414
. ${GACODE_ROOT}/shared/bin/gacode_setup
15+
module load ntcc
16+
1517
#. ${GACODE_ROOT}/platform/env/env.${GACODE_PLATFORM} # IMPORTANT to not do this, otherwise it will then point to atom
1618

1719
if [ $? -eq 124 ]
@@ -20,10 +22,3 @@ then
2022
else
2123
! [ -z "$PS1" ] && echo " * GACODE modules loaded"
2224
fi
23-
24-
# ------------------------------------------------------------------------------------------------
25-
# TRANSP/NTCC
26-
# ------------------------------------------------------------------------------------------------
27-
28-
module load omfit/unstable
29-
module load ntcc

config/machines_sources/nersc.bashrc

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# This is a setup file for NERSC Perlmutter. Remember (see Installation guide) that this is not
2+
# stricly necessary. However, it is convenient to have it here, so that you can load the modules
3+
# with a single command. If you do not want to use this file, you can load the modules manually
4+
# if you have these lines in your .bashrc (or equivalent)
5+
6+
if [ "$NERSC_HOST" = perlmutter ]
7+
then
8+
! [ -z "$PS1" ] && echo " * PERLMUTTER"
9+
10+
# ------------------------------------------------------------------------------------------------
11+
# GACODE
12+
# ------------------------------------------------------------------------------------------------
13+
14+
export GACODE_PLATFORM=PERLMUTTER_GPU
15+
export GACODE_ROOT=$HOME/gacode
16+
. $GACODE_ROOT/shared/bin/gacode_setup
17+
. ${GACODE_ROOT}/platform/env/env.$GACODE_PLATFORM
18+
fi
19+
20+
source $MITIM_PATH/config/machines_sources/slurm_aliases.bashrc

config/mitim.bashrc

+5-43
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,15 @@ then
4040
elif [ "${HOSTNAME:0:3}" = toki ]
4141
then
4242
source $MITIM_PATH/config/machines_sources/toki.bashrc
43+
# NERSC
44+
elif [ "$NERSC_HOST" = perlmutter ]
45+
then
46+
source $MITIM_PATH/config/machines_sources/nersc.bashrc
4347
# None of the above
4448
else
4549
! [ -z "$PS1" ] && echo " - No specific environment file loaded"
4650
fi
4751

48-
49-
5052
# -------------------------------------------------------------------------------------------------------
5153
# Aliases for quick tools (plotting, reading)
5254
# -------------------------------------------------------------------------------------------------------
@@ -55,44 +57,4 @@ fi
5557

5658
source $MITIM_PATH/config/machines_sources/aliases.bashrc
5759

58-
# -------------------------------------------------------------------------------------------------------
59-
# TRANSP Aliases
60-
# -------------------------------------------------------------------------------------------------------
61-
62-
# To run TRANSP (in folder with required files): transp 88664 P01 CMOD --version tshare --trmpi 32 --toricmpi 32 --ptrmpi 32
63-
alias transp="python3 $MITIM_PATH/src/mitim_tools/transp_tools/exe/run_transp.py"
64-
65-
# To send and get LOOK or do a FETCH: look 88664P01 CMOD --nofull --plot --remove
66-
alias look="python3 $MITIM_PATH/src/mitim_tools/transp_tools/exe/run_look.py"
67-
68-
# To check the grid: trcheck pablorf
69-
alias trcheck="python3 $MITIM_PATH/src/mitim_tools/transp_tools/exe/run_check.py"
70-
71-
# To check the grid periodically: trcheckp pablorf
72-
alias trcheckp="python3 $MITIM_PATH/src/mitim_tools/transp_tools/exe/run_check_periodic.py"
73-
74-
# To delete runs from TRANSP grid: cleanruns 88664P CMOD --numbers 1 --to 5 OR 88664P CMOD --numbers 1,2,3
75-
alias cleanruns="python3 $MITIM_PATH/src/mitim_tools/transp_tools/exe/run_clean.py"
76-
77-
# Plot transp: trplot transp.cdf
78-
alias trplot="ipython3 -i $MITIM_PATH/src/mitim_tools/transp_tools/outputs/exploreCDFs.py"
79-
80-
# -------------------------------------------------------------------------------------------------------
81-
# IM Aliases
82-
# -------------------------------------------------------------------------------------------------------
83-
84-
# To run complete IM evaluation: runim 7 [DebugOption: --debug 0]
85-
alias runim="python3 $MITIM_PATH/src/mitim_tools/im_tools/exe/run_im.py ./"
86-
87-
# To peform scenario optimization
88-
alias runmitim="python3 $MITIM_PATH/mitim_opt/scenarios_tools/routines/runMITIM_BO.py"
89-
90-
# -------------------------------------------------------------------------------------------------------
91-
# Other Useful Aliases
92-
# -------------------------------------------------------------------------------------------------------
93-
94-
# e.g.: grepy hola
95-
function grepy { clear; grep -rno "$1" . --color --include \*.py; }
96-
function grepf90 { clear; grep -rno "$1" . --color --include \*.{f90,F90}; }
97-
98-
! [ -z "$PS1" ] && echo -e "\033[32m>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\033[0m"
60+
! [ -z "$PS1" ] && echo -e "\033[32m>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\033[0m"

docs/capabilities/portals_capabilities.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PORTALS
22
=======
33

4-
The PORTALS method, described in `P. Rodriguez-Fernandez et al., Nulc. Fusion (2022) <https://iopscience.iop.org/article/10.1088/1741-4326/ac64b2>`_ consists of using Bayesian Optimization techniques to find steady-state solutions of transport codes of arbitrary fidelity.
4+
The PORTALS method, described in `P. Rodriguez-Fernandez et al.,arXiv (2023) <https://arxiv.org/abs/2312.12610>`_ consists of using Bayesian Optimization techniques to find steady-state solutions of transport codes of arbitrary fidelity.
55

66
Once setup has been successful, the following regression test should run smoothly:
77

docs/capabilities/tglf_capabilities.rst

+10-19
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ To generate the input files (input.tglf) to TGLF at each radial location, MITIM
7676

7777
Now, we are ready to run TGLF. Once the ``prep()`` command has finished, one can run TGLF with different settings and assumptions. That is why, at this point, a sub-folder name for this specific run can be provided. Similarly to the ``prep()`` command, a ``restart`` flag can be provided.
7878
The set of control inputs to TGLF (like saturation rule, electromagnetic effects, etc.) are provided in two ways.
79-
First, the argument ``TGLFsettings`` (which goes from 1 to 5 as of now) indicates the base case to start with. The user is referred to ``GACODEdefaults.py`` to understand the meaning of each setting.
79+
First, the argument ``TGLFsettings`` indicates the base case to start with.
80+
The user is referred to ``templates/input.tglf.models.json`` to understand the meaning of each setting, and ``templates/input.tglf.controls`` for the default setup.
8081
Second, the argument ``extraOptions`` can be passed as a dictionary of variables to change.
8182
For example, the following two commands will run TGLF with saturation rule number 2 with and without electromagnetic effets. After each ``run()`` command, a ``read()`` is needed, to populate the *tglf.results* dictionary with the TGLF outputs (``label`` refers to the dictionary key for each run):
8283

@@ -96,19 +97,6 @@ For example, the following two commands will run TGLF with saturation rule numbe
9697
9798
tglf.read( label = 'no_em' )
9899
99-
.. note::
100-
101-
One can change every TGLF input with the ``extraOptions = {}`` dictionary, as shown earlier. However, ``GACODEdefaults.py`` contains a list of presets for TGLF that can be selected by simply passing the argument ``TGLFsettings`` to the ``.run()`` method. Available preset are:
102-
103-
- TGLFsettings = 0: Minimal working example
104-
- TGLFsettings = 1: "Old" ES SAT1
105-
- TGLFsettings = 2: ES SAT0
106-
- TGLFsettings = 3: ES SAT1 (a.k.a. SAT1geo)
107-
- TGLFsettings = 4: ES SAT2
108-
- TGLFsettings = 5: EM SAT2
109-
110-
The user is not limited to use those combinations. One can start with a given ``TGLFsettings`` option, and then modify as many parameters as needed with the ``extraOptions`` dictionary.
111-
112100
.. tip::
113101

114102
In this example, ``tglf.results['yes_em']`` and ``tglf.results['no_em']`` are themselves dictionaries, so please do ``.keys()`` to get all the possible results that have been obtained.
@@ -117,7 +105,7 @@ TGLF results can be plotted together by indicating what labels to plot:
117105

118106
.. code-block:: python
119107
120-
tglf.plotRun( labels = ['yes_em', 'no_em'] )
108+
tglf.plot( labels = ['yes_em', 'no_em'] )
121109
122110
As a result, a TGLF notebook with different tabs will be opened with all relevant output quantities:
123111

@@ -162,7 +150,7 @@ Similarly as in the previous section, you need to run the ``prep()`` command, bu
162150
- **PROFILES_GEN** to generate an *input.gacode* file from the *plasmastate.cdf* and *.geq* files. This file is standard within the GACODE suite and contains all plasma information that is required to run core transport codes.
163151

164152

165-
The rest of the workflow is identical to the previous section, including ``.run()``, ``.read()`` and ``.plotRun()``.
153+
The rest of the workflow is identical to the previous section, including ``.run()``, ``.read()`` and ``.plot()``.
166154

167155

168156
Run TGLF from input.tglf file
@@ -182,7 +170,7 @@ If you have a input.tglf file already, you can still use this script to run it.
182170
tglf = TGLFtools.TGLF()
183171
tglf.prep_from_tglf( folder, inputtglf_file, input_gacode = inputgacode_file )
184172
185-
The rest of the workflow is identical, including ``.run()``, ``.read()`` and ``.plotRun()``.
173+
The rest of the workflow is identical, including ``.run()``, ``.read()`` and ``.plot()``.
186174

187175
.. tip::
188176

@@ -204,7 +192,7 @@ The rest of the workflow is identical, including ``.run()``, ``.read()`` and ``.
204192
tglf = TGLFtools.TGLF()
205193
tglf.prep_from_tglf( folder, inputtglf_file )
206194
tglf.read (folder = f'{folder}/', label = 'yes_em' )
207-
tglf.plotRun( labels = ['yes_em'] )
195+
tglf.plot( labels = ['yes_em'] )
208196
209197
Please note that the previous code will only work is TGLF was run using MITIM. This is because MITIM stores the results
210198
with a suffix that indicates the radial location (``rho``) where the run was performed.
@@ -219,7 +207,10 @@ The rest of the workflow is identical, including ``.run()``, ``.read()`` and ``.
219207
Run 1D scans of TGLF input parameter
220208
------------------------------------
221209

222-
*Nothing here yet*
210+
*Under Development*
211+
212+
*(In the meantime, please checkout* `tutorials/TGLF_tutorial.py <https://github.com/pabloprf/MITIM-fusion/blob/main/tutorials/PORTALS_tutorial.py>`_ *)*
213+
223214

224215
TGLF aliases
225216
------------

docs/capabilities/tgyro_capabilities.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ And plot:
9595

9696
.. code-block:: python
9797
98-
tgyro.plotRun(labels=['run1'])
98+
tgyro.plot(labels=['run1'])
9999
100100
As a result, a TGYRO notebook with different tabs will be opened with all relevant output quantities:
101101

docs/capabilities/transp_capabilities.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ If TRANSP has already been run and the .CDF results file already exists (``cdf_f
9191
9292
transp_results = CDFtools.CDFreactor( cdf_file )
9393
94-
transp_results.plotRun()
94+
transp_results.plot()
9595
9696
.. tip::
9797

@@ -114,7 +114,7 @@ If TRANSP has already been run and the .CDF results file already exists (``cdf_f
114114

115115
.. code-block:: python
116116
117-
transp_results.plotRun( time = t1 )
117+
transp_results.plot( time = t1 )
118118
119119
.. note::
120120

docs/faq.rst

+12-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ Frequently Asked Questions
55
:local:
66
:depth: 1
77

8-
Issues during MITIM setup
9-
-------------------------
8+
Issues during MITIM installation
9+
--------------------------------
1010

1111
.. dropdown:: ``pyqt`` fails to install
1212

@@ -24,6 +24,14 @@ Issues during MITIM setup
2424
2525
pip3 install -e $MITIM_PATH\[pyqt\]
2626
27+
.. dropdown:: ``ERROR: Wheel`` error in pip:
28+
29+
Make sure you are getting the fresh packages, by using the ``--no-cache`` option:
30+
31+
.. code-block:: console
32+
33+
pip3 install -e $MITIM_PATH\[pyqt\] --no-cache
34+
2735
Issues during MITIM tests
2836
-------------------------
2937

@@ -39,6 +47,8 @@ Issues during MITIM tests
3947
. $GACODE_ROOT/shared/bin/gacode_setup
4048
. ${GACODE_ROOT}/platform/env/env.${GACODE_PLATFORM}
4149
50+
\# Add also modules that are required to run MPI instances in your machine
51+
4252
If you still have problems with MITIM execution of TGLF and you have checked that by manually logging-in to the machine you can run TGLF,
4353
then it is possible that you have print or echo statements in your ``.bashrc`` or ``.zshrc`` files.
4454
Please remove them or add the following:

0 commit comments

Comments
 (0)