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  void setLengthEquil( const double &length_equil_in );
71  const double &getLengthEquil( ) const;
72  void setLimitLowSqr( const double &limit_low_sqr_in );
73  const double &getLimitLowSqr( ) const;
74  void setLimitHighSqr( const double &limit_high_sqr_in );
75  const double &getLimitHighSqr( ) const;
76  void setSqrLimits( const double &length_equil_in , const double &length_perc_in );
77  const double &getRate( ) const;
78  const std::vector< int > &getCatalyzingTypes( ) const;
79  const bool &isForm( ) const;
80 
81  protected:
82  int atom1_type = -1;
83  int atom2_type = -2;
84  int bond_type = -3;
85  double length_equil = 0.0; //Optional: Equilibrium bond length
86  double limit_low_sqr = 0.0; //Optional: Acceptable event only if bond length>= length_limit
87  double limit_high_sqr = 0.0;
88  double rate = 0.0;
89  std::vector< int > catalyzing_types;
90  bool is_form = false;
91 
92 
93  };
94 
96 
99 
100  public:
101  //Constructors/Destructors
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 );
103  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 );
105 
106  //Functions
107  const double &getBondDistSqr( ) const;
108  const bool &isSameMol( ) const;
109  const int &isDeleteAtoms( ) const;
110  const int &isLone( ) const;
111 
112  protected:
113  double bond_dist_sqr = 0.0;
114  bool same_mol = false;
115  int delete_atoms = 0;
116  int lone_candidates = 0;
117  };
118 
119 
121 
124 
125  public:
126  //Constructor/Destructors
127  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).
128  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).
130 
131  //Functions
132  const int &getParentAtomType( ) const;
133  const double &getInsertionVel( ) const;
134  const int &getDiffusedAtomType( ) const;
135  const bool &isDisplacive( ) const;
136  const double &getDiffusionDist( ) const;
137  const double &getRate( ) const;
138  const std::string &getCustomStyle( ) const;
139  const std::vector< int > &getStyleAtomTypes( ) const;
140 
141  private:
142  int parent_type = -1;
143  double insertion_vel = 0.0;
144  int diffused_type = -2;
145  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.
146  double diffusion_dist = 0.0;
147  std::string custom_style = "NONE";
148  std::vector< int > style_atomtypes;
149  double rate = 0.0;
150 
151  };
152 
154 
157  public:
158  //Constructor/Destructor
159  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 );
160  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 );
162 
163  //Functions
164  const int &getParentType( ) const;
165  const double &getRate( ) const;
166  const double &getDepoOffset( ) const;
167  const double &getInsertionVel( ) const;
168  const bool &hasVariableStickingCoeff( ) const;
169  const double &getStickingCoeff( ) const;
170  void setStickingCoeff( const double &sticking_coeff_in );
171  void incrementDepositionTries( );
172  const int &getDepositionTries( ) const;
173  void resetDepositionTries( );
174  void incrementDepositionSites( );
175  const int &getDepositionSites( ) const;
176  void resetDepositionSites( );
178  const std::string &getAdsorbateName( ) const;
179  const int &getAtomsNum( ) const;
180  int *getAtomTypes( );
181  double *getCenter( ) ;
182  double **getCoords( );
183 
184 
185  private:
186  int parent_type = -1;
187  double rate = 0.0;
188  double depo_offset = 0.0;
189  double insertion_vel = 0.0;
190  bool variable_sticking = true;
193  double sticking_coeff = -1.0;
194  std::string adsorbate_name = "NONE";
195 
196  //Lammps template definitions
197  int atoms_num = 0;
198  int *atom_types = NULL;
199  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).
200  double **coords = NULL;
201 
202 
203  };
204 
206 
209  public:
210  //Constructors/Destructors
211  PredefinedMonoatomicDesorption( const int &parent_type_in , const double &rate_in );
213 
214  //Functions
215  const int &getParentAtomType( ) const;
216  const double &getRate( ) const;
217 
218  private:
219  int parent_type = -1;
220  double rate = 0.0;
221 
222  };
223 
224  //Typedefs
225  typedef std::unordered_map< int , PredefinedReaction* > TYPE2REACTION_MAP;
226  typedef std::unordered_map< INT_PAIR , PredefinedBondForm* , PairHash > PAIR2BONDFORM_MAP;
227 
228  typedef std::unordered_map< int , PredefinedDiffusionHop* > TYPE2DIFFUSION_MAP;
229  typedef std::unordered_map< int , PredefinedDeposition* > TYPE2DEPOSITION_MAP;
230  typedef std::unordered_map< int , PredefinedMonoatomicDesorption* > TYPE2MONODES_MAP;
231 
232 
234 
241 
242  private:
243 
244  friend class PaprecaConfig; //PaprecaConfig is a friend class as it accesses some of those private members to return predefined events to the main function.
245 
246  //Functions used by the destructor
250  void clearBondsMaxMap( );
253 
254  //Constructors/Destructors
257 
258  //PredefinedReactions
261 
262  //Predefined bond forms
267 
268  //Predefined diffusions
271 
272 
273  //Predefined depositions
276 
277  //Predefined Monoatomic Desorptions
280 
281 
282  };
283 
284 
285 }//end of namespace PAPRECA
286 
287 
288 #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:95
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:116
const double & getBondDistSqr() const
Definition: event_list.cpp:70
const int & isDeleteAtoms() const
Definition: event_list.cpp:72
const bool & isSameMol() const
Definition: event_list.cpp:71
~PredefinedBondForm()
Definition: event_list.cpp:66
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:114
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:115
const int & isLone() const
Definition: event_list.cpp:73
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:113
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:64
class associated with deposition events. This is a Predefined template for PAPRECA::Deposition events...
Definition: event_list.h:153
const bool & hasVariableStickingCoeff() const
Definition: event_list.cpp:124
double depo_offset
the molecule/particle is placed at a distance of depo_offset above the parent candidate atom.
Definition: event_list.h:188
void setStickingCoeff(const double &sticking_coeff_in)
Definition: event_list.cpp:125
int * atom_types
Template molecule types from lammps. This is an int[mol_natoms] array.
Definition: event_list.h:198
double rate
Definition: event_list.h:187
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:100
void incrementDepositionSites()
Definition: event_list.cpp:130
const int & getParentType() const
Definition: event_list.cpp:120
const int & getAtomsNum() const
Definition: event_list.cpp:138
void resetDepositionSites()
Definition: event_list.cpp:132
const int & getDepositionTries() const
Definition: event_list.cpp:128
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:194
double ** coords
Template molecule xyz (coordinates) array from lammps. This is a pointer to double[mol_natoms][3].
Definition: event_list.h:200
double * center
Definition: event_list.h:199
const double & getInsertionVel() const
Definition: event_list.cpp:123
const std::string & getAdsorbateName() const
Definition: event_list.cpp:137
const double & getRate() const
Definition: event_list.cpp:121
int atoms_num
Number of molecule atoms in LAMMPS (and in the xyz molecule/particle input file).
Definition: event_list.h:197
const int & getDepositionSites() const
Definition: event_list.cpp:131
void resetDepositionTries()
Definition: event_list.cpp:129
double ** getCoords()
Definition: event_list.cpp:141
void resetDepositionTriesAndSites()
Definition: event_list.cpp:133
void incrementDepositionTries()
Definition: event_list.cpp:127
const double & getStickingCoeff() const
Definition: event_list.cpp:126
~PredefinedDeposition()
Definition: event_list.cpp:117
int deposition_sites
available deposition sites for that specific deposition event.
Definition: event_list.h:192
double insertion_vel
velocity of inserted molecule/particle.
Definition: event_list.h:189
double * getCenter()
Definition: event_list.cpp:140
bool variable_sticking
true or false for variable and fixed sticking coefficients, respectively.
Definition: event_list.h:190
const double & getDepoOffset() const
Definition: event_list.cpp:122
int deposition_tries
total sites (i.e., free + occupied) for that specific deposition event.
Definition: event_list.h:191
int parent_type
type of candidate parent atom.
Definition: event_list.h:186
int * getAtomTypes()
Definition: event_list.cpp:139
double sticking_coeff
sticking coefficient (i.e., free sites/ total sites). Does not change its value if variable_sticking=...
Definition: event_list.h:193
class associated with diffusion events. This is a Predefined template for PAPRECA::DiffusionHop event...
Definition: event_list.h:120
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:81
const int & getDiffusedAtomType() const
Definition: event_list.cpp:88
~PredefinedDiffusionHop()
Definition: event_list.cpp:83
const double & getRate() const
Definition: event_list.cpp:91
const std::string & getCustomStyle() const
Definition: event_list.cpp:92
const int & getParentAtomType() const
Definition: event_list.cpp:86
std::string custom_style
displace atom by that much.
Definition: event_list.h:147
const double & getDiffusionDist() const
Definition: event_list.cpp:90
double diffusion_dist
Definition: event_list.h:146
std::vector< int > style_atomtypes
vector that allows you to pass information about atom types from the PAPRECA input file.
Definition: event_list.h:148
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:144
const std::vector< int > & getStyleAtomTypes() const
Definition: event_list.cpp:93
const double & getInsertionVel() const
Definition: event_list.cpp:87
double rate
Definition: event_list.h:149
int parent_type
type of candidate parent atom.
Definition: event_list.h:142
double insertion_vel
velocity of the displaced atom.
Definition: event_list.h:143
bool is_displacive
Definition: event_list.h:145
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:89
General class that stores ALL the predefined events in the system. You can consider this as the Prede...
Definition: event_list.h:233
~PredefinedEventsCatalog()
Definition: event_list.cpp:302
INT2INT_MAP bonds_max
Limiting the maximum number of bonds per atom type.
Definition: event_list.h:265
INT_SET depositions_set
Set of atom types (ints) that can be parents to deposition events.
Definition: event_list.h:274
INT_SET diffusions_set
Set of diffusable types.
Definition: event_list.h:269
INT_SET monodes_set
Set of atom types (ints) that can be parents to monoatomic desorption events.
Definition: event_list.h:278
void deletePredefinedBondBreaksFromMap()
Definition: event_list.cpp:255
void deletePredefinedDiffusionsFromMap()
Definition: event_list.cpp:201
void clearBondsMaxMap()
Definition: event_list.cpp:253
PAIR_SET bond_forms_set
Set of bond formable pair of ints (representing types of atoms).
Definition: event_list.h:263
PAIR2BONDFORM_MAP bond_forms_map
Mapping pair of ints to corresponding predefined bond formation event.
Definition: event_list.h:264
void deletePredefinedBondFormsFromMap()
Definition: event_list.cpp:225
void deletePredefinedDepositionsFromMap()
Definition: event_list.cpp:156
void deletePredefinedMonoatomicDesorptionsFromMap()
Definition: event_list.cpp:277
TYPE2MONODES_MAP monodes_map
Mapping atom type to corresponding desorption event.
Definition: event_list.h:279
INT_SET bond_breaks_set
Set of ints (representing bond types).
Definition: event_list.h:259
TYPE2REACTION_MAP bond_breaks_map
Mapping breaking bond types to corresponding predefined bond break event.
Definition: event_list.h:260
PredefinedEventsCatalog()
Definition: event_list.cpp:301
TYPE2DEPOSITION_MAP depositions_map
Mapping atom type to corresponding deposition event.
Definition: event_list.h:275
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:266
TYPE2DIFFUSION_MAP diffusions_map
Mapping diffusable type to corresponding diffusion event.
Definition: event_list.h:270
associated with monoatomic desorption events. This is a Predefined template for PAPRECA::MonoatomicDe...
Definition: event_list.h:205
double rate
Definition: event_list.h:220
int parent_type
Definition: event_list.h:219
const double & getRate() const
Definition: event_list.cpp:151
PredefinedMonoatomicDesorption(const int &parent_type_in, const double &rate_in)
Definition: event_list.cpp:146
~PredefinedMonoatomicDesorption()
Definition: event_list.cpp:147
const int & getParentAtomType() const
Definition: event_list.cpp:150
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
void setLimitLowSqr(const double &limit_low_sqr_in)
Definition: event_list.cpp:40
const std::vector< int > & getCatalyzingTypes() const
Definition: event_list.cpp:56
const double & getLengthEquil() const
Definition: event_list.cpp:39
int atom2_type
Definition: event_list.h:83
double limit_high_sqr
Definition: event_list.h:87
void setLimitHighSqr(const double &limit_high_sqr_in)
Definition: event_list.cpp:42
int atom1_type
Definition: event_list.h:82
double length_equil
Definition: event_list.h:85
double limit_low_sqr
Definition: event_list.h:86
~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:90
const double & getLimitHighSqr() const
Definition: event_list.cpp:43
double rate
Definition: event_list.h:88
const double & getRate() const
Definition: event_list.cpp:55
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:89
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:84
const double & getLimitLowSqr() const
Definition: event_list.cpp:41
void setSqrLimits(const double &length_equil_in, const double &length_perc_in)
Definition: event_list.cpp:44
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
void setLengthEquil(const double &length_equil_in)
Definition: event_list.cpp:38
const bool & isForm() const
Definition: event_list.cpp:57
Definition: bond.cpp:26
std::unordered_map< INT_PAIR, PredefinedBondForm *, PairHash > PAIR2BONDFORM_MAP
Definition: event_list.h:226
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:228
std::unordered_map< int, PredefinedMonoatomicDesorption * > TYPE2MONODES_MAP
Definition: event_list.h:230
std::unordered_map< int, int > INT2INT_MAP
Definition: utilities.h:181
std::unordered_map< int, PredefinedDeposition * > TYPE2DEPOSITION_MAP
Definition: event_list.h:229
std::unordered_map< int, PredefinedReaction * > TYPE2REACTION_MAP
Definition: event_list.h:225
Utility functions (e.g., for arrays, strings etc.) and typedefs used in papreca.cpp main and in the o...