PAPRECA hybrid off-lattice kMC/MD simulator  2.0.0 (17 September 2024)
papreca.cpp File Reference

Driver function. Initializes MPI, LAMMPS, and PAPRECA. Then runs kMC/MD loops. More...

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <fstream>
#include <chrono>
#include <ctime>
#include <cmath>
#include <limits>
#include <mpi.h>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <algorithm>
#include "lammps.h"
#include "papreca.h"
Include dependency graph for papreca.cpp:

Functions

void initialize (int *narg, char ***arg, int *nprocs, int *proc_id, LAMMPS **lmp, PaprecaConfig &papreca_config)
 
void finalize (LAMMPS **lmp, PaprecaConfig &papreca_config, const int &proc_id)
 
int main (int narg, char **arg)
 

Detailed Description

Driver function. Initializes MPI, LAMMPS, and PAPRECA. Then runs kMC/MD loops.

Function Documentation

◆ finalize()

void finalize ( LAMMPS **  lmp,
PaprecaConfig papreca_config,
const int &  proc_id 
)

Called at the end of the PAPRECA simulation. This function 1) closes all open files (if any), 2) deletes the previously instantiated LAMMPS object (in initializeLMP() function), and 3) calls MPI_Finalize() to ensure proper termination of all MPI processes.

Parameters
[in,out]lmppointer to pointer of LAMMPS object (used to delete the instantiated LAMMPS object in initializeLMP() function).
[in]papreca_configobject of the PAPRECA::PaprecaConfig class that stores global variables and settings for the current PAPRECA run.
[in]proc_idID of current MPI process.
See also
PAPRECA::initializeLMP()
Note
No need to delete anything related to the PAPRECA::PaprecaConfig object (i.e., the object carrying global parameters and simulation settings). At the moment, all variables and containers initialized for the PAPRECA::PaprecaConfig object are allocated on stack and they will be deleted after the object destructor invokation (i.e., at the end of the main() function).

◆ initialize()

void initialize ( int *  narg,
char ***  arg,
int *  nprocs,
int *  proc_id,
LAMMPS **  lmp,
PaprecaConfig papreca_config 
)

Intializes MPI, LAMMPS, and PAPRECA

Parameters
[in]nargnumber of command-line arguments passed to the main function (i.e., the papreca executable) during the program invocation from the terminal.
[in]argarray containing the char* passed to the main function during the program invocation from the terminal.
[in,out]nprocsnumber of MPI processes.
[in,out]proc_idID of current MPI process.
[in,out]lmppointer to LAMMPS instance.
[in,out]papreca_configobject of the PAPRECA::PaprecaConfig class that stores global variables and settings for the current PAPRECA run.

◆ main()

int main ( int  narg,
char **  arg 
)

Driver function running the main PAPRECA simulation loop. The function sets up the MPI protocol, initializes all (LAMMPS and PAPRECA) variables, and performs the requested (by the user, in the PAPRECA input file) PAPRECA simulation KMC steps. On each PAPRECA simulation KMC step, each atom on every MPI process is scanned and PAPRECA::Events are discovered. Then, an event is executed on an MPI processes (the executed event as well as the MPI process firing the event are chosen based on the N-FOLD way).

Parameters
[in]nargnumber of command-line arguments passed to the main function (i.e., the papreca executable) during the program invocation from the terminal.
[in]argarray containing the char* passed to the main function during the program invocation from the terminal.
See also
PAPRECA::setupMPI(), PAPRECA::initializeLMP(), PAPRECA::readLMPinput(), PAPRECA::readInputAndInitPaprecaConfig(), PAPRECA::Bond::initAtomID2BondsMap(), PAPRECA::loopAtomsAndIdentifyEvents(), PAPRECA::selectAndExecuteEvent(), PAPRECA::deleteAndClearLocalEvents(), PAPRECA::equilibrate(), PAPRECA::finalize()
Note
Example execution of PAPRECA from UNIX terminal: mpiexec papreca -in in_kmc.lmp in_kmc.ppc. CAUTION: Always provide the LAMMPS input file first and the PAPRECA input file second, otherwise the code will exit with an error.
See paper this paper for more information regarding the classic N-FOLD way and the event selection process: https://www.sciencedirect.com/science/article/pii/S0927025623004159