Skip to content

Commit

Permalink
Merge pull request #8 from pabloprf/development_upgrade
Browse files Browse the repository at this point in the history
Refactored remote execution handler, general improvements and bug fixes in preparation for release
  • Loading branch information
pabloprf authored Jan 16, 2024
2 parents c19778d + 2e4959c commit d7a1f78
Show file tree
Hide file tree
Showing 101 changed files with 5,803 additions and 5,323 deletions.
20 changes: 17 additions & 3 deletions config/config_user_example.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,26 @@
"scratch": "/Users/exampleusername/scratch/",
"modules": ""
},
"perlmutter": {
"machine": "perlmutter.nersc.gov",
"username": "exampleusername",
"scratch": "/pscratch/sd/p/exampleusername/",
"identity": "$HOME/.ssh/nersc",
"slurm": {
"account": "m3195_g",
"partition": "debug",
"constraint": "gpu",
"mem": "4GB",
"email": "optional@email"
}
},
"engaging": {
"machine": "eofe7.mit.edu",
"username": "exampleusername",
"partition": "sched_mit_psfc",
"slurm": {
"partition": "sched_mit_psfc",
"exclude": "node584"
},
"identity": "~/.ssh/id_rsa",
"scratch": "/nobackup1/exampleusername/",
"modules": ""
Expand All @@ -39,7 +55,6 @@
"machine": "mfews02.psfc.mit.edu",
"username": "exampleusername",
"tunnel": "mferws01.psfc.mit.edu",
"scratch_tunnel": "/home/exampleusername/scratch/",
"port": 9224,
"scratch": "/home/exampleusername/scratch/",
"modules": ""
Expand All @@ -48,7 +63,6 @@
"machine": "irisa.gat.com",
"username": "exampleusername",
"tunnel": "cybele.gat.com",
"scratch_tunnel": "/home/exampleusername/scratch/",
"port": 2039,
"scratch": "/cluster-scratch/exampleusername/",
"modules": ""
Expand Down
37 changes: 24 additions & 13 deletions config/machines_sources/aliases.bashrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,34 @@
# ---------------------------------------------------------------------------------------------------------------------

# mitim_tools interfaces: read, run, plot
alias mitim_plot_gacode="ipython3 -i -- $MITIM_PATH/src/mitim_tools/gacode_tools/exe/read_gacodes.py --files $1"
alias mitim_plot_tgyro="ipython3 -i -- $MITIM_PATH/src/mitim_tools/gacode_tools/exe/read_tgyros.py --folders $1"
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]
alias mitim_plot_eq="ipython3 -i -- $MITIM_PATH/src/mitim_tools/gs_tools/exe/read_eqs.py --files $1"
alias mitim_read_transp="ipython3 -i -- $MITIM_PATH/src/mitim_tools/transp_tools/exe/read_transp.py --files $1"
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]

alias mitim_plot_gacode="ipython3 -i -- $MITIM_PATH/src/mitim_tools/gacode_tools/exe/read_gacode.py $1"
alias mitim_plot_tgyro="ipython3 -i -- $MITIM_PATH/src/mitim_tools/gacode_tools/exe/read_tgyro.py $1"
alias mitim_plot_tglf="ipython3 -i -- $MITIM_PATH/src/mitim_tools/gacode_tools/exe/read_tglf.py $1" # [--suffix _0.55] [--gacode input.gacode]
alias mitim_plot_cgyro="ipython3 -i -- $MITIM_PATH/src/mitim_tools/gacode_tools/exe/read_cgyro.py $1"
alias mitim_plot_eq="ipython3 -i -- $MITIM_PATH/src/mitim_tools/gs_tools/exe/read_eq.py $1"
alias mitim_plot_transp="ipython3 -i -- $MITIM_PATH/src/mitim_tools/transp_tools/exe/read_transp.py $1"

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]

