PAPRECA hybrid off-lattice kMC/MD simulator  2.0.0 (17 September 2024)
lammps_wrappers.h
Go to the documentation of this file.
1 /*----------------------------------------------------------------------------------------
2 PAPRECA hybrid off-lattice kinetic Monte Carlo/Molecular dynamics simulator.
3 Copyright (C) 2024 Stavros Ntioudis, James P. Ewen, Daniele Dini, and C. Heath Turner
4 
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 as published by the Free Software Foundation; either version 2
8 of the License, or (at your option) any later version.
9 
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14 
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 ----------------------------------------------------------------------------------------*/
19 
24 
25 #ifndef LAMMPS_WRAPPERS_H
26 #define LAMMPS_WRAPPERS_H
27 
28 //System Headers
29 #include <string>
30 #include <cstdio>
31 #include <cstdlib>
32 #include <cstring>
33 #include <iostream>
34 #include <mpi.h>
35 #include <vector>
36 #include <array>
37 #include <cmath>
38 
39 //LAMMPS headers
40 #include "lammps.h"
42 #include "atom.h"
43 #include "molecule.h"
44 #include "library.h"
45 #include "input.h"
46 #include "domain.h"
47 #include "force.h"
48 #include "pair.h"
50 
51 //kMC Headers
52 #include "papreca_error.h"
53 #include "utilities.h"
54 
55 
56 namespace PAPRECA{
57 
58  //Initialize LAMMPS
59  void initializeLMP( LAMMPS_NS::LAMMPS **lmp );
60  void readLMPinput( const std::string &lmp_input , LAMMPS_NS::LAMMPS *lmp );
61 
62  //Execute LAMMPS
63  void runLammps( LAMMPS_NS::LAMMPS *lmp , const int &timesteps_num );
64  void MPIBcastAndExecuteCommand( LAMMPS_NS::LAMMPS *lmp , std::string &command ); //This function gets a line command (std::string), casts it to all other procs, and executes the command
65 
66  //Period Box Operations
67  void remap3DArrayInPeriodicBox( LAMMPS_NS::LAMMPS *lmp , double *arr ); //Receives a 3D array and remaps it inside the existing periodic box.
68 
69  //kMC operations
70  void deleteAtoms( LAMMPS_NS::LAMMPS *lmp , LAMMPS_NS::tagint *atom_ids , const int &num_atoms , const std::string &delete_bonds , const std::string &delete_molecule );
71  void deleteAtoms( LAMMPS_NS::LAMMPS *lmp , std::vector< LAMMPS_NS::tagint > &atom_ids , const std::string &delete_bonds , const std::string &delete_molecule ); //Overloaded function of the deleteAtoms function to work with vectors
72  void deleteAtomsInBoxRegion( LAMMPS_NS::LAMMPS *lmp , double &boxxlo , double &boxxhi , double &boxylo , double &boxyhi , double &boxzlo , double &boxzhi , const std::string &delete_bonds , const std::string &delete_molecule );
73  void createAtom( LAMMPS_NS::LAMMPS *lmp , const double atom_pos[3] , const int &atom_type );
74  void deleteBond( LAMMPS_NS::LAMMPS *lmp , const LAMMPS_NS::tagint &atom1id , const LAMMPS_NS::tagint &atom2id , const bool special );
75  void formBond( LAMMPS_NS::LAMMPS *lmp , const LAMMPS_NS::tagint &atom1id , const LAMMPS_NS::tagint &atom2id , const int &bond_type );
76  void resetMobileAtomsGroups( LAMMPS_NS::LAMMPS *lmp , const std::vector< int > &fluid_atomtypes );
77  void insertMolecule( LAMMPS_NS::LAMMPS *lmp , const double site_pos[3] , const double rot_pos[3] , const double &rot_theta , const int &mol_id , const char *mol_name );
78  void diffuseAtom( LAMMPS_NS::LAMMPS *lmp , const double vac_pos[3] , const LAMMPS_NS::tagint &parent_id , const int &parent_type , const int &is_displacive , const int &diffused_type );
79 
80  //Sigmas
81  void initType2SigmaFromLammpsPairCoeffs( LAMMPS_NS::LAMMPS *lmp , INTPAIR2DOUBLE_MAP &type2sigma );
82 
83  //Neibs lists
84  int getMaskedNeibIndex( int *neighbors , int &j );
85 
86  //Bond Lists
87  void initAndGatherBondsList( LAMMPS_NS::LAMMPS *lmp , LAMMPS_NS::tagint **bonds_list , LAMMPS_NS::bigint &bonds_num );
88 
89  //Molecules
90  static inline const int getMolIndexFromMolName( LAMMPS_NS::LAMMPS *lmp , std::string mol_name );
91  void computeMolCenter( LAMMPS_NS::LAMMPS *lmp , std::string mol_name );
92 
93  //Files
94  void dumpRestart( LAMMPS_NS::LAMMPS *lmp , const int &KMC_loopid , const int &dump_freq );
95 
96  //LAMMPS Maths wrappers
97  double get3DSqrDistWithPBC( LAMMPS_NS::LAMMPS *lmp , const double *x1 , const double *x2 );
98 
99 
100 }//end of namespace PAPRECA
101 
102 
103 #endif
Definition: bond.cpp:26
void remap3DArrayInPeriodicBox(LAMMPS_NS::LAMMPS *lmp, double *arr)
Definition: lammps_wrappers.cpp:61
void computeMolCenter(LAMMPS_NS::LAMMPS *lmp, std::string mol_name)
Definition: lammps_wrappers.cpp:389
void MPIBcastAndExecuteCommand(LAMMPS_NS::LAMMPS *lmp, std::string &command)
void resetMobileAtomsGroups(LAMMPS_NS::LAMMPS *lmp, const std::vector< int > &fluid_atomtypes)
Definition: lammps_wrappers.cpp:73
void insertMolecule(LAMMPS_NS::LAMMPS *lmp, const double site_pos[3], const double rot_pos[3], const double &rot_theta, const int &type_offset, const char *mol_name)
Definition: lammps_wrappers.cpp:242
void deleteAtomsInBoxRegion(LAMMPS_NS::LAMMPS *lmp, double &boxxlo, double &boxxhi, double &boxylo, double &boxyhi, double &boxzlo, double &boxzhi, const std::string &delete_bonds, const std::string &delete_molecule)
Definition: lammps_wrappers.cpp:151
void runLammps(LAMMPS_NS::LAMMPS *lmp, const int &timesteps_num)
Definition: lammps_wrappers.cpp:47
void readLMPinput(const std::string &lmp_input, LAMMPS_NS::LAMMPS *lmp)
Definition: lammps_wrappers.cpp:37
void deleteAtoms(LAMMPS_NS::LAMMPS *lmp, LAMMPS_NS::tagint *atom_ids, const int &num_atoms, const std::string &delete_bonds, const std::string &delete_molecule)
Definition: lammps_wrappers.cpp:88
void initAndGatherBondsList(LAMMPS_NS::LAMMPS *lmp, LAMMPS_NS::tagint **bonds_list, LAMMPS_NS::bigint &bonds_num)
Definition: lammps_wrappers.cpp:358
void formBond(LAMMPS_NS::LAMMPS *lmp, const LAMMPS_NS::tagint &atom1id, const LAMMPS_NS::tagint &atom2id, const int &bond_type)
Definition: lammps_wrappers.cpp:227
void dumpRestart(LAMMPS_NS::LAMMPS *lmp, const int &KMC_loopid, const int &dump_freq)
Definition: lammps_wrappers.cpp:406
double get3DSqrDistWithPBC(LAMMPS_NS::LAMMPS *lmp, const double *x1, const double *x2)
Definition: lammps_wrappers.cpp:427
void initType2SigmaFromLammpsPairCoeffs(LAMMPS_NS::LAMMPS *lmp, INTPAIR2DOUBLE_MAP &type2sigma)
Definition: lammps_wrappers.cpp:301
int getMaskedNeibIndex(int *neighbors, int &j)
Definition: lammps_wrappers.cpp:342
void diffuseAtom(LAMMPS_NS::LAMMPS *lmp, const double vac_pos[3], const LAMMPS_NS::tagint &parent_id, const int &parent_type, const int &is_displacive, const int &diffused_type)
Definition: lammps_wrappers.cpp:266
std::unordered_map< INT_PAIR, double, PairHash > INTPAIR2DOUBLE_MAP
Definition: utilities.h:178
void deleteBond(LAMMPS_NS::LAMMPS *lmp, const LAMMPS_NS::tagint &atom1id, const LAMMPS_NS::tagint &atom2id, const bool special)
Definition: lammps_wrappers.cpp:196
void initializeLMP(LAMMPS_NS::LAMMPS **lmp)
Initialize LAMMPS.
Definition: lammps_wrappers.cpp:28
const int getMolIndexFromMolName(LAMMPS_NS::LAMMPS *lmp, std::string mol_name)
Definition: lammps_wrappers.cpp:374
void createAtom(LAMMPS_NS::LAMMPS *lmp, const double atom_pos[3], const int &atom_type)
Definition: lammps_wrappers.cpp:180
Functions that enable the communication of error/warning messages to the terminal and coordinate the ...
Utility functions (e.g., for arrays, strings etc.) and typedefs used in papreca.cpp main and in the o...