1#ifndef PREPARE_UNITCELL_H
2#define PREPARE_UNITCELL_H
14 bool selective_dynamics_in,
16 std::string fixed_axes_in,
18 std::valarray<double> latvec_in,
19 std::vector<std::string> elements_in,
20 std::vector<std::string> pp_files_in,
21 std::vector<std::string> pp_types_in,
22 std::vector<std::string> orb_files_in,
23 std::valarray<int> natom_in,
24 std::vector<double> atomic_mass_in,
25 std::string coor_type_in,
26 std::valarray<double> coordinates_in,
27 std::valarray<double> mbl_in,
28 std::valarray<double> velocity_in);
38 std::valarray<double>
latvec;
43 std::valarray<int>
natom;
47 std::valarray<double>
mbl;
56 this->ntype = this->elements.size();
57 std::unique_ptr<UnitCell> ucell(
new UnitCell);
58 ucell->setup(this->latname,
63 delete[] ucell->magnet.start_mag;
65 ucell->atom_label.resize(ucell->ntype);
66 ucell->atom_mass.resize(ucell->ntype);
67 ucell->pseudo_fn.resize(ucell->ntype);
68 ucell->pseudo_type.resize(ucell->ntype);
69 ucell->orbital_fn.resize(ucell->ntype);
70 ucell->magnet.start_mag =
new double[ucell->ntype];
71 ucell->magnet.ux_[0] = 0.0;
72 ucell->magnet.ux_[1] = 0.0;
73 ucell->magnet.ux_[2] = 0.0;
74 for(
int it=0;it<ucell->ntype;++it)
76 ucell->atom_label[it] = this->elements[it];
77 ucell->atom_mass[it] = this->atomic_mass[it];
78 ucell->pseudo_fn[it] = this->pp_files[it];
79 ucell->pseudo_type[it] = this->pp_types[it];
80 ucell->orbital_fn[it] = this->orb_files[it];
81 ucell->magnet.start_mag[it] = 0.0;
84 ucell->lat0 = this->
lat0;
85 ucell->lat0_angstrom = ucell->lat0 * 0.529177;
87 ucell->tpiba2 = ucell->tpiba * ucell->tpiba;
88 ucell->latvec.e11 = this->latvec[0];
89 ucell->latvec.e12 = this->latvec[1];
90 ucell->latvec.e13 = this->latvec[2];
91 ucell->latvec.e21 = this->latvec[3];
92 ucell->latvec.e22 = this->latvec[4];
93 ucell->latvec.e23 = this->latvec[5];
94 ucell->latvec.e31 = this->latvec[6];
95 ucell->latvec.e32 = this->latvec[7];
96 ucell->latvec.e33 = this->latvec[8];
97 ucell->a1.x = ucell->latvec.e11;
98 ucell->a1.y = ucell->latvec.e12;
99 ucell->a1.z = ucell->latvec.e13;
100 ucell->a2.x = ucell->latvec.e21;
101 ucell->a2.y = ucell->latvec.e22;
102 ucell->a2.z = ucell->latvec.e23;
103 ucell->a3.x = ucell->latvec.e31;
104 ucell->a3.y = ucell->latvec.e32;
105 ucell->a3.z = ucell->latvec.e33;
106 ucell->GT = ucell->latvec.Inverse();
107 ucell->G = ucell->GT.Transpose();
108 ucell->GGT = ucell->G*ucell->GT;
109 ucell->invGGT = ucell->GGT.Inverse();
110 ucell->omega = std::abs(ucell->latvec.Det())*(ucell->lat0)*(ucell->lat0)*(ucell->lat0);
113 ucell->atoms =
new Atom[ucell->ntype];
114 ucell->set_atom_flag =
true;
115 this->atomic_index = 0;
116 for(
int it=0;it<ucell->ntype;++it)
118 ucell->atoms[it].
label = this->elements[it];
119 ucell->atoms[it].nw = 0;
120 ucell->atoms[it].nwl = 2;
121 ucell->atoms[it].l_nchi.resize(ucell->atoms[it].nwl+1);
122 for(
int L=0; L<ucell->atoms[it].nwl+1; L++)
124 ucell->atoms[it].l_nchi[L] = 1;
125 ucell->atoms[it].nw += (2*L + 1) * ucell->atoms[it].l_nchi[L];
127 ucell->atoms[it].na = this->natom[it];
129 ucell->atoms[it].tau.resize(ucell->atoms[it].na);
130 ucell->atoms[it].dis.resize(ucell->atoms[it].na);
131 ucell->atoms[it].taud.resize(ucell->atoms[it].na);
132 ucell->atoms[it].vel.resize(ucell->atoms[it].na);
133 ucell->atoms[it].mag.resize(ucell->atoms[it].na);
134 ucell->atoms[it].angle1.resize(ucell->atoms[it].na);
135 ucell->atoms[it].angle2.resize(ucell->atoms[it].na);
136 ucell->atoms[it].m_loc_.resize(ucell->atoms[it].na);
137 ucell->atoms[it].mbl.resize(ucell->atoms[it].na);
138 ucell->atoms[it].mass = ucell->atom_mass[it];
139 for(
int ia=0; ia<ucell->atoms[it].na; ++ia)
141 if (ucell->Coordinate ==
"Direct")
143 ucell->atoms[it].taud[ia].x = this->coordinates[this->atomic_index*3+0];
144 ucell->atoms[it].taud[ia].y = this->coordinates[this->atomic_index*3+1];
145 ucell->atoms[it].taud[ia].z = this->coordinates[this->atomic_index*3+2];
146 ucell->atoms[it].tau[ia] = ucell->atoms[it].taud[ia]*ucell->latvec;
148 else if (ucell->Coordinate ==
"Cartesian")
150 ucell->atoms[it].tau[ia].x = this->coordinates[this->atomic_index*3+0];
151 ucell->atoms[it].tau[ia].y = this->coordinates[this->atomic_index*3+1];
152 ucell->atoms[it].tau[ia].z = this->coordinates[this->atomic_index*3+2];
154 ucell->atoms[it].tau[ia].x, ucell->atoms[it].tau[ia].y, ucell->atoms[it].tau[ia].z,
155 ucell->latvec.e11, ucell->latvec.e12, ucell->latvec.e13,
156 ucell->latvec.e21, ucell->latvec.e22, ucell->latvec.e23,
157 ucell->latvec.e31, ucell->latvec.e32, ucell->latvec.e33,
158 ucell->atoms[it].taud[ia].x, ucell->atoms[it].taud[ia].y, ucell->atoms[it].taud[ia].z);
160 ucell->atoms[it].dis[ia].set(0, 0, 0);
163 ucell->atoms[it].vel[ia].x = this->velocity[this->atomic_index*3+0];
164 ucell->atoms[it].vel[ia].y = this->velocity[this->atomic_index*3+1];
165 ucell->atoms[it].vel[ia].z = this->velocity[this->atomic_index*3+2];
169 ucell->atoms[it].vel[ia].set(0,0,0);
171 ucell->atoms[it].m_loc_[ia].set(0,0,0);
172 ucell->atoms[it].angle1[ia] = 0;
173 ucell->atoms[it].angle2[ia] = 0;
174 if(this->selective_dynamics)
176 ucell->atoms[it].mbl[ia].x = this->mbl[this->atomic_index*3+0];
177 ucell->atoms[it].mbl[ia].y = this->mbl[this->atomic_index*3+1];
178 ucell->atoms[it].mbl[ia].z = this->mbl[this->atomic_index*3+2];
182 ucell->atoms[it].mbl[ia] = {1,1,1};
187 ucell->nat = this->natom.sum();
195 bool selective_dynamics_in,
197 std::string fixed_axes_in,
199 std::valarray<double> latvec_in,
200 std::vector<std::string> elements_in,
201 std::vector<std::string> pp_files_in,
202 std::vector<std::string> pp_types_in,
203 std::vector<std::string> orb_files_in,
204 std::valarray<int> natom_in,
205 std::vector<double> atomic_mass_in,
206 std::string coor_type_in,
207 std::valarray<double> coordinates_in,
208 std::valarray<double> mbl_in,
209 std::valarray<double> velocity_in):
213 selective_dynamics(selective_dynamics_in),
214 relax_new(relax_new_in),
218 elements(elements_in),
219 pp_files(pp_files_in),
220 pp_types(pp_types_in),
221 orb_files(orb_files_in),
223 atomic_mass(atomic_mass_in),
224 coor_type(coor_type_in),
225 coordinates(coordinates_in),
227 velocity(velocity_in)
231 latname(utp.latname),
232 lmaxmax(utp.lmaxmax),
234 selective_dynamics(utp.selective_dynamics),
235 relax_new(utp.relax_new),
239 elements(utp.elements),
240 pp_files(utp.pp_files),
241 pp_types(utp.pp_types),
242 orb_files(utp.orb_files),
244 atomic_mass(utp.atomic_mass),
245 coor_type(utp.coor_type),
246 coordinates(utp.coordinates),
248 velocity(utp.velocity)
std::string label
Definition atom_spec.h:35
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
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
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:53
std::string fixed_axes
Definition for_testing_input_conv.h:105
void init_vel(const UnitCell &unit_in, const int &my_rank, const bool &restart, double &temperature, double *allmass, int &frozen_freedom, ModuleBase::Vector3< int > *ionmbl, ModuleBase::Vector3< double > *vel)
initialize the atomic velocities
Definition md_func.cpp:186
const double TWO_PI
Definition constants.h:21
std::map< std::string, UcellTestPrepare > UcellTestLib
Definition prepare_unitcell.h:306