# Optimizations
alias mitim_plot_opt="ipython3 -i -- $MITIM_PATH/src/mitim_tools/opt_tools/exe/read.py --type 4 --resolution 20 --folders $1"
alias mitim_plot_portalsSR="ipython3 -i -- $MITIM_PATH/src/mitim_modules/portals/exe/check_initialization.py $1"
alias mitim_plot_portals="mitim_plot_opt $1"
alias mitim_plot_opt="ipython3 -i -- $MITIM_PATH/src/mitim_tools/opt_tools/exe/read.py --type 4 --resolution 20 $1"
alias mitim_plot_portals="ipython3 -i -- $MITIM_PATH/src/mitim_modules/portals/exe/readMetrics.py $1"
alias mitim_slurm="python3 $MITIM_PATH/src/mitim_tools/opt_tools/exe/slurm.py $1"

# TRANSP
alias mitim_trcheck="python3 $MITIM_PATH/src/mitim_tools/transp_tools/exe/run_check.py $1" # mitim_trcheck pablorf
alias mitim_trclean="python3 $MITIM_PATH/src/mitim_tools/transp_tools/exe/run_clean.py $1" # mitim_trclean 88664P CMOD --numbers 1,2,3
alias mitim_trlook="ipython3 -i -- $MITIM_PATH/src/mitim_tools/transp_tools/exe/run_look.py $1" # mitim_trlook 152895P01 CMOD --nofull --plot --remove
alias mitim_trcheck="python3 $MITIM_PATH/src/mitim_tools/transp_tools/exe/run_check.py $1" # mitim_trcheck pablorf
alias mitim_trcheck_p="python3 $MITIM_PATH/src/mitim_tools/transp_tools/exe/run_check_periodic.py $1" # mitim_trcheck_p pablorf
alias mitim_trclean="python3 $MITIM_PATH/src/mitim_tools/transp_tools/exe/run_clean.py $1" # mitim_trclean 88664P CMOD --numbers 1,2,3
alias mitim_trlook="ipython3 -i -- $MITIM_PATH/src/mitim_tools/transp_tools/exe/run_look.py $1" # mitim_trlook 152895P01 CMOD --nofull --plot --remove

# To run TRANSP (in folder with required files): transp 88664 P01 CMOD --version tshare --trmpi 32 --toricmpi 32 --ptrmpi 32
alias transp="python3 $MITIM_PATH/src/mitim_tools/transp_tools/exe/run_transp.py"

# IM Aliases
alias runim="python3 $MITIM_PATH/src/mitim_tools/im_tools/exe/run_im.py ./" # To run complete IM evaluation: runim 7 [DebugOption: --debug 0]
alias runmitim="python3 $MITIM_PATH/mitim_opt/scenarios_tools/routines/runMITIM_BO.py" # To peform scenario optimization

# Others
alias compare_nml="python3 $MITIM_PATH/src/mitim_tools/transp_tools/routines/compareNML.py $1"
alias eff_job="python3 $MITIM_PATH/src/mitim_tools/misc_tools/PARALLELtools.py $1" # Give sbatch.out or slurm_output.dat
alias eff_job="python3 $MITIM_PATH/src/mitim_tools/misc_tools/PARALLELtools.py $1" # Give mitim.out or slurm_output.dat
6 changes: 5 additions & 1 deletion config/machines_sources/eofe.bashrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# This is a setup file for the EOFE cluster. Remember (see Installation guide) that this is not
# stricly necessary. However, it is convenient to have it here, so that you can load the modules
# with a single command. If you do not want to use this file, you can load the modules manually
# if you have these lines in your .bashrc (or equivalent)

module use /home/software/psfc/modulefiles/

Expand Down Expand Up @@ -64,7 +68,7 @@ then
# --------------------------------------------------------------------------------

export GACODE_PLATFORM=PSFC_EOFE_RPP
export GACODE_ROOT=/home/$USER/gacode_sparc
export GACODE_ROOT=/home/$USER/gacode_rpp

# --------------------------------------------------------------------------------
# ASTRA
Expand Down
17 changes: 6 additions & 11 deletions config/machines_sources/iris.bashrc
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
# Stuff only for IRIS machine
# This is a setup file for the IRIS cluster. Remember (see Installation guide) that this is not
# stricly necessary. However, it is convenient to have it here, so that you can load the modules
# with a single command. If you do not want to use this file, you can load the modules manually
# if you have these lines in your .bashrc (or equivalent)

