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 append( const int &KMC_loopid , const double &time , const char *event_type );
85 
86  };
87 
88 
89 
90 
91  class HeightVtime : public File{
92 
95 
96  friend class PaprecaConfig;
97 
98  public:
99  //Constructors/Destructors
100  HeightVtime( );
101  HeightVtime( const int &print_freq_in );
102  ~HeightVtime( );
103 
104  //functions
105  void init( );
106  void append( const double &time , const double &film_height );
107 
108  };
109 
110  class SurfaceCoverage : public File{
111 
114 
115  friend class PaprecaConfig;
116 
117  public:
118  //Constructors/Destructors
119  SurfaceCoverage( );
120  SurfaceCoverage( const int &print_freq_in );
121  ~SurfaceCoverage( );
122 
123  //Functions
124  void init( );
125  void append( const double &time , const double &surface_coverage );
126 
127  };
128 
129  class ElementalDistribution : public File{
130 
133 
134  friend class PaprecaConfig;
135 
136  public:
137  //Constructors/Destructors
139  ElementalDistribution( const int &print_freq_in );
141 
142  //functions
143  void init( const int &KMC_loopid , const int &types_num );
144  void append( LAMMPS_NS::LAMMPS *lmp , double **mass_profiles , const int &types_num , const int &bins_num , const double &bin_width , double *atom_mass );
145 
146  };
147 
148 
149  class ExecTime : public File{
150 
153 
154  friend class PaprecaConfig;
155 
156  public:
157  //Constructors/Destructors
158  ExecTime( );
159  ExecTime( const int &print_freq_in );
160  ~ExecTime( );
161 
162  //functions
163  void init( );
164  void append( const int &step_num , const int &atoms_num );
165  void close( ) override;
166  //Total Time Calculation
167  void setHybridStartTimeStamp( );
168  void calcHybridTime( const int &nprocs );
169  void resetHybridTimeVariables( );
170  //MD time calculation
171  void setMDstartTimeStamp( );
172  void calcMDtime( const int &nprocs );
173  void resetMDtimeVariables( );
174  //KMC time calculation
175  void calcKMCtime( const int &nprocs );
176  void resetKMCtimeVariables( );
177  //General functions
178  void calcTimes( const int &nprocs );
179  void resetTimeVariables( );
180 
181 
182  protected:
183 
184  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;
185  double thybrid_min = 0.0 , thybrid_avg = 0.0 , thybrid_max = 0.0;
186  double tkmc_min = 0.0 , tkmc_avg = 0.0 , tkmc_max = 0.0;
187  double tmd_min = 0.0 , tmd_avg = 0.0 , tmd_max = 0.0;
188  double thybrid_total = 0.0 , tkmc_total = 0.0 , tmd_total = 0.0;
189 
190 
191  };
192 
193 
194 }//end of namespace Papreca
195 
196 
197 #endif
Child class of File, manages distribution.log files.
Definition: export_files.h:129
void init(const int &KMC_loopid, const int &types_num)
Definition: export_files.cpp:144
~ElementalDistribution()
Definition: export_files.cpp:141
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:168
ElementalDistribution()
Definition: export_files.cpp:139
Child class of File, manages execTimes.log files.
Definition: export_files.h:149
double thybrid_min
Definition: export_files.h:185
void close() override
Definition: export_files.cpp:366
void setMDstartTimeStamp()
Definition: export_files.cpp:265
double t2_hybrid
Definition: export_files.h:184
double tmd_max
Definition: export_files.h:187
void resetTimeVariables()
Definition: export_files.cpp:339
void append(const int &step_num, const int &atoms_num)
Definition: export_files.cpp:349
void calcTimes(const int &nprocs)
Definition: export_files.cpp:330
double tmd_min
Definition: export_files.h:187
void resetKMCtimeVariables()
Definition: export_files.cpp:318
double t_hybrid
Definition: export_files.h:184
double t_md
Definition: export_files.h:184
double thybrid_total
Definition: export_files.h:188
void calcKMCtime(const int &nprocs)
Definition: export_files.cpp:304
void setHybridStartTimeStamp()
Definition: export_files.cpp:227
void init()
Definition: export_files.cpp:212
double tkmc_max
Definition: export_files.h:186
ExecTime()
Definition: export_files.cpp:206
double thybrid_max
Definition: export_files.h:185
double t1_md
Definition: export_files.h:184
void resetMDtimeVariables()
Definition: export_files.cpp:290
void resetHybridTimeVariables()
Definition: export_files.cpp:252
double t1_hybrid
Definition: export_files.h:184
double tkmc_min
Definition: export_files.h:186
double t2_md
Definition: export_files.h:184
double tmd_avg
Definition: export_files.h:187
double t_kmc
Definition: export_files.h:184
double thybrid_avg
Definition: export_files.h:185
~ExecTime()
Definition: export_files.cpp:208
double tkmc_avg
Definition: export_files.h:186
void calcHybridTime(const int &nprocs)
Definition: export_files.cpp:234
double tkmc_total
Definition: export_files.h:188
double tmd_total
Definition: export_files.h:188
void calcMDtime(const int &nprocs)
Definition: export_files.cpp:272
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:91
void append(const double &time, const double &film_height)
Definition: export_files.cpp:92
void init()
Definition: export_files.cpp:78
HeightVtime()
Definition: export_files.cpp:73
~HeightVtime()
Definition: export_files.cpp:75
Child class of File, manages papreca.log files.
Definition: export_files.h:70
~Log()
Definition: export_files.cpp:44
void init()
Definition: export_files.cpp:47
void append(const int &KMC_loopid, const double &time, const char *event_type)
Definition: export_files.cpp:63
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:110
void init()
Definition: export_files.cpp:109
~SurfaceCoverage()
Definition: export_files.cpp:106
SurfaceCoverage()
Definition: export_files.cpp:104
void append(const double &time, const double &surface_coverage)
Definition: export_files.cpp:123
Definition: bond.cpp:26