PAPRECA hybrid off-lattice kMC/MD simulator  2.0.0 (17 September 2024)
export_files.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 
22 
23 #ifndef EXPORT_FILES_H
24 #define EXPORT_FILES_H
25 
26 //System Headers
27 #include <cstdio>
28 #include <chrono>
29 #include <cmath>
30 #include <fstream>
31 #include <iomanip>
32 #include <mpi.h>
33 
34 //LAMMPS headers
35 #include "lammps.h"
36 #include "domain.h"
37 namespace PAPRECA{
38 
39  /* The classes below manage the result files exported by a run. New export files should be added here and a relevant implementation in the papreca_config.h and input_file.h headers should be included to read/manage/setup the files. */
40 
41  class File{
42 
45 
46  friend class PaprecaConfig; //PaprecaConfig reads the protected/private variables of file classes so it is declared as a friend class.
47 
48  public:
49  //Constructors/Destructors
50  File( );
51  File( const int &print_freq_in );
52  virtual ~File( );
53 
54  //Functions
55  virtual void close( );
56  void setActive( );
57  void setIncative( );
58  const bool isActive( ) const;
59  void setPrintFreq( const int &print_freq_in );
60  const int getPrintFreq( ) const;
61 
62  protected:
63  std::ofstream file;
64  bool is_active = false;
65  int print_freq = 0;
66 
67  };
68 
69 
70  class Log : public File{
71 
74 
75  friend class PaprecaConfig;
76 
77  public:
78  //Constructors/Destructors
79  Log( );
80  ~Log( );
81 
82  //functions
83  void init( );
84  void appendDeposition( const int &KMC_loopid , const double &time , const double *site_pos , const double *rot_pos , const double &rot_theta , const double &insertion_vel , const char *mol_name );
85  void appendBondForm( const int &KMC_loopid , const double &time , const LAMMPS_NS::tagint &atom1_id , const LAMMPS_NS::tagint &atom2_id , const int &bond_type);
86  void appendBondBreak( const int &KMC_loopid , const double &time , const LAMMPS_NS::tagint &atom1_id , const LAMMPS_NS::tagint &atom2_id , const int &bond_type);
87  void appendDiffusion( const int &KMC_loopid , const double &time , const double *vac_pos , const LAMMPS_NS::tagint &parent_id , const int &parent_type , const double &insertion_vel , const int &is_displacive , const int &diffused_type );
88  void appendMonoatomicDesorption( const int &KMC_loopid , const double &time , const int &parent_id , const int &parent_type );
89  };
90 
91 
92 
93 
94  class HeightVtime : public File{
95 
98 
99  friend class PaprecaConfig;
100 
101  public:
102  //Constructors/Destructors
103  HeightVtime( );
104  HeightVtime( const int &print_freq_in );
105  ~HeightVtime( );
106 
107  //functions
108  void init( );
109  void append( const double &time , const double &film_height );
110 
111  };
112 
113  class SurfaceCoverage : public File{
114 
117 
118  friend class PaprecaConfig;
119 
120  public:
121  //Constructors/Destructors
122  SurfaceCoverage( );
123  SurfaceCoverage( const int &print_freq_in );
124  ~SurfaceCoverage( );
125 
126  //Functions
127  void init( );
128  void append( const double &time , const double &surface_coverage );
129 
130  };
131 
132  class ElementalDistribution : public File{
133 
136 
137  friend class PaprecaConfig;
138 
139  public:
140  //Constructors/Destructors
142  ElementalDistribution( const int &print_freq_in );
144 
145  //functions
146  void init( const int &KMC_loopid , const int &types_num );
147  void append( LAMMPS_NS::LAMMPS *lmp , double **mass_profiles , const int &types_num , const int &bins_num , const double &bin_width , double *atom_mass );
148 
149  };
150 
151 
152  class ExecTime : public File{
153 
156 
157  friend class PaprecaConfig;
158 
159  public:
160  //Constructors/Destructors
161  ExecTime( );
162  ExecTime( const int &print_freq_in );
163  ~ExecTime( );
164 
165  //functions
166  void init( );
167  void append( const int &step_num , const int &atoms_num );
168  void close( ) override;
169  //Total Time Calculation
170  void setHybridStartTimeStamp( );
171  void calcHybridTime( const int &nprocs );
172  void resetHybridTimeVariables( );
173  //MD time calculation
174  void setMDstartTimeStamp( );
175  void calcMDtime( const int &nprocs );
176  void resetMDtimeVariables( );
177  //KMC time calculation
178  void calcKMCtime( const int &nprocs );
179  void resetKMCtimeVariables( );
180  //General functions
181  void calcTimes( const int &nprocs );
182  void resetTimeVariables( );
183 
184 
185  protected:
186 
187  double t_hybrid = 0.0 , t1_hybrid = 0.0 , t2_hybrid = 0.0 , t_md = 0.0 , t1_md = 0.0 , t2_md = 0.0 , t_kmc = 0.0;
188  double thybrid_min = 0.0 , thybrid_avg = 0.0 , thybrid_max = 0.0;
189  double tkmc_min = 0.0 , tkmc_avg = 0.0 , tkmc_max = 0.0;
190  double tmd_min = 0.0 , tmd_avg = 0.0 , tmd_max = 0.0;
191  double thybrid_total = 0.0 , tkmc_total = 0.0 , tmd_total = 0.0;
192 
193 
194  };
195 
196 
197 }//end of namespace Papreca
198 
199 
200 #endif
Child class of File, manages distribution.log files.
Definition: export_files.h:132
void init(const int &KMC_loopid, const int &types_num)
Definition: export_files.cpp:201
~ElementalDistribution()
Definition: export_files.cpp:198
void append(LAMMPS_NS::LAMMPS *lmp, double **mass_profiles, const int &types_num, const int &bins_num, const double &bin_width, double *atom_mass)
Definition: export_files.cpp:225
ElementalDistribution()
Definition: export_files.cpp:196
Child class of File, manages execTimes.log files.
Definition: export_files.h:152
double thybrid_min
Definition: export_files.h:188
void close() override
Definition: export_files.cpp:423
void setMDstartTimeStamp()
Definition: export_files.cpp:322
double t2_hybrid
Definition: export_files.h:187
double tmd_max
Definition: export_files.h:190
void resetTimeVariables()
Definition: export_files.cpp:396
void append(const int &step_num, const int &atoms_num)
Definition: export_files.cpp:406
void calcTimes(const int &nprocs)
Definition: export_files.cpp:387
double tmd_min
Definition: export_files.h:190
void resetKMCtimeVariables()
Definition: export_files.cpp:375
double t_hybrid
Definition: export_files.h:187
double t_md
Definition: export_files.h:187
double thybrid_total
Definition: export_files.h:191
void calcKMCtime(const int &nprocs)
Definition: export_files.cpp:361
void setHybridStartTimeStamp()
Definition: export_files.cpp:284
void init()
Definition: export_files.cpp:269
double tkmc_max
Definition: export_files.h:189
ExecTime()
Definition: export_files.cpp:263
double thybrid_max
Definition: export_files.h:188
double t1_md
Definition: export_files.h:187
void resetMDtimeVariables()
Definition: export_files.cpp:347
void resetHybridTimeVariables()
Definition: export_files.cpp:309
double t1_hybrid
Definition: export_files.h:187
double tkmc_min
Definition: export_files.h:189
double t2_md
Definition: export_files.h:187
double tmd_avg
Definition: export_files.h:190
double t_kmc
Definition: export_files.h:187
double thybrid_avg
Definition: export_files.h:188
~ExecTime()
Definition: export_files.cpp:265
double tkmc_avg
Definition: export_files.h:189
void calcHybridTime(const int &nprocs)
Definition: export_files.cpp:291
double tkmc_total
Definition: export_files.h:191
double tmd_total
Definition: export_files.h:191
void calcMDtime(const int &nprocs)
Definition: export_files.cpp:329
General parent file class. Any PAPRECA export file should be a child to this class.
Definition: export_files.h:41
void setActive()
Definition: export_files.cpp:34
File()
Definition: export_files.cpp:29
void setPrintFreq(const int &print_freq_in)
Definition: export_files.cpp:37
bool is_active
Definition: export_files.h:64
void setIncative()
Definition: export_files.cpp:35
const int getPrintFreq() const
Definition: export_files.cpp:38
std::ofstream file
Definition: export_files.h:63
virtual void close()
Definition: export_files.cpp:33
virtual ~File()
Definition: export_files.cpp:31
const bool isActive() const
Definition: export_files.cpp:36
int print_freq
Definition: export_files.h:65
Child class of File, manages heightVtime.log files.
Definition: export_files.h:94
void append(const double &time, const double &film_height)
Definition: export_files.cpp:149
void init()
Definition: export_files.cpp:135
HeightVtime()
Definition: export_files.cpp:130
~HeightVtime()
Definition: export_files.cpp:132
Child class of File, manages papreca.log files.
Definition: export_files.h:70
~Log()
Definition: export_files.cpp:44
void appendBondBreak(const int &KMC_loopid, const double &time, const LAMMPS_NS::tagint &atom1_id, const LAMMPS_NS::tagint &atom2_id, const int &bond_type)
Definition: export_files.cpp:91
void appendMonoatomicDesorption(const int &KMC_loopid, const double &time, const int &parent_id, const int &parent_type)
Definition: export_files.cpp:117
void init()
Definition: export_files.cpp:47
void appendBondForm(const int &KMC_loopid, const double &time, const LAMMPS_NS::tagint &atom1_id, const LAMMPS_NS::tagint &atom2_id, const int &bond_type)
Definition: export_files.cpp:81
void appendDiffusion(const int &KMC_loopid, const double &time, const double *vac_pos, const LAMMPS_NS::tagint &parent_id, const int &parent_type, const double &insertion_vel, const int &is_displacive, const int &diffused_type)
Definition: export_files.cpp:101
void appendDeposition(const int &KMC_loopid, const double &time, const double *site_pos, const double *rot_pos, const double &rot_theta, const double &insertion_vel, const char *mol_name)
Definition: export_files.cpp:69
Log()
Definition: export_files.cpp:43
Class storing settings and global variables for the PAPRECA run.
Definition: papreca_config.h:51
Child class of File, manages surface_coverage.log files.
Definition: export_files.h:113
void init()
Definition: export_files.cpp:166
~SurfaceCoverage()
Definition: export_files.cpp:163
SurfaceCoverage()
Definition: export_files.cpp:161
void append(const double &time, const double &surface_coverage)
Definition: export_files.cpp:180
Definition: bond.cpp:26