# ------------------------------------------------------------------------------------------------
# GACODE
# ------------------------------------------------------------------------------------------------

# module load atom/pygacode

! [ -z "$PS1" ] && echo " * Proceeding to load GACODE modules"

export GACODE_PLATFORM=IRIS
export GACODE_ROOT=/home/$USER/gacode

. ${GACODE_ROOT}/shared/bin/gacode_setup
module load ntcc

#. ${GACODE_ROOT}/platform/env/env.${GACODE_PLATFORM} # IMPORTANT to not do this, otherwise it will then point to atom

if [ $? -eq 124 ]
Expand All @@ -20,10 +22,3 @@ then
else
! [ -z "$PS1" ] && echo " * GACODE modules loaded"
fi

# ------------------------------------------------------------------------------------------------
# TRANSP/NTCC
# ------------------------------------------------------------------------------------------------

module load omfit/unstable
module load ntcc
20 changes: 20 additions & 0 deletions config/machines_sources/nersc.bashrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# This is a setup file for NERSC Perlmutter. Remember (see Installation guide) that this is not
# stricly necessary. However, it is convenient to have it here, so that you can load the modules
# with a single command. If you do not want to use this file, you can load the modules manually
# if you have these lines in your .bashrc (or equivalent)

if [ "$NERSC_HOST" = perlmutter ]
then
! [ -z "$PS1" ] && echo " * PERLMUTTER"

# ------------------------------------------------------------------------------------------------
# GACODE
# ------------------------------------------------------------------------------------------------

export GACODE_PLATFORM=PERLMUTTER_GPU
export GACODE_ROOT=$HOME/gacode
. $GACODE_ROOT/shared/bin/gacode_setup
. ${GACODE_ROOT}/platform/env/env.$GACODE_PLATFORM
fi

source $MITIM_PATH/config/machines_sources/slurm_aliases.bashrc
48 changes: 5 additions & 43 deletions config/mitim.bashrc
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,15 @@ then
elif [ "${HOSTNAME:0:3}" = toki ]
then
source $MITIM_PATH/config/machines_sources/toki.bashrc
# NERSC
elif [ "$NERSC_HOST" = perlmutter ]
then
source $MITIM_PATH/config/machines_sources/nersc.bashrc
# None of the above
else
! [ -z "$PS1" ] && echo " - No specific environment file loaded"
fi



# -------------------------------------------------------------------------------------------------------
# Aliases for quick tools (plotting, reading)
# -------------------------------------------------------------------------------------------------------
Expand All @@ -55,44 +57,4 @@ fi

source $MITIM_PATH/config/machines_sources/aliases.bashrc

# -------------------------------------------------------------------------------------------------------
# TRANSP Aliases
# -------------------------------------------------------------------------------------------------------

# To run TRANSP (in folder with required files): transp 88664 P01 CMOD --version tshare --trmpi 32 --toricmpi 32 --ptrmpi 32
alias transp="python3 $MITIM_PATH/src/mitim_tools/transp_tools/exe/run_transp.py"

# To send and get LOOK or do a FETCH: look 88664P01 CMOD --nofull --plot --remove
alias look="python3 $MITIM_PATH/src/mitim_tools/transp_tools/exe/run_look.py"

# To check the grid: trcheck pablorf
alias trcheck="python3 $MITIM_PATH/src/mitim_tools/transp_tools/exe/run_check.py"

# To check the grid periodically: trcheckp pablorf
alias trcheckp="python3 $MITIM_PATH/src/mitim_tools/transp_tools/exe/run_check_periodic.py"

# To delete runs from TRANSP grid: cleanruns 88664P CMOD --numbers 1 --to 5 OR 88664P CMOD --numbers 1,2,3
alias cleanruns="python3 $MITIM_PATH/src/mitim_tools/transp_tools/exe/run_clean.py"

# Plot transp: trplot transp.cdf
alias trplot="ipython3 -i $MITIM_PATH/src/mitim_tools/transp_tools/outputs/exploreCDFs.py"

# -------------------------------------------------------------------------------------------------------
# IM Aliases
# -------------------------------------------------------------------------------------------------------

