To run FLUKA, launch a terminal from the application menu of your Linux or macOS desktop.
Running a FLUKA simulation
FLUKA simulations are executed using the rfluka script located in the /pathtofluka/bin directory, where /pathtofluka/ refers to the directory where FLUKA has been installed.
The script can be used to launch multiple FLUKA cycles, each starting with a different random seed. A cycle comprises a fixed number of primary events (histories) or as many events until a certain time limit has been reached (to be specified on the START card inside the input file). The cycles are executed sequentially on the same CPU. Running multiple cycles is necessary for calculating statistical error estimates for quantities scored in the simulations. Contrary to other Monte Carlo codes, error estimates are calculated on a cycle-by-cycle basis and not on a history-by-history basis.
For example, to run 5 cycles using an input file called example.inp (a basic input file can be downloaded here), type the following:
/pathtofluka/bin/rfluka -M 5 example.inp
where -M specifies the last cycle to be executed (default 5) and -N specifies the previous cycle which has been completed (default 0). To run another 3 cycles, which restart from the last random seed created in the 5th cycle, type:
/pathtofluka/bin/rfluka -N 5 -M 8 example.inp
To avoid typing the full path for rfluka every time when running FLUKA it is recommended to add /pathtofluka/bin to the PATH environment variable (see bottom of the page).
Each time rfluka is executed, a unique name subdirectory is created and the program is run from there. In this subdirectory, symbolic links are created to the files in the parent directory. After a successful run of FLUKA, all the temporary links are removed and the newly created files are copied to the parent directory with the prefix <input_file_name><cycle number>.
For instance, the following files are created in the 1st cycle of the above example: example001.out, example001.err, example001.log. In addition, the random seed for the next cycle is saved in a file called ran<input_file_name><cycle number> (here: ranexample001). Depending on the simulation setup, further files might be created containing simulation scores etc.
Standard vs custom executables
By default, the rfluka script will use the standard FLUKA executable called fluka located in the /pathtofluka/bin/ directory. For applications, requiring the use of DPMJET and RQMD, the alternative executable flukadpm can be requested by using the -d option:
/pathtofluka/bin/rfluka -M 8 -d example.inp
In some cases, it may be necessary to use customized FLUKA user routines (see here). In that case, a custom executable needs to be compiled. Assuming the executable is called myfluka and is located in the current directory, then the simulation with the new executable can be launched using the -e option:
/pathtofluka/bin/rfluka -M 5 -e ./myfluka example.inp
Environment variables
It is convenient to add the directory where the FLUKA executables and post-processing utilities are located (/pathtofluka/bin) to the PATH environment variable. This avoids typing the full path every time when running FLUKA or executing FLUKA scripts.
The commands for setting environment variables differ for different shells. For bash shells, type:
export PATH=/pathtofluka/bin:$PATH
For csh or tcsh shells type:
setenv PATH "/pathtofluka/bin:${PATH}"
Such a definition of environment variables is lost when logging out or closing the terminal. To make them permanently available, the commands need to be added to the shell configuration file in the home directory (.bashrc file for bash shells, or .cshrc/.tcshrc files for csh/tcsh shells). Once the commands have been added to the configuration file, the settings not yet active in the present session. Hence one needs to use the source utility:
source ~/.bashrc
in bash shells or
source ~/.cshrc (or ~/.tcshrc)
in csh/tcsh shells. It is not necessary to use the source command every time if a new terminal is opened since the configuration files are automatically invoked at the start-up of a shell.