39 template <
typename Type>
40 static std::vector<Type>
Pointwise_Product(
const std::vector<Type> &f1,
const std::vector<Type> &f2)
42 assert(f1.size() == f2.size());
43 std::vector<Type> f(f1.size());
44 for (
int ir = 0; ir != f.size(); ++ir)
45 f[ir] = f1[ir] * f2[ir];
87 lattice_vector.
e11 = R11;
88 lattice_vector.
e12 = R12;
89 lattice_vector.
e13 = R13;
90 lattice_vector.
e21 = R21;
91 lattice_vector.
e22 = R22;
92 lattice_vector.
e23 = R23;
93 lattice_vector.
e31 = R31;
94 lattice_vector.
e32 = R32;
95 lattice_vector.
e33 = R33;
101 cartesian_vec = direct_vec * lattice_vector;
102 cx = cartesian_vec.
x;
103 cy = cartesian_vec.
y;
104 cz = cartesian_vec.
z;
145 lattice_vector.
e11 = R11;
146 lattice_vector.
e12 = R12;
147 lattice_vector.
e13 = R13;
148 lattice_vector.
e21 = R21;
149 lattice_vector.
e22 = R22;
150 lattice_vector.
e23 = R23;
151 lattice_vector.
e31 = R31;
152 lattice_vector.
e32 = R32;
153 lattice_vector.
e33 = R33;
155 inv_lat = lattice_vector.
Inverse();
158 cartesian_vec.
x = cx;
159 cartesian_vec.
y = cy;
160 cartesian_vec.
z = cz;
161 direct_vec = cartesian_vec * inv_lat;
172 proj.
x = std::abs( latvec[0] * (latvec[1] ^ latvec[2]).
normalize() );
173 proj.
y = std::abs( latvec[1] * (latvec[2] ^ latvec[0]).
normalize() );
174 proj.
z = std::abs( latvec[2] * (latvec[0] ^ latvec[1]).
normalize() );
192 if (nat <= 0 || force.
nr < nat || force.
nc < 3)
195 "nat must be positive and force must have at least nat x 3 elements");
198 for (
int iat = 0; iat < nat; ++iat)
200 net_force.
x += force(iat, 0);
201 net_force.
y += force(iat, 1);
202 net_force.
z += force(iat, 2);
220 const double compen_x = net_force.
x / nat;
221 const double compen_y = net_force.
y / nat;
222 const double compen_z = net_force.
z / nat;
223 for (
int iat = 0; iat < nat; ++iat)
225 force(iat, 0) -= compen_x;
226 force(iat, 1) -= compen_y;
227 force(iat, 2) -= compen_z;
static void Cartesian_to_Direct(const double &cx, const double &cy, const double &cz, const double &R11, const double &R12, const double &R13, const double &R21, const double &R22, const double &R23, const double &R31, const double &R32, const double &R33, double &dx, double &dy, double &dz)
Change Cartesian coordinate (cx,cy,cz) to direct coordinate (dx,dy,dz), (cx,cy,cz) = (dx,...
Definition mathzone.h:128
static void Direct_to_Cartesian(const double &dx, const double &dy, const double &dz, const double &R11, const double &R12, const double &R13, const double &R21, const double &R22, const double &R23, const double &R31, const double &R32, const double &R33, double &cx, double &cy, double &cz)
change direct coordinate (dx,dy,dz) to Cartesian coordinate (cx,cy,cz), (dx,dy,dz) = (cx,...
Definition mathzone.h:69
static std::vector< Type > Pointwise_Product(const std::vector< Type > &f1, const std::vector< Type > &f2)
Pointwise product of two vectors with same size.
Definition mathzone.h:40
static ModuleBase::Vector3< T > latvec_projection(const std::array< ModuleBase::Vector3< T >, 3 > &latvec)
Definition mathzone.h:169
3x3 matrix and related mathamatical operations
Definition matrix3.h:15
double e13
Definition matrix3.h:22
Matrix3 Inverse(void) const
Inverse a 3x3 matrix.
Definition matrix3.cpp:44
double e31
Definition matrix3.h:22
double e11
element e_ij: i_row, j_column
Definition matrix3.h:22
double e33
Definition matrix3.h:22
double e32
Definition matrix3.h:22
double e21
Definition matrix3.h:22
double e12
Definition matrix3.h:22
double e23
Definition matrix3.h:22
double e22
Definition matrix3.h:22
3 elements vector
Definition vector3.h:21
T x
Definition vector3.h:23
T y
Definition vector3.h:24
T z
Definition vector3.h:25
int nr
Definition matrix.h:19
int nc
Definition matrix.h:20
Definition clebsch_gordan_coeff.cpp:8
void remove_net_force(const int nat, ModuleBase::matrix &force)
Remove the uniform net-force component in place (Newton's 3rd law).
Definition mathzone.h:217
Vector3< double > net_force_vector(const int nat, const ModuleBase::matrix &force)
Sum the per-atom Cartesian forces into the net force vector.
Definition mathzone.h:190
void WARNING_QUIT(const std::string &, const std::string &)
Combine the functions of WARNING and QUIT.
Definition test_delley.cpp:15
void normalize(const std::vector< double > &r, std::vector< double > &flz)
Definition psi_init_nao.cpp:35