Python tools for FLUKA input files with Spawn, Execute and Notify features (FSEN). Allows to spawn FLUKA input files, execute them and notify by e-mail (or via telegram bot) about run state. After completion have a structure like it was done using Flair, so user can easily process data using Flair.
Made with Python 3
Author: Gordeev Ivan <GN> (gordeev@jinr.ru), Dubna, JINR, 2021
Python 3 (tested on 3.6 and 3.7) and dependencies: numpy and pyTelegramBotAPI (for telegram notifications).
One need to add this line in .bashrc file of home directory:
export FLUKA=~/path_to_bin_directory
where path_to_bin_directory is the path to FLUKA bin folder. Another option is to execute this command in terminal directly every time just before script launching.
Also, by default, script will search custom user executable under PATH_TO_CUSTOM (look at the settings.py file). If one has custom executables in another directory, PATH_TO_CUSTOM must be changed accordingly.
FSEN4cli tool supports 2 types of notification:
- Via email
- Via telegram bot
You need to change settings.py file according to your settings, to use first and second feature.
For telegram bot one need to create his own bot and change USER_ID and USERNAME accordingly. This gives permission to sent commands to only one user with specific USER_ID and USERNAME.
There are 3 commands for telegram bot available:
/help
This one shows available commands.
/status
This one sent status about current run.
/bomb
This one stops calculations by executing bomb.sh script (generates fluka.stop files in fluka_* directories)
FSEN4cli tool executes FLUKA input files via cli and notifies about run status (optional).
To show help in command line type:
./FSEN4cli.py -h
Default run, without any arguments (1 positional argument required):
./FSEN4cli.py example.inp
This will execute 1 copy of given input file without any notifications.
Simple run with 6 parallel jobs:
./FSEN4cli.py example.inp -cn 6
This will launch 6 copy of given input file without any notifications.
Simple run with 4 parallel jobs, skipping previous 6:
./FSEN4cli.py example.inp -cn 4 -sn 6
This will launch 6 copy of given input file without any notifications and first 6 files will be skipped (to avoid runs with the same seeds).
Run with 6 parallel jobs with notification via email (make sure to provide password and necessary settings in settings.py file):
./FSEN4cli.py example.inp -cn 6 -nm -p '***password***'
Run with 6 parallel jobs with notification via telegram bot (make sure to provide API token for your telegram bot):
./FSEN4cli.py example.inp -cn 6 -nb -t '***token***'
IMPORTANT: for notifications, one need to be sure that script will last in background processes, to run script in background do:
nohup ./FSEN4cli.py example.inp -cn 6 -nb -t '***token***' &
nohup command will add all output to nohup.out file and & sign will run script in background. Also, one could press "CTRL + Z" and do: bg (to force program run in background). After that terminal can be closed.
Otherwise, one should not close the terminal while the script is running.
During every execution, script creates so-called bomb.sh shell script. Execution of this script creates fluka.stop files in every 'fluka_*' directory this way, jobs can be finished correctly earlier.
This tool automates new launches with FSEN4cli tool.
For example, if one started N parallel jobs of FLUKA via FSEN4cli tool, and he wants to improve statistics by running more jobs just after these N jobs will be done, this tool will be helpful.
To show usage help in command line type:
./automate.py -h
Suppose, 6 jobs are already running via FSEN4cli tool. If one wants to perform 5 more launches after that with 6 parallel jobs:
nohup ./automate.py -sn 6 -cn 6 -bn 5 example.inp &
Where '-sn 6' tells skipping 6 jobs (which are handled by FSEN4cli tool), '-cn 6' - number of parallel jobs in the next batches, '-bn 5' - number of batches. One need to pay attention, that this should be executed in background.
All results will be automatically saved in 'autores' directory.
To process all the results from the terminal:
./harvest.py example.inp -trk 21 -yie 22
Here we suppose that all our fort files are in the 'autores' folder. We have one usrtrack scorer on the unit 21 and one usryield scorer on the unit 22.
Not all the scorers are currently available! Use --help to list all the options.
IMPORTANT: All the tools should be in the same directory! But it can be called from any path.