-
Notifications
You must be signed in to change notification settings - Fork 6
/
fix_eph_coloured_exp_v1.h
179 lines (137 loc) · 5.39 KB
/
fix_eph_coloured_exp_v1.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
/*
* Authors of the extension Artur Tamm, Alfredo Correa
* e-mail: [email protected]
*/
#ifdef FIX_CLASS
FixStyle(eph/coloured/exp/v1,FixEPHColouredExpV1)
#else
#ifndef LMP_FIX_EPH_COLOURED_EXP_V1_H
#define LMP_FIX_EPH_COLOURED_EXP_V1_H
// external headers
#include <memory>
#include <vector>
#include <cstddef>
// lammps headers
#include "fix.h"
// internal headers
#include "eph_beta.h"
#include "eph_fdm.h"
namespace LAMMPS_NS {
class FixEPHColouredExpV1 : public Fix {
public:
// enumeration for tracking fix state, this is used in comm forward
enum class FixState : unsigned int {
NONE,
RHO,
ZI,
ZV,
WI
};
// enumeration for selecting fix functionality
enum Flag : int {
FRICTION = 0x01,
RANDOM = 0x02,
FDM = 0x04,
NOINT = 0x08, // disable integration
NOFRICTION = 0x10, // disable effect of friction force
NORANDOM = 0x20 // disable effect of random force
};
FixEPHColouredExpV1(class LAMMPS *, int, char **); // constructor
~FixEPHColouredExpV1(); // destructor
void init() override; // called by lammps after constructor
void init_list(int id, NeighList *ptr) override; // called by lammps after constructor
int setmask() override; // called by lammps
void post_force(int) override; // called by lammps after pair_potential
void end_of_step() override; // called by lammps before next step
void reset_dt() override; // called by lammps if dt changes
void grow_arrays(int) override; // called by lammps if number of atoms changes for some task
double compute_vector(int) override; // called by lammps if a value is requested
double memory_usage() override; // prints the memory usage // TODO
void post_run() override; // called by lammps after run ends
/* integrator functionality */
void initial_integrate(int) override; // called in the beginning of a step
void final_integrate() override; // called in the end of the step
// forward communication copies information of owned local atoms to ghost
// atoms, reverse communication does the opposite
int pack_forward_comm(int, int *, double *, int, int *) override;
void unpack_forward_comm(int, int, double *) override;
// needed to distribute electronic energy per atom
int pack_exchange(int, double *) override;
int unpack_exchange(int, double*) override;
// copy_arrays
void copy_arrays(int i, int j, int /*delflag*/) override;
protected:
static constexpr size_t max_file_length = 256; // max filename length
int myID; // mpi rank for current instance
int nrPS; // number of processes
FixState state; // tracks the state of the fix
int eph_flag; // term flags
int types; // number of different types
int* type_map; // TODO: type map // change this to vector
//Container<uint8_t, Allocator<uint8_t> type_map; // type map // change this to vector
Beta beta; // instance for beta(rho) parametrisation
EPH_FDM fdm; // electronic FDM grid
double tau0; // time factor for exponent
/** integrator functionality **/
double dtv;
double dtf;
double r_cutoff; // cutoff for rho(r)
double r_cutoff_sq; // square of the r_cutoff
double rho_cutoff; // cutoff for beta(rho)
int T_freq; // frequency for printing electronic temperatures to files
char T_out[max_file_length]; // this will print temperature heatmap
char T_state[max_file_length]; // this will store the final state into file
double eta_factor; // this is for the conversion from energy/ps -> force
double zeta_factor; // this is used for evaluating the memory kernel
int seed; // seed for random number generator
class RanMars *random; // rng
class NeighList *list; // Neighbor list
double Ee; // energy of the electronic system
size_t n; // size of peratom arrays
// friction force
double **f_EPH; // size = [nlocal][3] // TODO: try switching to vector
// random force
double **f_RNG; // size = [nlocal][3] // TODO: try switching to vector
// Electronic density at each atom
double* rho_i; // size = [nlocal] // TODO: try switching to vector
// Inverse of electronic density in order to avoid 1./rho_i
double* inv_rho_i; // size = [nlocal] // TODO: try switching to vector
// dissipation vector W_ij v_j
double** w_i; // size = [nlocal][3]
// random numbers
double **xi_i; // size = [nlocal][3]
// coloured noise
double **zi_i; // size = [nlocal][3]
// coloured dissipation
double **zv_i; // size = [nlocal][3]
// electronic temperature per atom
double* T_e_i; // size = [nlocal + nghost]
// per atom array
double **array; // size = [nlocal][8] // TODO: try switching to vector
// private member functions
void calculate_environment(); // calculate the site density and coupling for every atom
void force_prl(); // PRL model with full functionality
static Float get_scalar(Float const* x, Float const* y) {
return x[0]*y[0] + x[1]*y[1] + x[2]*y[2];
}
static Float get_norm(Float const* x) {
return x[0]*x[0] + x[1]*x[1] + x[2]*x[2];
}
static Float get_distance_sq(Float const* x, Float const* y) {
Float dxy[3];
dxy[0] = x[0] - y[0];
dxy[1] = x[1] - y[1];
dxy[2] = x[2] - y[2];
return get_norm(dxy);
}
// TODO: add restrict
static Float get_difference_sq(Float const* x, Float const* y, Float* __restrict z) {
z[0] = x[0] - y[0];
z[1] = x[1] - y[1];
z[2] = x[2] - y[2];
return get_norm(z);
}
};
}
#endif
#endif