1#ifndef PREPARE_UNITCELL_H
2#define PREPARE_UNITCELL_H
13 bool selective_dynamics_in,
15 std::string fixed_axes_in,
17 std::valarray<double> latvec_in,
18 std::vector<std::string> elements_in,
19 std::vector<std::string> pp_files_in,
20 std::vector<std::string> pp_types_in,
21 std::vector<std::string> orb_files_in,
22 std::valarray<int> natom_in,
23 std::vector<double> atomic_mass_in,
24 std::string coor_type_in,
25 std::valarray<double> coordinates_in);
29 bool selective_dynamics_in,
31 std::string fixed_axes_in,
33 std::valarray<double> latvec_in,
34 std::vector<std::string> elements_in,
35 std::vector<std::string> pp_files_in,
36 std::vector<std::string> pp_types_in,
37 std::vector<std::string> orb_files_in,
38 std::valarray<int> natom_in,
39 std::vector<double> atomic_mass_in,
40 std::string coor_type_in,
41 std::valarray<double> coordinates_in,
42 std::valarray<double> mbl_in,
43 std::valarray<double> velocity_in);
53 std::valarray<double>
latvec;
58 std::valarray<int>
natom;
62 std::valarray<double>
mbl;
71 this->ntype = this->elements.size();
72 std::unique_ptr<UnitCell> ucell(
new UnitCell);
73 ucell->setup_from_input(this->latname,
79 ucell->pseudo_fn.resize(ucell->ntype);
80 ucell->pseudo_type.resize(ucell->ntype);
81 ucell->orbital_fn.resize(ucell->ntype);
82 ucell->magnet.ux_[0] = 0.0;
83 ucell->magnet.ux_[1] = 0.0;
84 ucell->magnet.ux_[2] = 0.0;
85 for(
int it=0;it<ucell->ntype;++it)
87 ucell->pseudo_fn[it] = this->pp_files[it];
88 ucell->pseudo_type[it] = this->pp_types[it];
89 ucell->orbital_fn[it] = this->orb_files[it];
92 ucell->lat0 = this->lat0;
95 ucell->tpiba2 = ucell->tpiba * ucell->tpiba;
96 ucell->latvec.e11 = this->latvec[0];
97 ucell->latvec.e12 = this->latvec[1];
98 ucell->latvec.e13 = this->latvec[2];
99 ucell->latvec.e21 = this->latvec[3];
100 ucell->latvec.e22 = this->latvec[4];
101 ucell->latvec.e23 = this->latvec[5];
102 ucell->latvec.e31 = this->latvec[6];
103 ucell->latvec.e32 = this->latvec[7];
104 ucell->latvec.e33 = this->latvec[8];
105 ucell->a1.x = ucell->latvec.e11;
106 ucell->a1.y = ucell->latvec.e12;
107 ucell->a1.z = ucell->latvec.e13;
108 ucell->a2.x = ucell->latvec.e21;
109 ucell->a2.y = ucell->latvec.e22;
110 ucell->a2.z = ucell->latvec.e23;
111 ucell->a3.x = ucell->latvec.e31;
112 ucell->a3.y = ucell->latvec.e32;
113 ucell->a3.z = ucell->latvec.e33;
114 ucell->GT = ucell->latvec.Inverse();
115 ucell->G = ucell->GT.Transpose();
116 ucell->GGT = ucell->G*ucell->GT;
117 ucell->invGGT = ucell->GGT.Inverse();
118 ucell->omega = std::abs(ucell->latvec.Det())*(ucell->lat0)*(ucell->lat0)*(ucell->lat0);
120 ucell->Coordinate = this->coor_type;
121 ucell->atoms =
new Atom[ucell->ntype];
122 ucell->set_atom_flag =
true;
123 this->atomic_index = 0;
124 for(
int it=0;it<ucell->ntype;++it)
126 ucell->atoms[it].label = this->elements[it];
127 ucell->atoms[it].nw = 0;
128 ucell->atoms[it].nwl = 2;
129 ucell->atoms[it].l_nchi.resize(ucell->atoms[it].nwl+1);
130 for(
int L=0; L<ucell->atoms[it].nwl+1; L++)
132 ucell->atoms[it].l_nchi[L] = 1;
133 ucell->atoms[it].nw += (2*L + 1) * ucell->atoms[it].l_nchi[L];
135 ucell->atoms[it].na = this->natom[it];
137 ucell->atoms[it].tau.resize(ucell->atoms[it].na);
138 ucell->atoms[it].dis.resize(ucell->atoms[it].na);
139 ucell->atoms[it].taud.resize(ucell->atoms[it].na);
140 ucell->atoms[it].vel.resize(ucell->atoms[it].na);
141 ucell->atoms[it].mag.resize(ucell->atoms[it].na);
142 ucell->atoms[it].angle1.resize(ucell->atoms[it].na);
143 ucell->atoms[it].angle2.resize(ucell->atoms[it].na);
144 ucell->atoms[it].m_loc_.resize(ucell->atoms[it].na);
145 ucell->atoms[it].mbl.resize(ucell->atoms[it].na);
146 ucell->atoms[it].lambda.resize(ucell->atoms[it].na);
147 ucell->atoms[it].constrain.resize(ucell->atoms[it].na);
148 ucell->atoms[it].mass = this->atomic_mass[it];
149 for(
int ia=0; ia<ucell->atoms[it].na; ++ia)
151 if (ucell->Coordinate ==
"Direct")
153 ucell->atoms[it].taud[ia].x = this->coordinates[this->atomic_index*3+0];
154 ucell->atoms[it].taud[ia].y = this->coordinates[this->atomic_index*3+1];
155 ucell->atoms[it].taud[ia].z = this->coordinates[this->atomic_index*3+2];
156 ucell->atoms[it].tau[ia] = ucell->atoms[it].taud[ia]*ucell->latvec;
158 else if (ucell->Coordinate ==
"Cartesian")
160 ucell->atoms[it].tau[ia].x = this->coordinates[this->atomic_index*3+0];
161 ucell->atoms[it].tau[ia].y = this->coordinates[this->atomic_index*3+1];
162 ucell->atoms[it].tau[ia].z = this->coordinates[this->atomic_index*3+2];
164 ucell->atoms[it].tau[ia].x, ucell->atoms[it].tau[ia].y, ucell->atoms[it].tau[ia].z,
165 ucell->latvec.e11, ucell->latvec.e12, ucell->latvec.e13,
166 ucell->latvec.e21, ucell->latvec.e22, ucell->latvec.e23,
167 ucell->latvec.e31, ucell->latvec.e32, ucell->latvec.e33,
168 ucell->atoms[it].taud[ia].x, ucell->atoms[it].taud[ia].y, ucell->atoms[it].taud[ia].z);
170 ucell->atoms[it].dis[ia].set(0, 0, 0);
173 ucell->atoms[it].vel[ia].x = this->velocity[this->atomic_index*3+0];
174 ucell->atoms[it].vel[ia].y = this->velocity[this->atomic_index*3+1];
175 ucell->atoms[it].vel[ia].z = this->velocity[this->atomic_index*3+2];
179 ucell->atoms[it].vel[ia].set(0,0,0);
181 ucell->atoms[it].m_loc_[ia].set(0,0,0);
182 ucell->atoms[it].angle1[ia] = 0;
183 ucell->atoms[it].angle2[ia] = 0;
184 if(this->selective_dynamics)
186 ucell->atoms[it].mbl[ia].x = this->mbl[this->atomic_index*3+0];
187 ucell->atoms[it].mbl[ia].y = this->mbl[this->atomic_index*3+1];
188 ucell->atoms[it].mbl[ia].z = this->mbl[this->atomic_index*3+2];
192 ucell->atoms[it].mbl[ia] = {1,1,1};
194 ++(this->atomic_index);
197 ucell->nat = this->natom.sum();
205 bool selective_dynamics_in,
207 std::string fixed_axes_in,
209 std::valarray<double> latvec_in,
210 std::vector<std::string> elements_in,
211 std::vector<std::string> pp_files_in,
212 std::vector<std::string> pp_types_in,
213 std::vector<std::string> orb_files_in,
214 std::valarray<int> natom_in,
215 std::vector<double> atomic_mass_in,
216 std::string coor_type_in,
217 std::valarray<double> coordinates_in):
221 selective_dynamics(selective_dynamics_in),
222 relax_new(relax_new_in),
226 elements(elements_in),
227 pp_files(pp_files_in),
228 pp_types(pp_types_in),
229 orb_files(orb_files_in),
231 atomic_mass(atomic_mass_in),
232 coor_type(coor_type_in),
233 coordinates(coordinates_in)
235 mbl = std::valarray<double>(0.0, coordinates_in.size());
236 velocity = std::valarray<double>(0.0, coordinates_in.size());
242 bool selective_dynamics_in,
244 std::string fixed_axes_in,
246 std::valarray<double> latvec_in,
247 std::vector<std::string> elements_in,
248 std::vector<std::string> pp_files_in,
249 std::vector<std::string> pp_types_in,
250 std::vector<std::string> orb_files_in,
251 std::valarray<int> natom_in,
252 std::vector<double> atomic_mass_in,
253 std::string coor_type_in,
254 std::valarray<double> coordinates_in,
255 std::valarray<double> mbl_in,
256 std::valarray<double> velocity_in):
260 selective_dynamics(selective_dynamics_in),
261 relax_new(relax_new_in),
265 elements(elements_in),
266 pp_files(pp_files_in),
267 pp_types(pp_types_in),
268 orb_files(orb_files_in),
270 atomic_mass(atomic_mass_in),
271 coor_type(coor_type_in),
272 coordinates(coordinates_in),
274 velocity(velocity_in)
278 latname(utp.latname),
279 lmaxmax(utp.lmaxmax),
281 selective_dynamics(utp.selective_dynamics),
282 relax_new(utp.relax_new),
286 elements(utp.elements),
287 pp_files(utp.pp_files),
288 pp_types(utp.pp_types),
289 orb_files(utp.orb_files),
291 atomic_mass(utp.atomic_mass),
292 coor_type(utp.coor_type),
293 coordinates(utp.coordinates),
295 velocity(utp.velocity)
388 0.00001,0.00001,0.00001,
467 {
"C_gga_8au_100Ry_2s2p1d.orb",
"H_gga_8au_100Ry_2s1p.orb"},
Atom class for storing atom information.
Definition atom_spec.h:14
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
Definition prepare_unitcell.h:8
std::valarray< double > mbl
Definition prepare_unitcell.h:63
std::vector< std::string > elements
Definition prepare_unitcell.h:55
UcellTestPrepare()=default
UcellTestPrepare(std::string latname_in, int lmaxmax_in, bool init_vel_in, bool selective_dynamics_in, bool relax_new_in, std::string fixed_axes_in, double lat0_in, std::valarray< double > latvec_in, std::vector< std::string > elements_in, std::vector< std::string > pp_files_in, std::vector< std::string > pp_types_in, std::vector< std::string > orb_files_in, std::valarray< int > natom_in, std::vector< double > atomic_mass_in, std::string coor_type_in, std::valarray< double > coordinates_in)
std::vector< std::string > pp_files
Definition prepare_unitcell.h:56
bool relax_new
Definition prepare_unitcell.h:51
std::valarray< double > velocity
Definition prepare_unitcell.h:64
std::valarray< double > coordinates
Definition prepare_unitcell.h:62
std::valarray< double > latvec
Definition prepare_unitcell.h:54
int atomic_index
Definition prepare_unitcell.h:67
std::vector< std::string > orb_files
Definition prepare_unitcell.h:58
UcellTestPrepare(const UcellTestPrepare &utp)
double lat0
Definition prepare_unitcell.h:53
int ntype
Definition prepare_unitcell.h:66
std::vector< double > atomic_mass
Definition prepare_unitcell.h:60
std::valarray< int > natom
Definition prepare_unitcell.h:59
std::string coor_type
Definition prepare_unitcell.h:61
int lmaxmax
Definition prepare_unitcell.h:48
bool selective_dynamics
Definition prepare_unitcell.h:50
std::string fixed_axes
Definition prepare_unitcell.h:52
std::string latname
Definition prepare_unitcell.h:47
bool init_vel
Definition prepare_unitcell.h:49
UcellTestPrepare(std::string latname_in, int lmaxmax_in, bool init_vel_in, bool selective_dynamics_in, bool relax_new_in, std::string fixed_axes_in, double lat0_in, std::valarray< double > latvec_in, std::vector< std::string > elements_in, std::vector< std::string > pp_files_in, std::vector< std::string > pp_types_in, std::vector< std::string > orb_files_in, std::valarray< int > natom_in, std::vector< double > atomic_mass_in, std::string coor_type_in, std::valarray< double > coordinates_in, std::valarray< double > mbl_in, std::valarray< double > velocity_in)
std::vector< std::string > pp_types
Definition prepare_unitcell.h:57
std::unique_ptr< UnitCell > SetUcellInfo()
Definition prepare_unitcell.h:68
Provide the basic information about unitcell.
Definition unitcell.h:16
std::string fixed_axes
Fixed axes constraint ("None", "shape", "volume", or specific axes).
Definition lattice_change_basic.cpp:12
void init_vel(MDCell &mdcell, const bool &init_vel, const bool &restart, double &temperature, std::int64_t &frozen_freedom)
Definition md_func.cpp:206
const double TWO_PI
Definition constants.h:21
const double BOHR_TO_A
Definition constants.h:55
constexpr double lat0
Definition dfpt_test_tool.h:36
std::map< std::string, UcellTestPrepare > UcellTestLib
Definition prepare_unitcell.h:299