PAPRECA hybrid off-lattice kMC/MD simulator  2.0.0 (17 September 2024)
event_list.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 
28 
29 #ifndef EVENT_LIST_H
30 #define EVENT_LIST_H
31 
32 //system headers
33 #include <utility>
34 #include <unordered_map>
35 #include <string>
36 #include <vector>
37 #include <unordered_set>
38 #include <unordered_map>
39 #include <mpi.h>
40 
41 //LAMMPS Headers
42 #include "lammps.h"
44 #include "atom.h"
45 #include "pointers.h"
46 #include "molecule.h"
48 
49 //kMC Headers
50 #include "utilities.h"
51 
52 
53 namespace PAPRECA{
54 
56 
59 
60  public:
61  //Constructors/Destructors. The user can use the first constructor if no catalyzing_type(s) are defined. We know that a reaction is NOT catalyzed if the catalyzing_types vector is empty.
62  PredefinedReaction( const int &atom1_type_in , const int &atom2_type_in , const int &bond_type_in , const double &rate_in );
63  PredefinedReaction( const int &atom1_type_in , const int &atom2_type_in , const int &bond_type_in , const double &rate_in , const std::vector< int > &catalyzing_types_in );
65 
66  //Functions
67  const int &getAtom1Type( ) const;
68  const int &getAtom2Type( ) const;
69  const int &getBondType( ) const;
70  const double &getRate( ) const;
71  const std::vector< int > &getCatalyzingTypes( ) const;
72  const bool &isForm( ) const;
73 
74  protected:
75  int atom1_type = -1;
76  int atom2_type = -2;
77  int bond_type = -3;
78  double rate = 0.0;
79  std::vector< int > catalyzing_types;
80  bool is_form = false;
81 
82  };
83 
85 
88 
89  public:
90  //Constructors/Destructors
91  PredefinedBondForm( const int &atom1_type_in , const int &atom2_type_in , const int &bond_type_in , const double &rate_in , const double &bond_dist_sqr_in , const int &delete_atoms_in , const int &lone_candidates_in , const bool &same_mol_in );
92  PredefinedBondForm( const int &atom1_type_in , const int &atom2_type_in , const int &bond_type_in , const double &rate_in , const double &bond_dist_sqr_in , const int &delete_atoms_in , const int &lone_candidates_in , const bool &same_mol_in , const std::vector< int > &catalyzing_types_in );
94 
95  //Functions
96  const double &getBondDistSqr( ) const;
97  const bool &isSameMol( ) const;
98  const int &isDeleteAtoms( ) const;
99  const int &isLone( ) const;
100 
101  protected:
102  double bond_dist_sqr = 0.0;
103  bool same_mol = false;
104  int delete_atoms = 0;
105  int lone_candidates = 0;
106  };
107 
108 
110 
113 
114  public:
115  //Constructor/Destructors
116  PredefinedDiffusionHop( const int &parent_type_in , const double &insertion_vel_in , const double &diffusion_dist_in , const double &rate_in , const std::string &custom_style_in , const std::vector< int > &style_atomtypes_in ); //Initializing a PredefinedDiffusionHop object without a diffused type immediately sets the diffusion type to displacive (i.e., the parent atom moves).
117  PredefinedDiffusionHop( const int &parent_type_in , const double &insertion_vel_in , const double &diffusion_dist_in , const double &rate_in , const std::string &custom_style_in , const std::vector< int > &style_atomtypes_in , const int &diffused_type_in , const bool &is_displacive_in ); //This constructor gives the freedom to set diffused type as well as type of diffusion hop (i.e., displacive==parent atom moves, non-displacive==new atom spawns on vacant site).
119 
120  //Functions
121  const int &getParentAtomType( ) const;
122  const double &getInsertionVel( ) const;
123  const int &getDiffusedAtomType( ) const;
124  const bool &isDisplacive( ) const;
125  const double &getDiffusionDist( ) const;
126  const double &getRate( ) const;
127  const std::string &getCustomStyle( ) const;
128  const std::vector< int > &getStyleAtomTypes( ) const;
129 
130  private:
131  int parent_type = -1;
132  double insertion_vel = 0.0;
133  int diffused_type = -2;
134  bool is_displacive = false; //You can have displacive diffusion and the parent type being different from the diffused type, if you want the atom type to change when it moves.
135  double diffusion_dist = 0.0;
136  std::string custom_style = "NONE";
137  std::vector< int > style_atomtypes;
138  double rate = 0.0;
139 
140  };
141 
143 
146  public:
147  //Constructor/Destructor
148  PredefinedDeposition( LAMMPS_NS::LAMMPS *lmp , const int &parent_type_in , const double &rate_in , const double &depo_offset_in , const double &insertion_vel_in , const std::string &adsorbate_name_in );
149  PredefinedDeposition( LAMMPS_NS::LAMMPS *lmp , const int &parent_type_in , const double &rate_in , const double &depo_offset_in , const double &insertion_vel_in , const std::string &adsorbate_name_in , const double &sticking_coeff_in );
151 
152  //Functions
153  const int &getParentType( ) const;
154  const double &getRate( ) const;
155  const double &getDepoOffset( ) const;
156  const double &getInsertionVel( ) const;
157  const bool &hasVariableStickingCoeff( ) const;
158  const double &getStickingCoeff( ) const;
159  void setStickingCoeff( const double &sticking_coeff_in );
160  void incrementDepositionTries( );
161  const int &getDepositionTries( ) const;
162  void resetDepositionTries( );
163  void incrementDepositionSites( );
164  const int &getDepositionSites( ) const;
165  void resetDepositionSites( );
167  const std::string &getAdsorbateName( ) const;
168  const int &getAtomsNum( ) const;
169  int *getAtomTypes( );
170  double *getCenter( ) ;
171  double **getCoords( );
172 
173 
174  private:
175  int parent_type = -1;
176  double rate = 0.0;
177  double depo_offset = 0.0;
178  double insertion_vel = 0.0;
179  bool variable_sticking = true;
182  double sticking_coeff = -1.0;
183  std::string adsorbate_name = "NONE";
184 
185  //Lammps template definitions
186  int atoms_num = 0;
187  int *atom_types = NULL;
188  double *center = NULL; //< Template molecule center coordinates array from lammps. This is a pointer to a double[3] array (defined in the LAMMPS header molecule.h).
189  double **coords = NULL;
190 
191 
192  };
193 
195 
198  public:
199  //Constructors/Destructors
200  PredefinedMonoatomicDesorption( const int &parent_type_in , const double &rate_in );
202 
203  //Functions
204  const int &getParentAtomType( ) const;
205  const double &getRate( ) const;
206 
207  private:
208  int parent_type = -1;
209  double rate = 0.0;
210 
211  };
212 
213  //Typedefs
214  typedef std::unordered_map< int , PredefinedReaction* > TYPE2REACTION_MAP;
215  typedef std::unordered_map< INT_PAIR , PredefinedBondForm* , PairHash > PAIR2BONDFORM_MAP;
216 
217  typedef std::unordered_map< int , PredefinedDiffusionHop* > TYPE2DIFFUSION_MAP;
218  typedef std::unordered_map< int , PredefinedDeposition* > TYPE2DEPOSITION_MAP;
219  typedef std::unordered_map< int , PredefinedMonoatomicDesorption* > TYPE2MONODES_MAP;
220 
221 
223 
230 
231  private:
232 
233  friend class PaprecaConfig; //PaprecaConfig is a friend class as it accesses some of those private members to return predefined events to the main function.
234 
235  //Functions used by the destructor
239  void clearBondsMaxMap( );
242 
243  //Constructors/Destructors
246 
247  //PredefinedReactions
250 
251  //Predefined bond forms
256 
257  //Predefined diffusions
260 
261 
262  //Predefined depositions
265 
266  //Predefined Monoatomic Desorptions
269 
270 
271  };
272 
273 
274 }//end of namespace PAPRECA
275 
276 
277 #endif
Class storing settings and global variables for the PAPRECA run.
Definition: papreca_config.h:51
child class of PAPRECA::PredefinedReaction associated with bond formation events. This is a Predefine...
Definition: event_list.h:84
int lone_candidates
Lones are atoms without any bonds. If line_candidates=true, then both atom1 and atom2 have to be "lon...
Definition: event_list.h:105
const double & getBondDistSqr() const
Definition: event_list.cpp:53
const int & isDeleteAtoms() const
Definition: event_list.cpp:55
const bool & isSameMol() const
Definition: event_list.cpp:54
~PredefinedBondForm()
Definition: event_list.cpp:49
bool same_mol
if true, then bond formation can occur even if the molecule IDs of atom1 and atom2 are the same.
Definition: event_list.h:103
int delete_atoms
if delete_atoms=1, then atom1 and atom2 are deleted after the formation event. This variable is "tech...
Definition: event_list.h:104
const int & isLone() const
Definition: event_list.cpp:56
double bond_dist_sqr
if the distance between atom1 and atom2 is less than or equal to bond_dist then the formation event i...
Definition: event_list.h:102
PredefinedBondForm(const int &atom1_type_in, const int &atom2_type_in, const int &bond_type_in, const double &rate_in, const double &bond_dist_sqr_in, const int &delete_atoms_in, const int &lone_candidates_in, const bool &same_mol_in)
Definition: event_list.cpp:47
class associated with deposition events. This is a Predefined template for PAPRECA::Deposition events...
Definition: event_list.h:142
const bool & hasVariableStickingCoeff() const
Definition: event_list.cpp:107
double depo_offset
the molecule/particle is placed at a distance of depo_offset above the parent candidate atom.
Definition: event_list.h:177
void setStickingCoeff(const double &sticking_coeff_in)
Definition: event_list.cpp:108
int * atom_types
Template molecule types from lammps. This is an int[mol_natoms] array.
Definition: event_list.h:187
double rate
Definition: event_list.h:176
PredefinedDeposition(LAMMPS_NS::LAMMPS *lmp, const int &parent_type_in, const double &rate_in, const double &depo_offset_in, const double &insertion_vel_in, const std::string &adsorbate_name_in)
Definition: event_list.cpp:83
void incrementDepositionSites()
Definition: event_list.cpp:113
const int & getParentType() const
Definition: event_list.cpp:103
const int & getAtomsNum() const
Definition: event_list.cpp:121
void resetDepositionSites()
Definition: event_list.cpp:115
const int & getDepositionTries() const
Definition: event_list.cpp:111
std::string adsorbate_name
name of adsorbate. This has to be identical to the adsorbate name as initialized in the LAMMPS input ...
Definition: event_list.h:183
double ** coords
Template molecule xyz (coordinates) array from lammps. This is a pointer to double[mol_natoms][3].
Definition: event_list.h:189
double * center
Definition: event_list.h:188
const double & getInsertionVel() const
Definition: event_list.cpp:106
const std::string & getAdsorbateName() const
Definition: event_list.cpp:120
const double & getRate() const
Definition: event_list.cpp:104
int atoms_num
Number of molecule atoms in LAMMPS (and in the xyz molecule/particle input file).
Definition: event_list.h:186
const int & getDepositionSites() const
Definition: event_list.cpp:114
void resetDepositionTries()
Definition: event_list.cpp:112
double ** getCoords()
Definition: event_list.cpp:124
void resetDepositionTriesAndSites()
Definition: event_list.cpp:116
void incrementDepositionTries()
Definition: event_list.cpp:110
const double & getStickingCoeff() const
Definition: event_list.cpp:109
~PredefinedDeposition()
Definition: event_list.cpp:100
int deposition_sites
available deposition sites for that specific deposition event.
Definition: event_list.h:181
double insertion_vel
velocity of inserted molecule/particle.
Definition: event_list.h:178
double * getCenter()
Definition: event_list.cpp:123
bool variable_sticking
true or false for variable and fixed sticking coefficients, respectively.
Definition: event_list.h:179
const double & getDepoOffset() const
Definition: event_list.cpp:105
int deposition_tries
total sites (i.e., free + occupied) for that specific deposition event.
Definition: event_list.h:180
int parent_type
type of candidate parent atom.
Definition: event_list.h:175
int * getAtomTypes()
Definition: event_list.cpp:122
double sticking_coeff
sticking coefficient (i.e., free sites/ total sites). Does not change its value if variable_sticking=...
Definition: event_list.h:182
class associated with diffusion events. This is a Predefined template for PAPRECA::DiffusionHop event...
Definition: event_list.h:109
PredefinedDiffusionHop(const int &parent_type_in, const double &insertion_vel_in, const double &diffusion_dist_in, const double &rate_in, const std::string &custom_style_in, const std::vector< int > &style_atomtypes_in)
Definition: event_list.cpp:64
const int & getDiffusedAtomType() const
Definition: event_list.cpp:71
~PredefinedDiffusionHop()
Definition: event_list.cpp:66
const double & getRate() const
Definition: event_list.cpp:74
const std::string & getCustomStyle() const
Definition: event_list.cpp:75
const int & getParentAtomType() const
Definition: event_list.cpp:69
std::string custom_style
displace atom by that much.
Definition: event_list.h:136
const double & getDiffusionDist() const
Definition: event_list.cpp:73
double diffusion_dist
Definition: event_list.h:135
std::vector< int > style_atomtypes
vector that allows you to pass information about atom types from the PAPRECA input file.
Definition: event_list.h:137
int diffused_type
type of diffused atom. This can be the same as the parent type. Alternatively, it can be set to a dif...
Definition: event_list.h:133
const std::vector< int > & getStyleAtomTypes() const
Definition: event_list.cpp:76
const double & getInsertionVel() const
Definition: event_list.cpp:70
double rate
Definition: event_list.h:138
int parent_type
type of candidate parent atom.
Definition: event_list.h:131
double insertion_vel
velocity of the displaced atom.
Definition: event_list.h:132
bool is_displacive
Definition: event_list.h:134
const bool & isDisplacive() const
Displacive events "move" the parent atom, while non-displacive events, create a new atom at the vacan...
Definition: event_list.cpp:72
General class that stores ALL the predefined events in the system. You can consider this as the Prede...
Definition: event_list.h:222
~PredefinedEventsCatalog()
Definition: event_list.cpp:285
INT2INT_MAP bonds_max
Limiting the maximum number of bonds per atom type.
Definition: event_list.h:254
INT_SET depositions_set
Set of atom types (ints) that can be parents to deposition events.
Definition: event_list.h:263
INT_SET diffusions_set
Set of diffusable types.
Definition: event_list.h:258
INT_SET monodes_set
Set of atom types (ints) that can be parents to monoatomic desorption events.
Definition: event_list.h:267
void deletePredefinedBondBreaksFromMap()
Definition: event_list.cpp:238
void deletePredefinedDiffusionsFromMap()
Definition: event_list.cpp:184
void clearBondsMaxMap()
Definition: event_list.cpp:236
PAIR_SET bond_forms_set
Set of bond formable pair of ints (representing types of atoms).
Definition: event_list.h:252
PAIR2BONDFORM_MAP bond_forms_map
Mapping pair of ints to corresponding predefined bond formation event.
Definition: event_list.h:253
void deletePredefinedBondFormsFromMap()
Definition: event_list.cpp:208
void deletePredefinedDepositionsFromMap()
Definition: event_list.cpp:139
void deletePredefinedMonoatomicDesorptionsFromMap()
Definition: event_list.cpp:260
TYPE2MONODES_MAP monodes_map
Mapping atom type to corresponding desorption event.
Definition: event_list.h:268
INT_SET bond_breaks_set
Set of ints (representing bond types).
Definition: event_list.h:248
TYPE2REACTION_MAP bond_breaks_map
Mapping breaking bond types to corresponding predefined bond break event.
Definition: event_list.h:249
PredefinedEventsCatalog()
Definition: event_list.cpp:284
TYPE2DEPOSITION_MAP depositions_map
Mapping atom type to corresponding deposition event.
Definition: event_list.h:264
INT2INTSMAP_MAP bondtypes_max
This can be used if you want to limit the number of specific bonds that an atom type can form....
Definition: event_list.h:255
TYPE2DIFFUSION_MAP diffusions_map
Mapping diffusable type to corresponding diffusion event.
Definition: event_list.h:259
associated with monoatomic desorption events. This is a Predefined template for PAPRECA::MonoatomicDe...
Definition: event_list.h:194
double rate
Definition: event_list.h:209
int parent_type
Definition: event_list.h:208
const double & getRate() const
Definition: event_list.cpp:134
PredefinedMonoatomicDesorption(const int &parent_type_in, const double &rate_in)
Definition: event_list.cpp:129
~PredefinedMonoatomicDesorption()
Definition: event_list.cpp:130
const int & getParentAtomType() const
Definition: event_list.cpp:133
class associated with reaction events. This is a Predefined template for PAPRECA::BondBreak and PAPRE...
Definition: event_list.h:55
const int & getAtom2Type() const
Definition: event_list.cpp:36
const std::vector< int > & getCatalyzingTypes() const
Definition: event_list.cpp:39
int atom2_type
Definition: event_list.h:76
int atom1_type
Definition: event_list.h:75
~PredefinedReaction()
Definition: event_list.cpp:32
bool is_form
this variable allows us to differentiate between the parent class PAPRECA::PredefinedReaction and the...
Definition: event_list.h:80
double rate
Definition: event_list.h:78
const double & getRate() const
Definition: event_list.cpp:38
std::vector< int > catalyzing_types
these types of atoms have to be present in the neighborhood of atom1 or atom2. Otherwise,...
Definition: event_list.h:79
const int & getAtom1Type() const
Definition: event_list.cpp:35
const int & getBondType() const
Definition: event_list.cpp:37
int bond_type
Definition: event_list.h:77
PredefinedReaction(const int &atom1_type_in, const int &atom2_type_in, const int &bond_type_in, const double &rate_in)
Definition: event_list.cpp:30
const bool & isForm() const
Definition: event_list.cpp:40
Definition: bond.cpp:26
std::unordered_map< INT_PAIR, PredefinedBondForm *, PairHash > PAIR2BONDFORM_MAP
Definition: event_list.h:215
std::unordered_map< int, INT2INT_MAP > INT2INTSMAP_MAP
Definition: utilities.h:182
std::unordered_set< int > INT_SET
Definition: utilities.h:183
std::unordered_set< INT_PAIR, PairHash > PAIR_SET
Definition: utilities.h:176
std::unordered_map< int, PredefinedDiffusionHop * > TYPE2DIFFUSION_MAP
Definition: event_list.h:217
std::unordered_map< int, PredefinedMonoatomicDesorption * > TYPE2MONODES_MAP
Definition: event_list.h:219
std::unordered_map< int, int > INT2INT_MAP
Definition: utilities.h:181
std::unordered_map< int, PredefinedDeposition * > TYPE2DEPOSITION_MAP
Definition: event_list.h:218
std::unordered_map< int, PredefinedReaction * > TYPE2REACTION_MAP
Definition: event_list.h:214
Utility functions (e.g., for arrays, strings etc.) and typedefs used in papreca.cpp main and in the o...