# To run complete IM evaluation: runim 7 [DebugOption: --debug 0]
alias runim="python3 $MITIM_PATH/src/mitim_tools/im_tools/exe/run_im.py ./"

# To peform scenario optimization
alias runmitim="python3 $MITIM_PATH/mitim_opt/scenarios_tools/routines/runMITIM_BO.py"

# -------------------------------------------------------------------------------------------------------
# Other Useful Aliases
# -------------------------------------------------------------------------------------------------------

# e.g.: grepy hola
function grepy { clear; grep -rno "$1" . --color --include \*.py; }
function grepf90 { clear; grep -rno "$1" . --color --include \*.{f90,F90}; }

! [ -z "$PS1" ] && echo -e "\033[32m>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\033[0m"
! [ -z "$PS1" ] && echo -e "\033[32m>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\033[0m"
2 changes: 1 addition & 1 deletion docs/capabilities/portals_capabilities.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PORTALS
=======

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.
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.

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

Expand Down
29 changes: 10 additions & 19 deletions docs/capabilities/tglf_capabilities.rst
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ To generate the input files (input.tglf) to TGLF at each radial location, MITIM

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.
The set of control inputs to TGLF (like saturation rule, electromagnetic effects, etc.) are provided in two ways.
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.
First, the argument ``TGLFsettings`` indicates the base case to start with.
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.
Second, the argument ``extraOptions`` can be passed as a dictionary of variables to change.
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):

Expand All @@ -96,19 +97,6 @@ For example, the following two commands will run TGLF with saturation rule numbe
tglf.read( label = 'no_em' )
.. note::

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:

- TGLFsettings = 0: Minimal working example
- TGLFsettings = 1: "Old" ES SAT1
- TGLFsettings = 2: ES SAT0
- TGLFsettings = 3: ES SAT1 (a.k.a. SAT1geo)
- TGLFsettings = 4: ES SAT2
- TGLFsettings = 5: EM SAT2

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.

.. tip::

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.
Expand All @@ -117,7 +105,7 @@ TGLF results can be plotted together by indicating what labels to plot:

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

Expand Down Expand Up @@ -162,7 +150,7 @@ Similarly as in the previous section, you need to run the ``prep()`` command, bu
- **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.


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


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

.. tip::

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

*Nothing here yet*
*Under Development*

*(In the meantime, please checkout* `tutorials/TGLF_tutorial.py <https://github.com/pabloprf/MITIM-fusion/blob/main/tutorials/PORTALS_tutorial.py>`_ *)*


TGLF aliases
------------
Expand Down
2 changes: 1 addition & 1 deletion docs/capabilities/tgyro_capabilities.rst
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ And plot:

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

Expand Down
4 changes: 2 additions & 2 deletions docs/capabilities/transp_capabilities.rst
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ If TRANSP has already been run and the .CDF results file already exists (``cdf_f
transp_results = CDFtools.CDFreactor( cdf_file )
transp_results.plotRun()
transp_results.plot()
.. tip::

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

.. code-block:: python
transp_results.plotRun( time = t1 )
transp_results.plot( time = t1 )
.. note::

Expand Down
14 changes: 12 additions & 2 deletions docs/faq.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ Frequently Asked Questions
:local:
:depth: 1

Issues during MITIM setup
-------------------------
Issues during MITIM installation
--------------------------------

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

Expand All @@ -24,6 +24,14 @@ Issues during MITIM setup
pip3 install -e $MITIM_PATH\[pyqt\]
.. dropdown:: ``ERROR: Wheel`` error in pip:

Make sure you are getting the fresh packages, by using the ``--no-cache`` option:

.. code-block:: console
pip3 install -e $MITIM_PATH\[pyqt\] --no-cache
Issues during MITIM tests
-------------------------

Expand All @@ -39,6 +47,8 @@ Issues during MITIM tests
. $GACODE_ROOT/shared/bin/gacode_setup
. ${GACODE_ROOT}/platform/env/env.${GACODE_PLATFORM}
\# Add also modules that are required to run MPI instances in your machine
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,
then it is possible that you have print or echo statements in your ``.bashrc`` or ``.zshrc`` files.
Please remove them or add the following:
Expand Down
Loading

0 comments on commit d7a1f78

Please sign in to comment.