ABACUS develop
Atomic-orbital Based Ab-initio Computation at UStc
Loading...
Searching...
No Matches
mathzone.h
Go to the documentation of this file.
1#ifndef MATHZONE_H
2#define MATHZONE_H
3
4#include "global_function.h"
5#include "matrix3.h"
6#include "vector3.h"
7#include "realarray.h"
8
9#include <cassert>
10#include <complex>
11#include <map>
12#include <vector>
13#include <array>
14namespace ModuleBase
15{
16
22{
23 public:
26
27 public:
37 template <typename Type>
38 static std::vector<Type> Pointwise_Product(const std::vector<Type> &f1, const std::vector<Type> &f2)
39 {
40 assert(f1.size() == f2.size());
41 std::vector<Type> f(f1.size());
42 for (int ir = 0; ir != f.size(); ++ir)
43 f[ir] = f1[ir] * f2[ir];
44 return f;
45 }
46
67 static inline void Direct_to_Cartesian(const double &dx,
68 const double &dy,
69 const double &dz,
70 const double &R11,
71 const double &R12,
72 const double &R13,
73 const double &R21,
74 const double &R22,
75 const double &R23,
76 const double &R31,
77 const double &R32,
78 const double &R33,
79 double &cx,
80 double &cy,
81 double &cz)
82 {
83 ModuleBase::Matrix3 lattice_vector;
84 ModuleBase::Vector3<double> direct_vec, cartesian_vec;
85 lattice_vector.e11 = R11;
86 lattice_vector.e12 = R12;
87 lattice_vector.e13 = R13;
88 lattice_vector.e21 = R21;
89 lattice_vector.e22 = R22;
90 lattice_vector.e23 = R23;
91 lattice_vector.e31 = R31;
92 lattice_vector.e32 = R32;
93 lattice_vector.e33 = R33;
94
95 direct_vec.x = dx;
96 direct_vec.y = dy;
97 direct_vec.z = dz;
98
99 cartesian_vec = direct_vec * lattice_vector;
100 cx = cartesian_vec.x;
101 cy = cartesian_vec.y;
102 cz = cartesian_vec.z;
103 return;
104 }
105
126 static inline void Cartesian_to_Direct(const double &cx,
127 const double &cy,
128 const double &cz,
129 const double &R11,
130 const double &R12,
131 const double &R13,
132 const double &R21,
133 const double &R22,
134 const double &R23,
135 const double &R31,
136 const double &R32,
137 const double &R33,
138 double &dx,
139 double &dy,
140 double &dz)
141 {
142 ModuleBase::Matrix3 lattice_vector, inv_lat;
143 lattice_vector.e11 = R11;
144 lattice_vector.e12 = R12;
145 lattice_vector.e13 = R13;
146 lattice_vector.e21 = R21;
147 lattice_vector.e22 = R22;
148 lattice_vector.e23 = R23;
149 lattice_vector.e31 = R31;
150 lattice_vector.e32 = R32;
151 lattice_vector.e33 = R33;
152
153 inv_lat = lattice_vector.Inverse();
154
155 ModuleBase::Vector3<double> direct_vec, cartesian_vec;
156 cartesian_vec.x = cx;
157 cartesian_vec.y = cy;
158 cartesian_vec.z = cz;
159 direct_vec = cartesian_vec * inv_lat;
160 dx = direct_vec.x;
161 dy = direct_vec.y;
162 dz = direct_vec.z;
163 return;
164 }
165
166 template<typename T>
168 {
170 proj.x = std::abs( latvec[0] * (latvec[1] ^ latvec[2]).normalize() );
171 proj.y = std::abs( latvec[1] * (latvec[2] ^ latvec[0]).normalize() );
172 proj.z = std::abs( latvec[2] * (latvec[0] ^ latvec[1]).normalize() );
173 return proj;
174 }
175};
176
177} // namespace ModuleBase
178
179#endif
atomic coordinates conversion functions
Definition mathzone.h:22
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:126
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:67
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:38
static ModuleBase::Vector3< T > latvec_projection(const std::array< ModuleBase::Vector3< T >, 3 > &latvec)
Definition mathzone.h:167
3x3 matrix and related mathamatical operations
Definition matrix3.h:19
double e13
Definition matrix3.h:26
Matrix3 Inverse(void) const
Inverse a 3x3 matrix.
Definition matrix3.cpp:44
double e31
Definition matrix3.h:26
double e11
element e_ij: i_row, j_column
Definition matrix3.h:26
double e33
Definition matrix3.h:26
double e32
Definition matrix3.h:26
double e21
Definition matrix3.h:26
double e12
Definition matrix3.h:26
double e23
Definition matrix3.h:26
double e22
Definition matrix3.h:26
3 elements vector
Definition vector3.h:22
T x
Definition vector3.h:24
T y
Definition vector3.h:25
T z
Definition vector3.h:26
Definition array_pool.h:6
void normalize(const std::vector< double > &r, std::vector< double > &flz)
Definition psi_initializer_nao.cpp:33